var localRoot = "";
var siteRoot = "";

//function track(page, link){
//	alert(page);
//	alert(link);
//	hitbox.Set_hbPageView(page, link);
//};


var newwindow;
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");
}
function openWindow2(url, win){
	newwindow = window.open(url,win,"directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes");
	if (window.focus) {newwindow.focus()}
}

function popWindow( url, width, height, windowName ) {
    //get center coords
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    
    newwindow = window.open(url, windowName, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
	if (window.focus) {newwindow.focus()}
}
function popLink( url, width, height, windowName ) {
	popWindow( url, width, height, windowName );
}


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 popWallpaper(country, filename){
	//openWindow2(siteRoot + country + "/wallpaper.html?image=../"+filename, "wllpapers");
	popup(siteRoot + country + "/wallpaper.html?image=../"+filename, 700, 500, 'wallpaper', 'yes', 'yes');
}

function popAIM(country, filename){
	popWindow(siteRoot + country + '/aim.html?image=../'+filename, 413, 490, "aim");
}

function popSignatures(country, filename){
	track('email+sigs+download');
	popWindow(siteRoot + country + '/signatures.html?image=../'+filename, 300, 300, "signatures");
}

function popAdsPrintXXX(country, filename){
	openWindow(siteRoot + country + "/ads.html?image=../"+filename);
}

function popAdsPrint(country, filename){
	openWindow2(siteRoot + country + "/ads.html?image=../"+filename, "printAds");
}

function popTokenzone(url){
	hitbox.Set_hbLink('Exit_cars_TOKENZONE');
	openWindow2(url, "_blank");
}

//function popDownload(country, filename){
//	popWindow(siteRoot + filename, 200, 200, "_self");
//}


function popDownload(country, theFile, title){
    if (theFile == 'http://media.disney.go.com/disneypictures/cars/CarsDemo.exe'){//this is what the flash is passing
		theFile = 'http://amedia.disney.go.com/disneypictures/cars/CarsDemo.exe';//if url needs to be changed, change here
		track('pc');
	}
	else if (theFile == 'http://media.disney.go.com/disneypictures/cars/CarsDemo.dmg'){//this is what the flash is passing
		theFile = 'http://amedia.disney.go.com/disneypictures/cars/CarsDemo.dmg';//if url needs to be changed, change here
		track('mac');
	}
	popWindow(siteRoot + "download.html?theFile="+escape(theFile), 400, 200, "downloadWindow");
}

function popDownAds(country, theFile){
    popWindow(siteRoot + "download.html?theFile="+theFile, 400, 200, "downloadWindow");
}

function popPodcastSubscribe(){
    popWindow(siteRoot + "podcast_subscribe.html", 370, 240, "podcast");
}

function debug(string){
    if (debugFlag == true) { alert(string); }
}

function flashDebug(string){
	//to make sure nothing breaks
}

function popClip(clip, player, size){
    player = player.toUpperCase();
    size = size.toLowerCase();
    popWindow(localRoot + 'clips/clips.html?movie='+clip+'&size='+player+size, 648, 488, "trailer");
}