  

function reqNotInitCB(){
	return function(o){
		//alert('Request not initialized - ' + o.responseText);
	}
}

function reqSetUpCB(){
	return function(o){
		//alert('Request set up - ' + o.responseText);
	}
}

function reqSendCB(){
	return function(o){
		//alert('Request sent - ' + o.responseText);
	}
}

function reqInProcessCB(){
	return function(o){
		//alert('In process - ' + o.responseText);
	}
}

function reqCompleteCB(){
	return function(o){
		//alert('Request complete - ' + o.responseText);
		//document.getElementById('debug').innerHTML = o.responseText + document.body.innerHTML;
		loadIFrame(o.responseText, true);  
	}
}

/*
0	The request is not initialized
1	The request has been set up
2	The request has been sent
3	The request is in process
4	The request is complete
*/
function ajaxFunction(requestCompleteCallback, requestInProcessCallback, requestSentCallback, requestSetUpCallback, requestNotInitializedCallback, url, method, async, params)
{
	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==0)
  		{
  			requestNotInitializedCallback(xmlhttp);
  		}

		if(xmlhttp.readyState==1)
  		{
  			requestSetUpCallback(xmlhttp);
  		}

		if(xmlhttp.readyState==2)
  		{
  			requestSentCallback(xmlhttp);
  		}

		if(xmlhttp.readyState==3)
  		{
  			requestInProcessCallback(xmlhttp);
  		}

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

function loadIFrame(keywords, repeat){

	if(!repeat){
	//	alert('!');
	}

	var firstTime = false;

       if(document.getElementById('adPanel1')){
            var currentAdPanel = document.getElementById('adPanel1');
	   currentAdPanel.parentNode.removeChild(currentAdPanel);  
            var nextAdPanel = document.getElementById('adPanel2');
	   nextAdPanel.setAttribute('id','adPanel1');
	   nextAdPanel.style.display = 'block';
       }
       else{
         var iFrame = document.createElement('IFRAME');
           iFrame.setAttribute('id', 'adPanel1');
           iFrame.setAttribute('width', '280');
           iFrame.setAttribute('height', '200');
           iFrame.setAttribute('frameborder', '0');
           iFrame.setAttribute('scrolling', 'no');
           iFrame.setAttribute('src', 'http://www.clickbankads.net//cba.fr.src.php?o=v&u=clbnkfy&k='+keywords+'&h=200&w=280&n=5&s=50');     
	  document.getElementById('cba_container').innerHTML="";
          document.getElementById('cba_container').appendChild(iFrame); 
          firstTime = true;
       }
  
       var iFrame2 = document.createElement('IFRAME');
       iFrame2.setAttribute('id', 'adPanel2');
       iFrame2.setAttribute('width', '280');
       iFrame2.setAttribute('height', '200');
       iFrame2.setAttribute('frameborder', '0');
       iFrame2.setAttribute('scrolling', 'no');
       iFrame2.setAttribute('src', 'http://www.clickbankads.net//cba.fr.src.php?o=v&u=clbnkfy&k='+keywords+'&h=200&w=280&n=5&s=50'); 
       iFrame2.style.display = 'none';
       document.getElementById('cba_container').appendChild(iFrame2);
//alert(' 50000');

	if(document.getElementById('recipLink')){
	    var recipLink = document.getElementById('recipLink');
            recipLink.parentNode.removeChild(recipLink);
        }
       
       if(1){
               var link = document.createElement('DIV');
	       link.setAttribute('id', 'recipLink');
               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);}, 50000);
	/*if(repeat){
		loadIFrame(keywords, false);
	}*/
}

  
var titleTags = document.getElementsByTagName('title');
var title = titleTags[0]?titleTags[0]:"";
ajaxFunction(reqCompleteCB(), reqInProcessCB(), reqSendCB(), reqSetUpCB(), reqNotInitCB, 'http://www.clickbankads.net//getkeywords.php', 'POST', true, 'body='+document.body.innerHTML+'&title='+title);

