function moveCursor(inForm, CurrentElement, MaxSize, NextElement)
{
    if (CurrentElement.value.length == MaxSize)
    {
        if (NextElement != null)
        {
            NextElement.focus();
        }
    }
}
function validatePreRegisteredEnterPinForm(bCandidateIdtypeSSN, SCandidateIDTypeValue)
{
    SValidiationErrorMsg = '';
    bValidationErrorOccured = false;
    if(bCandidateIdtypeSSN)
    {
        if(trim(document.forms[0].candidateid1.value) == ''  || trim(document.forms[0].candidateid2.value) == ''
            || trim(document.forms[0].candidateid3.value) == '')
        {
            SValidiationErrorMsg = SCandidateIDTypeValue + ' ' + sMessageArr[MSG_CANNOT_BE_BLANK];
            bValidationErrorOccured = true;
        }
    }
    else
    {
        if(trim(document.forms[0].candidateid.value) == '')
        {
            SValidiationErrorMsg = SCandidateIDTypeValue + ' ' + sMessageArr[MSG_CANNOT_BE_BLANK];
            bValidationErrorOccured = true;
        }
    }
    if(trim(document.forms[0].pin.value) == '')
    {
        SValidiationErrorMsg  = SValidiationErrorMsg + '\n' + sMessageArr[MSG_LOGIN_PIN_LAST_NAME_CANNOT_BE_BLANK];
        bValidationErrorOccured = true;
    }
    if(bValidationErrorOccured)
    {
        alert(SValidiationErrorMsg);
    }
    return !bValidationErrorOccured;
}

// added by rishabh - taken from LM
function isAlphanumeric(string, ignoreWhiteSpace) {
   if (string.search) {
      if ((ignoreWhiteSpace && string.search(/[^\w\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\W/) != -1)) return false;
   }
   return true;
}

function validateCreateAccountFormEntry(createAccountForm) {

	if (createAccountForm.firstname.value == '') {
		alert ("First name field cannot be left blank");
		createAccountForm.firstname.focus();
		return false;
	}

	if (createAccountForm.lastname.value == '') {
		alert ("Last name field cannot be left blank");
		createAccountForm.lastname.focus();
		return false;
	}

	if(createAccountForm.password.value =='') {
		alert ("Password field cannot be left blank");
		createAccountForm.password.focus();
		return false;
	}
	
	if(!isAlphanumeric(createAccountForm.password.value, false)) {
		alert ("Password field can contain only alphabets and numerals.");
		createAccountForm.password.focus();
		return false;
	}

	if (createAccountForm.emailid.value == '') {
		alert ("Email ID field cannot be left blank");
		createAccountForm.emailid.focus();
		return false;
	}
	
	if (createAccountForm.password.value != createAccountForm.confirmpassword.value) {
		alert("The Password and Re-entered Password do not match");
		createAccountForm.password.focus();
		return false;
	}

	if (createAccountForm.hintquestion.value == '') {
		alert("Select a security question");
		createAccountForm.hintquestion.focus();
		return false;
	}

	if (createAccountForm.hintanswer.value == '') {
		alert("Security answer field cannot be left blank");
		createAccountForm.hintanswer.focus();
		return false;
	}
	
	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,}))$/
	if (! createAccountForm.emailid.value.match(re)) {
		alert("Invalid email address");
		createAccountForm.emailid.focus();
		createAccountForm.emailid.select();
		return false;
	}

	return true;
}

// added by rishabhj
function validateLoginForm(loginForm) {

      bSubmitForm = false;
   
	if (loginForm.emailid.value == '') {
		alert ("Email Address field cannot be left blank");
		loginForm.emailid.focus();
		return false;
	}

	if(loginForm.password.value =='') {
		alert ("Password field cannot be left blank");
		loginForm.password.focus();
		return false;
	}
	
	//var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
	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,}))$/
    if (! loginForm.emailid.value.match(re)) {
        alert("Invalid email address");
        loginForm.emailid.focus();
        loginForm.emailid.select();
        return false;
    }
    
    if (loginForm.rememberme.checked == true) {
    	setCookie('emailID', loginForm.emailid.value, '5');
    }
    else {
    	setCookie('emailID', '', '-10');
    	bSubmitForm = true;
    }
    if(bSubmitForm)
    {
      
        if (loginForm.loginbtn)
        {      
            loginForm.loginbtn.disabled=true;
            loginForm.submit();
        }
        return true;
       
    }

}

// added by rishabhj
// modified by manoj k v
function validateUpdateForm(updateForm) {

	if ((updateForm.firstname.value).replace(/^\s*|\s*$/g, "") == '') {
		alert ("First name field cannot be left blank");
		updateForm.firstname.focus();
		return false;
	}

	if ((updateForm.lastname.value).replace(/^\s*|\s*$/g, "") == '') {
		alert ("Last name field cannot be left blank");
		updateForm.lastname.focus();
		return false;
	}
	if(updateForm.ssnone &&updateForm.ssntwo && updateForm.ssnthree)
	{
		if( updateForm.ssnone.value =="" )
		{
			alert("Please Enter SSN");
			updateForm.ssnone.focus();
			return false;
		}
		if(updateForm.ssntwo.value =="")
		{
			alert("Please Enter SSN");
			updateForm.ssntwo.focus();
			return false;
		}
		if(updateForm.ssnthree.value =="")
		{
			alert("Please Enter SSN");
			updateForm.ssnthree.focus();
			return false;
		}
	}


//	var SSNRowVisibility = document.getElementById('SSNRow').style.display;    
	
	if(document.getElementById('SSNRow'))
	{
		var ssn = updateForm.ssnone.value + updateForm.ssntwo.value + updateForm.ssnthree.value;

		if (ssn.length < 9) {
			alert("Please enter your full SSN");
			updateForm.ssnone.focus();
			return false;
		}
		if (!isInteger(ssn)) {
	        alert("Invalid SSN. Alphabets and Special Characters not allowed.");
	        updateForm.ssnone.focus();
	        updateForm.ssnone.select();
	        return false;
    	}
	}
   
	if ((updateForm.hintquestion.value != '') && ((updateForm.hintanswer.value).replace(/^\s*|\s*$/g, "") == '')) {
		alert("Security answer field cannot be left blank");
		updateForm.hintanswer.focus();
		return false;
	}
     
	var name;
	var type;	

	if(updateForm.id)
	{
		if (updateForm.id.length > 1)
		{
			for (var i = 0; i < updateForm.id.length; i++)
			{
				name = updateForm.id[i].value;
				type = updateForm.idt[i].value;
			    var txtobj =document.getElementById(name);		
				if (txtobj.value == '')
				 {
					alert( type + " field cannot be left blank");
					txtobj.focus();
					return false;
				}
			}
		}

		else 
		{
			name = updateForm.id.value;
			var txtobj =document.getElementById(name);
			type = updateForm.idt.value;
			if (txtobj.value == '') 
			{
				alert(type + " field cannot be left blank");
				txtobj.focus();
				return false;
			}
		}    
     }
    return true;
}

function onChangeDisableEnableSSN(obj, val) {

	if (val == '') {
        document.getElementById("ans").style.display="none";		
	} else {	
        document.getElementById("ans").style.display="";		
	}
}


// added by rishabhj
/***********************************************
* Cross browser Marquee II- ? Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=1000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
	if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
		cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
	else
		cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
	cross_marquee=document.getElementById("vmarquee")
	cross_marquee.style.top=0
	marqueeheight=document.getElementById("tickercontainer").offsetHeight
	actualheight=cross_marquee.offsetHeight
	if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
		cross_marquee.style.height=marqueeheight+"px"
		cross_marquee.style.overflow="scroll"
		return
	}
	setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}
/***********************************************
* Cross browser Marquee II- ? Dynamic Drive (www.dynamicdrive.com)
***********************************************/