
function loadIFrame(keywords){

       var firstTime = false;

       if(document.getElementById('cba_containeradPanel1')){
            var currentAdPanel = document.getElementById('cba_containeradPanel1');
	   currentAdPanel.parentNode.removeChild(currentAdPanel);  
            var nextAdPanel = document.getElementById('cba_containeradPanel2');
	   nextAdPanel.setAttribute('id','cba_containeradPanel1');
	   nextAdPanel.style.display = 'block';
       }
       else{
            var iFramecba_container = document.createElement('IFRAME');
            iFramecba_container.setAttribute('id', 'cba_containeradPanel1');
            iFramecba_container.setAttribute('width', '500');
            iFramecba_container.setAttribute('height', '120');
            iFramecba_container.setAttribute('frameborder', '0');
            iFramecba_container.setAttribute('scrolling', 'no');
  	   document.getElementById('cba_container').innerHTML="";
            document.getElementById('cba_container').appendChild(iFramecba_container); 
            firstTime = true;
            iFramecba_container.setAttribute('src', 'http://www.clickbankads.net/cba.fr.src.php?o=h&u=clbnkfy&k='+keywords+'&h=120&w=500&n=3&s=5');     
       }
  
            var iFrame2cba_container = document.createElement('IFRAME');
            iFrame2cba_container.setAttribute('id', 'cba_containeradPanel2');
            iFrame2cba_container.setAttribute('width', '500');
            iFrame2cba_container.setAttribute('height', '120');
            iFrame2cba_container.setAttribute('frameborder', '0');
            iFrame2cba_container.setAttribute('scrolling', 'no');
            document.getElementById('cba_container').appendChild(iFrame2cba_container); 
	   iFrame2cba_container.style.display = 'none';
            iFrame2cba_container.setAttribute('src', 'http://www.clickbankads.net/cba.fr.src.php?o=h&u=clbnkfy&k='+keywords+'&h=120&w=500&n=3&s=5');     

       if(document.getElementById('cba_containerrecipLink')){
	    var recipLink = document.getElementById('cba_containerrecipLink');
             recipLink.parentNode.removeChild(recipLink);
       }
       
       var link = document.createElement('DIV');
       link.setAttribute('id', 'cba_containerrecipLink');
       link.innerHTML = "<a style='font-size:12px;margin:0 0 0 15px;font-weight:bold;' href='http://www.clickbankads.net'>Ads by clickbankads.net</a>";
       document.getElementById('cba_container').appendChild(link);

       setTimeout(function(){loadIFrame(keywords, false);}, 5000);

}

function reqCompleteCB(){
  return function(o){
     loadIFrame(o.responseText, true);  
  }
}

function ajaxFunction(requestCompleteCallback, params)
{
	var url = 'http://www.clickbankads.net//cbads.php';
	var xmlhttp;
	if (window.XMLHttpRequest)
  	{
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}
	else
  	{
  		// code for IE6, IE5
 		 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 	 }
	xmlhttp.onreadystatechange=function()
	{

		if(xmlhttp.readyState==4)
  		{
  			requestCompleteCallback(xmlhttp);
  		}
	}
	xmlhttp.open('POST',url, true);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlhttp.setRequestHeader("Content-length", params.length);
        xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);

}

var titleTags = document.getElementsByTagName('title');
var title = titleTags[0]?titleTags[0]:"";
ajaxFunction(reqCompleteCB(),'body='+document.body.innerHTML+'&title='+title);


