var pillar = 0;
var UpdateDurationInterval;
var FeedbackWindow;
var openeval = true;
var isunload = false;

function toolbarstart()
{
    LinkClick(1);
}

function logoff()
{
    LinkClick(13);
    self.location.href = "default.aspx";
}

function moreinfo()
{
    LinkClick(2);
    var w = screen.width;
    var h = screen.height;
    var features = "height=600,width=960,resizable=1,scrollbars=1";
    helpWindow = window.open("http://www.windowsvista.com/", "_blank", features , "help");
}

function referafriend()
{
    LinkClick(3);
    location.href="mailto:?subject=Try%20the%20Microsoft%20Windows%20Vista%20Business%20Test%20Drive&Body=Hello%2C%20I%20thought%20you%20might%20like%20to%20try%20Windows%20Vista%20Business%20for%20yourself%21%20%20The%20Windows%20Vista%20Business%20test-drive%20allows%20you%20to%20try%20%28or%20%22test-drive%22%29%20the%20latest%20operating%20system%20from%20Microsoft%20without%20having%20to%20install%20it%20on%20your%20PC.%20%20By%20simply%20logging%20onto%20our%20test-drive%20environment%20using%20your%20web-browser%2C%20you%20will%20be%20able%20to%20experience%20Windows%20Vista%20first-hand.%0D%0A%0D%0AClick%20http%3A//www.windowsvistatestdrive.com%20to%20begin%20your%20test-drive%20experience%21";
}

function buynow()
{
    LinkClick(4);
    var w = screen.width;
    var h = screen.height;
    var features = "height=600,width=960,resizable=1,scrollbars=1";
    
    window.open("http://www.microsoft.com/smallbusiness/buy/software/detail.mspx/", "_blank", features , "buynow");                
}

function openFeedback(linkclick)
{
    if(FeedbackWindow == null || FeedbackWindow.closed)
    {
        LinkClick(linkclick);
        var w = 975;
	    var h = 600;
	    wleft = (screen.width - w) / 2;
        wtop = (screen.height - h - 30) / 2;
	    if (wleft < 0) wleft = 0;
	    if (wtop < 0) wtop = 0;
	    FeedbackWindow = window.open("feedback/eval.aspx?cid="+CID+"&token="+Token, "FeedbackWindow", "height="+h+",width="+w+",left="+wleft+",top="+wtop+",scrollbars=yes,resizable=0");

		if (isunload==false && (FeedbackWindow==null || typeof(FeedbackWindow)=="undefined"))
		{
			alert("You have a pop-up blocker that blocked the feedback window from being opened.\rPlease configure your pop-up blocker to allow pop-ups from this site.");
		}
		else if (FeedbackWindow!=null && typeof(FeedbackWindow)!="undefined")
		{
		    document.cookie = "evalopen=1";
            FeedbackWindow.focus();
		}
	}
	else
	{
        FeedbackWindow.focus();
    }
}

function unload()
{
    if (openeval)
    {
        if (get_cookie("evalopen") != "1")
        {
            isunload = true;
            openFeedback(15);
        }
    }
}

function openWindow(url, linkclick)
{
    LinkClick(linkclick);
    var w = 960;
	var h = 600;
	wleft = (screen.width - w) / 2;
    wtop = (screen.height - h - 30) / 2;
	if (wleft < 0) wleft = 0;
	if (wtop < 0) wtop = 0;
	OpenWindow = window.open(url, "_blank", "height="+h+",width="+w+",left="+wleft+",top="+wtop+",scrollbars=yes,resizable=1");

	if (OpenWindow==null || typeof(OpenWindow)=="undefined")
	{
		alert("You have a pop-up blocker that blocked the new window from being opened.\rPlease configure your pop-up blocker to allow pop-ups from this site.");
	}
}

var labID;

function getURLParameters() 
{
    var sURL = window.document.URL.toString();
	
    if (sURL.indexOf("?") > 0)
    {
        var arrParams = sURL.split("?");
			
        var arrURLParams = arrParams[1].split("&");
		
        var arrParamNames = new Array(arrURLParams.length);
        var arrParamValues = new Array(arrURLParams.length);
		
        var i = 0;
        for (i=0;i<arrURLParams.length;i++)
        {
	        var sParam =  arrURLParams[i].split("=");
	        arrParamNames[i] = sParam[0];
	        if (sParam[1] != "")
		        arrParamValues[i] = unescape(sParam[1]);
	        else
		        arrParamValues[i] = "No Value";
        }
		
        for (i=0;i<arrURLParams.length;i++)
        {
        }
    }
    else
    {
    }
    
    labID = arrParamValues[0];        
}
        
function playVid(sz)
{
    switch(sz)
    {
        case "view1":
            document.getElementById("titlebar").src = "images/safe_dh1.gif";
            break;
        case "view2":
            document.getElementById("titlebar").src = "images/safe_dh2.gif";
            break;
        case "view3":
            document.getElementById("titlebar").src = "images/safe_dh3.gif";
            break;
        case "view4":
            document.getElementById("titlebar").src = "images/safe_dh4.gif";
            break;
        case "view5":
            document.getElementById("titlebar").src = "images/safe_dh5.gif";
            break;
        case "view6":
            document.getElementById("titlebar").src = "images/efficient_dh1.gif";
            break;
        case "view7":
            document.getElementById("titlebar").src = "images/efficient_dh2.gif";
            break;
        case "view8":
            document.getElementById("titlebar").src = "images/efficient_dh3.gif";
            break;
        case "view9":
            document.getElementById("titlebar").src = "images/efficient_dh4.gif";
            break;
        case "view10":
            document.getElementById("titlebar").src = "images/connected_dh1.gif";
            break;
        case "view11":
            document.getElementById("titlebar").src = "images/connected_dh2.gif";
            break; 
        case "view12":
            document.getElementById("titlebar").src = "images/connected_dh3.gif";
            break;
        case "view13":
            document.getElementById("titlebar").src = "images/connected_dh4.gif";
            break;
        case "view14":
            document.getElementById("titlebar").src = "images/collaborate_dh1.gif";
            break;
        case "view15":
            document.getElementById("titlebar").src = "images/collaborate_dh2.gif";
            break;
        case "view16":
            document.getElementById("titlebar").src = "images/collaborate_dh3.gif";
            break;
        case "view17":
            document.getElementById("titlebar").src = "images/collaborate_dh4.gif";
            break;
        case "view18":
            document.getElementById("titlebar").src = "images/collaborate_dh5.gif";
            break;
        default : alert(sz);
    }
        
    var vid = "videos/" + sz + ".asx";

    var d = document.getElementById("vidhere");
    d.innerHTML = "<object id='VideoPlayer' height='480' width='640' classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' standby='Loading the video preview...' type='application/x-oleobject' VIEWASTEXT>" +
        "<PARAM NAME='FileName' VALUE='" + vid + "'>" +
        "<PARAM NAME='AnimationatStart' VALUE='1'>" +
        "<PARAM NAME='TransparentatStart' VALUE='1'>" +
        "<PARAM NAME='AutoStart' VALUE='1'>" +
        "<PARAM NAME='ShowControls' VALUE='0'>" +
        "<PARAM NAME='ShowDisplay' VALUE='0'>" +
        "<PARAM NAME='ShowStatusBar' VALUE='0'>" +
        "<PARAM NAME='AutoSize' VALUE='1'>" +
        "<PARAM NAME='InvokeUrls' VALUE='0'>" +
        "</object>";
    VideoPlayer = document.getElementById("VideoPlayer");
}                

function hideDivs()
{
    document.getElementById("divSafe").style.display = 'none';
    document.getElementById("divEfficient").style.display = 'none';
    document.getElementById("divConnected").style.display = 'none';
    document.getElementById("divCollaborative").style.display = 'none';
}

function pillarClick(sz)
{                        
    var cdiv, imgsrc;
    hideDivs();
    contents.scrollTop = 0;
    switch (sz)
    {
        case "safe":
            cdiv = document.getElementById("divSafe"); 
            imgsrc = "images/safe_header.gif";
            pillar = 1;
            break;
        case "efficient":
            cdiv = document.getElementById("divEfficient");
            imgsrc = "images/efficient_header.gif";
            pillar = 2;
            break;
        case "connected":
            cdiv = document.getElementById("divConnected");
            imgsrc = "images/connected_header.gif";
            pillar = 3;
            break;
        case "collaborative":
            cdiv = document.getElementById("divCollaborative");
            imgsrc = "images/collaborate_header.gif";
            pillar = 4;
            break;
    }
    document.getElementById("titleimage").src = imgsrc;
    cdiv.style.display = 'inline';
    try
    {
	    clearInterval(UpdateDurationInterval);
        UpdateDuration();
        UpdateDurationInterval = setInterval("UpdateDuration()",10000);
    }
    catch(e) {}
}

function videoPillarClick(src, cid, token)
{
    openeval = false;
    top.location.href = "pillarmenus.aspx?cid="+cid+"&token="+token+"&src="+src;
}

function ImageOver(el)
{
    el.src = el.src.replace(".gif", "_over.gif");
}

function ImageOut(el)
{
    el.src = el.src.replace("_over", "");
}

function viewClick(sz, src, cid, token)// go to video page
{
    openeval = false;
    top.location.href = "video.aspx?cid="+cid+"&token="+token+"&src="+src+"&video=" + sz;
}

var WindowObjectReference;

function driveClick(sz, cid, token)
{
    if (CCode != "US" && CCode != "CA")
    {
        alert("Thank you for your interest in the Windows Vista Business test drive.\n\nThis trial program is available in limited geographies and languages,\nand you are currently located outside of the available area.\n\nPlease check http://www.windowsvista.com for other Windows Vista\ninformation and experiences that may be available to you.");
        return;
    }

    sz = sz.replace("drive", "");
    
    var console = "console.aspx?cid="+cid+"&token="+token+"&exercise=" + sz;

	if(WindowObjectReference == null || WindowObjectReference.closed)
	{
		var w = 1020;
		var h = 715;
		wleft = (screen.width - w) / 2;
		wtop = (screen.height - h - 95) / 2;
		if (wleft < 0) wleft = 0;
		if (wtop < 0) wtop = 0;
		WindowObjectReference = window.open(console, "vlabenhancedwindow", "height="+h+",width="+w+",left="+wleft+",top="+wtop+",scrollbars=yes,status=1,resizable=1",true);

		if (WindowObjectReference==null || typeof(WindowObjectReference)=="undefined") {
			alert("You have a pop-up blocker that blocked the console window from being opened.\rPlease configure your pop-up blocker to allow pop-ups from this site.");
		}
		clearInterval(UpdateDurationInterval);
	}
	else
	{
		WindowObjectReference.focus();
	}
}

function get_cookie(Name)
{
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0)
    {
        offset = document.cookie.indexOf(search)
        // if cookie exists
        if (offset != -1)
        { 
            offset += search.length
            // set index of beginning of value
            end = document.cookie.indexOf(";", offset);
            // set index of end of cookie value
            if (end == -1) end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}