function popWindow( 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=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
}
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 openWindow(url)
{
    var rand = "_blank";
    return window.open(url,rand,"directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes");
}

var debugFlag = false;
function debug(text)
{
	if (debugFlag)
	{
		alert(text);
	}
}

function downloadFile(theFile)
{
    popWindow("download.html?theFile="+theFile, 400, 150, "downloadWindow");
}

function popDVDClipWindow(clipCode)
{
    popWindow("http://www.totaleclips.com/disney/player/splash.asp?clipid="+clipCode,340,490,"trailer");
}

function popTrailer()
{
    track("trailer");
	popDVDClipWindow("e20228");
}

function popClip(clip, player, size)
{
	if (clip == "1" || clip == "trailer")
	{
		popTrailer();
	}
	else if (clip == "2" || clip == "clip1")
	{
		track("clip1");
		popDVDClipWindow("e20927");
	}
	else if (clip == "3" || clip == "clip2")
	{
		track("clip2");
		popDVDClipWindow("e20928");
	}
	else if (clip == "4" || clip == "clip3")
	{
		track("clip3");
		popDVDClipWindow("e20929");
	}
	else if (clip == "5" || clip == "clip4")
	{
		track("clip4");
		popDVDClipWindow("e20930");
	}
	else if (clip == "6")
	{
		track("clip5");
		popDVDClipWindow("xxx");
	}
	else if (clip == "commercial1")
	{
		track("commercial1");
		popDVDClipWindow("e21788");
	}
}

function popAim()
{
	track("icons+downloads");
	popWindow('aim/aim.html', 500, 416, 'aim_icons');
}

function popEcard(card)
{
	//track("ecard+"+card);
	popScrollingWindow("ecards/ecards.html?card="+card+"_card.jpg", 600, 600, "ecards");
}

function popEcard1()
{
	track("card1");
	popEcard("maggie");
}
function popEcard2()
{
	track("card2");
	popEcard("slim");
}
function popEcard3()
{
	track("card3");
	popEcard("buck");
}
function popEcard4()
{
	track("card4");
	popEcard("jack");
}

function popWallpaper(number, size)
{
	track("wp"+number+"+"+size);
	openWindow("wallpaper/wallpaper.html?wallpaper=wallpaper_"+number+"_"+size+".jpg");
}

function popColorUsGame()
{
	track("color+us");
	popWindow('colorus.html', 637, 500, 'color_us');
}

function popMineGame()
{
	//track("mine+race+game");
	popWindow("hotr-minecar.html", 640, 480, "minecar");
}
function popMineGameNoTrack()
{
	popWindow("hotr-minecar.html", 640, 480, "minecar");
}

function popTokenGame()
{
	track("tokenzone");
	openWindow("http://disney.tokenzone.com/dtz2/set/hotr/Home");
}

function popBuckGame()
{
	track("buck+game");
	//popWindow("http://disney.go.com/disneypictures/homeontherange/buckrescue/index.html", 750, 450, "buck_game");
	popWindow("http://disney.go.com/disneyvideos/animatedfilms/homeontherange/buckrescue/index.html", 750, 450, "buck_game");
}

function popPatchChoir()
{
	track("little+patch+game");
	popWindow("patch.html", 640, 582, "patch_game");
}

function popSSOS9()
{
	track("ss+ox9");
	downloadFile("screensaver/hotr_ss_OS9.sit");
}

function popSSOSX()
{
	track("ss+ox10");
	downloadFile("screensaver/hotr_ss_OSX.sit");
}

function popSSWindows()
{
	track("ss+pc");
	downloadFile("screensaver/screensaver_setup.zip");
}

function popThemePC()
{
	track("desktop+icons+dload");
	downloadFile("themes/theme.zip");
}
function popThemeMac()
{
	track("desktop+icons+dload");
	downloadFile("themes/theme.sitx");
}

function popOrder()
{
	track("order");
	openWindow("http://go-disneystore.com/homeontherangedvd");
}

function popMailtoCall(targetEmail, subject, body)
{
	window.location.href = "mailto:"+targetEmail+"?subject="+subject+"&body="+body;
}
function popMailto()
{
	track("challengeSend");
	var subject = escape("");
	var body = escape("Check out this cool game online:\nhttp://www.luckyjackminerace.com\n\nWalt Disney Pictures presents\nHOME ON THE RANGE\nComing to Disney DVD & Video September 14\nFor more fun games and activities go to www.homeontherangeDVD.com\n\nRated G for General audiences.\n(c) Disney");
	popMailtoCall("",subject,body);
}

var aimPopup = "";
function popAimWindow(name, message)
{
	message = escape(escape(message) );
	//window.location.href = "aim:goim?screenname="+name+"&message="+message;
	aimPopup = popWindow("aim:goim?screenname="+name+"&message="+message,1,1,"aim");
	setTimeout("killAimPopup()",5000);
}
function killAimPopup()
{
	aimPopup.close();
}

function popCommercialIM()
{
	track("im+a+friend");
	popAimWindow("","Check Out This Cool Video Clip on http://www.HomeOnTheRangeDVD.com.<br>Home On the Range - Now On DVD And Video!");
}
