
function loadAd(content){
	if (adZone.artist.toUpperCase() == "THISIS50.COM")adZone.artist = "50 Cent";
	adZone.artist = encodeURIComponent(adZone.artist);
	adZone.genre = encodeURIComponent(adZone.genre);
	adZone.loadCounter = 0;
	adZone.adLoaded = false;
	adZone.elementName = content;
	if ((adZone.artist == null) || (adZone.artist == ''))adZone.artist = "Madonna";
	if ((adZone.genre == null) || (adZone.genre == ''))adZone.genre = "POP";
//========
	adZone.maxSlots = 4; // Max types of slot used
	//adZone.adtype = 0;  // 0=Random, else see Select AdStyle below 
	if ((adZone.adtype == 0) || (adZone.adtype == null))adZone.adtype = Math.floor(Math.random()* adZone.maxSlots)+1;
	routeToAdsense = false;	// Route all ads to Adsense

	adZone.debug = false;

	//adZone.location = 'local';
	//adZone.location = 'test';
	adZone.location = 'production';

	adZone.traceON = "TRUE";
//========					
		//set all the parameters for adZone		
	setZoneParams(); // Set common params
	setSizeParams();
//alert("Type="+adZone.adtype);
	if (routeToAdsense){
		showAdSenseTargeted(content);
	}else{
		//Select ad Style
		//alert('AdType='+adZone.adtype)
	    switch (parseInt(adZone.adtype)){
		default: //"quiz"
		case 1: //"control";
			adZone.zoneid = 346;
			adZone.contestid = 85;
			adZone.designid = 49;
			adZone.introStyle = '';
			break;
		case 2:	//"Version B"
			adZone.zoneid = 347;
			adZone.contestid = 85;
			adZone.designid = 50;
			adZone.introStyle = '';
			break;
		case 3:	//"c"
			adZone.zoneid = 348;
			adZone.contestid = 85;
			adZone.designid = 52;
			adZone.introStyle = '';
			//adZone.soundeffect = "FALSE"
			break;
		case 4:	//"Version C"
			adZone.zoneid = 349;
			adZone.contestid = 85;
			adZone.designid = '';
			adZone.introStyle = '1';
			//adZone.soundeffect = "FALSE"
			break;
		case 5:	//"Version D"
			adZone.zoneid = 350;
			adZone.contestid = 85;
			adZone.designid = '';
			adZone.introStyle = '1';
			//adZone.soundeffect = "FALSE"
			break;
		}
		PlayListSite();
	}
}	
function PlayListSite(){
	showSurePeak(adZone.elementName);
}

function setSizeParams(){
switch (adZone.width){
case "160":
	adZone.googleslot = "8758232127";
	break;
case "250":			
	adZone.googleslot = "2495754152";
	break;
case "300":
	adZone.googleslot = "9650837814";
	break;
case "728":
	adZone.googleslot = "7910838097";
	break;
default:
	adZone.googleslot = "2495754152";
	break;
}
}
function setZoneParams(){
	adZone.soundeffect = "FALSE"
	adZone.showqa = "FALSE";	// do not show AD on quiz
	adZone.donotautostartad == "FALSE";
	adZone.searchMode = 0;	// Do not need to crawl the page Artist
	adZone.filterid = 0;	// no filter id used
	adZone.adstyle = "list";			
	adZone.autoduration="30000";
	adZone.adfontcolor="255";
	adZone.adfont="Arial";
	adZone.adbackgroundcolor="16777215";
	adZone.apercent="0";
	adZone.bpercent="0";
	adZone.aretrypercent="1";
	adZone.pageview="true";
	adZone.opmode="startevent";
	adZone.gridstylename = "";
	if (adZone.xid == undefined)adZone.xid = "";
	if (adZone.quizLandingURL == undefined)adZone.quizLandingURL ="";
	adZone.plID = "";
	adZone.searchMode = 0;
	adZone.filterid = 0;
	
	adZone.googleclientid="pub-3290174722613795";
	adZone.googleurl = document.URL;
	if (adZone.zoneid =="172")adZone.googleurl = "http%3A%2F%2F%2FC%3A%2Fwww.site.com%2F"+adZone.artist+".htm";
		
	//adZone.adbritesid="867800"; //RN right side
	adZone.adbritesid="894205";	//RN 1
	adZone.adbritezs="3732385f3930";
	
	adZone.widgetName = "AdWidget";
	adZone.widgetNameSize = adZone.widgetName+adZone.width+"x"+adZone.height;
//===========
	if (adZone.location == "production")adZone.widgeturl = "http://rnquiz.surepeak.net/QuizPlayer/Quiz250x250.swf";			
	if (adZone.location == "test")adZone.widgeturl = "http://go.surepeak.net/QuizPlayer/Quiz250x250.swf";			
	if (adZone.location == "local")adZone.widgeturl = "file:///C:/Working/SurePeak/QuizPlayer/bin-debug/Quiz250x250.swf";
	//myAlert("widget used",adZone.widgeturl);
//===========
}
 		
//============
function showSurePeak(content){
	pStr = '?zoneid='+adZone.zoneid+'&contestid='+adZone.contestid+'&showbackground=0&displaymode=4&designid='+adZone.designid+'&introstyle='+adZone.introStyle+'&soundeffect='+adZone.soundeffect+'&artist1='+adZone.artist+'&artistgenre='+adZone.genre;
	//aStr = '<object '+'width="'+adZone.width+'" height="'+adZone.height+'"><param name="wmode" value="transparent"><param name="AllowScriptAccess" value="always"><param name="movie" value="'+adZone.widgeturl+pStr+'"><embed src="'+adZone.widgeturl+pStr+'" '+'width="'+adZone.width+'" height="'+adZone.height+'"></embed></object>';
	aStr = '<object type="application/x-shockwave-flash" width="'+adZone.width+'" height="'+adZone.height+'" data="'+adZone.widgeturl+pStr+'"><param name="wmode" value="transparent"><param name="AllowScriptAccess" value="always"><param name="movie" value="'+adZone.widgeturl+pStr+'"/></object><br><br>';
//alert(aStr);
	document.write(aStr);
}

function showAdSenseTargeted(content){
	var clientID = adZone.googleclientid;
	var slot = adZone.googleslot;
	var myURL = adZone.googleurl;
	//alert(adZone.googleurl);
	var aStr = '<SCRIPT type=text/javascript><!--google_ad_client = '+clientID+';/* Google Ad Slot */google_ad_slot = '+slot+';google_ad_width = '+adZone.width+';google_ad_height = '+adZone.height+';//--></SCRIPT><SCRIPT type=text/javascript src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></SCRIPT><SCRIPT> window.google_render_ad(); </SCRIPT><IFRAME height='+adZone.height+' marginHeight=0 src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-'+clientID+'&amp;dt=1222733808640&amp;lmt=1222733808&amp;output=html&amp;slotname='+slot+'&amp;correlator=1222733808640&amp;url='+myURL+'&amp;frm=0&amp;ga_vid=2021607141.1222733809&amp;ga_sid=1222733809&amp;ga_hid=1164950069&amp;flash=9.0.124.0&amp;u_h=1050&amp;u_w=1680&amp;u_ah=1020&amp;u_aw=1680&amp;u_cd=32&amp;u_tz=-420&amp;u_java=true" frameBorder=0 width='+adZone.width+' allowTransparency name=google_ads_frame marginWidth=0 scrolling=no></IFRAME>';
	document.getElementById(content).innerHTML = aStr;
}

function AdSense(content){
	document.write('<script type="text/javascript"><!--\n');
	document.write('google_ad_client = "pub-3290174722613795";\n');
	document.write('/* zone, created 9/27/08 */\n');
	document.write('google_ad_slot = "'+adZone.googleslot+'";\n');
	document.write('google_ad_width = '+adZone.width+';\n');
	document.write('google_ad_height = '+adZone.height+';\n');
	document.write('//-->\n');
	document.write('</script>');
	document.write('<script type="text/javascript"\n');
	document.write('src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\n');
	document.write('</script>\n');
}
function showAdBrite(content){
	document.write('<div id="AdBrite">');
	document.write('<!-- Begin: AdBrite -->\n');
	document.write('<script type="text/javascript">\n');
	document.write('   var AdBrite_Title_Color = "0000FF";\n');
	document.write('   var AdBrite_Text_Color = "000000";\n');
	document.write('   var AdBrite_Background_Color = "FFFFFF";\n');
	document.write('   var AdBrite_Border_Color = "FFFFFF";\n');
	document.write('</script>\n');
	document.write('<span style="white-space:nowrap;">\n');
	document.write('<script src="http://ads.adbrite.com/mb/text_group.php?sid='+adZone.adbritesid+'&zs='+adZone.adbritezs+' type="text/javascript"></script>\n');
	document.write('<!--\n');
	document.write('-->\n');
	document.write('</p>\n');
	document.write('<p>\n');
	document.write('<!-- End: AdBrite -->\n');
	document.write('</div>');
	//document.write('<a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid='+adZone.adbritesid+'&afsid=1">\n');
	//document.write('<img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-leaderboard.gif" style="background-color:#FFFFFF" alt="Your Ad Here" width="14" height="90" border="0"></a></span>');
}
	
function addElement(ele) {
    var m = "New Element";
    var n = document.createElement("div");
    n.appendChild(document.createTextNode(m));
    document.getElementById(ele).appendChild(n); 
} 

function removeElement(ele) {
    var x = document.getElementById(ele);
    x.removeChild(x.lastChild);
}

function myAlert(title,msg){
	if (adZone.debug)alert(title+": "+msg);
}
function myTrace(tfile,tinfo,tdata){ //Ajax call
    myRequest = createXMLHTTPRequest(); // get an object to call the server
    try {
        hostURL = "http://"+window.location.hostname + "/trace.php"
		//myRequest.open("GET",+hostURL+"?tfile="+tfile+"&tinfo="+tinfo+"&tdata="+tdata, true);
        myRequest.open("GET","http://www.surepeak.net/site/trace.php?tfile="+tfile+"&tinfo="+tinfo+"&tdata="+tdata, true);
    	}
    catch (err4) {
        //alert('failed to open a connection to the server: ' + err4.description); return;
    	}
    myRequest.onreadystatechange = checkStatus; // assign callback function
    try {
        myRequest.send(null); // body is null
    	}
    catch (err5) {
        //alert('failed to send to server'); return;
    	}
}

function createXMLHTTPRequest() {
var request = false;
try {
    request = new XMLHttpRequest(); /* Firefox */
}
catch (err1) 
{
    try {
        request = new ActiveXObject('Msxml2.XMLHTTP'); // some IE's
    }
    catch (err2) {
        try {
            request = new ActiveXObject('Microsoft.XMLHTTP'); // some IE's
        }
        catch (err3) {
        	//alert("Ajax not supported");
            request = false;
        }
    }
}
return request;
} // end getXMLHTTPRequest

function checkStatus(){
	if (myRequest.readyState == 4) {
		if (myRequest.status == 200) {
			//alert(myRequest.responseText);
		}
		else {
			//alert('an error occurred in state 4: ' + myRequest.status);
		}
	}
}
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?"));
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
		aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}
 