document.onkeypress = fnCheckKey;       
var KeyID;
function fnCheckKey(e)
{
   //alert("hi"); 
   KeyID = (window.event) ? event.keyCode : e.which;
}


var intCurrentYear = 2009;

function fnNext()
{
	if(document.getElementById('txtname').value == "")
	{
		alert('Please enter name.');
		document.getElementById('txtname').focus();
		return false;
	}
	if(!fnValidateName())
		return false;
	
	if(document.getElementById("ddl_Month").value=="")
	{
	alert("Please select Month");
	document.getElementById("ddl_Month").focus();
	return false;
	}
	if(document.getElementById("ddl_Date").value=="")
	{
	alert("Please select Date");
	document.getElementById("ddl_Date").focus();
	return false;
	}
	if(document.getElementById("ddl_Year").value=="")
	{
	alert("Please select Year");
	document.getElementById("ddl_Year").focus();
	return false;
	}			  
	if(!fnValidateDOB())
		return false;
	
	var rb1=document.getElementById("rdmale");
	var rb2=document.getElementById("rdfemale");
	if(rb1.checked==false && rb2.checked==false)
	{
		alert("Please select gender.");
		rb1.focus();
		return false;
	}
	if(!fnValidatePhoneNumber())
		return false;	
		
	if(!fnValidateStdCode())
		return false;	

	if(!fnValidateMobileNumber())
		return false;	
	
	if(!fnValidateEmailId())
		return false;	

	
		
	if(document.getElementById("txtCMobile").value == '' && document.getElementById("txtCSTDCode").value == '' && document.getElementById("txtCPhone").value == '' )
	{
		alert("You need to enter either mobile number or landline number. Mobile number would be preferred.");
		document.getElementById("txtCMobile").focus();
		return false;
	}
				
	if(document.getElementById('txtCPhone').value.length + document.getElementById('txtCSTDCode').value.length != 10 && ( document.getElementById("txtCPhone").value != '' || document.getElementById("txtCSTDCode").value != '' ))
	{
		alert("std code + phone no. should be exactly of 10 digits");
		document.getElementById("txtCPhone").value="";
		document.getElementById("txtCPhone").focus()
		return false;
	}
	if(document.getElementById('txtCEmail').value == "")
	{
		alert('Please enter Email Id.');
		document.getElementById('txtCEmail').focus();
		return false;	
	}
	if(!fnValidateEmailId())
		return false;	


	if (document.getElementById("ddlLocation").value=="")
	{
	alert(" Please select Location");
	document.getElementById("ddlLocation").focus();
	return false;
	} 

	if(document.getElementById('txtCorrAdd').value == "")
	{
		alert('Please enter address.');
		document.getElementById('txtCorrAdd').focus();
		return false;
	}
	if(!fnValidateAddress())
		return false;

	
	if(document.getElementById("txtCState").selectedIndex=="")				
	{
		alert("Please enter state ");
		document.getElementById("txtCState").focus();
		return false;
	}
	if(document.getElementById('txtCCity').value == "")
	{
		alert('Please enter city.');
		document.getElementById('txtCCity').focus();
		return false;
	}
	
	if(!fnValidateCity())
		return false;
				
	
	if(document.getElementById('txtCPin').value == "")
	{
		alert('Please enter pincode.');
		document.getElementById('txtCPin').focus();
		return false;
	}	
	
    document.getElementById("trSubmitButton").style.display = "none";
    document.getElementById("trSubmitting").style.display = "block";
	document.form1.action="EnquiryFormAction.asp?Faction=Save";
}


function fnSubmit()
{
	if(document.getElementById('txtYrPass1').value == "")
	{
		alert('Please enter 10th Passing Year.');
		document.getElementById('txtYrPass1').focus();
		return false;	
	}
	if(!fnValidateXthPassingYr())
		return false;	

	if(document.getElementById('txtSch_Coll1').value == "")
	{
		alert('Please enter 10th School/College.');
		document.getElementById('txtSch_Coll1').focus();
		return false;	
	}
	if(!fnValidateXthSchool())
		return false;	

	if(document.getElementById('txtBoard1').value == "")
	{
		alert('Please enter 10th Education Board.');
		document.getElementById('txtBoard1').focus();
		return false;	
	}
	if(!fnValidateXthBoard())
		return false;	

	if(document.getElementById('txtSubj1').value == "")
	{
		alert('Please enter Xth Subjects.');
		document.getElementById('txtSubj1').focus();
		return false;	
	}
	if(!fnValidateXthSubjects())
		return false;	

	if(document.getElementById("ddlpercxth").value=="" )
	{
		alert("Please select percentage");
		document.getElementById("ddlpercxth").focus();
		return false;
	}

	if(document.getElementById('txtYrPass2').value == "")
	{
		alert('Please enter 12th Passing Year.');
		document.getElementById('txtYrPass2').focus();
		return false;	
	}
	if(!fnValidateXIIthPassingYr())
		return false;	

	if(document.getElementById('txtSch_Coll2').value == "")
	{
		alert('Please enter 12th School/College.');
		document.getElementById('txtSch_Coll2').focus();
		return false;	
	}
	if(!fnValidateXIIthSchool())
		return false;	

	if(document.getElementById('txtBoard2').value == "")
	{
		alert('Please enter 12th Education Board.');
		document.getElementById('txtBoard2').focus();
		return false;	
	}
	if(!fnValidateXIIthBoard())
		return false;	

	if(document.getElementById('txtSubj2').value == "")
	{
		alert('Please enter XIIth Subjects.');
		document.getElementById('txtSubj2').focus();
		return false;	
	}
	if(!fnValidateXIIthSubjects())
		return false;	

	if(document.getElementById("ddlpercxii").value=="" )
	{
		alert("Please select percentage");
		document.getElementById("ddlpercxii").focus();
		return false;
	}

	if (document.getElementById("ddl_Graduation").value=="")
	{
		alert("Please select graduation");
		document.getElementById("ddl_Graduation").focus();
		return false;
	}

	if (document.getElementById("ddl_Graduation").value!="Final Year")
	{
		if(document.getElementById('txtYrPass3').value == "")
		{
			alert('Please enter Graduation Passing Year.');
			document.getElementById('txtYrPass3').focus();
			return false;	
		}
		if(!fnValidateGradPassingYr())
			return false;	
		
		if(document.getElementById('txtSch_Coll3').value == "")
		{
			alert('Please enter Graduation School/College.');
			document.getElementById('txtSch_Coll3').focus();
			return false;	
		}
		if(!fnValidateGradSchool())
			return false;	
	
		if(document.getElementById('txtBoard3').value == "")
		{
			alert('Please enter Graduation Education Board.');
			document.getElementById('txtBoard3').focus();
			return false;	
		}
		if(!fnValidateGradBoard())
			return false;	
	
		if(document.getElementById('txtSubj3').value == "")
		{
			alert('Please enter Graduation Subjects.');
			document.getElementById('txtSubj3').focus();
			return false;	
		}
		if(!fnValidateGradSubjects())
			return false;	

		if(document.getElementById("ddlpercgraduation").value=="" )
		{
			alert("Please select percentage");
			document.getElementById("ddlpercgraduation").focus();
			return false;
		}
	}
	
	if(document.getElementById ("tdgfinalyear").style.display=="block")
	{
		if(document.getElementById("ddlfinalyear").value=="" )
		{
			alert("Select final year graduation stream");
			document.getElementById("ddlfinalyear").focus();
			return false;
		}
		if(document.getElementById('txt4thsem').value == "")
		{
			alert('Please enter 4th Semester marks.');
			document.getElementById('txt4thsem').focus();
			return false;	
		}
		if(!fnValidate4thSemMarks())
			return false;	
	
//		if(document.getElementById('txt6thsem').value == "")
//		{
//			alert('Please enter 6th Semester marks.');
//			document.getElementById('txt6thsem').focus();
//			return false;	
//		}
		if(!fnValidate6thSemMarks())
			return false;	
	}

    if(document.getElementById("ddl_Post_Graduation"))
    {
	    if (document.getElementById("ddl_Post_Graduation").value!="")
	    {
		    if(document.getElementById('txtYrPass4').value == "")
		    {
			    alert('Please enter Post Graduation Passing Year.');
			    document.getElementById('txtYrPass4').focus();
			    return false;	
		    }
		    if(!fnValidatePostGradPassingYr())
			    return false;	
    	
		    if(document.getElementById('txtSch_Coll4').value == "")
		    {
			    alert('Please enter Post Graduation School/College.');
			    document.getElementById('txtSch_Coll4').focus();
			    return false;	
		    }
		    if(!fnValidatePostGradSchool())
			    return false;	
    	
    	
		    if(document.getElementById('txtBoard4').value == "")
		    {
			    alert('Please enter Post Graduation Education Board.');
			    document.getElementById('txtBoard4').focus();
			    return false;	
		    }
		    if(!fnValidatePostGradBoard())
			    return false;	
    	
		    if(document.getElementById('txtSubj4').value == "")
		    {
			    alert('Please enter Post Graduation Subjects.');
			    document.getElementById('txtSubj4').focus();
			    return false;	
		    }
		    if(!fnValidatePostGradSubjects())
			    return false;	

		    if(document.getElementById("ddlpercpgraduation").value=="" )
		    {
			    alert("Please select percentage");
			    document.getElementById("ddlpercpgraduation").focus();
			    return false;
		    }
	    }

	    if (document.getElementById("RdExp1").checked==true)
	    {	
		    if(document.getElementById('txtOrga1').value == "")
		    {
			    alert('Please enter name of your Organization.');
			    document.getElementById('txtOrga1').focus();
			    return false;	
		    }
		    if(!fnValidateOrganization())
			    return false;	
    	
		    if(document.getElementById('txtFrom1').value == "")
		    {
			    alert('Please enter your experience From Date.');
			    document.getElementById('txtFrom1').focus();
			    return false;	
		    }
		    if(!fnValidateExpFromDate())
			    return false;	
    	
		    if(document.getElementById('txtTo1').value == "")
		    {
			    alert('Please enter your experience To Date.');
			    document.getElementById('txtTo1').focus();
			    return false;	
		    }
		    if(!fnValidateExpToDate())
			    return false;	
    	
		    if(document.getElementById('txtTMExp1').value == "")
		    {
			    alert('Please enter your total Experience in Months.');
			    document.getElementById('txtTMExp1').focus();
			    return false;	
		    }
		    if(!fnValidateExpTotalMonth())
			    return false;	
    	
		    if(document.getElementById('txtDesg1').value == "")
		    {
			    alert('Please enter your Designation.');
			    document.getElementById('txtDesg1').focus();
			    return false;	
		    }
		    if(!fnValidateExpDesg())
			    return false;	
    	
		    if(document.getElementById('txtLSALD1').value == "")
		    {
			    alert('Please enter your Last Salary Drawn.');
			    document.getElementById('txtLSALD1').focus();
			    return false;	
		    }
		    if(!fnValidateLastSalary())
			    return false;	
    	
		    if(document.getElementById('txtJDesc1').value == "")
		    {
			    alert('Please enter your Job Description.');
			    document.getElementById('txtJDesc1').focus();
			    return false;	
		    }
		    if(!fnValidateJobDescription())
			    return false;	
    		
		    var strFromDate = document.getElementById('txtFrom1').value;
		    var strToDate = document.getElementById('txtTo1').value;
		    var intStatus = CompareDates(strToDate, strFromDate );
		    if(intStatus != 1)
		    {
			    alert('Experience "To Date" must be greater than "From Date".');
			    return false;
		    }
	    }
    }
	
	if(!fnValidateRadioHow())
	{
		alert('Please select "How you came to know about".');
		return false;	
	}
	
	if(document.getElementById("trAnyOther").style.display != "none")
	{
		if(document.getElementById("txtAnyOther").value=='')
		{
			alert("Please enter 'How you came to know about'");
			document.getElementById("txtAnyOther").focus();
			return false;				
		}
		if(!fnValidateAnyOther())
			return false;	
	}
    document.getElementById("trSubmitButton").style.display = "none";
    document.getElementById("trSubmitting").style.display = "block";
	document.form1.action="EnquiryForm1Action.asp?Faction=Save";
}












function fnValidateSmsCode()
{
	var strSmsCode = fnTrim(document.getElementById('txtSmsCode').value);
	if(strSmsCode != '')
	{
//	    if(strSmsCode.length != 4)
//	    {
//			alert('SMS Code is not valid.');
//			document.getElementById('txtSmsCode').focus();
//			return false;		        
//	    } 
		if(!fnIsNumeric(strSmsCode))
		{
			alert('SMS Code is not valid.');
			document.getElementById('txtSmsCode').focus();
			return false;	
		}	
		//fnAjaxValidateSmsCode();
	}
	return true;
}

function fnValidateName()
{
	var strName = fnTrim(document.getElementById('txtname').value);
	if(strName != '')
	{
		if(!fnIsAlphaNChar(strName, ' '))
		{
			alert('Name is not valid.');
			document.getElementById('txtname').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateDOB()
{
	var strDOB = document.getElementById('ddl_Month').value + '/' + document.getElementById('ddl_Date').value + '/' + document.getElementById('ddl_Year').value;
	if(!isDate(strDOB))
	{
		document.getElementById('ddl_Month').focus();
		return false;						
	}
	if(CompareDates(strDOB, '4/30/1979') != 1)
	{
		alert('Date of Birth should be greater than 30th April 1979.');
		document.getElementById('ddl_Month').focus();
		return false;				
	}
	return true;	
}

function fnValidateAddress()
{
	var strAddress = fnTrim(document.getElementById('txtCorrAdd').value);
	if(strAddress != '')
	{
		if(fnIsNumeric(strAddress))
		{
			alert('Address is not valid.');
			document.getElementById('txtCorrAdd').focus();
			return false;				
		}
	}
	return true;
}
function fnValidateCity()
{
	var strCity = fnTrim(document.getElementById('txtCCity').value);
	if(strCity != '')
	{
		if(!fnIsAlphaNChar(strCity, ' '))
		{
			alert('City is not valid.');
			document.getElementById('txtCCity').focus();
			return false;	
		}		
	}
	return true;
}

function fnValidatePinCode()
{
	var strPincode = fnTrim(document.getElementById('txtCPin').value);
	if(strPincode != '')
	{
		if(strPincode.length != 6)
		{
			alert('Pincode should be exactly 6 digits in length.');
			document.getElementById('txtCPin').focus();
			return false;			
		}
		if(!fnIsNumeric(strPincode))
		{
			alert('Pincode should not be non numeric.');
			document.getElementById('txtCPin').focus();
			return false;	
		}	
		if(strPincode.charAt(0) == '0')
		{
			alert('Pincode can not start with 0.');
			document.getElementById('txtCPin').focus();
			return false;			
		}		
	}
	return true;
}

function fnValidateStdCode()
{
	var strStdCode = fnTrim(document.getElementById('txtCSTDCode').value);
	if(strStdCode != '')
	{
		if(strStdCode.length > 4)
		{
			alert('STD Code can not be greater than 4 digits in length.');
			document.getElementById('txtCSTDCode').focus();
			return false;			
		}
		if(!fnIsNumeric(strStdCode))
		{
			alert('STD Code can not be non numeric.');
			document.getElementById('txtCSTDCode').focus();
			return false;	
		}	
		if(strStdCode.charAt(0) == '0')
		{
			alert('STD Code can not start with 0.');
			document.getElementById('txtCSTDCode').focus();
			return false;			
		}		
	}
	return true;
}

function fnValidatePhoneNumber()
{
	var strPhoneNumber = fnTrim(document.getElementById('txtCPhone').value);
	if(strPhoneNumber != '')
	{
		if(strPhoneNumber.length > 8)
		{
			alert('Phone number can not be greater than 8 digits in length.');
			document.getElementById('txtCPhone').focus();
			return false;			
		}
		if(!fnIsNumeric(strPhoneNumber))
		{
			alert('Phone number can not be non numeric.');
			document.getElementById('txtCPhone').focus();
			return false;	
		}	
		if(strPhoneNumber.charAt(0) == '0')
		{
			alert('Phone number can not start with 0.');
			document.getElementById('txtCPhone').focus();
			return false;			
		}		
		if(strPhoneNumber.charAt(0) == '1')
		{
			alert('Phone number can not start with 1.');
			document.getElementById('txtCPhone').focus();
			return false;			
		}		
	}
	return true;
}

function fnValidateMobileNumber()
{
	var strMobileNumber = fnTrim(document.getElementById('txtCMobile').value);
	if(strMobileNumber != '')
	{
		if(strMobileNumber.length != 10)
		{
			alert('Mobile number should be exactly 10 digits in length.');
			document.getElementById('txtCMobile').focus();
			return false;			
		}
		if(!fnIsNumeric(strMobileNumber))
		{
			alert('Mobile number can not be non numeric.');
			document.getElementById('txtCMobile').focus();
			return false;	
		}	
		if(strMobileNumber.charAt(0) != '9' && strMobileNumber.charAt(0) != '8' && strMobileNumber.charAt(0) != '7')
		{
			alert('Mobile number is not valid.');
			document.getElementById('txtCMobile').focus();
			return false;			
		}		
		if(strMobileNumber =='9000000000' || strMobileNumber == '9111111111' || strMobileNumber == '9222222222' || strMobileNumber == '9333333333' || strMobileNumber == '944444444' || strMobileNumber == '955555555' || strMobileNumber == '966666666' || strMobileNumber == '9777777777' || strMobileNumber == '9888888888' || strMobileNumber == '9999999999')
		{
			alert('Mobile number is not valid.');
			document.getElementById('txtCMobile').focus();
			return false;			
		}		
		if(strMobileNumber =='8000000000' || strMobileNumber == '8111111111' || strMobileNumber == '8222222222' || strMobileNumber == '8333333333' || strMobileNumber == '844444444' || strMobileNumber == '855555555' || strMobileNumber == '866666666' || strMobileNumber == '8777777777' || strMobileNumber == '8888888888' || strMobileNumber == '8999999999')
		{
			alert('Mobile number is not valid.');
			document.getElementById('txtCMobile').focus();
			return false;			
		}		
		
	}
	return true;
}

function fnValidateEmailId()
{
	var strEmailId = fnTrim(document.getElementById('txtCEmail').value);
	if(strEmailId != '')
	{
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(strEmailId))
		{
			alert('Email Id is not valid.');
			document.getElementById('txtCEmail').focus();
			return false;			
		}		
	}
	return true;
}

function fnValidateXthPassingYr()
{
	var strXthPassingYr = fnTrim(document.getElementById('txtYrPass1').value);
	if(strXthPassingYr != '')
	{
		if(strXthPassingYr.length != 4)
		{
			alert('Please enter year as "YYYY".');
			document.getElementById('txtYrPass1').focus();
			return false;			
		}
		if(!fnIsNumeric(strXthPassingYr))
		{
			alert('Year can not be non numeric.');
			document.getElementById('txtYrPass1').focus();
			return false;	
		}	
		if(strXthPassingYr > intCurrentYear)
		{
			alert('Passing Year can not be greater than current year.');
			document.getElementById('txtYrPass1').focus();
			return false;			
		}		
	}
	return true;
}

function fnValidateXIIthPassingYr()
{
	var strXIIthPassingYr = fnTrim(document.getElementById('txtYrPass2').value);
	if(strXIIthPassingYr != '')
	{
		if(strXIIthPassingYr.length != 4)
		{
			alert('Please enter year as "YYYY".');
			document.getElementById('txtYrPass2').focus();
			return false;			
		}
		if(!fnIsNumeric(strXIIthPassingYr))
		{
			alert('Year can not be non numeric.');
			document.getElementById('txtYrPass2').focus();
			return false;	
		}	
		if(strXIIthPassingYr > intCurrentYear)
		{
			alert('Passing Year can not be greater than current year.');
			document.getElementById('txtYrPass2').focus();
			return false;			
		}		
	}
	return true;
}

function fnValidateGradPassingYr()
{
	var strGradPassingYr = fnTrim(document.getElementById('txtYrPass3').value);
	if(strGradPassingYr != '')
	{
		if(strGradPassingYr.length != 4)
		{
			alert('Please enter year as "YYYY".');
			document.getElementById('txtYrPass3').focus();
			return false;			
		}
		if(!fnIsNumeric(strGradPassingYr))
		{
			alert('Year can not be non numeric.');
			document.getElementById('txtYrPass3').focus();
			return false;	
		}	
		if(strGradPassingYr > intCurrentYear)
		{
			alert('Passing Year can not be greater than current year.');
			document.getElementById('txtYrPass3').focus();
			return false;			
		}		
	}
	return true;
}

function fnValidatePostGradPassingYr()
{
	var strPostGradPassingYr = fnTrim(document.getElementById('txtYrPass4').value);
	if(strPostGradPassingYr != '')
	{
		if(strPostGradPassingYr.length != 4)
		{
			alert('Please enter year as "YYYY".');
			document.getElementById('txtYrPass4').focus();
			return false;			
		}
		if(!fnIsNumeric(strPostGradPassingYr))
		{
			alert('Year can not be non numeric.');
			document.getElementById('txtYrPass4').focus();
			return false;	
		}	
		if(strPostGradPassingYr > intCurrentYear)
		{
			alert('Passing Year can not be greater than current year.');
			document.getElementById('txtYrPass4').focus();
			return false;			
		}		
	}
	return true;
}

function fnValidateXthSchool()
{
	var strXthSchool = fnTrim(document.getElementById('txtSch_Coll1').value);
	if(strXthSchool != '')
	{
		if(fnHasDigits(strXthSchool))
		{
			alert('School/College can not have digits.');
			document.getElementById('txtSch_Coll1').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateXIIthSchool()
{
	var strXIIthSchool = fnTrim(document.getElementById('txtSch_Coll2').value);
	if(strXIIthSchool != '')
	{
		if(fnHasDigits(strXIIthSchool))
		{
			alert('School/College can not have digits.');
			document.getElementById('txtSch_Coll2').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateGradSchool()
{
	var strGradSchool = fnTrim(document.getElementById('txtSch_Coll3').value);
	if(strGradSchool != '')
	{
		if(fnHasDigits(strGradSchool))
		{
			alert('School/College can not have digits.');
			document.getElementById('txtSch_Coll3').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidatePostGradSchool()
{
	var strPostGradSchool = fnTrim(document.getElementById('txtSch_Coll4').value);
	if(strPostGradSchool != '')
	{
		if(fnHasDigits(strPostGradSchool))
		{
			alert('School/College can not have digits.');
			document.getElementById('txtSch_Coll4').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateXthBoard()
{
	var strXthBoard = fnTrim(document.getElementById('txtBoard1').value);
	if(strXthBoard != '')
	{
		if(fnHasDigits(strXthBoard))
		{
			alert('Board name can not have digits.');
			document.getElementById('txtBoard1').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateXIIthBoard()
{
	var strXIIthBoard = fnTrim(document.getElementById('txtBoard2').value);
	if(strXIIthBoard != '')
	{
		if(fnHasDigits(strXIIthBoard))
		{
			alert('Board name can not have digits.');
			document.getElementById('txtBoard2').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateGradBoard()
{
	var strGradBoard = fnTrim(document.getElementById('txtBoard3').value);
	if(strGradBoard != '')
	{
		if(fnHasDigits(strGradBoard))
		{
			alert('Board name can not have digits.');
			document.getElementById('txtBoard3').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidatePostGradBoard()
{
	var strPostGradBoard = fnTrim(document.getElementById('txtBoard4').value);
	if(strPostGradBoard != '')
	{
		if(fnHasDigits(strPostGradBoard))
		{
			alert('Board name can not have digits.');
			document.getElementById('txtBoard4').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateXthSubjects()
{
	var strXthSubjects = fnTrim(document.getElementById('txtSubj1').value);
	if(strXthSubjects != '')
	{
		if(fnHasDigits(strXthSubjects))
		{
			alert('Subject names can not have digits.');
			document.getElementById('txtSubj1').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateXIIthSubjects()
{
	var strXIIthSubjects = fnTrim(document.getElementById('txtSubj2').value);
	if(strXIIthSubjects != '')
	{
		if(fnHasDigits(strXIIthSubjects))
		{
			alert('Subject names can not have digits.');
			document.getElementById('txtSubj2').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateGradSubjects()
{
	var strGradSubjects = fnTrim(document.getElementById('txtSubj3').value);
	if(strGradSubjects != '')
	{
		if(fnHasDigits(strGradSubjects))
		{
			alert('Subject names can not have digits.');
			document.getElementById('txtSubj3').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidatePostGradSubjects()
{
	var strPostGradSubjects = fnTrim(document.getElementById('txtSubj4').value);
	if(strPostGradSubjects != '')
	{
		if(fnHasDigits(strPostGradSubjects))
		{
			alert('Subject names can not have digits.');
			document.getElementById('txtSubj4').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidate4thSemMarks()
{
	var str4thSemMarks = fnTrim(document.getElementById('txt4thsem').value);
	if(str4thSemMarks != '')
	{
		if(!fnIsPositiveDecimalValue(str4thSemMarks))
		{
			alert('Marks should be a positive decimal value.');
			document.getElementById('txt4thsem').focus();
			return false;			
		}
	}
	return true;
}

function fnValidate6thSemMarks()
{
	var str6thSemMarks = fnTrim(document.getElementById('txt6thsem').value);
	if(str6thSemMarks != '')
	{
		if(!fnIsPositiveDecimalValue(str6thSemMarks))
		{
			alert('Marks should be a positive decimal value.');
			document.getElementById('txt6thsem').focus();
			return false;			
		}
	}
	return true;
}

function fnValidateOrganization()
{
	var strOrganization = fnTrim(document.getElementById('txtOrga1').value);
	if(strOrganization != '')
	{
		if(fnIsNumeric(strOrganization))
		{
			alert('Organization can not be numeric.');
			document.getElementById('txtOrga1').focus();
			return false;			
		}
	}
	return true;
}

function fnValidateExpFromDate()
{
	var strExpFromDate = document.getElementById("txtFrom1").value;
	if(strExpFromDate != '')
	{
		if (isDate(strExpFromDate) == false)
		{
			//alert('Invalid Date.');
			document.getElementById('txtFrom1').focus();
			return false;
		}
	}
    return true;
}

function fnValidateExpToDate()
{
	var strExpToDate = document.getElementById("txtTo1").value;
	if(strExpToDate != '')
	{
		if (isDate(strExpToDate) == false)
		{
			//alert('Invalid Date');
			document.getElementById('txtTo1').focus();
			return false;
		}
	}
    return true;
}

function fnValidateExpTotalMonth()
{
	var strExpTotalMonth = document.getElementById("txtTMExp1").value;
	if(strExpTotalMonth != '')
	{
		if (!fnIsNumeric(strExpTotalMonth))
		{
			alert('Experience in month can not be non numeric.');
			document.getElementById('txtTMExp1').focus();
			return false;
		}
	}
    return true;
}

function fnValidateExpDesg()
{
	var strExpDesg = fnTrim(document.getElementById('txtDesg1').value);
	if(strExpDesg != '')
	{
		if(fnHasDigits(strExpDesg))
		{
			alert('Designation can not have digits.');
			document.getElementById('txtDesg1').focus();
			return false;	
		}	
	}
	return true;
}

function fnValidateLastSalary()
{
	var strLastSalary = fnTrim(document.getElementById('txtLSALD1').value);
	if(strLastSalary != '')
	{
		if(!fnIsPositiveDecimalValue(strLastSalary))
		{
			alert('Last Salary should be a positive decimal value.');
			document.getElementById('txtLSALD1').focus();
			return false;			
		}
	}
	return true;
}

function fnValidateJobDescription()
{
	var strJobDescription = fnTrim(document.getElementById('txtJDesc1').value);
	if(strJobDescription != '')
	{
		if(fnIsNumeric(strJobDescription))
		{
			alert('Job Description is not valid.');
			document.getElementById('txtJDesc1').focus();
			return false;				
		}
	}
	return true;

//		if(!fnIsPositiveDecimalValue(strJobDescription))
//		{
//			alert('Last Salary should be a positive decimal value.');
//			document.getElementById('txtJDesc1').focus();
//			return false;			
//		}
//	}
	return true;
}

function fnValidateRadioHow()
{
	for(var i = 0; i < document.form1.rdHow.length; i++) 
	{
		if(document.form1.rdHow[i].checked) 
		{
			return true;
		}
	}
	return false;	
}

function fnValidateAnyOther()
{
	var strAnyOther = fnTrim(document.getElementById('txtAnyOther').value);
	if(strAnyOther != '')
	{
		if(fnHasDigits(strAnyOther))
		{
			alert('How you came to know about can not have digits.');
			document.getElementById('txtAnyOther').focus();
			return false;	
		}	
	}
	return true;
}


function fnShowHideAnyOther()
{
	for(var i = 0; i < document.form1.rdHow.length; i++) 
	{
		if(document.form1.rdHow[i].checked) 
		{
			if(document.form1.rdHow[i].value == 'Any other')
			{
				document.getElementById("trAnyOther").style.display = "block";
				return;
			}
		}
	}
	document.getElementById("trAnyOther").style.display = "none";		
}

function ddlgraduationdrop_change()
{
	if(document.getElementById("ddl_Graduation").value=="Final Year" )
		document.getElementById ("tdgfinalyear").style.display="block";          
	else
		document.getElementById ("tdgfinalyear").style.display="none";
	return true;            
}
            
function showExp()
{
	//alert("checked");
	document.getElementById("expid").style.display="block";
	document.getElementById("RdExp2").checked=false;
	return true;
}
function hideexp()
{
	//alert("checked");
	document.getElementById("expid").style.display="none";
	document.getElementById("RdExp1").checked=false;
	return true;
}

function fnValidateRadioHow()
{
	for(var i = 0; i < document.form1.rdHow.length; i++) 
	{
		if(document.form1.rdHow[i].checked) 
		{
			return true;
		}
	}
	return false;	
}

function fnAnyOther()
{
	for(var i = 0; i < document.form1.rdHow.length; i++) 
	{
		if(document.form1.rdHow[i].checked) 
		{
			if(document.form1.rdHow[i].value == 'Any other')
			{
				document.getElementById("trAnyOther").style.display = "block";
				return;
			}
		}
	}
	document.getElementById("trAnyOther").style.display = "none";		
}

function fnSendSms()
{
    document.getElementById("trResendSms").style.display = "none";
    document.getElementById("trConfirmSms").style.display = "none";
    if(document.getElementById("txtCMobile").value != "")
    {
        if(fnValidateMobileNumber())
        {
            xmlHttp=GetXmlHttpObject();
            if (xmlHttp==null)
            {
                alert ("Your browser does not support AJAX!");
                return;
            } 
            else
            {
                var url="ajax/generateSmsCode.asp?mobile=";
                url = url + document.getElementById("txtCMobile").value;
                url = url + "&randCode="
                var randCode = Math.floor(Math.random()*1001);
                randCode = randCode + 'a';
                if(randCode.length == 2)
                    randCode = "000" + randCode;
                else if(randCode.length == 3)
                    randCode = "00" + randCode;
                else if(randCode.length == 4)
                    randCode = "0" + randCode;        
                randCode = randCode.substring(0,4)
                url=url + randCode;
                document.getElementById("hdnRandCode").value = randCode;
                xmlHttp.onreadystatechange=stateChanged;
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
            }
        }    
    }
}

function stateChanged() 
{ 
    if (xmlHttp.readyState==4)
    {
        var strResponse = xmlHttp.responseText;
        strResponse = fnTrim(strResponse);
        if(strResponse == "success")
            document.getElementById("trConfirmSms").style.display = "block";
        else
            document.getElementById("trResendSms").style.display = "block";
    }
}

function fnAjaxValidateSmsCode()
{
	var strSmsCode = fnTrim(document.getElementById('txtSmsCode').value);
	if(strSmsCode != '')
    {
        document.getElementById("trInValidSmsCode").style.display = "none";
        xmlHttp=GetXmlHttpObject();
        if (xmlHttp==null)
        {
            alert ("Your browser does not support AJAX!");            
        } 
        else
        {
            var url="ajax/verifySmsCode.asp?mobile=";
            url = url + fnTrim(document.getElementById("txtCMobile").value);
            url = url + "&randCode="    
            url = url + strSmsCode;
            xmlHttp.onreadystatechange=stateChanged1;
            xmlHttp.open("GET",url,true);
            xmlHttp.send(null);
            
        }
        return false;
    }
    else
    {
        return fnNext();
    }
}

function stateChanged1() 
{ 
    if (xmlHttp.readyState==4)
    {
        var strResponse = xmlHttp.responseText;    
        strResponse = fnTrim(strResponse);
        if(strResponse != "success")
            document.getElementById("trInValidSmsCode").style.display = "block";
        else
            fnNext();    
    }
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
    // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

