///////////////////////////////////
//Disable right mouse click
///////////////////////////////////
function clickIE4(){
if (event.button==2){
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false");


function CheckEmail(NameObject)
{
var txt;

if (NameObject.value == "")
  {
    return (true);
  }
txt = NameObject.value;
if (txt.indexOf("@")<2)
  {
	return (false);
}
if (txt.lastIndexOf(".")<txt.indexOf("@"))
  {
	return (false);
  }

if (txt.length<6)
  {
	return (false);
  }

return (true);
}

function CheckRadio(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].checked) { return false; }
	}
return true;
}

function CheckCheckbox(ss, iMax) {
for(var i = 1; i <= iMax; i++) {
	if(eval(ss + "_a" + i).checked) { return false; }
	}
return true;
}

function InputCheck(elem,format)
{
var mes, oks, checkOK, checkStr, nam, allValid;
checkStr=elem.value;
nam=elem.name;
mes=new Array("Please enter letters and spaces only in the selected text box.","Please enter numbers only in the selected text box.","Please enter a valid number in the selected text box.");
oks=new Array("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f","0123456789-","0123456789-.");
checkOK=oks[format]
allValid=true
for (i = 0;  i < checkStr.length;  i++)
{ ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{allValid = false;break;}}
if (!allValid)
{alert(mes[format]);return (false);}
return (true);
}

function Trim(orgString){
return LTrim(RTrim(orgString))
}

function LTrim(orgString){
return orgString.replace(/^\s+/,'')
}

function RTrim(orgString){
return orgString.replace(/\s+$/,'')
}

function fill(s,l){
	s=s+""
	for (y=1;y<=l;y++)
		if (s.length>=l) break; else s="0"+s;
	return s
}

function stms(s){
	if (Math.abs(tmMx)>=3600){
		h=Math.floor(s/3600);m=Math.floor((s%3600)/60);s=((s%3600)%60);return fill(h,2)+":"+fill(m,2)+":"+fill(s,2);
	}else{
		m=Math.floor(s/60);s=s%60;return fill(m,2)+":"+fill(s,2);
	}
}

function shtm(t){
	tmVl=t+1
	self.status=stms(Math.abs(t))
    document.forms[0].TimeElapsed.value = Math.abs(t);
	tmId = setTimeout("shtm(tmVl)",1000)
	if (t==((tmMx>0)? tmMx : 0)){
		clearTimeout(tmId)
		alert("Time has elapsed. Please press Ok to continue.")
        document.forms[0].LastQuestion.value = document.forms[0].StatusID.value
		submitForm(3);
	}
}

function checkTime(bShowMsg){ 
	if (tmMx!=0){ 
 	 	if (bShowMsg==true) alert('This test is time limited: '+stms(Math.abs(tmMx))+'\n\nYou can check the remaining time on your status bar at the bottom of the screen.'); 
 	 	shtm((tmMx>0) ? 0 : tmMx) 
 	}
}

tmId=null
tmVl=0

