// JavaScript Document
// modified on 29.12.2005 Auto complete age while selecting the DOB combo box
// modified on 15.01.2006 to validate the fields

var DOBYear, textAge, cDate;
var testresults;
function autoAge(){
	cDate = new Date();
	DOBYear = document.getElementById ("DOBYear");
	textAge = document.getElementById ("textAge");
	var comboVal = DOBYear.options[DOBYear.selectedIndex].value;
	var cYear = cDate.getFullYear();
	textAge.value = ( cYear - comboVal);
}
// email validation 
function checkemail(){
var textEmail = document.getElementById ('textEmail');
var textEmailValue = document.getElementById ('textEmail').value;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(textEmailValue))
		testresults=true;
	else{
		alert("Please input a valid email address!");
		textEmail.focus();
		testresults=false;
	}
}
//validating page 1
function sumbitPage1(){
	var textName = document.getElementById ('textName');
	var textCitizen = document.getElementById ('textCitizen');
	var comboGender = document.getElementById ('comboGender');
	var comboDobDay = document.getElementById ('comboDobDay');
	var comboDobMonth = document.getElementById ('comboDobMonth');
	var DOBYear = document.getElementById ('DOBYear');
	var textAge = document.getElementById ('textAge');
	var comboReligion = document.getElementById ('comboReligion');
	var textCaste = document.getElementById ('textCaste');
	var comboHeight = document.getElementById ('comboHeight');
	var comboWeight = document.getElementById ('comboWeight');
	var comboEducation = document.getElementById ('comboEducation');
	var textCourse = document.getElementById ('textCourse');
	var textEmail = document.getElementById ('textEmail');

if(textName.value == ""){
	alert ("Please enter Name");
	textName.focus();
}else if(textCitizen.options[textCitizen.selectedIndex].value == 0){
	alert ("Please select 'Country living in'");
	textCitizen.focus();
}else if (comboGender.options[comboGender.selectedIndex].value == 0){
	alert ("Please select 'Gender'");
	comboGender.focus();
}else if (comboDobDay.options[comboDobDay.selectedIndex].value == 0){
	alert ("Please select 'Date of birth'");
	comboDobDay.focus();
}else if (comboDobMonth.options[comboDobMonth.selectedIndex].value == 0){
	alert ("Please select 'Date of birth'");
	comboDobMonth.focus();
}else if (DOBYear.options[DOBYear.selectedIndex].value == 0){
	alert ("Please select 'Date of birth'");
	DOBYear.focus();
}else if (textAge.value == ""){
	alert ("Please enter Age");
	textAge.focus();
}/*else if (textAge.value){//else if (isNaN(parseFloat(textAge.vlaue))){
	alert (document.getElementById ('textAge').vlaue);
	var AgeVal = parseFloat(textAge.vlaue);
	alert (AgeVal);
	alert ("Please enter a valid Age");
	textAge.focus();
}*/else if (comboReligion.options[comboReligion.selectedIndex].value == 0){
	alert ("Please select 'Religion'");
	comboReligion.focus();
}else if (textCaste.options[textCaste.selectedIndex].value == 0){
	alert ("Please select 'Caste'");
	textCaste.focus();
}else if (comboHeight.options[comboHeight.selectedIndex].value == 0){
	alert ("Please select 'Height'");
	comboHeight.focus();
}else if (comboWeight.options[comboWeight.selectedIndex].value == 0){
	alert ("Please select 'Weight'");
	comboWeight.focus();
}else if (comboEducation.options[comboEducation.selectedIndex].value == 0){
	alert ("Please select 'Qualification'");
	comboEducation.focus();
}else if (textCourse.value == ""){
	alert ("Please enter Course name(s)");
	textCourse.focus();
}else if (textEmail.value == ""){
	alert ("Please input a valid email address");
	textEmail.focus();
}else{
	document.forms[0].submit();
	}
}

//validating page 2
function sumbitPage2(){
	var textHomeName2 = document.getElementById ('textHomeName2');
	var textStreet2 = document.getElementById ('textStreet2');
	var textCity2 = document.getElementById ('textCity2');
	var textLandmark2 = document.getElementById ('textLandmark2');
	var comboDistrict1 = document.getElementById ('comboDistrict1');
	var textPincode2 = document.getElementById ('textPincode2');
	var textPhoneOff2 = document.getElementById ('textPhoneOff2');
	var textFatherName = document.getElementById ('textFatherName');

if(textHomeName2.value == ""){
	alert ("Please enter House Name");
	textHomeName2.focus();
}else if(textStreet2.value == ""){
	alert ("Please enter Street Name");
	textStreet2.focus();
}else if(textCity2.value == ""){
	alert ("Please enter City");
	textCity2.focus();
}else if(textLandmark2.value == ""){
	alert ("Please enter Landmark");
	textLandmark2.focus();
}else if (comboDistrict1.options[comboDistrict1.selectedIndex].value == 0){
	alert ("Please select 'District'");
	comboDistrict1.focus();
}else if(textPincode2.value == ""){
	alert ("Please enter Picode");
	textPincode2.focus();
}else if(textPhoneOff2.value == ""){
	alert ("Please enter Phone");
	textPhoneOff2.focus();
}else if(textFatherName.value == ""){
	alert ("Please enter Father's Name & Occupation");
	textFatherName.focus();
}else{
	document.forms[0].submit();
	}
}