function isBlank(s) {
	for (i=0;i<s.length;i++) {
		if (s.charAt(i) !=" ") {
			return false;
		}
	}
	return true;
}
function validate(f) {
	if (f.filledby.selectedIndex<1) {
		alert("Please select the person who is filling the profile !!");
		f.filledby.focus();
		return false;
	}
	if (isBlank(f.name.value)) {
		alert("Please Enter Name !!");
		f.name.select();
		f.name.focus();
		return false;
	}
  if (isBlank(f.address.value)) {
		alert("Please Enter Address !!");
		f.address.select();
		f.address.focus();
		return false;
	}
	 if (isBlank(f.phone.value)) {
		alert("Please Enter Contact Number !!");
		f.phone.select();
		f.phone.focus();
		return false;
	}
	if (isBlank(f.email1.value)) {
		alert("Please enter Email ID !!");
		f.email1.select();
		f.email1.focus();
		return false;
	}
    if (isBlank(f.email2.value)) {
		alert("Please confirm Email ID !!");
		f.email2.select();
		f.email2.focus();
		return false;
	}
	if (f.email1.value != f.email2.value) {
		alert("Email addresses do not match, please re-enter !!");
		f.email1.select();
		f.email1.focus();
		return false;
	}
var email=f.email1.value;
	if (email.indexOf("@")<1 || email.length<7 || email.indexOf(".") < 1)	{
		alert("Invalid Email address !!");
		f.email1.select();
		f.email2.select();
		f.email1.focus();
		return false;
	}
	if (isBlank(f.pwd1.value)) {
		alert("Please enter Password !!");
		f.pwd1.select();
		f.pwd1.focus();
		return false;
	}
	if (isBlank(f.pwd2.value)) {
		alert("Please confirm Password !!");
		f.pwd2.select();
		f.pwd2.focus();
		return false;
	}
	if (f.pwd1.value != f.pwd2.value){
		alert("Passwords do not match, please  re-enter!!");
		f.pwd1.select();
		f.pwd2.select();
		f.pwd1.focus();
		return false;
	}
if(!f.sex[0].checked && !f.sex[1].checked) {
		alert("Please select your gender!!");
		f.sex[0].focus();
		return false;
	}
	var dd,mm,yy;
	try{
		dd=f.day.options[f.day.selectedIndex].text;
		mm=f.month.value-1;
		yy=f.year.options[f.year.selectedIndex].text;
		d=new Date(yy,mm,dd);
		if(d.getDate() != dd || d.getMonth() != mm || d.getFullYear() != yy ) {
			alert("Date of Birth is invalid !!");
			f.day.focus();
			return false;
		}
		
	}
	catch(e) {
		alert(" Invalid date of birth specified !!");
		return false;
	}
if(!f.m_status[0].checked && !f.m_status[1].checked && !f.m_status[2].checked && !f.m_status[3].checked  && !f.m_status[4].checked) {
		alert("Please select your Marital Status!!");
		f.m_status[0].focus();
		return false;
	}
if(!f.child[0].checked && !f.child[1].checked && !f.child[2].checked ) {
		alert("Please select Have children!!");
		f.child[0].focus();
		return false;
	}
if (f.education.selectedIndex<1) {
		alert("Please select Education !!");
		f.education.focus();
		return false;
	}
if (f.in_edu.selectedIndex<1) {
		alert("Please select Education in Details!!");
		f.in_edu.focus();
		return false;
	}
if (f.occupation.selectedIndex<1) {
		alert("Please select Occupation!!");
		f.occupation.focus();
		return false;
	}
if (f.income.selectedIndex<1) {
		alert("Please select Income!!");
		f.income.focus();
		return false;
	}
	var country=f.country.options[f.country.selectedIndex].text;
	var state=f.state.options[f.state.selectedIndex].text;
if (f.country.selectedIndex<1) {
		alert("Please choose a country from the list!!");
		f.country.focus();
		f.stateother.disabled=true;
		return false;
	}
 else if(f.country.selectedIndex==1) {
		    	 obj=f.state;
			     objs=f.city;
			     if (obj.selectedIndex<1) {
				     alert("Please selecte an " + country + " state !!");
				     obj.focus();
				     return false;
			     }
			     else if (f.country.selectedIndex ==1 && objs.selectedIndex<1) {
				alert("Please selecte an City of Indian state !!");
				objs.focus();
				return false;
			    }
 }
 else if(f.country.selectedIndex==2){
		    	 obj=f.state;
			     if (obj.selectedIndex<1) {
				     alert("Please selecte an " + country + " state !!");
				     obj.focus();
				     return false;
			     }
			     
 }
 
if(!f.rstatus[0].checked && !f.rstatus[1].checked && !f.rstatus[2].checked && !f.rstatus[3].checked && !f.rstatus[4].checked) {
		alert("Please select Resident status!!");
		f.rstatus[0].focus();
		return false;
	}
	
return true;
}

function selectstate() {
	var f=document.form1;
	var country=f.country.options[f.country.selectedIndex].text;
	if (country=="1") {
		f.statesusa.disabled=true;
		f.stateother.disabled=true;
	}
	else if (country=="2") {
		f.city.disabled=true;
		f.statesusa.disabled=false;
		f.stateother.disabled=true;
	}
	else {
		f.statesindia.disabled=true;
		f.statesusa.disabled=true;
		f.stateother.disabled=false;
	}

}
