var agt;
var ver;
var is_major;
var is_minor;
var is_nav;
var is_nav2;
var is_nav3;
var is_nav4;
var is_nav4up;
var is_nav46up;
var is_navonly     ;
var is_nav5;
var is_nav5up;
var is_ie  ;
var is_ie3 ;
var is_ie4 ;
var is_ie5 ;
var is_ie6 ;
var is_ie7 ;
var is_ie4up ;
var is_ie401up ;
var is_ie5up ;
var is_aol  ;
var is_aol3 ;
var is_aol4 ;
var is_aol5 ;
var is_aol6 ;
var is_aol7 ;
var is_win  ;
var is_win95;
var is_win16;
var is_win31;
var is_win98;
var is_winnt;
var is_win32;

if ((parent.frames.menu != null) &&
    !(document.documentElement && typeof document.documentElement.style.maxHeight != "undefined")) //not IE7, which breaks when asking apbout the parent in frames with cross-domain content
{
	if (parent.frames.menu.document.location.href.indexOf("home_menu.asp") > 0)
	{
		for (i=0; i<parent.frames.menu.document.images.length; i++)
		{
			if (parent.frames.menu.document.images[i].name.substring(0,3) == "img")
				parent.frames.menu.document.images[i].src = 'images/trans.gif'
		}
		if (parent.frames.menu.document.images.img2 != null)
			parent.frames.menu.document.images.img2.src = "images/left_arrow_yellow.gif"
	}
}

function DoIt(CourseID, Version, NextLook, Expired, CustomerNumber)
{
	var t = new Date().getTime();

	idBrowser();

	protocol = document.location.protocol;
	protocol = protocol.toLowerCase();
	if (protocol == 'https:')
	{
		protocol = 'http:';
	}

	host = document.location.host;
	host = host.toLowerCase();

	if (Expired != 0)
	{
		alert("Your license for for this course has expired. 'Refresh' this page to purchase a new license.");
		return;
	}

	if ( (NextLook != 0) && (!is_ie401up) || is_nav )
	{
		alert("Microsoft IE 4.01 or higher is required to run this course.");
		return;
	}

	if ( (NextLook == 0) && (!is_ie401up) )
	{
		alert("Microsoft IE 4.01 or higher is required to run this course.");
		return;
	}
	if (NextLook == 0)
	{
		window.top.location.href=protocol + "//" + host + "/CPE/cpeonline/CourseNotAvail.htm";
	}
	else
	{
		launchWin = window.open("","LaunchWin")
		launchWin.top.location.href=protocol + "//" + host + "/cpeonline2/" + CourseID + "/" + Version + "/" +  "startup.htm?ID=" + CustomerNumber + "&CourseID=" + CourseID + "&Version=" + Version + "&xyzzy=" + t;
		launchWin.focus();
	}
}

function idBrowser()
{
	agt=navigator.userAgent.toLowerCase();
	ver=navigator.appVersion.toLowerCase();

	is_major = parseInt(ver);
	is_minor = parseFloat(ver);

	is_nav = ((agt.indexOf('mozilla') != -1)    &&
				 (agt.indexOf('spoofer') == -1)    &&
				 (agt.indexOf('compatible') == -1) &&
				 (agt.indexOf('opera') == -1)      &&
				 (agt.indexOf('webtv') == -1));
	is_nav2    = (is_nav && (is_major == 2));
	is_nav3    = (is_nav && (is_major == 3));
	is_nav4    = (is_nav && (is_major == 4));
	is_nav4up  = (is_nav && (is_major >= 4));
	is_nav46up = (is_nav && ((is_major > 4) || ((is_major==4) && (is_minor >= 4.6))));
	is_navonly = (is_nav && ((agt.indexOf(";nav")  != -1) ||
	                         (agt.indexOf("; nav") != -1)));
	is_nav5   = (is_nav && (is_major == 5));
	is_nav5up = (is_nav && (is_major >= 5));

	is_ie  = (agt.indexOf("msie") != -1);
	is_ie3 = (is_ie && (is_major < 4));
	is_ie4 = (is_ie && (is_major == 4) &&  (agt.indexOf("msie 5.0") == -1));
	is_ie5 = (is_ie && (is_major == 4) && ((agt.indexOf("msie 5.0") != -1) || (agt.indexOf("msie 5.5") != -1)));
	is_ie6 = (is_ie && (is_major == 4) && ((agt.indexOf("msie 6.") != -1)));
	is_ie7 = (is_ie && (is_major == 4) && ((agt.indexOf("msie 7.") != -1)));

	if (is_ie5 || is_ie6 || is_ie7) is_ie4 = false;

	is_ie4up  = (is_ie  && (is_major >= 4));
	is_ie401up =
		(is_ie &&
			(
				is_ie5 || is_ie6 || is_ie7 ||
				(
					(is_major == 4) &&
					(
						(is_minor >= 4.01) || (agt.indexOf("msie 4.01") != -1)
					)
				)
			)
		);
	is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);

	// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
	// or if this is the first browser window opened.  Thus the
	// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.

	is_aol  = (agt.indexOf("aol") != -1);
	is_aol3 = (is_aol && is_ie3);
	is_aol4 = (is_aol && is_ie4);
	is_aol5 = (is_aol && is_ie5);
	is_aol6 = (is_aol && is_ie6);
	is_aol7 = (is_aol && is_ie7);

    is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );

    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.

    is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?

    is_win16 = ((agt.indexOf("win16")!=-1) ||
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
               (agt.indexOf("windows 16-bit")!=-1) );

    is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".

    is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    is_win32 = (is_win95 || is_winnt || is_win98 ||
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));
}

