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)
{
	debug(clip +" - "+ player +"."+ size);
    player = player.toUpperCase();
    size = size.toLowerCase();

    popWindow(siteRoot + "clips/clips.html?movie="+clip+"&size="+player+size, 648, 488, "trailer");
}

function popAIM()
{
    popWindow(siteRoot + "aim/index.html", 700, 500, "aim_icons");
}

function popWallpaper(number, size)
{
	openWindow(siteRoot + "wallpaper/wallpaper.html?image=cm_wall"+size+"_0"+number+".jpg");
}

function downloadScreensaver(os)
{
	if (os == "mac")
	{
		downloadFile(siteRoot + "screensavers/screensaver_setup.sit");
	}
	else if (os == "pc")
	{
		downloadFile(siteRoot + "screensavers/screensaver_setup.zip");
	}
}
