function change_ad(image_number)
{
	
	if(image_number==1)
	{
		document.getElementById("start_show").style.display="block";
		document.getElementById("start_show").style.visibility="visible";
	}
	else
	{		
		document.getElementById("start_show").style.display="none";
		document.getElementById("start_show").style.visibility="hidden";
	}
	
	var ad_divs = ["sidebar-ad-300","sidebar-ad-300top2","sidebar-3","home-header-ad","below-post","home-footer-ad"]
	
	for(var x in ad_divs)
	{
		x = document.getElementById(ad_divs[x]+"_iframe");
		x.src = x.src + "&rand=" + Math.random();
	}
	
	/*
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 && xmlhttp.status==200)
    {
	//alert(xmlhttp.responseText);
   // document.getElementById("new_ad").innerHTML=xmlhttp.responseText;
	//document.getElementById("old_ad").style.display="none";
	
	
	
	   // document.getElementById("image_show").style.display='none';
	  // change_ad_1();
    }
  }
xmlhttp.open("GET","/ad_change.php",true);
xmlhttp.send();
*/
}


//for rightside below 300*250 add refresh
function change_ad_1()
{
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 && xmlhttp.status==200)
    {
	//alert(xmlhttp.responseText);
    	document.getElementById("new_ad_side_2").innerHTML=xmlhttp.responseText;
	    document.getElementById("old_ad_side_2").style.display="none";
	//change_ad_2();
    // document.getElementById("image_show").style.display='none';
    }
  }
xmlhttp.open("GET","/ad_change.php",true);
xmlhttp.send();
}

//for leftside 300*250 add refresh
function change_ad_2()
{
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 && xmlhttp.status==200)
    {
		//alert(xmlhttp.responseText);
    	document.getElementById("new_ad_left").innerHTML=xmlhttp.responseText;
	    document.getElementById("old_ad_left").style.display="none";
		//window.location.reload();
		//change_ad_header();
	   	// document.getElementById("image_show").style.display='none';
    }
  }
xmlhttp.open("GET","/ad_change.php",true);
xmlhttp.send();
}

//header ad changing function starts

function change_ad_header()
{
		
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 && xmlhttp.status==200)
    {
		//alert(xmlhttp.responseText);
    	document.getElementById("new_header_ad").innerHTML=xmlhttp.responseText;
	    document.getElementById("old_header_ad").style.display="none";
	
		//change_ad_footer();
    // document.getElementById("image_show").style.display='none';
    }
  }
xmlhttp.open("GET","/ad_change_2.php",true);
xmlhttp.send();
}
//header ad changing function ends


//footer ad changing function starts
function change_ad_footer()
{
	
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 && xmlhttp.status==200)
    {
	//alert(xmlhttp.responseText);
    	document.getElementById("new_footer_ad").innerHTML=xmlhttp.responseText;
	    document.getElementById("old_footer_ad").style.display="none";
	//	window.location.reload();
	//change_right_side_ad();
	
    // document.getElementById("image_show").style.display='none';
    }
  }
xmlhttp.open("GET","/ad_change_2.php",true);
xmlhttp.send();
}
//footer ad changing function ends

//right side 160*600 ad changing function starts

function change_right_side_ad()
{
		
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 && xmlhttp.status==200)
    {
		//alert("right_bigger");
		//alert(xmlhttp.responseText);
    	document.getElementById("new_right_side").innerHTML=xmlhttp.responseText;
	    document.getElementById("old_right_side").style.display="none";
	
		// document.getElementById("image_show").style.display='none';
    }
  }
xmlhttp.open("GET","/ad_change_1.php",true);
xmlhttp.send();
}
//right side 160*600 ad changing function starts

/*
var org_url=String(window.location);
find=org_url.search("/rantgallery/image/");

if((find!=-1) && (window.location.hash))
{
newstr=org_url.split("/image");
hashed_value=newstr[1].split("#slide:");
//alert(newstr[0])
//hashed_url=org_url.replace(window.location.hash,'');
//alert(newstr[0]+"/image/"+hashed_value[1]);
window.location=newstr[0]+"/image/"+hashed_value[1];
}

if(window.location.hash && (find==-1))
{
//alert(window.location.hash);
url_str=String(window.location.hash);
key=url_str.replace("#slide:",'');
url=String(window.location);
url=url.replace("#slide:",'');
url=url.replace(key,'');
new_url=url+'rantgallery/image/'+key;
//alert(new_url);
window.location.replace(new_url);
}
else
{
// Fragment doesn't exist
}
*/
