function loadurl(dest) {
 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }
 
 xmlhttp.onreadystatechange = triggered;
 xmlhttp.open("GET", dest);
 xmlhttp.send(null);
}

function triggered() {
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200)
  {
    document.getElementById("affiliate_links").innerHTML =xmlhttp.responseText;
  }
}

function hide_aff_links() {
	document.getElementById("affiliate_links").innerHTML = "<a href=\"javascript:loadurl('myaffiliate.php?page=links');\">View Available Banners and Links</a>";
}

function load_month_stats() {
	select_box = document.getElementById('month');
	for(var i=0; i < select_box.options.length; i++)
	{
	      var option = select_box.options[i];
            if(option.selected)
		{
  			var dest = "myaffiliate.php?month="+option.value;
			 try {
			   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
			  		new ActiveXObject("Microsoft.XMLHTTP");
			 }
			 catch (e) { /* do nothing */ }
 
			 xmlhttp.onreadystatechange = month_trig;
			 xmlhttp.open("GET", dest);
			 xmlhttp.send(null);

            }
     	}
}

function month_trig() {
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200)
  {
    document.getElementById("month_stats").innerHTML =xmlhttp.responseText;
  }
}

function reverify_site($site_id) {
	if ( document.getElementById("v"+$site_id) )
	{
		document.getElementById("v"+$site_id).innerHTML="<font color=\"FF0000\"><b>Verified:</b></font> ReVerifying...";
		 try {
		   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
				new ActiveXObject("Microsoft.XMLHTTP");
		 }
		 catch (e) { /* do nothing */ }
		 
		 xmlhttp.onreadystatechange = function() {
			 if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200))
			 {
				if ( xmlhttp.responseText == "GOOD" )
				{
					document.getElementById("v"+$site_id).innerHTML="<b>Verified:</b> Linkpage verified.";
					alert("Linkpage has passed verification.");
				}
				else
				{
					document.getElementById("v"+$site_id).innerHTML="<font color=\"FF0000\"><b>Verified:</b> <a href=\"javascript:reverify_site("+$site_id+")\" class=\"dir_link\">Linkpage not verified, click to reverify and activate</a>";	
					alert("Linkpage did not pass verification");
				}
			 }
};
		 xmlhttp.open("GET", "verify_link_page.php?site_id="+$site_id);
		 xmlhttp.send(null);
	}
}

