var siteRoot = "";

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");
}

function downloadFile(theFile){
    popWindow(siteRoot + "download.html?theFile="+theFile, 300, 100, "downloadWindow");
}

var debugFlag=false;
function debug(string){
    if (debugFlag == true)
	{
		alert(string);
	}
}

function track(trackString){
    switch (trackString)
    {
    case "XXXXX":
        debug(trackString);
        break;
    default:
        debug(trackString);
        //_hbPageView(trackString, "/NewProject");
        break;
    }
}

function popClip(clip, player, size){
    player = player.toUpperCase();
    size = size.toLowerCase();

    popWindow(siteRoot + "clips/clips.html?movie="+clip+"&size="+player+size, 648, 488, "trailer");
}

function popNews() {
    popWindow(siteRoot + "news_popup.html", 400, 400, "pop_news");
}


function popAIM() {
    popWindow(siteRoot + "aim.html", 461, 540, "aim_icons");
}

function popRegister(){
    popWindow(siteRoot + "register.html", 406, 530, "register");
}

function popWallpaper(number, size){
	openWindow(siteRoot + "wallpaper/wallpaper.html?image=wallpaper_05_"+number+"_"+size+".jpg");
}

function launchSite(){
	var url = "main.html";
	//var width = document.width;
	var width = 980;
	var height = 625;
	var windowName = "site";

	var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    
    window.open(url, windowName, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);

}

var screenWidth = screen.width;
var screenHeight = screen.height;
//
function newWindow(mypage, myname, w, h, scroll, size) {
	var winl = Math.round((screenWidth-w)/2);
	var wint = Math.round((screenHeight-h)/2);
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+size;
	myWin = window.open(mypage, myname, winprops);
	if (parseInt(navigator.appVersion)>=4) {
		myWin.window.focus();
	}
}

function popFooterLink(num){
	if(num == "1"){
		var url ="http://www.sonybmgmasterworks.com/artistsites/producers/main_module.html";
		newWindow(url,'soundtrack',550,350,'no','no');
	} else if (num == "2"){
		//tickets
		var url = "http://movies.aol.com/movie/main.adp?_pgtyp=pdct&mid=19246";
		openWindow(url);
	} else if (num == "3"){
		//deeplink trailer
		var url = "http://www.apple.com/trailers/universal/the_producers/";
		openWindow(url);
	} else if (num == "4"){
		var url ="http://www.producersonbroadway.com/";
		openWindow(url);
	} else if (num == "5"){
		//partners
	} else if (num == "6"){
	} else if (num == "7"){
		var url ="http://homevideo.universalstudios.com/title_old.php?titleId=2783";
		openWindow(url);
	}
};

function popScreensaver(num){
	if(num == "1"){
		downloadFile("screensaver/TheProducers_ScreensaverMacX.sitx");
	} else if (num == "2"){
		downloadFile("screensaver/TheProducers_ScreensavePC.zip");
	}
}