var pageRoot = "";

function popWindow( url, width, height, windowName )
{
    //get center coords
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    
    win=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;
    
    win=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";
    win=window.open(url,rand,"directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes");
}

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

function downloadFile(theFile)
{
    popWindow(pageRoot + "download.html?theFile="+theFile, 400, 250, "downloadWindow");
}

function track(trackString)
{
	debug(trackString);
    switch (trackString)
    {
    case "XXXXX":
        break;
    default:
        debug("unhandled: " + trackString);
        _hbPageView(trackString, "/Life+Aquatic");
        break;
    }
}

function popClip(clip, player, size)
{
    player = player.toUpperCase();
    size = size.toLowerCase();

    track("watch+video+" + clip + "+" + player + "+" + size);

    popWindow(pageRoot + 'clips/clips.html?movie='+clip+'&size='+player+size, 700, 420, "_blank");
}
function popClipMenu(clip)
{
    track("watch+video+" + clip);

	if (clip.indexOf("Pods_") == -1)
	{
		popWindow(pageRoot + 'clips/clip_menu.html?movie='+clip, 700, 420, "_blank");
	}
	else
	{
		popWindow(pageRoot + 'clips/pods_menu.html?movie='+clip, 700, 420, "_blank");
	}
}

function popTrailer()
{
	track("watch+trailer");
	popTrailerNoTrack();
}
function popTrailerNoTrack()
{
	popWindow(pageRoot + "clips/trailer_menu.html", 700, 420, "trailer_menu");
}
function popJaguarSharkClip()
{
	track("watch+jaguar+shark+clip");
	popJaguarSharkClipNoTrack();
}
function popJaguarSharkClipNoTrack()
{
	popWindow(pageRoot + "clips/episode1_menu.html", 700, 420, "episode_menu");
}

function popAim()
{
	track("aim+icons")
	popWindow(pageRoot + "aim/aim.html", 700, 420, "aim_icons");
}

function popWallpaper(number, size)
{
	track("wallpaper+"+number+"+"+size);
	openWindow(pageRoot + "wallpaper/wallpaper.html?wallpaper=la_wall_"+size+"_"+number+".jpg");
}

function popFanClub()
{
	track("fan+club");
	alert("fan club pdf?");
}

function popReg()
{
	openWindow(pageRoot + "register/register.html");
}

function popID()
{
	popWindow(pageRoot + "id/idcard.html", 500, 400, "la_id");
}

function popSoundtrack()
{
	openWindow("http://hollywoodrecords.go.com/lifeaquatic/");
}
