var message="System Maintenance Warning: Maintenance was recently performed on the Course Manager/Player. Click [OK] to update your course manager now!";
var strHelpOptions = "location=no";
strHelpOptions += ",toolbar=yes";
strHelpOptions += ",menubar=yes";
strHelpOptions += ",status=yes";
strHelpOptions += ",scrollbars=yes";
strHelpOptions += ",resizable=yes";
strHelpOptions += ",top=0";
strHelpOptions += ",left=0";
strHelpOptions += ",width=630";
strHelpOptions += ",height=440";

function BrowserCheck() {
	var b = navigator.appName;
	var agt=navigator.userAgent.toLowerCase();

	if ( b == "Netscape" ) {
		this.b = "ns";
	} else if ( b == "Microsoft Internet Explorer" ) {
		this.b = "ie";
	} else {
		this.b = b;
	}

	this.v = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns3  = (this.b == "ns" && this.v  < 4); // modified by Wendy Bossons, Skillsoft Corporation, October 2000
	this.ns   = (this.b == "ns" && this.v >= 4);
	this.ns4  = (this.b == "ns" && this.v == 4);
	this.ns6  = (this.b == "ns" && this.v == 5); // odd as this seems... (JeffMacD 2002/06)
	this.ns62 = (agt.indexOf('gecko') != -1);  // could be mozilla or netscape
	this.ie3  = (this.b == "ie" && this.v  < 4); // modified by Wendy Bossons, Skillsoft Corporation, October 2000
	this.ie   = (this.b == "ie" && this.v >= 4);
	this.ie4  = (navigator.userAgent.indexOf('MSIE 4')  == 0);
	this.ie5  = (navigator.userAgent.indexOf('MSIE 5')   > 0);
	this.ie50 = (navigator.userAgent.indexOf('MSIE 5.0') > 0);
	this.ie55 = (navigator.userAgent.indexOf('MSIE 5.5') > 0);
	if (this.ie5) { 
		this.v = 5;
	}
	this.min = (this.ns || this.ie);

	//Begin Macintosh fixed PhongLe 02-09-2006
	//---------------------------------------------------------------
	var APPLE_WEB_KIT__BEGIN_BUILD_FOR_V12 = 125.2;
	var SAFARI_BEGIN_BUILD_FOR_V12 = 125.8;

	var APPLE_WEB_KIT__BEGIN_BUILD_FOR_V13 = 312.1;
	var SAFARI_BEGIN_BUILD_FOR_V13 = 312;

	var APPLE_WEB_KIT__BEGIN_BUILD_FOR_V20 = 412;
	var SAFARI_BEGIN_BUILD_FOR_V20 = 412;

	var APPLE_WEB_KIT_LENGTH = 12;
	var SAFARI_LENGTH = 7;
	var appleWebKitIndex = -1;
	var emptyIndex = -1;
	var userAgent = navigator.userAgent;
	var appleWebKitIndex = userAgent.indexOf("AppleWebKit");
	var safariIndex = userAgent.indexOf("Safari");
	var macIndex = userAgent.indexOf("Mac");
	
	if (macIndex > 0 && appleWebKitIndex > 0 && safariIndex >0) {
		emptyIndex = userAgent.indexOf(" ", appleWebKitIndex + APPLE_WEB_KIT_LENGTH);
		var appleWebKitBuild = parseInt(userAgent.substring(appleWebKitIndex + APPLE_WEB_KIT_LENGTH, emptyIndex));
		emptyIndex = -1;	
		emptyIndex = userAgent.indexOf(" ", safariIndex + SAFARI_LENGTH);
		if (emptyIndex = -1) emptyIndex = userAgent.length;
		var safariBuild = parseFloat(userAgent.substring(safariIndex + SAFARI_LENGTH, emptyIndex));
		
		if (appleWebKitBuild < APPLE_WEB_KIT__BEGIN_BUILD_FOR_V20 &&	safariBuild < SAFARI_BEGIN_BUILD_FOR_V20 ) 	{
			this.v = 1.3;			
		
			if (appleWebKitBuild < APPLE_WEB_KIT__BEGIN_BUILD_FOR_V13 && safariBuild < SAFARI_BEGIN_BUILD_FOR_V13 ) {
				this.v = 1.2;			
		
				if (appleWebKitBuild < APPLE_WEB_KIT__BEGIN_BUILD_FOR_V12 && safariBuild < SAFARI_BEGIN_BUILD_FOR_V12 )  {
					this.v = 1;
				}
			}
		} else {
			this.v = 2;
		}

		this.b = "sf";
		this.sf = (this.b == "sf" && this.v >= 1.2 );
		this.sf12 = (this.v == 1.2);
		this.sf13 = (this.v == 1.3);
		this.sf2 = (this.v == 2);		
		this.min = (this.min || this.sf);
	}
	//---------------------------------------------------------------
	//End Macintosh fixed PhongLe 02-09-2006

}

// automatically create the "is" object
is = new BrowserCheck();

function doLogin() {
	if( document.loginForm.login.disabled == true || document.loginForm.password.disabled == true) {
		alert("\nSkillPort has not finished initializing your desktop settings.\n\nClick OK, wait a few seconds, then login again.\n\n");
		return;
	}

	var the_form;
	the_form = document.forms['loginForm'];
	  // Code for popup box
	
	if (the_form.login.value == "") {
		alert("\n Data Validation Error.\nPlease enter your user name.");
		if( the_form.login.disabled == false) {
			 the_form.login.focus();
		}
		return;
	}

	if (the_form.password.value == "") {
		alert("\n Data Validation Error.\nPlease enter your password.");
		if( the_form.password.disabled == false) {
			the_form.password.focus();
		}
		return;
	}
	
	findTime();
	confirmSkillportMessage(message);
}

function findTime() {
	var theMonths = new Array();
	theMonths = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
	var now = new Date();
	var theHour = now.getHours();
	var theMin = now.getMinutes();
	var theDay = now.getDate();
	var theMonth = now.getMonth();
	var theYear = now.getYear();
	g24Time = "" + (theHour);
	g24Time += ((theMin<10) ? ":0" : ":")+theMin;
	g24Time += (theHour >= 12) ? " pm" : " am";
	g24Time = escape(g24Time);
	gTime = "" + ((theHour>12) ? theHour - 12 : theHour);
	gTime += ((theMin<10) ? ":0" : ":")+theMin;
	gTime += (theHour >= 12) ? " pm" : " am";
	gTime = escape(gTime);

	if ((!is.ie)&&(!(is.minor== "4.05"))) {
		theYear+=1900;
	}

	gDate = ""+theMonths[theMonth]+" "+theDay+" "+theYear;
	gDate = escape(gDate);
} 

function confirmSkillportMessage(message) {
	doSubmitForm();
} 

function doSubmitForm()	{
	var now = new Date();
	var offset = now.getTimezoneOffset()/60;
	document.forms['loginForm'].utcoffset.value = offset;
	document.forms['loginForm'].lmode.value = "login";
	document.forms['loginForm'].theTime.value = gTime;
	document.forms['loginForm'].theDate.value = gDate;
	document.forms['loginForm'].method = "post";
	document.forms['loginForm'].action = "http://msbcollege.skillport.com/skillportfe/login/validate.cfm";
	document.forms['loginForm'].submit();
}

function showContextSpecificHelp(strUrl) {
	window.open(strUrl, "Help", strHelpOptions);
}