/* calculate ratio number of 10000*/



var p=parent;var d=document;var axel=Math.random()+"";var rNum=(axel*10000)+"";var dotat=rNum.indexOf(".");var aNum=rNum.substring(0,dotat);

var count=1;var dUnit=false;var dUnitSky=false;var dUnitBox=false;var sops="";var spos;var skyAd=false;

if(!snc){if(p.snc){var snc=p.snc;}else{var snc="";}}

if(!spos){if(p.spos){var spos=p.spos;}else{var spos="";}}

if(!sky_exist){if(p.sky_exist){var sky_exist=p.sky_exist;}else{var sky_exist=false;}}

// set variable defaults

useHouseAds = true;

// house list array - edited by Rachel, Ednel & Neil. 

// If you aren't Rachel or Ednel and want to edit

// this file make sure you're using the latest version

// format is:

// added google ads functionality which is still very basic - only one google add exists for the skyscraper slot. 

// I also split the ad formats out into a block each - houseList is for leaderboards, skyList is for skyscrapers,  boxList for boxes.

// flash is selected by filename. you can have a swf leaderboard and a jpg sky or vice-versa. If the swf is created, as for dart, with a clickTag, the same link as for the image will be used.

// leaving include empty means the file may appear anywhere, inserting sadpg or szone include means that a unit will not appear in a page that doesn't have either its szone or sadpg listed

// exclude is performed after include so a page that is first included then excluded will not run the unit.

// include and exclude can contain multiple entries separated by commas -- <Idol,Junos,TopStories, ShowsHome>

// default for target is "_top". Use "_blank" to open in a new window. Target doesn't work for flash.

// all artwork, except for swf files, need to filed using the img2 option in the pub tool. Path = /CTVShows/img2/Programs/Ads/

// all swf artwork needs to be FTP'd to: /generic/images/ads/SWF/

// format is:

// <link><sky ad filename><alt text><stats counter><szone exclude><sadpg exclude><szone include><sadpg include><target>

// ads on hold:

// none





var ord = -1;



var houseList_ctv = new Array(



"<http://healthblog.ctv.ca/blog><728medNEWS_blog2.gif><Med News Express Blog><medBlog><><><><><_self>",



"<http://www.ctv.ca/mednewsexpress><728medNEWS_lttr.gif><Med News Express Newsletter><medNews><><><><><_self>"

);

// format is:



// <link><sky ad filename><alt text><stats counter><szone exclude><sadpg exclude><szone include><sadpg include><target>



// ads on hold:





var skyList_ctv = new Array(



"<><google1><><><Consumer,WFive><><><><>",

"<><google3><><><Consumer,WFive><><><><>",

"<><google2><><><Consumer,WFive><><><><>"

);





// format is:

// <link><Box ad filename><alt text><stats counter><szone exclude><sadpg exclude><szone include><sadpg include><target>

// ads on hold:

// none



var boxList_ctv = new Array(





"<http://healthblog.ctv.ca/blog><300medNEWS_blog2.gif><Med News Express><medBlog><><><><><_self>",



"<http://www.ctv.ca/mednewsexpress><300medNEWS_lttr2.gif><Med News Express><medBlog><><><><><_self>",



"<http://www.ctv.ca/mednewsexpress><300medNEWS_lttr.gif><Med News Newsletter><medNews><><><><><_self>",



"<http://broadband.ctv.ca/?nla=1&id=4512><300_lost815.gif><Lost in 8:15><lost815><><><><><_blank>",



"<http://www.oprah.com/obc_classic/webevent_registration.jsp><ane_island_300x250_v7.jpg><Oprah><Oprahweb><><><><><_blank>",





"<><google4><><><><><FilmFest,PhotoGallery><><>");



// ads on hold:





// none

var forcedHoused;

function initForced()

{

forcedHoused = new Array(20);

for (var i = 0; i < 20; i++)

{

    forcedHoused[i] = new Array(2);

}

//forcedHoused[0][0] = "lost";

//forcedHoused[0][1] = "3";

forcedHoused[0][0] = "Oprah2";

forcedHoused[0][1] = "4";







}



function findSpecialHouse(idname, indexID)

{

if (forcedHoused == null)

{

initForced();

}



for (var i = 0; i < 20; i++)

{

if (forcedHoused[i][indexID] == idname)

{

return forcedHoused[i][1];

}

}

return -1;

}







/* for google ads */



function googleAdVars(adname,width,height){ 



if(adname=="google1" && width=="120"){



google_ad_client = "pub-8664210252640829";

google_alternate_ad_url = "http://www.ctv.ca/generic/dynInclude/ads/skyAd/iframe.html";

google_ad_width = 120;

google_ad_height = 600;

google_ad_format = "120x600_as";

google_ad_type = "text";

google_ad_channel ="1396848704";

google_color_border = "FFFFFF";

google_color_bg = "FFFFFF";

google_color_link = "003094";

google_color_url = "003094";

google_color_text = "000000";

}



else if (adname=="google2" && width=="120"){



google_ad_client = "pub-8664210252640829";

google_alternate_ad_url = "http://www.ctv.ca/generic/dynInclude/ads/skyAd/iframe.html";

google_ad_width = 120;

google_ad_height = 600;

google_ad_format = "120x600_as";

google_ad_type = "text";

google_ad_channel ="1396848704";

google_color_border = "FFFFFF";

google_color_bg = "FFFFFF";

google_color_link = "003094";

google_color_url = "003094";

google_color_text = "000000";

}



else if (adname=="google3" && width=="120"){



google_ad_client = "pub-8664210252640829";

google_alternate_ad_url = "http://www.ctv.ca/generic/dynInclude/ads/skyAd/iframe.html";

google_ad_width = 120;

google_ad_height = 600;

google_ad_format = "120x600_as";

google_ad_type = "text";

google_ad_channel ="1396848704";

google_color_border = "FFFFFF";

google_color_bg = "FFFFFF";

google_color_link = "003094";

google_color_url = "003094";

google_color_text = "000000";

}



else if(width=="300" && szone != "Toronto"){



google_ad_client = "pub-8664210252640829";

google_alternate_ad_url = "http://www.ctv.ca/generic/dynInclude/ads/skyAd/iframe.html";

google_ad_width = 300;

google_ad_height = 250;

google_ad_format = "300x250_as";

google_ad_type = "text";

google_ad_channel ="7884233294";

google_color_border = "FFFFFF";

google_color_bg = "FFFFFF";

google_color_link = "003094";

google_color_text = "000000";

google_color_url = "003094";

}



else if(width=="300"){



google_ad_client = "pub-8664210252640829";

google_alternate_ad_url = "http://www.ctv.ca/generic/dynInclude/ads/skyAd/iframe.html";

google_ad_width = 300;

google_ad_height = 250;

google_ad_format = "300x250_as";

google_ad_type = "text";

google_ad_channel ="4661160393";

google_color_border = "FFFFFF";

google_color_bg = "FFFFFF";

google_color_link = "003094";

google_color_text = "000000";

google_color_url = "003094";

}



}



// pick house ad

function selectImg(format,num){



			if (format == "728x90"){



			houseArray = houseList_ctv;	}



			else if (format == "300x250"){ houseArray = boxList_ctv;	}



			else if (format == "120x600"){ houseArray = skyList_ctv;}

			houseArrayParse     = /<(.*)><(.*)><(.*)><(.*)><(.*)><(.*)><(.*)><(.*)><(.*)>/g ;

			szoneExclIndex = "5";

			sadpgExclIndex = "6";

			szoneInclIndex = "7";

			sadpgInclIndex = "8";

			popWin = "9";



dropAds(format);



// alert(houseArray.length);

if (num == -1)

{

	randNum = Math.floor(Math.random()*houseArray.length) ;

        var specialH = findSpecialHouse(randNum,1);

        if (specialH != -1 && format == "300x250")

        {

            randNum = 0;

        }



        

}

else

{

	randNum = num;

}



// alert(randNum);

	url = houseArray.slice(randNum,randNum+1) ;



	if (houseArray.length > 1) {



	left  = houseArray.slice(0,randNum) ;



	right = houseArray.slice(randNum+1) ;



// alert(houseArray);

	houseArray = left.concat(right) ;

	}



	return url ;

}



function dropAds(format){

		for (i=(houseArray.length) ; i > 0 ; --i) {





			var currentZone = houseArray[i-1].replace(houseArrayParse,"$"+szoneExclIndex);







			var currentAdpg = houseArray[i-1].replace(houseArrayParse,"$"+sadpgExclIndex);	





			var currentiZone = houseArray[i-1].replace(houseArrayParse,"$"+szoneInclIndex);







			var currentiAdpg = houseArray[i-1].replace(houseArrayParse,"$"+sadpgInclIndex);





			var testCurrentZone = currentZone.split(/\,/g);





			var testCurrentAdpg = currentAdpg.split(/\,/g);



			var testCurrentiZone = currentiZone.split(/\,/g);



			var testCurrentiAdpg = currentiAdpg.split(/\,/g);		





			var currentAdIncl = 1;





			//if (sadpg == "Whistler-episodes") alert(houseArray[i-1].replace(houseArrayParse,"$"+3));



			if((currentiZone != "") || (currentiAdpg != "")) {



			currentAdIncl = 0;

			inZone = 0;

			inPage = 0;



			//#1





			//if (sadpg == "Whistler-episodes") alert("#1: " + currentAdIncl);



			for (j=(testCurrentiZone.length) ; j > 0 ; --j) {



			if(testCurrentiZone[j-1] == szone){





				currentAdIncl = 1;

				inZone = 1;



			}





			}







			//#2





			//if (sadpg == "Whistler-episodes") alert("#2: " + currentAdIncl);





			for (j=(testCurrentiAdpg.length) ; j > 0 ; --j) {



			if(testCurrentiAdpg[j-1] == sadpg){



				currentAdIncl = 1;

				inPage = 1;



			}			



			}



			//#3



			//if (sadpg == "Whistler-episodes") alert("#3: " + currentAdIncl);



			if((currentiZone != "") && (currentiAdpg != "") && (inZone === 0 || inPage === 0)) {

				currentAdIncl = 0;

			}

			

			}

			







			for (j=(testCurrentZone.length) ; j > 0 ; --j) {



			if((testCurrentZone[j-1] == szone) && (szone != "")){



				currentAdIncl = 0;



			}





			}



			//#4





			//if (sadpg == "Whistler-episodes") alert("#4: " + currentAdIncl);



			for (j=(testCurrentAdpg.length) ; j > 0 ; --j) {





			if((testCurrentAdpg[j-1] == sadpg) && (sadpg != "")){



				currentAdIncl = 0;

			}			

			}

			if(currentAdIncl === 0){

				houseArray.splice((i-1),1);

			}

		}



}



// house ad code

function writeHouseAd(format,num){

display = selectImg(format,num);



if(houseArray.length > 0) {

	pick = 1 ;

		for (i=0 ; i <= pick-1 ; i++ ) {



			var urlVal  = display[0].replace(houseArrayParse,"$1") ;



			var text  = display[0].replace(houseArrayParse,"$3") ;



			var adCounter  = display[0].replace(houseArrayParse,"$4") ;



			var currentDiv = document.getElementById(format+"temp");}



			var img=display[0].replace(houseArrayParse,"$2") ;



		if(format=="120x600"){

			var ad_width="120";

			var ad_height="600";



		}	

		else if(format=="728x90") {

			var ad_width="728";

			var ad_height="90";

		}



		else if (format=="300x250"){

			var ad_width="300";

			var ad_height="250";

}



		var currentPopWin = display[0].replace(houseArrayParse,"$"+popWin);

		var	imgParse     = /(.*)\.(.*)/g ;

		var imgFormat = img.replace(imgParse,"$2") ;



		if(isbroadband=true && szone.match(/Video/)){

		currentPopWin = "_blank";

		}



		else if(currentPopWin == ""){

		currentPopWin = "_top";

		}



			var adString = "";



			if(imgFormat.indexOf("google")!=-1){



			googleAdVars(img,ad_width,ad_height);



			adString+= '<scr'+'ipt type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></scr'+'ipt>';



 adString += '<div style="display: none"><img src="http://adcounter.theglobeandmail.com/servlet/AdletCounter?ad1=ctv_google_'+ad_width+'x'+ad_height+'_ctv&ad2=ctv_'+sadpg+'Google_'+ad_width+'x'+ad_height+'_ctv" width="1" height="1" border="0"></div>';

			}



					else if(imgFormat=="swf"){



if (sadpg=="CriminalMinds-episodes2" || sadpg=="CSI-default" || sadpg=="ClosetoHome2-default" || sadpg=="LawOrderSVU-default" || sadpg=="LawOrder-episodes17" || sadpg=="ER-default" || sadpg=="bio_gary_sinise_csi_ny" || sadpg=="feature-weekend" || sadpg=="bio_patricia_arquette_medium" || sadpg=="ColdCase-episodes4" || sadpg=="CriminalMinds-default") {



adString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0" id="FLASH_AD" height="'+ad_height+'" width="'+ad_width+'"><param name="movie" value="http://www.ctv.ca/generic/images/ads/SWF/'+img+'"><param name="quality" value="autohigh"><param name="wmode" value="opaque"><embed wmode="opaque" src="http://www.ctv.ca/generic/images/ads/SWF/'+img+'" quality="autohigh" swliveconnect="TRUE" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" height="'+ad_height+'" width="'+ad_width+'"></object>'





                        adString += '<div style="display: none"><img src="http://adcounter.theglobeandmail.com/servlet/AdletCounter?ad1=ctv_'+adCounter+'House_'+ad_width+'x'+ad_height+'swf_ctv&ad2=ctv_'+sadpg+'House_'+ad_width+'x'+ad_height+'_ctv" width="1" height="1" border="0"></div>';



} else {



adString += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=3,0,0,0" id="FLASH_AD" height="'+ad_height+'" width="'+ad_width+'"><param name="movie" value="http://www.ctv.ca/generic/images/ads/SWF/'+img+'?clickTag='+urlVal+'"><param name="quality" value="autohigh"><param name="wmode" value="opaque"><embed wmode="opaque" src="http://www.ctv.ca/generic/images/ads/SWF/'+img+'?clickTag='+urlVal+'" quality="autohigh" swliveconnect="TRUE" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" height="'+ad_height+'" width="'+ad_width+'"></object>'





                        adString += '<div style="display: none"><img src="http://adcounter.theglobeandmail.com/servlet/AdletCounter?ad1=ctv_'+adCounter+'House_'+ad_width+'x'+ad_height+'swf_ctv&ad2=ctv_'+sadpg+'House_'+ad_width+'x'+ad_height+'_ctv" width="1" height="1" border="0"></div>';



}



}



		else {



			adString += '<a href="'+urlVal+'" target="'+currentPopWin+'"><img src="http://www.ctv.ca/archives/CTVShows/img2/Programs/Ads/'+img+'" width="'+ad_width+'" name="&lid=AdLink_' + adCounter + '_' +ad_width+'x'+ad_height+ '" height="'+ad_height+'" alt="'+text+'" border="0"></a>';



			adString += '<div style="display: none"><img src="http://adcounter.theglobeandmail.com/servlet/AdletCounter?ad1=ctv_'+adCounter+'House_'+ad_width+'x'+ad_height+'_ctv&ad2=ctv_'+sadpg+'House_'+ad_width+'x'+ad_height+'_ctv" width="1" height="1" border="0"></div>'; 

}



// if(format == '120x600'){



// document.write('<scr'+'ipt type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></scr'+'ipt>')



// }

// else{

if((document.getElementById(format+"temp")) && (imgFormat.indexOf("google")==-1)){

			currentDiv.innerHTML = adString;

			currentDiv.style.display = "block";

}



else{



document.write(adString);



}



}



}	



// doubleclick code

function writeDClick(size) {



if(ord == -1){var abc=Math.random()+"";ord=abc.substring(2,abc.length);}



if((size=="728x90")&&(sky_exist)){spos="dsky";}



if(isbroadband=true && szone.match(/Video/)){



var adCodeTxt ='<iframe src="http://ad.ca.doubleclick.net/adi/ctv/Video'+szone+';!category=pop;!category=video;!category=float;!category=expand;sz='+size+';ord='+ord+'" id="adiframe" width="728" height="90" scrolling="no" frameborder="0"></iframe>';



adCodeTxt += '<div style="display: none"><img src="http://adcounter.theglobeandmail.com/servlet/AdletCounter?ad1=ctv_'+sadpg+'Dart_'+size+'_ctv" width="1" height="1" border="0"></div>';

document.getElementById(size+'temp').innerHTML=adCodeTxt;

}



else{

var newT = "";

if (size=="728x90")

{

newT = ";dcopt=ist";

}

var adCodeTxt='<scr'+'ipt type=\"text/javascript\" src=\"http://ad.ca.doubleclick.net/adj/ctv.'+szone+';sz='+size+newT+';tile='+count+';ord='+ord+'?\">'+'<\/scr'+'ipt>';



document.write(adCodeTxt);






	var currentDiv = document.getElementById(size+"temp");



if (currentDiv != null) {

	currentDiv.style.display = "none";

}



}



	count=count+1;spos="";

}



// main functions

// the stardard way to place an ad is writeHouseAd("120x600");

function placeRandom(format){



// ratio of doubleclick ads to house ads is 1 to nth (right now 1 to 8) 

var nth = 8;

var rnd = Math.floor(Math.random() * nth) + 1;

if (rnd == nth) {

     useHouseAds = false; 

}



// initialize variables and set conditions

// exceptions to this ratio follow:

// only doubleclick ads on the Contest Hub 

// - traffic is low on this hub and it 

// makes it easy to see dart ads to have 

// one hub with only doubleclick.



// skyscrapers ratio

if((format == "120x600")){

	useHouseAds = true;

        //if(aNum>=0000){useHouseAds=false;}
	}



// Home

if((szone == "Home")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	}



// TopStories

if((szone == "TopStories")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// Canada, World, Health, Politics, MSNHome

if((szone == "Canada" || szone == "World" || szone == "Politics" || szone == "MSNHome" || szone == "Health")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}	

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// Business

if((szone == "Business")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// SciTech

if((szone == "SciTech")){

	useHouseAds = true;

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// Entertainment

if((szone == "Entertainment" || szone == "entertainment")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}	

	}



// only paid ads on Canada AM 

if((szone == "CanadaAM")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// only paid ads on Holiday Main 

if((szone == "holiday/main")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// only paid ads on Poll Results 

if((szone == "AM")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	}



// only paid ads on Photo Gallery

if((szone == "PhotoGallery" && format == "300x250")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// only paid on Photo Sky

if((szone == "PhotoSky")){

	useHouseAds = true;

	if(format=="160x600"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// Sports

if((szone == "Sports")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// Peak Performer

if((szone == "PeakPerformer")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// Kris Abel

if((szone == "krisabel")){

	useHouseAds = true;

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	}



// only paid ads on Programs, TV Listings and Contest

if((szone == "ShowsHome" || szone == "ComingUp" || szone == "Daytime" || szone == "HDTV" ||  szone == "LateNight" || szone == "TopShows" ||  szone == "tvlist" || szone == "AToZ" || szone == "Primetime" || szone == "ContestsHub")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	}



// only paid ads on Weather 

if((szone == "Weather")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// only paid on Junos

if((szone == "Junos")){

	useHouseAds = true;

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	}



// only paid on Oscars

if((szone == "Oscars")){

	useHouseAds = true;

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	}



// only paid on FilmFest

if((szone == "FilmFest")){

	useHouseAds = true;

	}



// only paid ads on Toronto

if((szone == "Toronto" || szone == "TorontoHome")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// only house ads on Consumer

if((szone == "Consumer")){

	useHouseAds = true;

	}



// only paid ads on test

if((szone == "test" || "test2")){

	useHouseAds = false;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="120x600"){if(aNum>=0000){useHouseAds=false;}}

	}



// only house ads on PSA

if((szone == "PSA")){

	useHouseAds = true;

	}



// only house ads on idol

if((szone == "Idol" || szone == "idol" || szone == "idolblogs" || szone == "idolblogshouse" || szone == "Idol/pantene/backstage" || szone == "Idol/pantene/competitors" || szone == "Idol/allaccess" || szone == "Idol/confidential" || szone == "idolphotogallery")){

	useHouseAds = true;

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}		

	}



// Degrassi

if((szone == "Degrassi")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	}



// Controls Concert for Diana

if((szone == "concertfordiana")){

	useHouseAds = true;

	if(format=="728x90"){if(aNum>=0000){useHouseAds=false;}}

	if(format=="300x250"){if(aNum>=0000){useHouseAds=false;}}

	}



// Instant Star

if((szone == "InstantStar")){

	useHouseAds = true;

	}



// Video

if(szone.match(/Video/)){

	useHouseAds = true;

	}



// Video News Zones

if((szone == "VideoETalk" || szone.match("VideoToronto") || szone.match("VideoBritishColumbia") || szone.match("VideoOttawa") || szone.match("VideoEdmonton") || szone.match("VideoWinnipeg") || szone == "VideoCanadaAM" || szone == "VideoNews" || szone == "VideoElevenP" || szone == "VideoWFive" || szone == "VideoNewsTab" || szone == "VideoDocs" || szone =="VideorelatedTopStories" || szone =="VideorelatedWorld" || szone=="VideorelatedCanada" || szone=="VideoVGDEGR" || szone=="VideoVGCIDOL")){

	useHouseAds = false;

	}



// Happy box ads

if((szone == "happy" && format == "300x250")){

	useHouseAds = false;

	}



// Happy leaderboard

if((szone == "happy" && format == "728x90")){

	useHouseAds = false;

	}



// Lost

if (sadpg == "Lost" && format =="120x600") {

	useHouseAds = true;

}



//Criminal Minds pages

if((szone == "Degrassi" )){

	useHouseAds = false;

	}

	

if((szone == "InstantStar" )){

	useHouseAds = false;

	}



if((dUnitSky)||(dUnitBox)){useHouseAds=false;}

//FORCE

//useHouseAds = false;



var specialH = findSpecialHouse(szone,0);

if (specialH != -1 && format == "300x250")

{

   writeHouseAd(format, specialH);

}

else if(useHouseAds == true){

	writeHouseAd(format,-1);

	}



else {

	writeDClick(format);

}



	}



// these functions are for reverse-compatibility 

function placeCTVRandom120x600Img(isBlank){

placeRandom("120x600");

}



function placeRandom728x90Img(isBlank){

placeRandom("728x90");

}



function placeRandom300x250Img(isBlank){

placeRandom("300x250");

}

function writeFooterLocal()
{
    document.write('<style>#footTopNav {background-color:#EFEFEF;padding-bottom:5px;padding-top:5px;text-align:center;}#totalBottomFooter {color:black;font-size:10px;font-weight:bold;text-align:center;}#allFooter {color:black;font-family:Verdana,Arial,sans-serif;font-size:11px;text-align:left;}#footBottomNav {background-color:#CFCFCF;padding-bottom:5px;padding-top:5px;}#totalBottomFooter {color:black;font-size:10px;font-weight:bold;text-align:center;}#footIcons {background-color:#C61B13;padding-bottom:5px;padding-top:5px;}#totalBottomFooter2 {color:white;font-size:10px;font-weight:bold;text-align:center;}#totalBottomFooter a {color:black;}#allFooter a:hover {text-decoration:underline;}#allFooter a {text-decoration:none}#totalBottomFooter2 a {color:#FFFFFF;padding:3px;}</style>\
     <div id="allFooter"><div id="totalBottomFooter"> <div id="footTopNav">  <a href="http://www.ctv.ca/generic/generated/static/CorpAbout/about.html" name="&lid=Footnav_About">About CTV</a>  |  <a href="http://works.workopolis.com/customers/bgm/gi/" target="_blank" name="&lid=Footnav_Careers">Careers</a>  |  <a href="http://www.ctv.ca/announce" name="&lid=Footnav_Announce">CTV Announcements</a>  |  <a href="http://sales.ctv.ca/" target="_blank" name="&lid=Footnav_AdTV">Advertise on TV</a>  |  <a href="http://ctvmedia.ca/" target="_blank" name="&lid=Footnav_AdMedia">CTV Media</a>  |  <a href="http://www.ctv.ca/generic/generated/static/CorpAdvertise/default.html" name="&lid=Footnav_AdWeb">Advertise on Web</a></div><div id="footBottomNav">  \
     <a href="http://www.ctv.ca/generic/generated/static/CorpTranscripts/transcripts.html" name="&lid=Footnav_ArchiveSales">Archive Sales</a>  |  <a href="http://www.ctv.ca/generic/generated/static/CorpTranscripts/transcripts.html" name="&lid=Footnav_Transcripts">Tapes and Transcripts</a>  |  <a href="http://www.ctvglobemedia.com/en/policiestermsconditions/privacypolicy/" name="&lid=Footnav_Privacy">Privacy Policy</a>  |  <a href="http://www.ctvglobemedia.com/en/policiestermsconditions/termsconditions/" name="&lid=Footnav_Terms">Terms and Conditions</a>  |  <a href="http://www.ctv.ca/contactus">Contact Us</a>  |  <a href="http://www.ctv.ca/sitemap">Site&nbsp;Map</a></div></div><div id="totalBottomFooter2"><div id="footIcons"> \
      <a href="http://www.ctv.ca/servlet/ArticleNews/story/CTVNews/1124900164735_120309364" name="&lid=Footnav_Newsnet">CTV Newsnet </a>  |  <a href="http://www.bnn.ca" target="_blank" name="&lid=Footnav_Rob">BNN </a>  |  <a href="http://www.cp24.com" target="_blank" name="&lid=Footnav_CP24">CP24 </a>  |    <a href="http://www.Atv.ca/" target="_blank" name="&lid=Footnav_Achannel">&rsquo;A&rsquo;</a>  |  <a href="http://www.muchmusic.com" target="_blank" name="&lid=Footnav_Much">MuchMusic </a>  |  <a href="http://www.mtv.ca" target="_blank" name="&lid=Footnav_Mtv">MTV </a>  |  <a href="http://www.muchloud.com/" target="_blank" name="&lid=Footnav_Muchloud">MuchLoud </a>  |  <a href="http://www.muchmoremusic.com/" target="_blank" name="&lid=Footnav_Muchmoremusic">MuchMoreMusic </a> \
         |  <a href="http://www.muchmoreretro.com/" target="_blank" name="&lid=Footnav_Muchmoreretro">MuchMoreRetro </a>    |  <a href="http://www.muchvibe.ca/" target="_blank" name="&lid=Footnav_Muchvibe">MuchVibe</a>  |  <a href="http://www.punchmuch.com/" target="_blank" name="&lid=Footnav_Punch">PunchMuch </a>  |  <a href="http://www.mtv2.ca/" target="_blank" name="&lid=Footnav_MTV2">MTV2</a>  <br/>    <a href="http://www.tsn.ca" target="_blank" name="&lid=Footnav_Tsn">TSN </a>	| <a href="http://www.tsn2.ca" target="_blank" name="&lid=Footnav_Tsn2">TSN2</a>	| <a href="http://www.rds.ca/" target="_blank" name="&lid=Footnav_Rds">RDS</a>  |  <a href="http://www.tsn.ca/nhl_network" name="&lid=Footnav_Nhl">NHL Network </a> |  <a href="http://www.rds.ca/ris/index.php" target="_blank" name="&lid=Footnav_Rob">RIS Info Sports </a>  | \
          <a href="http://www.tsn.ca/classic" target="_blank" name="&lid=Footnav_Cp24">ESPN Classic </a>  |  <a href="http://www.thecomedynetwork.ca" target="_blank" name="&lid=Footnav_Comedy">Comedy</a>  |  <a href="http://www.fashiontelevision.com/" target="_blank" name="&lid=Footnav_Fashion">Fashion TV </a>  |  <a href="http://www.courttvcanada.ca/" target="_blank" name="&lid=Footnav_Court">Court TV </a>  |  <a href="http://www.sextelevision.net/" target="_blank" name="&lid=Footnav_Sex">Sex TV </a>    |  <a href="http://www.bravo.ca" target="_blank" name="&lid=Footnav_Bravo">Bravo!</a>|  <a href="http://www.booktelevision.com/" target="_blank" name="&lid=Footnav_Booktv">Book TV </a>    |  <a href="http://www.accesstv.ca/" target="_blank" name="&lid=Footnav_Accesstv">ACCESS </a> \
           <br/>  <a href="http://www.discoverychannel.ca" target="_blank" name="&lid=Footnav_Discovery">Discovery Channel</a>|  <a href="http://www.discoveryhd.ca/" target="_blank" name="&lid=Footnav_Discoveryhd">Discovery HD </a>    |  <a href="http://www.discoverycivilization.ca/" target="_blank" name="&lid=Footnav_Discoveryciv">Discovery Civilization </a>  |  <a href="http://www.animalplanet.ca/" target="_blank" name="&lid=Footnav_Animalplanet">Animal Planet </a>  |  <a href="http://www.travelandescape.ca/" target="_blank" name="&lid=Footnav_Travel">Travel+escape</a>  |  <a href="http://www.driveinclassics.ca/" target="_blank" name="&lid=Footnav_Drivein">Drive-in Classics</a>  |  <a href="http://www.tvlandcanada.com/" target="_blank" name="&lid=Footnav_Tvland">TV Land</a>  | \
            <a href="http://www.star-tv.ca/" name="&lid=Footnav_Star">Star! </a>  |    <a href="http://www.spacecast.com/" target="_blank" name="&lid=Footnav_Rob">Space </a>  </div></div><div id="footCopyRight"><p>&copy; 2008 <a href="http://www.ctvglobemedia.com" target="_blank"><img src="http://images.ctv.ca/mar/images/logo/ctvglobemedia.gif" class="inline" width="144" height="34" alt="CTVglobemedia" style="vertical-align: middle" border="0" /></a> All Rights Reserved.</p></div></div></div>');
}


