//random number generator

	var adSlotArray= new Array();
	function regAdSlot(param){  // registers all the ad slots in the page. params=ADSLOTID|KEYVALUES
		adSlotArray[adSlotArray.length] = param;
	}
	
	var seed = Math.random() + "";
	var ord= seed * 1000000000000000000;
	
//these write the iframes into the pages
function banAd(cat){
	document.write('<iframe id="adSlot1" src="http://ad.doubleclick.net/adi/'+ show +'/' + cat +';sz=728x90;tile=1;ord=' + ord + '?" width="728" height="90" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no">');
	document.write('</IFRAME>');
	 // register slot 1
	document.write('<script type="text/javascript">');
	document.write('regAdSlot(\'adSlot1|sz=728x90;tile=1;\');');
	document.write('</script>');
}

function skyAd(cat){
document.write('<iframe id="adSlot2" src="http://ad.doubleclick.net/adi/'+ show +'/' + cat +';sz=160x600;tile=2;ord=' + ord + '?" width="160" height="600" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no">');
document.write('</IFRAME>');
 // register slot 2
document.write('<script type="text/javascript">');
document.write('regAdSlot(\'adSlot2|sz=160x600;tile=2;\');');
document.write('</script>');
}

function boxAd(cat){
document.write('<iframe id="adSlot3" src="http://ad.doubleclick.net/adi/'+ show +'/' + cat +';sz=300x250;tile=3;ord=' + ord + '?" width="300" height="250" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no">');
document.write('</IFRAME>');
 // register slot 3
document.write('<script type="text/javascript">');
document.write('regAdSlot(\'adSlot3|sz=300x250;tile=3;\');');
document.write('</script>');
}

function btnAd(cat){
document.write('<iframe id="adSlot4" src="http://ad.doubleclick.net/adi/'+ show +'/' + cat +';sz=160x90;tile=4;ord=' + ord + '?" width="160" height="90" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no">');
document.write('</IFRAME>');
 // register slot 4
document.write('<script type="text/javascript">');
document.write('regAdSlot(\'adSlot4|sz=160x90;tile=4;\');');
document.write('</script>');
}

function galleryHeadAd(cat){
document.write('<iframe id="adSlot5" src="http://ad.doubleclick.net/adi/'+ show +'/' + cat +';sz=300x60;tile=5;ord=' + ord + '?" width="300" height="60" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no">');
document.write('</IFRAME>');
 // register slot 5
document.write('<script type="text/javascript">');
document.write('regAdSlot(\'adSlot5|sz=300x60;tile=5;\');');
document.write('</script>');
}

function oneBy1Ad(cat){
document.write('<script language="JavaScript" src="http://ad.doubleclick.net/adj/'+ show +'/' + cat +';sz=1x1;tile=6;ord=' + ord + '?" type="text/javascript"><\/script>');
}

function ad185by60(cat){
document.write('<iframe id="adSlot7" src="http://ad.doubleclick.net/adi/'+ show +'/' + cat +';sz=185x60;tile=7;ord=' + ord + '?" width="185" height="60" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no">');
document.write('</IFRAME>');
 // register slot 7
document.write('<script type="text/javascript">');
document.write('regAdSlot(\'adSlot7|sz=185x60;tile=7;\');');
document.write('</script>');
}

function ad300by100(cat){
document.write('<iframe id="adSlot8" src="http://ad.doubleclick.net/adi/'+ show +'/' + cat +';sz=300x100;tile=8;ord=' + ord + '?" width="300" height="100" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no">');
document.write('</IFRAME>');
 // register slot 8
document.write('<script type="text/javascript">');
document.write('regAdSlot(\'adSlot8|sz=300x100;tile=8;\');');
document.write('</script>');
}

//use this on the pages refreshIframes('home') or whatever the section is
function refreshIframes(cat){
		var adUrl = "http://ad.doubleclick.net/adi/" + show + "/" + cat + ";";
//		alert(adUrl);
		var seed = Math.random() + "";
		var ord= seed * 1000000000000000000;
		for(var i=0; i<adSlotArray.length; i++){
			var adSlotId =adSlotArray[i].substring(0,adSlotArray[i].indexOf("|"));
			var adSlotParam = adSlotArray[i].substring(adSlotArray[i].indexOf("|")+1);
			var newAdUrl= adUrl + adSlotParam  +"ord=" + ord + "?";
			findObj(adSlotId).src=newAdUrl;
		}
	}
	
	function findObj(name) {
		if(document.layers) {
			return (document.layers[name]) ? eval(document.layers[variableName]) : null;
		}
		else if(document.all && !document.getElementById) {
			return (eval("document.all." + name)) ? eval("document.all." + name) : null;
		}
		else if(document.getElementById && document.body.style) {
			return (document.getElementById(name)) ? eval(document.getElementById(name)) : null;
		}
	}
