var siteRoot = "";

function popWindow( url, width, height, windowName )
{
    //get center coords
    var windowLeft = (screen.width - width) / 2;
    var windowTop = (screen.height - height) / 2;
    
    return window.open(url, windowName, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + windowLeft + ',top=' + windowTop);
}
function popScrollingWindow(url, width, height, windowName)
{
    //get center coords
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    
    return window.open(url, windowName, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
}
function popScrollingWindowWithMenu(url, width, height, windowName)
{
    //get center coords
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    
    return window.open(url, windowName, 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
}
function openWindow(url)
{
    return window.open(url,"_blank");
}

function downloadFile(theFile)
{
    popWindow(siteRoot + "download.html?theFile="+theFile, 400, 200, "downloadWindow");
	//window.location.href = theFile;
}

var debugFlag=false;
function debug(string)
{
    if (debugFlag == true)
	{
		alert(string);
	}
}

function popBuddyIcons()
{
	track("download+icons");
    //popWindow(siteRoot + "aim/index.html", 770, 500, "aim_icons");
    //openWindow(siteRoot + "aim/index.html");
	window.location.href = siteRoot + "aim/index.html";
}

function popWallpaper(number, size)
{
	track("wp"+number+"+"+size);
	openWindow(siteRoot + "wallpaper/wallpaper.html?image=incred_wall_"+number+"_"+size+".jpg");
}

function popSecretWallpaper(size)
{
	var wpnumber = "ss";
	var wpsize = "800";

	if (size == "small") wpsize = "800";
	if (size == "medium") wpsize = "1024";
	if (size == "large") wpsize = "1280";

	popWallpaper(wpnumber, wpsize);
}

function popScreensaver(os)
{
	if (os == "win")
	{
		track("ss+windows+dload");
		downloadFile(siteRoot + "screensavers/screensaver_setup.zip")
	}
	else if (os == "mac")
	{
		track("ss+os10+dload");
		downloadFile(siteRoot + "screensavers/incredibles_ss_OSX.sit")
	}
}

function popOrder()
{
	popOrderNow();
}
function popOrderNow()
{
	track("order+now");
	//popWindow("http://disneyvideos.disney.go.com/moviefinder/calltoorder.html",375,280,"order");
	openWindow("http://www.go-disneydirect.com/theincrediblespreorderdvd");
}

function refreshPage()
{
	window.location.href = window.location.pathname;
}

function downloadAlarmClock(clock)
{
	track("download+clocks");
	downloadFile("clocks/alarm" + clock + ".zip");
}

function popMobilePhone()
{
	track("mobile+phone");
	openWindow("http://mobile.disney.go.com/incredibles/index");
}
function popMediaPlayer()
{
	track("media+player");
	alert("Coming Soon");
}

function popTokenzone(section)
{
	switch(section)
	{
	case "landing":
		track("tokenzone");
		openWindow("http://disney.tokenzone.com/dus/processHiddenToken?setId=6015&ac=6015127-tc127-qy5yu-n4wi2-ssij2-5gsnd");
		break;
	case "about":
		track("additional+tokenzone");
		openWindow("http://disney.tokenzone.com/dus/processHiddenToken?setId=6015&ac=6015128-tc128-7pfnf-vv82s-xnh8m-whm62");
		break;
	case "games":
		track("additional+tokenzone");
		openWindow("http://disney.tokenzone.com/dus/processHiddenToken?setId=6015&ac=6015132-tc132-jy5jw-ykig6-vajkb-kn6u8");
		break;
	case "strength":
		track("additional+tokenzone");
		openWindow("http://disney.tokenzone.com/dus/processGame?setId=6015&ac=6015108-tc108-qwhel-ynwlm-38dnk-e4ry8");
		break;
	case "activities":
		track("additional+tokenzone");
		openWindow("http://disney.tokenzone.com/dus/processHiddenToken?setId=6015&ac=6015129-tc129-rb2tj-s85m4-8rj8e-xdiv7");
		break;
	case "downloads":
		track("additional+tokenzone");
		openWindow("http://disney.tokenzone.com/dus/processHiddenToken?setId=6015&ac=6015130-tc130-e7mhg-bzcyi-zmkp6-yryw2");
		break;
	case "clips":
		track("additional+tokenzone");
		openWindow("http://disney.tokenzone.com/dus/processHiddenToken?setId=6015&ac=6015131-tc131-hqqsy-6dg8c-sweft-dsdnv");
		break;
	case "galleries":
		track("additional+tokenzone");
		openWindow("http://disney.tokenzone.com/dus/processHiddenToken?setId=6015&ac=6015131-tc131-hqqsy-6dg8c-sweft-dsdnv");
		break;
	default:
		track("tokenzone");
		openWindow("http://disney.tokenzone.com/incredibles");
		break;
	}
}
function popTradingCards()
{
	popTokenzone();
}

function popShop()
{
	track("disney+store");
	openWindow("http://disney.store.go.com/DSSectionPage.process?Merchant_Id=2&Section_Id=13951");
}

function popSoundtrack()
{
	track("disney+records");
	openWindow("http://disney.go.com/disneyrecords/soundtracks/incredibles/index.html");
}

function linkTo(section)
{
	switch (section)
	{
	case "home":
		window.location.href = siteRoot + "index.html";
		break;
	case "download":
		window.location.href = siteRoot + "index.html?deeplink=download";
	default:
		break;
	}
}

function popGame_strength()
{
	popWindow("superstrength.html",777,525,"strength")
}
function popGame_thin_ice()
{
	popWindow("thin_ice.html",620,450,"thin_ice")
}
function popGame_catch_dash()
{
	popWindow("catch_dash.html",620,450,"catch_dash")
}
function popSticker(number)
{
	track("ss+bumper+download");
	var stickerLink = "stickers/DadBumperFinalrev.jpg";

	if (number == 1) stickerLink = "stickers/DadBumperFinalrev.jpg";
	if (number == 2) stickerLink = "stickers/MomBumperFinalrev.jpg";
	if (number == 3) stickerLink = "stickers/VioletBumperFinalrev.jpg";
	if (number == 4) stickerLink = "stickers/DashBumperFinalrev.jpg";
	if (number == 5) stickerLink = "stickers/JackJackBumperFinal.jpg";

	openWindow(siteRoot + stickerLink);
}

function popSweepstakes()
{
	popEnterSweepstakes()
}

function popFreeDVDPoster()
{
	track("ss+poster+download");
	window.location.href = "https://register.go.com/bvhe/incredibles/poster";
}

function popOfficialRules()
{
	openWindow("http://disney.go.com/disneyvideos/animatedfilms/incredibles/sweepstakes/rules.html");
}

function popEnterSweepstakes()
{
	track("ss+enter+sweepstakes");
//	window.location.href = "https://register.go.com/bvhe/sweeps/incredibles/entry";
	popWindow('sweepsover.html',400,300,'sweepsover');
}

function popEnterSecretSite()
{
	window.location.href = "https://register.go.com/bvhe/incredibles/secretsite";
}

function popWMPSkin()
{
	popSkinDownload("inc_skinpopup_mediaplayer.jpg", "Incredibles.wmz");
}

function popWinAmpSkin()
{
	popSkinDownload("inc_skinpopup_winamp.jpg", "Incredibles.wal");
}

function popIMSkin(skinNum)
{
	var imageFile = "";
	var downloadLink = "";

	if (skinNum == 1)
	{
		imageFile = "inc_skinpopup_im_dash.jpg";
		downloadLink = "Dash_IncredibleSkin.545";
	}
	else if (skinNum == 2)
	{
		imageFile = "inc_skinpopup_im_edna.jpg";
		downloadLink = "Edna_IncredibleSkin.545";
	}
	else if (skinNum == 3)
	{
		imageFile = "inc_skinpopup_im_mr.jpg";
		downloadLink = "MrIncredible_IncredibleSkin.545";
	}

	popSkinDownload(imageFile, downloadLink);
}

function popSkinDownload(imageFile, downloadLink)
{
	window.location.href = siteRoot + "skins/index.html?image="+imageFile+"&link="+downloadLink;
	//downloadFile(siteRoot + "skins/" + downloadLink);
}
