/* Checking of 
BLANK FIELD-----LENGTH CHECKING----PASSWORD & CONFIRM PASSWORD CHECKING-----EMAIL-----DROP-DOWN-VALUE CHECKING(BLANK/NOT BLANK)

PASS THESE VALUES ---------------- (ID,minlength, LABEL VALUE)
 */




/*--Checks the field value blank or not-*/			
function check_blank(field_name,label){
	if(document.getElementById(field_name).value==""){
	alert(label+" is mandatory");
	document.getElementById(field_name).focus();
	return false
	}
	else
	return true
}
/*--Checks the field length is more than  minlength-*/	
function length_checking(field_name,minlength,label){
if(check_blank(field_name,label)){
		var value = document.getElementById(field_name).value;
		if(value.length < minlength){
			alert(label+' must be more than '+minlength+" character");
			return false
		}
		return false
	}
	else
	return true
}	
		
function validate_name(field_name,msg_display_position,minlength,label){

	var msg="";
	var value = document.getElementById(field_name).value;
	var length = value.length;
	if(length<minlength || value==""){
		alert(label+" is mandatory & "+"Minimum character length is "+minlength);
		return false
	}
	else
	return true

}

		
function pass_confirm_pass_checking(password,cpassword,minlength){
var pass = document.getElementById(password).value;
var cpass = document.getElementById(cpassword).value;
		if(pass=="" || cpass=="")
		{
			alert("Password & Confirm-password is mandatory");
			return false
		}
		if(pass.length<minlength || cpass.length<minlength){
			alert("Password Confirm-password length must be more than "+minlength);
			return false
		}
		if(pass!=cpass){
			alert("Password Confirm-password does not match");
			return false
		}
		else
		return true
	
	
}		
		
function validate_birth_day(day,month,year){
/*if(day!=""){*/
	if(document.getElementById(day).value==""){
		alert("Date is not selected for Date of Birth");
		/*document.getElementById('submit-btn').hide();*/
		return false
	}
	if(document.getElementById(month).value==""){
		alert("Month is not selected for Date of Birth");
		return false
	}
	if(document.getElementById(year).value==""){
		alert("Year is not selected for Date of Birth");
		return false
	}
	else 
	return true
	/*}
	else
	return false*/
}

function drop_down_checking(name,label){
	if(document.getElementById(name).value=="")
	{
		alert(label+" not selected");
		return false
	}
	else 
	return true
}

function echeck(email) {
 		if(check_blank(email,'EMAIL ')){
			var str = document.getElementById(email).value;
			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			if (str.indexOf(at)==-1){
			   alert("Invalid E-mail ID")
			   return false
			}
	
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   alert("Invalid E-mail ID")
			   return false
			}
	
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
				alert("Invalid E-mail ID")
				return false
			}
	
			 if (str.indexOf(at,(lat+1))!=-1){
				alert("Invalid E-mail ID")
				return false
			 }
	
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
				alert("Invalid E-mail ID")
				return false
			 }
	
			 if (str.indexOf(dot,(lat+2))==-1){
				alert("Invalid E-mail ID")
				return false
			 }
			
			 if (str.indexOf(" ")!=-1){
				alert("Invalid E-mail ID")
				return false
			 }
	
			 return true
		 }	
		 else 
		 return false				
	}

function all_check(){
//if( !echeck('email')  || !validate_name('user-name','err_msg',6,'Name') || !validate_birth_day('day','mon','yr') || !length_checking('password1',6,'Password') || !pass_confirm_pass_checking('password1','confirm_password') || !drop_down_checking('community','Religion') || !drop_down_checking('mother_tongue','Mother Tounge') || !drop_down_checking('countryofresidence','Country') || !drop_down_checking('postedBy','Profile Created for')){

//!validate_name('user-name','err_msg',6,'Name') || !echeck('email')  ||  !validate_birth_day('day','mon','yr') || !pass_confirm_pass_checking('password1','confirm_password',6) || !drop_down_checking('postedBy','Profile Created for') || !drop_down_checking('community','Religion') || !drop_down_checking('countryofresidence','Country') || !drop_down_checking('mother_tongue','Mother Tounge')
if(!validate_name('first_name','err_msg',6,'First Name')  || !validate_name('last_name','err_msg',6,'Last Name') || !validate_birth_day('day','month','year') || !echeck('email')  ||   !pass_confirm_pass_checking('password1','confirm_password',6) || !drop_down_checking('community','Religion') || !drop_down_checking('mother_tongue','Mother Tounge') ||  !drop_down_checking('countryofresidence','Country') ||  !drop_down_checking('postedBy','Profile Created for')    ){
return false;
}
else
{
document.frm_registration.submit();
return true;
}
}
