/* calculate ratio number of 10000*/
var newT = "";
if (typeof(window["showTop"]) == "undefined")
{
newT = ";dcopt=ist";
}
var ord = -1;
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(!spos){if(p.spos){var spos=p.spos;}else{var spos="";}}
var sky_exist = false;
//if(!sky_exist){if(p.sky_exist){var sky_exist=p.sky_exist;}else{var sky_exist=false;}}

// set variable defaults

// 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 forcedDart = new Array();
forcedDart[0] = "http://www.ctv.ca/home/index2.html";
forcedDart[1] = "Awadia";
forcedDart[2] = "http://www.ctv.ca/servlet/ArticleNews/story/CTVNews/20090902/local_northern_ontario/20090902/";
forcedDart[3] = "NorthernOntario";
forcedDart[4] = "http://autos.ctv.ca";
forcedDart[5] = "autos/home";
forcedDart[6] = "http://ctv.strathcom.com/";
forcedDart[7] = "autos/home";


var nodcopt = new Array()
nodcopt[0] = "GossipGirlOneClip";
nodcopt[1] = "Home";
nodcopt[2] = "holidayguide";
nodcopt[3] = "holidayguide/tech";
nodcopt[4] = "TopStories/home";
nodcopt[5] = "TopStories/galleries";
nodcopt[6] = "Entertainment/galleries";

function getAdName(hubName)
{
    if (hubName == "##URL_hub##")
    {
        return "Home";
    }
    else if (hubName.toLowerCase() == "news")
    {
        return "TopStories/home";
    }
    else if (hubName.toLowerCase().indexOf("autos") != -1)
    {
        return "autos";
    }

	else if (hubName.toLowerCase() == "topstoriesv2")
	{
		return "TopStories/story";
	}
	else if (hubName.toLowerCase() == "entertainmentv2")
	{
		return "Entertainment";
	}
	else if (hubName.toLowerCase() == "canadaamv2")
	{
		return "CanadaAM";
	}
	
	return hubName;
}




// 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";}
var newT = "";
var addcopt = true;
for (var i = 0; i < nodcopt.length; i++)
{
    if (nodcopt[i] == szone)
    {
        addcopt = false;
        break;
    }
}

if (typeof(window["showTop"]) != "undefined")
{
addcopt = false;
}

if (size=="728x90" && addcopt == true)
{
newT = ";dcopt=ist";
}
var nszone;
var checkzone = szone.substring(0, 3);
if (checkzone == "bcc")
{
nszone = "ctvbc.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "wpg")
{
nszone = "ctvwinnipeg.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "cal")
{
nszone = "ctvcalgary.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "tor")
{
nszone = "ctvtoronto.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "edm")
{
nszone = "ctvedmonton.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "ott")
{
nszone = "ctvottawa.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "mon")
{
nszone = "ctvmontreal.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "swo")
{
nszone = "ctvswo.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "reg")
{
nszone = "ctvregina.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "sas")
{
nszone = "ctvsaskatoon.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "nby")
{
nszone = "ctvnorthbay.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "sud")
{
nszone = "ctvsudbury.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "sau")
{
nszone = "ctvsaultstemarie.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "tim")
{
nszone = "ctvtimmins.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "nor")
{
nszone = "ctvnorthernontario.ca/" + szone.substring(4).toLowerCase();
}
else if (checkzone == "atl")
{
nszone = "ctvatlantic.ca/" + szone.substring(4).toLowerCase();
}
else
{
nszone = "ctv.ca/" + szone.toLowerCase();
}

var adCodeTxt='<scr'+'ipt type=\"text/javascript\" src=\"http://ad.ca.doubleclick.net/adj/ctv.'+nszone+';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)
{
    //check to see if we should override the zone name
    for (i = 0; i < forcedDart.length; i++)
    {
        if (window.location.href == forcedDart[i])
        {
            szone = forcedDart[i + 1];
        }
    }
	writeDClick(format);
}


