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 supportEmail() {
	window.location = switchPageProtocol('?cmd=supportemail', 'http_page');
}

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 popWin() {
	var url_page, x, y, window_width, window_height;
	if(arguments.length == 1) {
		url_page = arguments[0];
		window_width = window.screen.width * 2.0;
		window_height = window.screen.height * 0.9;
	} 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);
}

var blnAuthorizeSumbit = false;
function authorize() {
	var index = 0;
	if(document.forms.length > 1) index = 1;		

	if(checkBrowserInfo()) return;
	if(document.forms[index].authcode.value == '') {
		alert('Please enter a authorization number to proceed!');
		return;		
	}
	if(blnAuthorizeSumbit) return;
	getClientInfo();
	document.forms[index].action = switchPageProtocol('?cmd=authorize', 'https_page');
	blnAuthorizeSumbit = true;
	document.forms[index].submit();	
}

var blnLoginSubmit = false;
function validateLogin() {
	if(checkBrowserInfo()) return;
	if(document.forms[0].username.value == '' || document.forms[0].pwd.value == '') {
		alert('Please enter your email address and password to proceed!');
		return;
	}	
	if(blnLoginSubmit) return;
	getClientInfo();
	document.forms[0].action = switchPageProtocol('?cmd=validatelogin', 'https_page');	
	blnLoginSubmit = true;
	document.forms[0].submit();	
}

var blnActivateSubmit = false;
function activateNewUser() {
	var index = 0;
	if(document.forms.length > 1) index = 1;	

	if(checkBrowserInfo()) return;

	if(document.forms[0].username.value == '') {
		alert('Please enter your email to continue!');
		return;
	} 
	if(!checkEmail(document.forms[0].username.value)) {
		alert('You have entered an invalid email!');
		return;
	} 
	if(blnActivateSubmit) return;
	getClientInfo();
	document.forms[index].action = switchPageProtocol('?cmd=activate', 'http_page');
	blnActivateSubmit = true;
	document.forms[index].submit();
}

function forgetPwd() {
	var index = 0;
	if(document.forms.length > 1) index = 1;	

	if(checkBrowserInfo()) return;
	getClientInfo();
	document.forms[index].action = switchPageProtocol('?cmd=forgetpwd', 'http_page');	
	document.forms[index].submit();		
}

function returnToLogin() {
	window.location = switchPageProtocol('?cmd=logout', 'http_page');	
}

function checkEmail(emailAddress) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(emailAddress);
}

function renewProduct() {
	window.location = "cart.aspx";		
}

function getClientInfo() {
	var vRes = window.screen.width + 'x' + window.screen.height;
	var vColors = window.screen.colorDepth;	

	if(document.forms[0].sysinfo) {
		document.forms[0].sysinfo.value = escape('<VideoResolution>' + vRes + '</VideoResolution><NumberofColors>' + vColors + '</NumberofColors>');
		var now = new Date(); 
		document.forms[0].timeoffset.value = now.getTimezoneOffset();
	}

	var index = 0;
	if(document.forms.length > 1) index = 1;
	if(document.forms[index].sysinfo) {
		document.forms[index].sysinfo.value = escape('<VideoResolution>' + vRes + '</VideoResolution><NumberofColors>' + vColors + '</NumberofColors>');
		var now = new Date(); 
		document.forms[index].timeoffset.value = now.getTimezoneOffset();
	}
}

function checkBrowserInfo() {			
	var browser = navigator.appName
        var ver = navigator.appVersion
	var bAgent = window.navigator.userAgent; 
	var bAppName = window.navigator.appName; 
	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') >= 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 7') >= 0) && (bAgent.indexOf('Win') >= 0))
		skipPage = false; //win ie7
	else if ((bAppName.indexOf('Explorer') >= 0) && (bAgent.indexOf('MSIE 5') >= 0) && (bAgent.indexOf('Mac') >= 0))
		skipPage = false; //mac ie5
	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 ((bAppName.indexOf('Netscape') >= 0) && (bMozIdx >= 0) && (bAgent.indexOf('Gecko/2009') >=0))
		skipPage = false; //future mozilla
	else if (bAgent.indexOf('Safari') >= 0)
		skipPage = false; //mac safari
		if ((browser=="Microsoft Internet Explorer") && (brow_ver > 5))
		{
		skipPage = false; //win ie6+
		}	

	if(skipPage) window.location = 'templates_starttest/browser.htm';
	return skipPage;		
}

function switchPageProtocol(vNextCmd, vHttpType) {
	var vNewUrl = window.location.host + window.location.pathname;

	vNewUrl = vNewUrl.replace('setuptest.aspx', 'starttest.aspx');
	vNewUrl = vNewUrl.replace('searchcert.aspx', 'starttest.aspx');

	switch(vHttpType) 
	{
		case 'http_page':
			vNewUrl = 'http://' + vNewUrl;
			break;
		case 'https_page':
			if(window.location.hostname == 'localhost' || readCookie('secureconn') != 'true') 				
				vNewUrl = 'http://' + vNewUrl;
			else
				vNewUrl = 'https://' + vNewUrl;
			break;
	}
	return vNewUrl + vNextCmd;
}

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;
}

function runTestLocal( testUrl, installServer, mimeType )
{
    var minVersion = 1;
    var installName = '';
    var confirmMessage = '';

    // Get optional variables    
    if( arguments.length > 3 )
	    minVersion = arguments[3];
    if( arguments.length > 4 )
	    installName = arguments[4];
    if( arguments.length > 5 )
	    confirmMessage = arguments[5];

	if( !isDriverLoaded( mimeType, minVersion ) )
	{
		//installDriver( installServer, mimeType, installName, confirmMessage );
		alert('The Secure Browser is not currently installed on your system, or does not meet the minimum version requirements. \n\n If you are testing at an Autodesk Certification Center, contact the center administrator for help installing the secure browser.  If you are testing at another location, return to \"Practice Tests Setup\" page and install the At-home Secure Browser.');
		return false;
	}
	else 
	{
		window.location.replace( testUrl );
		return true;
	}
    
    return false;
}

function runTestMinChk( testUrl, installServer, mimeType )
{
    var minVersion = 1;
    var installName = '';
    var confirmMessage = '';

    // Get optional variables    
    if( arguments.length > 3 )
	    minVersion = arguments[3];
    if( arguments.length > 4 )
	    installName = arguments[4];
    if( arguments.length > 5 )
	    confirmMessage = arguments[5];

/* alert('hit');
alert(isDriverLoaded( mimeType, minVersion ));
alert(mimeType);
alert(minVersion);
return; */

	if( !isDriverLoaded( mimeType, minVersion ) )
	{
		//installDriver( installServer, mimeType, installName, confirmMessage );
		alert('The Secure Browser is not currently installed on your system, or does not meet the minimum version requirements. \n\n If you are testing at an Autodesk Certification Center, contact the center administrator for help installing the secure browser.  If you are testing at another location, return to \"Practice Tests Setup\" page and install the At-home Secure Browser.');
		return false;
	}
    
    return true;
}

function isSBHybrid() {
                try {
			return top.external.IsHybridSecureBrowser;
                }
                catch(e) {}
                return false;
}

function isSB() {
                try {
			return top.external.IsSecureBrowser;
                }
                catch(e) {}
                return false;
}

var itd;
var intervalID; 
var vTestLaunched = new Array(); 
function checkTestWindow() {
try {
	if(itd.closed) {
		window.clearInterval(intervalID);
		window.location = 'starttest.aspx?cmd=home';
	} 
} catch(e) { window.location = 'starttest.aspx?cmd=home'; }
}

function cancelMonitoring() {
	window.clearInterval(intervalID);
}

function launchTest(vLink, vTestName) {

	if(vTestName && vTestLaunched[vTestName]) return;

	var vRes = window.screen.width + 'x' + window.screen.height;
	var vColors = window.screen.colorDepth;	
	vLink = vLink + '&res=' + vRes + '&color=' + vColors + '&dupchk=true';

	//if(arguments.length > 1) { startTest(vLink, vTestName); return; } //uncomment this line if start test requires option page	

	var pos = vLink.indexOf("DR=");
	var cmd = vLink.indexOf("cmd=scorereport");
	if(pos > 0 && cmd == -1) {
	    if(isSBHybrid()) {//secure or offline browser
    		
		    var DR = parseInt(vLink.substr(pos+3));

		    var DMIN = 1;
		    var idx = vLink.indexOf("HMIN="); //use HMIN for hybrid		
		    if(idx > 0) {
			    DMIN = parseInt(vLink.substr(idx+5));
		    }
		    if(!runTestMinChk(vLink, 'http://driverinstalls.testsys.com', findMimType(DR), DMIN, findInstallName(DR))) return;			

		    vLink = vLink.replace('DR=', 'ddddddd=');					
		    window.location = vLink;			
		    return;

	    } else if(isSB()) {//secure or offline browser
    		
		    var DR = parseInt(vLink.substr(pos+3));

		    var DMIN = 1;
		    var idx = vLink.indexOf("DMIN="); //use DMIN for secure		
		    if(idx > 0) {
			    DMIN = parseInt(vLink.substr(idx+5));
		    }
		    if(!runTestMinChk(vLink, 'http://driverinstalls.testsys.com', findMimType(DR), DMIN, findInstallName(DR))) return;			

		    vLink = vLink.replace('DR=', 'ddddddd=');					
		    window.location = vLink;			
		    return;

	    } else { //mime browser

		    var DMIN = 1;
		    var idx = vLink.indexOf("DMIN=");
		    if(idx > 0) {
			    DMIN = parseInt(vLink.substr(idx+5));
		    }    		
		    var DR = parseInt(vLink.substr(pos+3));
		    if(DR > 0) {
			    vLink += '&ext=' + escape(findExt(DR)) + '&mim=' + escape(findMimType(DR));
			    runTestLocal(vLink, 'http://driverinstalls.testsys.com', findMimType(DR), DMIN, findInstallName(DR));	
			    return;
		    }
	    }
	}
	if(cmd > 0) vLink = vLink.replace('DR=', 'DDDDDD=');
	
	var vExtraOption = ',resizable=1';

	if(window.navigator.appName.indexOf('Netscape') != -1 && window.navigator.userAgent.indexOf('Mac') != -1)
		itd = 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)+vExtraOption);
	else if(window.navigator.appName.indexOf('Netscape') != -1)
		itd = 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)+vExtraOption);
	else if(window.navigator.userAgent.indexOf('Mac') != -1) { 
		itd = window.open(vLink, null, 'resizeable=yes');
		itd.resizeTo(window.screen.width, window.screen.height);
		itd.moveTo(0, 0);
	} else
		itd = window.open(vLink, null, 'toolbar=no,menubar=no,location=no,directories=no'+vExtraOption);				
			
	if(itd == null) {
		alert("Your browser has pop-up blocker enabled, this can prevent the test window from opening properly. If your test did not launch, disable your pop-up blocker and try again.");
		return;
	}

	if(vTestName) vTestLaunched[vTestName] = true;
	intervalID = window.setInterval('checkTestWindow()', 200);
}


function findMimType(DR) {
	if(drlist && mimlist) {
		var tmpDrlist = drlist.split("|");
		var tmpMimlist = mimlist.split("|");
		for(var i=0; i < tmpDrlist.length; i++) {
			if(tmpDrlist[i] == DR) return tmpMimlist[i];
		}
	}
	return '';	
}

function findInstallName(DR) {
	if(drlist && instlist) {
		var tmpDrlist = drlist.split("|");
		var tmpInstlist = instlist.split("|");
		for(var i=0; i < tmpDrlist.length; i++) {
			if(tmpDrlist[i] == DR) return tmpInstlist[i];
		}
	}
	return '';
}

function findExt(DR) {
	if(drlist && instlist) {
		var tmpDrlist = drlist.split("|");
		var tmpExtlist = extlist.split("|");
		for(var i=0; i < tmpDrlist.length; i++) {
			if(tmpDrlist[i] == DR) return tmpExtlist[i];
		}
	}
	return '';
}

function deleteTest(vLink) {
	var msg = 'Are you sure you want to delete this in-progress test? This is a permanent delete, and all answers will be lost.';
	if(confirm(msg)) window.location = vLink;
}

function startTest(vLink, vTestName) {
	vLink = vLink.replace('setuptest.aspx?', '&');
	window.location = 'examoptions.aspx?test=' + escape(vTestName) + vLink;
}


//Appointment tooltip
var appset = new Array();

function displayLocInfo(e, id) {
	if(appset[id]) {
		var tiphtml = appset[id].split("|");
		var finalhtml = "<table border=0 cellpadding=4 cellspacing=0>";
		finalhtml += "<tr><td><b>%location%</b><br>%address1%<br>%address2%<br>%address3%<br>%city%, %region% %postal%<br>Phone: %phone%<br>Hours: %hour%";
		finalhtml += "</td></tr></table>";
			
		for(var i = 0; i < tiphtml.length; i++) {				
			if(i == 0)
				finalhtml = finalhtml.replace("%address1%", unescape(tiphtml[0]));
			else if(i == 1) {
				if(tiphtml[1] != '')
					finalhtml = finalhtml.replace("%address2%", unescape(tiphtml[1]));
				else
					finalhtml = finalhtml.replace("%address2%<br>", "");
			} 
			else if(i == 2) {
				if(tiphtml[2] != '')
					finalhtml = finalhtml.replace("%address3%", unescape(tiphtml[2]));
				else
					finalhtml = finalhtml.replace("%address3%<br>", "");
			}
			else if(i == 3)
				finalhtml = finalhtml.replace("%city%", unescape(tiphtml[3]));		
			else if(i == 4)
				finalhtml = finalhtml.replace("%region%", unescape(tiphtml[4]));			
			else if(i == 5)
				finalhtml = finalhtml.replace("%postal%", unescape(tiphtml[5]));
			else if(i == 6)
				finalhtml = finalhtml.replace("%hour%", unescape(tiphtml[6]));
			else if(i == 7)
				finalhtml = finalhtml.replace("%phone%", unescape(tiphtml[7]));
			else if(i == 8)
				finalhtml = finalhtml.replace("%direction%", unescape(tiphtml[8]));
			else if(i == 9)
				finalhtml = finalhtml.replace("%location%", unescape(tiphtml[9]));			
		}
		showmenu(e, finalhtml);			
	}
}

function loadAppDetail(id, code, option) {
	if(appset[id]) {
		var tiphtml = appset[id].split('|');
		var finalhtml = '';
		var addrinfo = '';
		var mapaddr = '';
		var mapcsz = '';

			
		for(var i = 0; i < tiphtml.length; i++) {				
			if(i == 0 && tiphtml[i] != '') {
				addrinfo += unescape(tiphtml[i]) + '<br>';
				mapaddr += unescape(tiphtml[i]);
			} else if(i == 1 && tiphtml[i] != '') {
				addrinfo += unescape(tiphtml[i]) + '<br>';
				mapaddr += '+' + unescape(tiphtml[i]);
			} else if(i == 2 && tiphtml[i] != '') {
				addrinfo += unescape(tiphtml[i]) + '<br>';
				mapaddr += '+' + unescape(tiphtml[i]);
			} else if(i == 3 && tiphtml[i] != '') {
				addrinfo += unescape(tiphtml[i]) + ',';
				mapcsz += unescape(tiphtml[i]);
			} else if(i == 4 && tiphtml[i] != '') {
				addrinfo += ' ' + unescape(tiphtml[i]);			
				mapcsz += '+' + unescape(tiphtml[i]);
			} else if(i == 5 && tiphtml[i] != '') {
				addrinfo += ' ' + unescape(tiphtml[i]);
				mapcsz += '+' + unescape(tiphtml[i]);
			} else if(i == 6)
				finalhtml += '<Hour>' + tiphtml[i] + '</Hour>';
			else if(i == 7)
				finalhtml += '<Phone>' + tiphtml[i] + '</Phone>';					
			else if(i == 8)
				finalhtml += '<Direction>' + tiphtml[i] + '</Direction>';
			else if(i == 9)
				finalhtml += '<Location>' + tiphtml[i] + '</Location>';
			else if(i == 10)
				finalhtml += '<CheckInTime>' + tiphtml[i] + '</CheckInTime>';
			else if(i == 11)
				finalhtml += '<Event>' + tiphtml[i] + '</Event>';
			else if(i == 12)
				finalhtml += '<Date>' + tiphtml[i] + '</Date>';
			else if(i == 13)
				finalhtml += '<Time>' + tiphtml[i] + '</Time>';					
		}
		finalhtml += '<LocationInfo><![CDATA[' + addrinfo + ']]></LocationInfo>';		
		finalhtml += '<csz><![CDATA[' + mapcsz + ']]></csz>';
		finalhtml += '<addr><![CDATA[' + mapaddr + ']]></addr>';
		document.forms[0].action = 'certifications.aspx?cmd=appdetail&id=' + id + '&code=' + code + '&option=' + option + '&applist=' + escape(document.forms[0].existingapplist.value);
		document.forms[0].appinfo.value = escape('<Root>' + finalhtml + '</Root>');
		document.forms[0].submit();
	}
}

function loadUnschedule(id, code, option) {
	if(option==1)
		document.forms[0].action = 'certifications.aspx?cmd=centersearch&id=' + id + '&code=' + code + '&option=1&applist=' + escape(document.forms[0].existingapplist.value);
	else
		document.forms[0].action = 'certifications.aspx?cmd=appoptions&id=' + id + '&code=' + code + '&resch=1&option=' + option + '&applist=' + escape(document.forms[0].existingapplist.value);		
	document.forms[0].submit();
}

//Pop-it menu- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use
var vCurrentResultID = '';
var linkset = new Array()
linkset[0]='<div class="menuitems"><a href="javascript:deleteCompleteResult()">Delete completed result</a></div>';

////No need to edit beyond here
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers

function showmenu(e,which){

	if (!document.all&&!document.getElementById&&!document.layers) return

	clearhidemenu()

	menuobj=ie4? document.all.popmenu : ns6? document.getElementById("popmenu") : ns4? document.popmenu : ""
	menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj

	if (ie4||ns6) menuobj.innerHTML=which
	else{
		menuobj.document.write('<layer name=gui bgColor=#E6E6E6 width=165 onmouseover="clearhidemenu()" onmouseout="hidemenu()">'+which+'</layer>')
		menuobj.document.close()
	}
	
	menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.gui.document.width
	menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.gui.document.height
	eventX=ie4? event.clientX : ns6? e.clientX : e.x
	eventY=ie4? event.clientY : ns6? e.clientY : e.y

	//Find out how close the mouse is to the corner of the window
	var rightedge=ie4? document.body.clientWidth-eventX : window.innerWidth-eventX
	var bottomedge=ie4? document.body.clientHeight-eventY : window.innerHeight-eventY

	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<menuobj.contentwidth)
	//move the horizontal position of the menu to the left by it's width
		menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX-menuobj.contentwidth : ns6? window.pageXOffset+eventX-menuobj.contentwidth : eventX-menuobj.contentwidth
	else
	//position the horizontal position of the menu where the mouse was clicked
		menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX : ns6? window.pageXOffset+eventX : eventX

	//same concept with the vertical position
	if (bottomedge<menuobj.contentheight)
		menuobj.thestyle.top=ie4? document.body.scrollTop+eventY-menuobj.contentheight : ns6? window.pageYOffset+eventY-menuobj.contentheight : eventY-menuobj.contentheight
	else
		menuobj.thestyle.top=ie4? document.body.scrollTop+event.clientY : ns6? window.pageYOffset+eventY : eventY
	menuobj.thestyle.visibility="visible"
	return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
	while (b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
}

function hidemenu(){
	if (window.menuobj) menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"
}

function dynamichide(e){
	if (ie4&&!menuobj.contains(e.toElement))
		hidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		hidemenu()
}

function delayhidemenu(){
	if (ie4||ns6||ns4) delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
	if (window.delayhide) clearTimeout(delayhide)
}

function highlightmenu(e,state){
	if (document.all) source_el=event.srcElement
	else if (document.getElementById) source_el=e.target
	if (source_el.className=="menuitems"){
		source_el.id=(state=="on")? "mouseoverstyle" : ""
	} else {
		while(source_el.id!="popmenu"){
			source_el=document.getElementById? source_el.parentNode : source_el.parentElement
			if (source_el.className=="menuitems"){
				source_el.id=(state=="on")? "mouseoverstyle" : ""
			}
		}
	}
}
if (ie4||ns6) document.onclick=hidemenu

function deleteCompleteResult() {
	var msg = 'Are you sure you want to delete this complete test? This is a permanent delete, and all answers and scores will be lost.';
	if(confirm(msg))
		window.location = 'starttest.aspx?cmd=deletetest&resultid=' + vCurrentResultID;
}

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}