
		/* on selection of drive through combo */
		function ShowDrive()
		{
			document.form1.submit();
		}
		
		function showDemoAnswer()
		{
			document.form1.submit();
		}
		/* end of function */
		
		function ClearFields(totalQues,srno)
		{                    
			document.form1.txtStoreNumber.value="";
			document.form1.txtCaller.value = "";                     
			for(i=srno;i<=13;i++)
			{
				eval("document.form1.SQUES"+i).value = "";                                
			}//for    
			
			/* clear all the demo graphic check boxes if selected */
			for(i=1;i<document.form1.elements.length;i++)
			{
				if(document.form1.elements[i].type == "checkbox")
					document.form1.elements[i].checked = false;
			}
			/*
			* set focus on the first combo
			* clear search and comparison values of avg column
			*/
			document.form1.SAVG.value = ""
			document.form1.SAVGCOMPARE.options.selectedIndex = "0";
		}
		/* end of function */
		
		function checkValues(totalQues,srno)
		{                     
			if(isNaN(document.form1.txtCaller.value))
			{
				alert("Please enter numeric Caller ID !");
				document.form1.txtCaller.focus();
				return false;
			}
			
			if(document.form1.txtCaller.value != "" && document.form1.txtCaller.value.length < 10)
			{
				alert("Please enter 10 digit Caller ID !");
				document.form1.txtCaller.focus();
				return false;
			}    
			return true;            
		}//function 

	//this function validates the start & end  dates and months
	function Validate(objStartDate,objEndDate,objStartMonth,objEndMonth,objStartYear,objEndYear)
	{
		startdate = eval(objStartDate + ".value");
		enddate = eval(objEndDate + ".value");		
		startmonth = eval(objStartMonth + ".value");
		endmonth = eval(objEndMonth + ".value");
		
		startYear = eval(objStartYear + ".value");
		endYear = eval(objEndYear + ".value");
		
		if(Number(startYear) > Number(endYear))
		{
			alert("Starting Year should be less than the Ending Year !");
			//eval(objStartYear).focus();
			return false;
		}
		
		if(Number(endmonth) < Number(startmonth) && (Number(startYear) >= Number(endYear)) )
		{
			alert("Ending Month should be greater than Starting Month !");
			eval(objEndMonth).focus();
			return false;
		}		
		
		if(Number(endmonth) == Number(startmonth) && (Number(startYear) >= Number(endYear)))
		{
			if(Number(enddate) < Number(startdate))
			{
				alert("To Date should be greater than From Date !");
				eval(objEndDate).focus();
				return false;
			}
		}	
		
		if ((startmonth==4 || startmonth==6 || startmonth==9 || startmonth==11) && startdate==31) 
		{
			alert("From Month doesn't have 31 days!")
			eval(objStartDate).focus();
			return false
		}
		
		if ((endmonth==4 || endmonth==6 || endmonth==9 || endmonth==11) && enddate==31) 
		{
			alert("To Month doesn't have 31 days!")
			eval(objEndDate).focus();
			return false
		}

		if (startmonth == 2) 
		{ // check for february 29th for starting month
			var today = new Date()
    		var year = today.getYear()
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (startdate>29 || (startdate==29 && !isleap)) 
			{
				alert("February " + year + " doesn't have " + startdate + " days!");
				eval(objStartDate).focus();
				return false;
			}
			
			/*if (enddate>29 || (enddate==29 && !isleap)) 
			{
				alert("February " + year + " doesn't have " + enddate + " days!");
				eval(objEndDate).focus();
				return false;
			}*/
		}
		if(endmonth == 2)
		{	 // check for february 29th for the end month
			var today = new Date()
    		var year = today.getYear()
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (enddate>29 || (enddate==29 && !isleap)) 
			{
				alert("February " + year + " doesn't have " + enddate + " days!");
				eval(objEndDate).focus();
				return false;
			}			
		}
		return true;
	}	


function Validate_survey(isNat)
{
	formname = document.frm;

	if(formname.txt_email.value=="")
	{
		alert("Please enter your Email ID.");
		txt_email.focus();
		return false;
	}
	if(formname.txt_email.value!="")
	{
		var alnum="a-zA-Z0-9"; 
		strEmail=txt_email.value;
		//exp="^[^@\\s]+@(["+alnum+"+\\-]+\\.)+["+alnum+"]["+alnum+"]["+alnum+"]?$"; 
		var exp=/^\w+([\_\.])?\w+\@\w+\.\w+(\.\w+)?$/i; 
		emailregexp = new RegExp(exp); 
		result = strEmail.match(emailregexp)
		if (result == null) 
		{
			alert("Please enter your Email ID in correct format.");
			txt_email.select();
			return false;
		}
	}
	if(txt_email.value != confirm_txt_email.value)
	{
		alert("Email and confirm email should be same.");
		txt_email.focus();
		return false;
	}
	if(FIRST.value=="")
	{
		alert("Please enter First Name.");
		FIRST.focus();
		return false;
	}
	if(LAST.value=="")
	{
		alert("Please enter Last Name.");
		LAST.focus();
		return false;
	}
	if(txtPhone.value=="")
	{
		alert("Please enter Your Phone Number.");
		txtPhone.focus();
		return false;
	}
}

function hideDiv(divID,todo)
{
	if(todo == "hide")
	{
		document.getElementById(divID).style.display = "none";
		document.getElementById(divID).style.display = "none"; 
	}
	else
	{
		document.getElementById(divID).style.display = "";
		document.getElementById(divID).style.display = ""; 		
	}
	
}
	
	
function populate(objyear,objmonth,objday)
{
	var t = objday.options[objday.selectedIndex].value
	var yearval = objyear; //pass as 2004
	timeA = new Date(yearval, objmonth.options[objmonth.selectedIndex].value,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	if(objday.options.length>0)
	{
		for (var i = 0; i < objday.length; i++)
		{
			objday.options[0] = null;
		}
	}
	for (var i = 0; i < daysInMonth; i++)
	{
		if(i<9)
		{	
			v = i+1;
			objday.options[i] = new Option("0"+v,v);
		}
		else
			objday.options[i] = new Option(i+1,i+1);
			
	}
	if ((t != "") && (t!= 0))
	{	
		objday.options[t-1].selected = true;
	}
}




	function ValidateNewUser(dsgnId)
	{	
    
		//alert("Design Id : " + dsgnId);
		if(dsgnId == 5)
		{
			if(document.form1.txtUser.value == "")
			{
				alert("Please specify User Id!");
				document.form1.txtUser.focus();
				return false;
			}		
			if (isNaN(document.form1.txtUser.value) == true)
			{
				alert("Please specify numberic User Id!");
				document.form1.txtUser.focus();
				return false;
			}
			if (Number(document.form1.txtUser.value) <=0)
			{
				alert("Please specify valid User Id!");
				document.form1.txtUser.focus();
				return false;
			}
			
			/*if(document.form1.txtUserName.value == "")
			{
				alert("Please specify the Name !");
				document.form1.txtUserName.focus();
				return false;
			}
			var str=document.form1.txtUserName.value;
			var len = str.length;
			if (len <5 || len >10)
			{
				alert("Please check length of User Name \n It should be greater then 5 characters and less then 10 characters!");
				document.form1.txtUserName.focus();
				return false;
			}
			if(document.form1.txtPassword.value == "")
			{
				alert("Please specify Password!");
				document.form1.txtPassword.focus();
				return false;
			}
			if(document.form1.txtConfirmPassword.value == "")
			{
				alert("Please specify Password!");
				document.form1.txtConfirmPassword.focus();
				return false;
			}
			if((document.form1.txtPassword.value != "" && document.form1.txtConfirmPassword.value != "") && (document.form1.txtPassword.value != document.form1.txtConfirmPassword.value))
			{
				alert("Password and Confirm Password are not same!");
				document.form1.txtConfirmPassword.focus();
				return false;
			}
			var str1=document.form1.txtPassword.value;
			var len1 = str1.length;
			if (len1 <5 || len1 >10)
			{
				alert("Please check length of Password \n It should be greater then 5 characters and less then 10 characters!");
				document.form1.txtPassword.focus();
				return false;
			}*/
            var str=document.form1.txtUserName.value;
            var illegalChars = /\W/;
            if(str != "")
            {  
                if (illegalChars.test(str)) 
                {
                  error = "The username contains illegal characters.\n";
                  alert(error);
                  document.form1.txtUserName.focus();
                  return false;
                }
            }
            var str1=document.form1.txtPassword.value;
            var illegalChars1 = /[\W_]/; // allow only letters and numbers
             if(str != "")
            {
             if (illegalChars1.test(str1)) 
             {
                 error = "The password contains illegal characters.\n";
                 alert(error);
                  document.form1.txtPassword.focus();
                  return false;
             }
            }
            if((document.form1.txtPassword.value != "" && document.form1.txtConfirmPassword.value != "") && (document.form1.txtPassword.value != document.form1.txtConfirmPassword.value))
            {
                alert("Password and Confirm Password are not same!");
                document.form1.txtConfirmPassword.focus();
                return false;
            }
			
			if(document.form1.txtName.value == "")
			{
				alert("Please specify the Name !");
				document.form1.txtName.focus();
				return false;
			}
			
            if((document.form1.txtPrimaryEmail.value != "") && (checkemail(document.form1.txtPrimaryEmail) == false))
            {            
                //alert("Please specify valid Primary Email address !");
                document.form1.txtPrimaryEmail.focus();
                return false;
            }
			if((document.form1.txtSecondaryEmail.value != "") && (checkemail(document.form1.txtSecondaryEmail) == false))
			{			
				//alert("Please specify valid email address !");
				document.form1.txtSecondaryEmail.focus();
				return false;
			}				
			return true;
		} // end if
		else
		{
			if(document.form1.txtUser.value == "")
			{
				alert("Please specify User Id!");
				document.form1.txtUser.focus();
				return false;
			}		
			if (isNaN(document.form1.txtUser.value) == true)
			{
				alert("Please specify numberic User Id!");
				document.form1.txtUser.focus();
				return false;
			}
			if (Number(document.form1.txtUser.value) <=0)
			{
				alert("Please specify valid User Id!");
				document.form1.txtUser.focus();
				return false;
			}
			
			if(document.form1.txtUserName.value == "")
			{
				alert("Please specify the Name !");
				document.form1.txtUserName.focus();
				return false;
			}
			var str=document.form1.txtUserName.value;
			var len = str.length;
			if (len <2 || len >255)
			{
				alert("Please check length of User Name \n It should be greater then 2 characters and less then 255 characters!");
				document.form1.txtUserName.focus();
				return false;
			}
			if(document.form1.txtPassword.value == "")
			{
				alert("Please specify Password!");
				document.form1.txtPassword.focus();
				return false;
			}
			if(document.form1.txtConfirmPassword.value == "")
			{
				alert("Please specify Password!");
				document.form1.txtConfirmPassword.focus();
				return false;
			}
			if((document.form1.txtPassword.value != "" && document.form1.txtConfirmPassword.value != "") && (document.form1.txtPassword.value != document.form1.txtConfirmPassword.value))
			{
				alert("Password and Confirm Password are not same!");
				document.form1.txtConfirmPassword.focus();
				return false;
			}
			var str1=document.form1.txtPassword.value;
			var len1 = str1.length;
			if (len1 <2 || len1 >255)
			{
				alert("Please check length of Password \n It should be greater then 2 characters and less then 255 characters!");
				document.form1.txtPassword.focus();
				return false;
			}
			
            var illegalChars = /\W/;
            if(str != "")
            {
                //alert(strng);
                
                if (illegalChars.test(str)) 
                {
                  error = "The username contains illegal characters.\n";
                  alert(error);
                  document.form1.txtUserName.focus();
                  return false;
                }
            }
             var illegalChars1 = /[\W_]/; // allow only letters and numbers
             if (illegalChars1.test(str1)) 
             {
                 error = "The password contains illegal characters.\n";
                 alert(error);
                  document.form1.txtPassword.focus();
                  return false;
             }
            
			if(document.form1.txtName.value == "")
			{
				alert("Please specify the Name !");
				document.form1.txtName.focus();
				return false;
			}
			/*if(document.form1.txtAddress1.value == "")
			{
				alert("Please specify Address !");
				document.form1.txtAddress1.focus();
				return false;
			}
			if(document.form1.txtCity.value == "")
			{
				alert("Please specify the City!");
				document.form1.txtCity.focus();
				return false;
			}
			if(document.form1.txtState.value == "")
			{
				alert("Please specify the State !");
				document.form1.txtState.focus();
				return false;
			}
			if(document.form1.txtCountry.value == "")
			{
				alert("Please specify the Country!");
				document.form1.txtCountry.focus();
				return false;
			}		
			if(document.form1.txtPhone.value != "")
			{
				if(fnValidUSPhoneNumber(document.form1.txtPhone.value) == false)
				{
					alert("Please specify Valid Phone No.!");
					document.form1.txtPhone.focus();
					return false;
				}
			}	
            */		
			if(document.form1.txtPrimaryEmail.value == "")
			{
				alert("Please specify Primary Email Address !");
				document.form1.txtPrimaryEmail.focus();
				return false;
			}
			
			//if((document.form1.txtPrimaryEmail.value != "") && (fnValidEmail(document.form1.txtPrimaryEmail.value) == false))
			if((document.form1.txtPrimaryEmail.value != "") && (checkemail(document.form1.txtPrimaryEmail) == false))
			{			
				//alert("Please specify valid Primary Email address !");
				document.form1.txtPrimaryEmail.focus();
				return false;
			}
			//if((document.form1.txtSecondaryEmail.value != "") && (fnValidEmail(document.form1.txtSecondaryEmail.value) == false))
			if((document.form1.txtSecondaryEmail.value != "") && (checkemail(document.form1.txtSecondaryEmail) == false))
			{			
				//alert("Please specify valid Secondary Email address !");
				document.form1.txtSecondaryEmail.focus();
				return false;
			}				
			return true;
		} // end else
	}//function
	
	
	//validate existing user (on edit)
	function ValidateUser(desgId)
	{	
        if(desgId == 5)
        {
            if(document.form1.txtName.value == "")
            {
                alert("Please specify the Name !");
                document.form1.txtName.focus();
                return false;
            }
            return true;
        }
        else
        {	
		    if(document.form1.txtName.value == "")
		    {
			    alert("Please specify the Name !");
			    document.form1.txtName.focus();
			    return false;
		    }
	    /*	if(document.form1.txtAddress1.value == "")
		    {
			    alert("Please specify Address !");
			    document.form1.txtAddress1.focus();
			    return false;
		    }
		    if(document.form1.txtCity.value == "")
		    {
			    alert("Please specify the City!");
			    document.form1.txtCity.focus();
			    return false;
		    }
		    if(document.form1.txtState.value == "")
		    {
			    alert("Please specify the State !");
			    document.form1.txtState.focus();
			    return false;
		    }
		    if(document.form1.txtCountry.value == "")
		    {
			    alert("Please specify the Country!");
			    document.form1.txtCountry.focus();
			    return false;
		    }
		    if(document.form1.txtPhone.value != "")
		    {
			    if(fnValidUSPhoneNumber(document.form1.txtPhone.value) == false)
			    {
				    alert("Please specify Valid Phone No.!");
				    document.form1.txtPhone.focus();
				    return false;
			    }
		    }	*/		
		    /* Removed mandatory check for Primary Email Address
		    if(document.form1.txtPrimaryEmail.value == "")
		    {
			    alert("Please specify Primary Email Address !");
			    document.form1.txtPrimaryEmail.focus();
			    return false;
		    }*/

            if( ( (document.form1.txtNewPassword.value != "") || (document.form1.txtConfirmPassword.value != "") ) && (document.form1.hidStatus.value != "N"))
            {
                 if(document.form1.txtConfirmPassword.value == "")
                {
                    alert("Please specify Confirm Password !");
                    document.form1.txtConfirmPassword.focus();
                    return false;
                }
                if(document.form1.txtNewPassword.value == "")
                {
                    alert("Please specify New Password !");
                    document.form1.txtNewPassword.focus();
                    return false;
                }
                if(document.form1.txtNewPassword.value != document.form1.txtConfirmPassword.value)
                {
                    alert("New Password and Confirm Password are not same!");
                    document.form1.txtNewPassword.focus();
                    return false;
                }
                if(document.form1.txtOldPassword.value == document.form1.txtNewPassword.value)
                {
                    alert("Old Password and New Password can not be same!");
                    document.form1.txtOldPassword.focus();
                    return false;
                }
                var str2=document.form1.txtNewPassword.value;
                var len2 = str2.length;
                if (len2 <2 || len2 >255)
                {
                    alert("Please check length of New Password \n It should be greater then 2 characters and less then 255 characters!");
                    document.form1.txtNewPassword.focus();
                    return false;
                }
            }
		    if( ( (document.form1.txtOldPassword.value != "") || (document.form1.txtNewPassword.value != "") || (document.form1.txtConfirmPassword.value != "") ) && (document.form1.hidStatus.value != "Y"))
		    {
			    if(document.form1.txtOldPassword.value == "")
			    {
				    alert("Please specify Old Password !");
				    document.form1.txtConfirmPassword.focus();
				    return false;
			    }
			    if(document.form1.txtConfirmPassword.value == "")
			    {
				    alert("Please specify Confirm Password !");
				    document.form1.txtConfirmPassword.focus();
				    return false;
			    }
			    if(document.form1.txtNewPassword.value == "")
			    {
				    alert("Please specify New Password !");
				    document.form1.txtNewPassword.focus();
				    return false;
			    }
			    if(document.form1.txtNewPassword.value != document.form1.txtConfirmPassword.value)
			    {
				    alert("New Password and Confirm Password are not same!");
				    document.form1.txtNewPassword.focus();
				    return false;
			    }
			    if(document.form1.txtOldPassword.value == document.form1.txtNewPassword.value)
			    {
				    alert("Old Password and New Password can not be same!");
				    document.form1.txtOldPassword.focus();
				    return false;
			    }
			    var str2=document.form1.txtNewPassword.value;
			    var len2 = str2.length;
			    if (len2 <2 || len2 >255)
			    {
				    alert("Please check length of New Password \n It should be greater then 2 characters and less then 255 characters!");
				    document.form1.txtNewPassword.focus();
				    return false;
			    }
		    }
		    
		    //if((document.form1.txtPrimaryEmail.value != "") && (fnValidEmail(document.form1.txtPrimaryEmail.value) == false))
		    if((document.form1.txtPrimaryEmail.value != "") && (checkemail(document.form1.txtPrimaryEmail) == false))
		    {			
			    //alert("Please specify valid email address !");
			    document.form1.txtPrimaryEmail.focus();
			    return false;
		    }
		    //if((document.form1.txtSecondaryEmail.value != "") && (fnValidEmail(document.form1.txtSecondaryEmail.value) == false))
		    if((document.form1.txtSecondaryEmail.value != "") && (checkemail(document.form1.txtSecondaryEmail) == false))
		    {			
			    //alert("Please specify valid email address !");
			    document.form1.txtSecondaryEmail.focus();
			    return false;
		    }		
		    return true;
        }
	}//function
	
	function fnValidEmail(sEmail) 
	{ 
	   var rgemail =/^\w+([\_\.])?\w+\@\w+\.\w+(\.\w+)?$/i; 
	   var result = rgemail.test(sEmail); 
	   return result; 
	}
	
	function fnValidUSPhoneNumber(phone) 
	{ 
	   var rgphone = /^\d{3}\-\d{3}\-\d{4}$/; 
	   var result = rgphone.test(phone); 
	   return result; 
	}

	function PhoneNumberOnly(e)
	{
		// This function will allow to type only numbers and hyphen(-).
		if(window.event) 
		{ // if browser is Internet explorer
			key = e.keyCode; 
			if (key==45) 
				return true;
			else
			{
				if(key <48||key>57)
				return false;
			}
		}
		else if(e.which)
		{	// if browser is Netscape or mozilla
			key = e.which; 
			if (key==45) 
				return true;
			else
			{
				if(key <48||key>57)
				return false;
			}
		}
		else
		 {
			// no event, so pass through
			return true;
		}
	}

	function NumbersOnly(e)
	{
		// This function will allow to type only numbers.

		if(window.event) 
		{ // if browser is Internet explorer
			key = e.keyCode;   
			if(key == 8 || key ==9 || key == 46)
				return true;
			if(key <48||key>57)
			return false;		
		}
		else if(e.which)
		{	// if browser is Netscape or mozilla
			key = e.which; 			
			if(key == 8 || key ==9 || key == 46)
				return true;
				
			if(key <48||key>57)
			return false;		
		}
		else
		 {
			// no event, so pass through
			return true;
		}
	}
		function fnIntegersOnly(e)
	{
		// This function will allow to type only numbers.
         
		if(window.event) 
		{ // if browser is Internet explorer
			key = e.keyCode;   
			if(key == 8 || key ==9)
				return true;
			if(key <48||key>57)
			return false;		
		}
		else if(e.which)
		{	// if browser is Netscape or mozilla
			key = e.which; 			
			if(key == 8 || key ==9)
				return true;
				
			if(key <48||key>57)
			return false;		
		}
		else
		 {
			// no event, so pass through
			return true;
		}
	}
	
	function FloatsOnly(e)
	{
		// This function will allow to type only numbers.				
		
		if(window.event) 
		{ // if browser is Internet explorer
			key = e.keyCode; 
			if (window.event.shiftKey) 
			{
				key=key+16;
			}

		}
		else if(e.which)
		{	// if browser is Netscape or mozilla
			key = e.which; 
			if (e.modifiers & Event.SHIFT_MASK) 
			{
				key=key+16;
			}

		}
		else
		 {
			// no event, so pass through
			return true;            
		}
//		alert("key="+key);
					
		if((key >=48 && key<=57) || (key >= 96 && key <= 105) || key == 110 || key==8 || key ==9 || key==46 || key==16 || key==35 || key==36 || (key >= 37 && key <= 40) || key==190 || key == 13)
			return true;
		else
		{
			return false;		
		}	
	}
	
	function ValidateFaxNumber(e)
	{
		// This function will allow to type only numbers.
		 
		if(window.event) 
		{ // if browser is Internet explorer
			key = e.keyCode; 						
			if((key<45) || (key > 46 && key <48)||key>57)
			return false;		
		}
		else if(e.which)
		{	// if browser is Netscape or mozilla
			key = e.which; 
			if(key <48||key>57)
			return false;		
		}
		else
		{
			// no event, so pass through
			return true;
		}
	} 
	
	function noSpace(e)
	{
		// This function will allow to type only numbers.
		 
		if(window.event) 
		{ // if browser is Internet explorer
			key = e.keyCode; 	 
			if(key == 32)
				return false;
		}
		else if(e.which)
		{	// if browser is Netscape or mozilla
			key = e.which; 
			if(key =32)
				return false;		
		} 
	} 
	
	function putFocus(control,user)
	{
		con=eval(control+"."+user);

		if(con)
		{
			if((con !="undefined") || (con !=""))
			{
				con.focus();
			}
		}
	}
	
	
	function checkemail(field)
	{
	var emailStr = new String();
	emailStr=field.value;
	if(emailStr!='')
		{
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
			alert("Email address seems incorrect (check @ and .'s)");
			field.focus();
			field.select();
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
	
		if (user.match(userPat)==null) {
			alert("Please enter valid email address !");
			field.focus();
			field.select();
	
			return false;
		}
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null)
			{
			for (var i=1;i<=4;i++)
				{
				if (IPArray[i]>255)
					{
					alert("Destination IP in the Email Address address is invalid !");
					field.focus();
					field.select();
					return false;
					}
				}
			return true;
			}
	
		var domainArray=domain.match(domainPat);
		if (domainArray==null)
			{
			alert("The domain name in the Email Address doesn't seem to be valid.");
			field.focus();
			field.select();
			return false;
			}
		var atomPat=new RegExp(atom,"g");
		var domArr=domain.match(atomPat);
		var len=domArr.length;
		if (domArr[domArr.length-1].length<2 ||
			domArr[domArr.length-1].length>3)
			{
		   // the address must end in a two letter or three letter word.
			alert("The Email address must end in a three-letter domain, or two letter country.");
			field.focus();
			field.select();
			return false;
			}
	
		if (len<2)
			{
			var errStr="The Email address is missing a hostname!";
			alert(errStr);
			field.focus();
			field.select();
			return false
			}
		}
	return true;
	}
	
	//function to validate the search text boxes values 
	 function ValidateSearch(totalQues,srno)
	 {		 
		for(i=srno;i<totalQues;i++)
		{	//check if any response is greater than 5
			
			txtval = eval("document.form1.SQUES"+i).value;				 
			if(isNaN(txtval))
			{
				alert("Please enter numeric value !");
				eval("document.form1.SQUES"+i).focus();
				return false;					
			}
			if(txtval > 5)
			{
				alert("Please enter value less than 5");
				eval("document.form1.SQUES"+i).focus();
				return false;					
			}//if								
		}//for	  					
		return true;
	 }
	 
	  //function to clear the search textboxes
	function ClearValues(totQues,srno,formname)
	{
		for(i=srno;i<=totQues;i++)
		{
			eval("document.form1.SQUES"+i).value = ""
			eval("document.form1.SCOMPARE"+i).options.selectedIndex = "0";
		}
		
		//clear all the demo graphic check boxes if selected
		for(i=0;i<document.form1.elements.length;i++)
		{
			if(eval("document." + formname +".elements[i]").type == "checkbox")
				eval("document."+ formname +".elements[i]").checked = false;
		}

			
		//clear search and comparison values of avg column
		document.form1.SAVG.value = ""
		document.form1.SAVGCOMPARE.options.selectedIndex = "0";
		if(document.form1.SURVEY)
		{
			document.form1.SURVEY.value = ""
			document.form1.SURCOMPARE.options.selectedIndex = "0";
		}
		//set the focus on  the first question text
		eval("document.form1.SQUES"+srno).focus();
	
	}//function
	
 function checkparameter(noOfques)
  {
  	totalQues=noOfques+5;
  	srno=6;
  	for(i=srno;i<=totalQues;i++)
		{	//check if any response is greater than 5
			txtval = eval("document.form1.SQUES"+i).value;				 
			if(isNaN(txtval))
			{
				alert("Please enter numeric value !");
				eval("document.form1.SQUES"+i).focus();
				return false;					
			}
			if(txtval > 5)
			{
				alert("Please enter value less than 5");
				eval("document.form1.SQUES"+i).focus();
				return false;					
			}//if								
		}//for	  		
  	
  	if(document.form1.SAVG)
  	{
	  	Avgval=document.form1.SAVG.value
	  
	  	if(isNaN(Avgval))
			{
				alert("Please enter numeric value !");
				document.form1.SAVG.focus();
				return false;					
			}
		if(Avgval > 5)
			{
				alert("Please enter AVG value less than 5");
				document.form1.SAVG.focus();
				return false;					
			}//if	
  	}
  	return true;
  }	
  
	function checkLoyaltyQuestions()
	{
		for(i=0;i<document.form1.elements.length;i++)
		{
			if(document.form1.elements[i].name == 'questions1[]')
			{
				if(document.form1.elements[i].checked == true)
					return true;
			}
		}
		alert("Please select atleast One question ");
		return false;
	}

function ValNUserFD()
	{	
		if(document.form1.txtUser.value == "")
		{
			alert("Please specify User Id!");
			document.form1.txtUser.focus();
			return false;
		}	
			
		if (isNaN(document.form1.txtUser.value) == true)
		{
			alert("Please specify numberic User Id!");
			document.form1.txtUser.focus();
			return false;
		}
		
		if (Number(document.form1.txtUser.value) <=0)
		{
			alert("Please specify valid User Id!");
			document.form1.txtUser.focus();
			return false;
		}
		
		if(document.form1.txtUserName.value == "")
		{
			alert("Please specify the User Name !");
			document.form1.txtUserName.focus();
			return false;
		}
		
		var str=document.form1.txtUserName.value;
		var len = str.length;
		if (len <2 || len >255)
		{
			alert("Please check length of User Name \n It should be greater then 2 characters and less then 255 characters!");
			document.form1.txtUserName.focus();
			return false;
		}
		if(document.form1.txtPassword.value == "")
		{
			alert("Please specify Password!");
			document.form1.txtPassword.focus();
			return false;
		}
		if(document.form1.txtConfirmPassword.value == "")
		{
			alert("Please specify Password!");
			document.form1.txtConfirmPassword.focus();
			return false;
		}
		if((document.form1.txtPassword.value != "" && document.form1.txtConfirmPassword.value != "") && (document.form1.txtPassword.value != document.form1.txtConfirmPassword.value))
		{
			alert("Password and Confirm Password are not same!");
			document.form1.txtConfirmPassword.focus();
			return false;
		}
		
		var str1=document.form1.txtPassword.value;
		var len1 = str1.length;
		if (len1 <2 || len1 >255)
		{
			alert("Please check length of Password \n It should be greater then 2 characters and less then 255 characters!");
			document.form1.txtPassword.focus();
			return false;
		}
		
		if(document.form1.txtName.value == "")
		{
			alert("Please specify the Name !");
			document.form1.txtName.focus();
			return false;
		}
		if((document.form1.txtPrimaryEmail.value != "") && (checkemail(document.form1.txtPrimaryEmail) == false))
		{			
			//alert("Please specify valid email address !");
			document.form1.txtPrimaryEmail.focus();
			return false;
		}
		if((document.form1.txtSecondaryEmail.value != "") && (checkemail(document.form1.txtSecondaryEmail) == false))
		{			
			//alert("Please specify valid email address !");
			document.form1.txtSecondaryEmail.focus();
			return false;
		}				
		return true;
	}//function
	
	
	function ValEditUserFD()
	{	
		
		if(document.form1.txtUserName.value == "")
		{
			alert("Please specify the Name !");
			document.form1.txtUserName.focus();
			return false;
		}
		
		var str=document.form1.txtUserName.value;
		var len = str.length;
		if (len <2 || len >255)
		{
			alert("Please check length of Name \n It should be greater then 2 characters and less then 255 characters!");
			document.form1.txtUserName.focus();
			return false;
		}
		
		if((document.form1.txtNewPassword.value != "" && document.form1.txtConfirmPassword.value != "") && (document.form1.txtNewPassword.value != document.form1.txtConfirmPassword.value))
		{
			alert("Password and Confirm Password are not same!");
			document.form1.txtConfirmPassword.focus();
			return false;
		}
		if(document.form1.txtNewPassword.value != "")
		{
			var str1=document.form1.txtNewPassword.value;
			var len1 = str1.length;
			if (len1 <2 || len1 >255)
			{
				alert("Please check length of Password \n It should be greater then 2 characters and less then 255 characters!");
				document.form1.txtNewPassword.focus();
				return false;
			}
		}
		if(document.form1.txtName.value == "")
		{
			alert("Please specify the Name !");
			document.form1.txtName.focus();
			return false;
		}
		if((document.form1.txtPrimaryEmail.value != "") && (checkemail(document.form1.txtPrimaryEmail) == false))
		{			
			//alert("Please specify valid email address !");
			document.form1.txtPrimaryEmail.focus();
			return false;
		}
		if((document.form1.txtSecondaryEmail.value != "") && (checkemail(document.form1.txtSecondaryEmail) == false))
		{			
			//alert("Please specify valid email address !");
			document.form1.txtSecondaryEmail.focus();
			return false;
		}				
		return true;
	}//function
	
	function ClearAllValues(formname)
	{       
		//alert("length : " + document.frm1.elements.length);
        //alert(formname);
        //clear all the demo graphic check boxes if selected
		//for(i=0;i<document.form1.elements.length;i++)
        for(i=0;i<document.frm1.elements.length;i++)
		{
			//alert(eval("document." + formname +".elements[i]").type);
			if(eval("document." + formname +".elements[i]").type == "checkbox")
				eval("document."+ formname +".elements[i]").checked = false;
			if(eval("document." + formname +".elements[i]").type == "text")	
				eval("document." + formname +".elements[i]").value = ""
				//eval("document.form1.elements[i]").options.selectedIndex = "0";
			if(eval("document." + formname +".elements[i]").type == "select-one")	
				eval("document." + formname +".elements[i]").options.selectedIndex = "0";
				
		}
	}//function
    
    function ClearAllValuesNew(formname)
    {       
        //alert("length : " + document.frm1.elements.length);
        //alert(formname);
        //clear all the demo graphic check boxes if selected
        //for(i=0;i<document.form1.elements.length;i++)
        for(i=0;i<document.frm1.elements.length;i++)
        {
            //alert(eval("document." + formname +".elements[i]").type);
            if(eval("document." + formname +".elements[i]").type == "checkbox")
                eval("document."+ formname +".elements[i]").checked = false;
            if(eval("document." + formname +".elements[i]").type == "text")    
                eval("document." + formname +".elements[i]").value = ""
                //eval("document.form1.elements[i]").options.selectedIndex = "0";
            if(eval("document." + formname +".elements[i]").type == "select-one")    
                eval("document." + formname +".elements[i]").options.selectedIndex = "0";
                
        }
    }//function


	function trim(str, chars) {
		return ltrim(rtrim(str, chars), chars);
	}
	 
	function ltrim(str, chars) {
		chars = chars || "\\s";
		return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	}
	 
	function rtrim(str, chars) {
		chars = chars || "\\s";
		return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	}


	function checkControl(ctrlName, ctrlLabel, ctrlType)
	{
		formname = document.form4;
		

		if(ctrlType == "radio")
		{
			flag="0";
			val = eval("formname."+ ctrlName +".length");
	 
			for(j=0;j<val;j++)
			{
				ans = eval("formname."+ ctrlName +"["+j+"].checked");
	 
				if(ans == true)
				{
					  flag = "1";                
				}  
			}

			if(flag=="0")
			{
				 alert("Please select atleast one response for Question: "+ ctrlLabel +".");      
				 return false;   
			}
		}
		
		if(ctrlType == "checkbox")
		{	
			var chks = document.getElementsByName(ctrlName);
			
			var isChecked = false;

			// Get the checkbox array length and iterate it to see if any of them is selected
			for (var k = 0; k < chks.length; k++)
			{	
				if (chks[k].checked)
				{
					isChecked = true;
					break;
				}
			}

			// if ishasChecked is false then throw the error message
			if (!isChecked)
			{	
				alert("Please select at least one response for Question: "+ ctrlLabel +".");
				chks[0].focus();
				return false;
			}
			
		}
		else
		{
			thCtrl = eval("formname."+ctrlName);
			if(thCtrl.value=="")
			{
				alert("Please enter response for Question: "+ ctrlLabel +".");
				
				thCtrl.focus();
				return 0;
			}
		}

		return 1;
	}


	function checkControl_2(ctrlName, ctrlLabel, ctrlType)
	{
		formname = document.form4;
		

		if(ctrlType == "radio")
		{
			flag="0";
			val = eval("formname."+ ctrlName +".length");
	 
			for(j=0;j<val;j++)
			{
				ans = eval("formname."+ ctrlName +"["+j+"].checked");
	 
				if(ans == true)
				{
					  flag = "1";                
				}  
			}

			if(flag=="0")
			{
				 return false;   
			}
		}
		if(ctrlType == "checkbox")
		{
			var chks = document.getElementsByName(ctrlName);
			
			var isChecked = false;

			// Get the checkbox array length and iterate it to see if any of them is selected
			for (var k = 0; k < chks.length; k++)
			{
				if (chks[k].checked)
				{
					isChecked = true;
					break;
				}
			}

			// if ishasChecked is false then throw the error message
			if (!isChecked)
			{
				return false;
			}
			
		}
		else
		{
			thCtrl = eval("formname."+ctrlName);
			if(thCtrl.value=="")
			{
				return 0;
			}
		}

		return 1;
	}

	/**
	** These are the functions for the new application form.
	** Developer Sachin Khairnar.
	*/
	/*function loadData(control)
	{
		formname = document.form4;
		var control_set = control - 1;

		//First employeer
		if(!checkControl("QUES_"+ control_set +"_4","Employer Name","")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_5","Type of Business","")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_6","Street Address","")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_7","Phone Number","")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_8","City","")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_9","State","")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_10","Zip Code","")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_11","Supervisor`s Name","")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_12","Supervisor`s Phone Number","")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_14","Starting Salary", "")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_15","Ending Salary", "")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_19","Position", "")){ return false; };
		if(!checkControl("QUES_"+ control_set +"_20","Reason for Leaving", "")){ return false; };

		//document.getElementById("EMPLOYER_HISTORY"+control).style.display = "block";
		//document.getElementById("EMPLOYER_LINK"+control).style.display = "none";
	} */

	function validateAppOne()
	{
		formname = document.form4;
		
		if(!checkControl("FIRST","First Name","")){ return false; };
		if(!checkControl("LAST","Last Name","")){ return false; };
		if(!checkControl("EMAIL","Email Address","")){ return false; };
		if(!checkControl("ADDR","Address","")){ return false; };
		if(!checkControl("CITY","City","")){ return false; };
		if(!checkControl("STATE","State","")){ return false; };
		if(!checkControl("ZIP","Zip Code","")){ return false; };
		if(!checkControl("selPrimary","Primary Location","")){ return false; };
		if(!checkControl("selSecondary","Secondary Location","")){ return false; };
		if(!checkControl("HOMEPHONE","Primary Phone","")){ return false; };
		if(!checkControl("QUES1[]","Position Desired","checkbox")){ return false; };
		if(!checkControl("QUES2","How did you hear about Sport Clips?", "")){ return false; };
		if(!checkControl("QUES3","When are you available to start work?", "radio")){ return false; };

		return true
	}

	function validateAppTwo()
	{
		formname = document.form4;
		//First employeer
		if(!checkControl_2("QUES_1_4","Employer Name","")){ return false; };
		if(!checkControl_2("QUES_1_5","Type of Business","")){ return false; };
		if(!checkControl_2("QUES_1_9","State","")){ return false; };
		if(!checkControl_2("QUES_1_14","Starting Hourly Salary", "")){ return false; };
		if(!checkControl_2("QUES_1_15","Ending Hourly Salary", "")){ return false; };
		if(!checkControl_2("QUES_1_19","Position", "")){ return false; };
		if(!checkControl_2("QUES_1_20","Reason for Leaving", "")){ return false; };

		return true;
	}

	function validateAppThree()
	{
		formname = document.form4;
		
		//Referral 1 valdiation
		if(!checkControl("txtName_1","Reference Name","")){ return false; };
		if(!eval("formname."+"txtAddress_1").value && !eval("formname."+"txtPhone_1").value)
		{
			alert("Please enter Address / Phone Number");
			eval("formname."+"txtAddress_1").focus();
			return false;
		}

		if(eval("formname."+"txtSch_1").value)
		{
			if(!checkControl("txtLocation_1","School Location","")){ return false; };
			//if(!checkControl("txtMajor_1","Major Subject or Degree","")){ return false; };
		}

		if(eval("formname."+"txtSch_2").value)
		{
			if(!checkControl("txtLocation_2","Location","")){ return false; };
			//if(!checkControl("txtMajor_2","Major Subject or Degree","")){ return false; };
		} 

		if(eval("formname."+"txtSch_3").value)
		{
			if(!checkControl("txtLocation_3","Location","")){ return false; };
			//if(!checkControl("txtMajor_3","Major Subject or Degree","")){ return false; };
		} 

		if(!checkControl("QUES37", "Can you, after employment, submit verification of your legal right to work in the U.S.?", "radio")){ return false; };
		if(!checkControl("QUES41", "Have you ever been convicted, or pled guilty or no contest to a felony?", "radio")){ return false; };

		if(!checkControl("agree1", "Terms & conditions paragraph 1", "checkbox")){ return false; };
		if(!checkControl("agree2", "Terms & conditions paragraph 2", "checkbox")){ return false; };
		if(!checkControl("txtName", "Please type your full name in the space", "")){ return false; };
	}

	/**
	* @desc Function () - This function is used to show/hide div
	* @param form frm, int ques, visib  
	*/ 
	function OpenHideDiv(frm,ques,visib)
	{ 
		var str=ques;
		var subs=str.substring(4);
		var subs="QUES"+subs;

		var btn = frm[subs];       
		var valid;

		for (var x=0; x < btn.length; x++)
		{
			valid = btn[x].checked;     
		  
			if (valid) 
			{	
				if(visib=='1')
				{
					document.getElementById(ques).style.display = 'block'; 
				}
				else if(visib=='0')
				{
					document.getElementById(ques).style.display = "none";
				}
				
				break;
			}
		}
	}
	/* End of function OpenHide_Div */ 
	
	//validate existing user (on edit)
	function ValidateUserEdit(desgId)
	{	
        if(desgId == 5)
        {
            if(document.form1.txtName.value == "")
            {
                alert("Please specify the Name !");
                document.form1.txtName.focus();
                return false;
            }
            return true;
        }
        else
        {	
		    if(document.form1.txtName.value == "")
		    {
			    alert("Please specify the Name !");
			    document.form1.txtName.focus();
			    return false;
		    }
	    
           
            if( ( (document.form1.txtNewPassword.value != "") || (document.form1.txtConfirmPassword.value != "") || (document.form1.txtOldPassword.value != "") ) )
            {  
                 if(document.form1.txtConfirmPassword.value == "")
                {
                    alert("Please specify Confirm Password !");
                    document.form1.txtConfirmPassword.focus();
                    return false;
                }
                if(document.form1.txtNewPassword.value == "")
                {
                    alert("Please specify New Password !");
                    document.form1.txtNewPassword.focus();
                    return false;
                }
                if(document.form1.txtOldPassword.value == "")
                {
                    alert("Please specify Old Password !");
                    document.form1.txtOldPassword.focus();
                    return false;
                }
                if(document.form1.txtNewPassword.value != document.form1.txtConfirmPassword.value)
                {
                    alert("New Password and Confirm Password are not same!");
                    document.form1.txtNewPassword.focus();
                    return false;
                }
                if(document.form1.txtOldPassword.value == document.form1.txtNewPassword.value)
                {
                    alert("Old Password and New Password can not be same!");
                    document.form1.txtOldPassword.focus();
                    return false;
                }
                var str2=document.form1.txtNewPassword.value;
                var len2 = str2.length;
                if (len2 <2 || len2 >255)
                {
                    alert("Please check length of New Password \n It should be greater then 2 characters and less then 255 characters!");
                    document.form1.txtNewPassword.focus();
                    return false;
                }
            }
           
		    
		    
		    //if((document.form1.txtPrimaryEmail.value != "") && (fnValidEmail(document.form1.txtPrimaryEmail.value) == false))
		    if((document.form1.txtPrimaryEmail.value == "") || (checkemail(document.form1.txtPrimaryEmail) == false))
		    {			
			    alert("Please specify valid email address !");
			    document.form1.txtPrimaryEmail.focus();
			    return false;
		    }
		    
		    return true;
        }
	}//function
    function newPopup(url) {
            popupWindow = window.open(
                url,'popUpWindow','height=700,width=851 ,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
        }
