function imgOver(theName) {
	document.getElementById(theName).src="programs/" + vPPath + "/images/" + theName + "_over.gif";
}

function imgOrig(theName) {
	document.getElementById(theName).src="programs/" + vPPath + "/images/" + theName + ".gif";
}

function imgDown(theName) {
	document.getElementById(theName).src="programs/" + vPPath + "/images/" + theName + "_down.gif";
}

function imgUp(theName) {
	document.getElementById(theName).src="programs/" + vPPath + "/images/" + theName + "_over.gif";
}

function arrowOver(theName) {
	document.getElementById(theName).src="programs/" + vPPath + "/images/arrow_over.gif";
}

function arrowOrig(theName) {
	document.getElementById(theName).src="programs/" + vPPath + "/images/arrow.gif";
}

function authCodeUsedMsg() {
	document.getElementById('msg').innerHTML = '<b>Your authorization number (' + readCookie('authcode') + ') was activated while you were entering your profile. Please check your number, and try again. If you believe your number is correct, please contact tech support.</b>';		
}

function multiUserMsg() {
	document.getElementById('msg').innerHTML = '<b>Another login was detected to this account. Only one user can log into an account at the same time. This typically happens when a person logs into from a different machine without logging out of the original machine. It can also happen if another user has the same login information. If you are not sure why you got this message, please notify tech support.</b>';
}

function setTextInputFocus() {
	for(var i=0; i < document.forms[0].elements.length; i++) {
		var objElement = document.forms[0].elements[i];
		if(objElement.type == "text" || objElement.type == "password") {
			objElement.focus();
			break;	
		}
	}
}

function startDemo() {

	if(checkBrowserInfo()) return;
	
	var vLink = 'setuptest.aspx?cmd=demo&formid=' + document.forms[0].formid.value + '&urid=' + document.forms[0].urid.value + '&ITDVersion=' + document.forms[0].version.value ;	
	//alert(vLink);
	//return;

	if(window.navigator.appName.indexOf('Netscape') != -1 && window.navigator.userAgent.indexOf('Mac') != -1)
		window.open(vLink, null, 'toolbar=no,menubar=no,location=no,directories=no,screenX=0,screenY=0,width='+(window.screen.availWidth-20)+',height='+(window.screen.availHeight-40)+',fullscreen=yes');
	else if(window.navigator.appName.indexOf('Netscape') != -1)
		window.open(vLink, null, 'toolbar=no,menubar=no,location=no,directories=no,screenX=0,screenY=0,width='+window.screen.availWidth+',height='+(window.screen.availHeight-20)+',fullscreen=yes');
	else if(window.navigator.userAgent.indexOf('Mac') != -1) { 
		var itdWin = window.open(vLink, null, 'resizeable=yes');
		itdWin.resizeTo(window.screen.width, window.screen.height);
		itdWin.moveTo(0, 0);
	} else
		window.open(vLink, null, 'toolbar=no,menubar=no,location=no,directories=no,fullscreen=yes');
}


function checkBrowserInfo() {			
	var browser = navigator.appName
 	var ver = navigator.appVersion
	var thestart = parseFloat(ver.indexOf("MSIE"))+1
 	var brow_ver = parseFloat(ver.substring(thestart+4,thestart+7))                                 
	var bAgent = window.navigator.userAgent; 
	var bAppName = window.navigator.appName; 
	var bMozIdx = bAgent.indexOf("Mozilla/");	
	var skipPage = true;	
	if ((bAppName.indexOf('Explorer') >= 0) && (bAgent.indexOf('MSIE 5.01') >= 0) && (bAgent.indexOf('Win') >= 0))
		skipPage = false; //win ie5
	if ((bAppName.indexOf('Explorer') >= 0) && (bAgent.indexOf('MSIE 5.5') >= 0) && (bAgent.indexOf('Win') >= 0))
		skipPage = false; //win ie5  
	else if ((bAppName.indexOf('Explorer') >= 0) && (bAgent.indexOf('MSIE 6') >= 0) && (bAgent.indexOf('Win') >= 0))
		skipPage = false; //win ie6
	else if ((bAppName.indexOf('Explorer') >= 0) && (bAgent.indexOf('MSIE 5') >= 0) && (bAgent.indexOf('Mac') >= 0))
		skipPage = false; //mac ie5
	else if ((bAppName.indexOf('Explorer') >= 0) && (bAgent.indexOf('MSIE 7') >= 0) && (bAgent.indexOf('Win') >= 0))
		skipPage = false; //mac ie5
	else if ((browser=="Microsoft Internet Explorer") && (brow_ver > 5))
		skipPage = false; //win ie6+
	else if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Netscape/7') >=0))
		skipPage = false; //netscape 7
	else if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Netscape6') >=0))
		skipPage = true;  //netscape 6
	else if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Gecko/2002') >=0))
		skipPage = false; //mozilla 1.0
	else if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Gecko/2003') >=0))
		skipPage = false; //mozilla 1.0 or above
	else if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Gecko/2004') >=0))
		skipPage = false; //future mozilla
	else if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Gecko/2005') >=0))
		skipPage = false; //future mozilla
	else if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Gecko/2006') >=0))
		skipPage = false; //future mozilla
	else if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Gecko/2007') >=0))
		skipPage = false; //future mozilla
	else if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Gecko/2008') >=0))
		skipPage = false; //future mozilla
	else if (bAgent.indexOf('Safari') >= 0)
		skipPage = false; //mac safari

	if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Netscape/7.0') >=0))
		skipPage = true;
	if ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Netscape/7.1') >=0))
		skipPage = true;
	
	if(skipPage) window.location = 'templates_starttest/browser_ascponline.htm';
	return skipPage;		
}

var blnDemoUserSumbit = false;
function demoLogin() {
	if(checkBrowserInfo()) return;

	if(document.forms[0].username.value == '')
	{
		alert('Please enter your username to proceed.');
		return;
	}
	if(document.forms[0].pwd.value == '')
	{
		alert('Please enter your password to proceed.');
		return;	
	}
	if(blnDemoUserSumbit) return;	
	document.forms[0].action = 'starttest.aspx?cmd=validatedemouser';
	blnDemoUserSumbit = true;
	document.forms[0].submit();	
}


function popWin() {
	var url_page, x, y, window_width, window_height;
	if(arguments.length == 1) {
		url_page = arguments[0];
		window_width = window.screen.width * 0.7;
		window_height = window.screen.height * 0.6;
	} else if(arguments.length == 3) {
		url_page = arguments[0];
		window_width = arguments[1];
		window_height = arguments[2];		
	} else {
		alert('Invalid parameters!');
		return;
	}	
	x = (window.screen.width - window_width) / 2 
	y = (window.screen.height - window_height) / 2;			
	var pWin = window.open(url_page, null, 'toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1,width=' + window_width + ',height=' + window_height + ',top=' + y + ',left=' + x);
	if(window.navigator.userAgent.indexOf('Mac') != -1) pWin.resizeTo(window_width, window_height);
}

function checkEmail(email) {   
		
	var invalidChars ="/:,;"
	var atPos = email.indexOf("@",1)
	var periodPos = email.indexOf(".", atPos)
	
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if(email.indexOf(badChar,0) != -1) return false;
	}
	if (atPos == -1) return false;		
	if (periodPos == -1) return false;
	if (email.indexOf("@@") != -1) return false;
	if (email.indexOf("@.") != -1) return false;
	if (email.indexOf(".@") != -1) return false;

	return true;	
}


function readCookie(CookieName) {
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var CookiePieces
  var ReturnValue = "";
  var x = 0;

  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) {

    CookiePieces = CookieSet[x].split ('=');

    if (CookiePieces[0].substring (0,1) == ' ') {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
    }

    if (CookiePieces[0] == CookieName) {
      ReturnValue = CookiePieces[1];
    }

  }
   return ReturnValue;
}

