
// quich search form validation

function quicksearch(){

	 var gender = document.homesearch.gender.value;
	 var rel = document.homesearch.religion.value;
	 var ageone = document.homesearch.age1.value;
	 var agetwo = document.homesearch.age2.value;
	 
	 if(gender == '0'){
		alert("Please select Search for");
	    document.homesearch.gender.focus();
		return false;
	 }
	 
	 if(ageone == ''){
		alert("Please enter age between to age");
	    document.homesearch.age1.focus();
		return false;
	 }
	 
	  if(agetwo == ''){
		alert("Please enter age between From age");
	    document.homesearch.age2.focus();
		return false;
	 }
	 if(parseInt(agetwo)<parseInt(ageone)){
		alert("From age should be less than to age");
	    document.homesearch.age2.focus();
		return false;
		 
	 }

	 
	 return true;
}


// is passwds equal

function isPasswdEqual (strngA, strngB){
	var error = "";
	if (strngA != strngB){	 error = "Passwords are not same.\n";	 }
return error;
}


// checking name for minimum 3 characters.
function checkName (strng){
	var error = "";
	if (strng.length < 3) { error = "Name should be greater than 3 letters. \n"; }
return error;
}


// email
function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a phone number.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.";
  
    }
    if (!(stripped.length >6)&&(stripped.length< 12)) {
	error = "Check the Phone number.\n";
    } 
return error;
}

// Mobile number - check for 10 digits

function checkMobile (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a mobile number.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The mobile number contains illegal characters.";
  
    }
    if (!(stripped.length == 10)) {
	error = "Check the mobile number.\n";
    } 
return error;
}


// password - between > 6, uppercase, lowercase, and numeral

function checkPassword (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a password.\n";
}

    var illegalChars = /[\W_]/; // allow only letters and numbers
    
    if ((strng.length < 5) ) {
       error = "The password should be more than 5 characters.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    } 
   
     
return error;    
}    


// username - 4-10 chars, uc, lc, and underscore only.

function checkUsername (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a username.\n";
}


    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 10)) {
       error = "The username is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The username contains illegal characters.\n";
    } 
return error;
}       


// non-empty textbox

function isEmpty(strng,error) {

  if (strng.length == 0) {
   return error;	   
  }
  else { return error="";}	
}


function isVisible(strng,error) {

  if (strng.style.display=='') {
   if(strng.value=="")
   {
   return error;	   
  }
  else { return error="";}	
  
  }
  else { return error="";}	
}



// exactly one radio button is chosen

function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
return error;
}

// valid selector from dropdown list

function checkDropdown(choice, error) {

    if (choice == 0 ) {
    return error;
    }    
	else{ return error="";}
} 

function checkCheckList(list,error){	
	if(list.length == 0){
		return error;
	}else{
		return error ="";
	}
}



//---------------------------message list---------------------------//


function confirmSubmit()
{
var agree=confirm("Are you sure want to remove?");
if (agree)
	return true ;
else
	return false ;
}


//----------------------------------------------------------------//

function closeFavrates(imgid)
{
	var pid="bb_"+imgid;
	var sid="cc_"+imgid;

	$('#'+pid).slideUp('slow');
    $('#'+sid).animate({opacity: 0.7});	
}


function checkPasswordFrm(changepasswordform)
{
	  var why = "";

	  why += isEmpty(changepasswordform.oldpssw.value,' Old Password is empty.\n');
	  why += isEmpty(changepasswordform.newpssw.value,' New Password is empty.\n');
	  why += isEmpty(changepasswordform.repssw.value,' Retype Password is empty.\n');
	  why += checkPassword(changepasswordform.oldpssw.value); 
	  why += checkPassword(changepasswordform.newpssw.value);
	  why += checkPassword(changepasswordform.repssw.value);
	  why += isPasswdEqual(changepasswordform.newpssw.value,changepasswordform.repssw.value);

          if (why != "")
	  {
	    alert(why);
	    return false;
	  }
	
	  return true;
}

function checkLoginForm1(loginform)
{
	  var why = "";

	  why += isEmpty(loginform.email.value,' Email is empty.\n');
	  why += isEmpty(loginform.password.value,' Password is empty.\n');

	  why += checkEmail(loginform.email.value);

          if (why != "")
	  {
	    alert(why);
	    return false;
	  }
	
	  return true;
}
/////////////////////////////PROFILE PAGE////////////////////////////////////

function checkPersonalInformation()
{
if(document.formPersonal.weight.value != '' && document.formPersonal.weight.value != 'Not filled'){
	if(!document.formPersonal.weight.value.toString().match(/^[-]?\d*\.?\d*$/)){
		alert( "Weight should be numeric." );
		document.formPersonal.weight.focus();	
		return false;
	}
}
if(document.formPersonal.marital.value=="")
{
alert( "Please provide your marital status." );
document.formPersonal.marital.focus();	
return false;
}
if(document.formPersonal.day.value=="")
{
alert( "Please select day." );
document.formPersonal.day.focus();	
return false;
}
if(document.formPersonal.month.value=="")
{
alert( "Please select month." );
document.formPersonal.month.focus();	
return false;
}
if(document.formPersonal.bodytype.value == "")
{
alert( " Please provide your body type." );
document.formPersonal.bodytype.focus();
return false;
}
if( document.formPersonal.height1.value == "")
{
alert( "Please provide your height(in ft)." );
document.formPersonal.height1.focus();
return false;
}
if( document.formPersonal.height2.value == "")
{
alert( "Please provide your height(in inch). " );
document.formPersonal.height2.focus();
return false;
}
if( document.formPersonal.colour.value == "")
{
alert( "Please provide your complexion(colour). " );
document.formPersonal.colour.focus();
return false;
}
if( document.formPersonal.specialcase.value == "")
{
alert( "Please provide your special case. " );
document.formPersonal.specialcase.focus();
return false;
}
return true;
}


function checkEducationCareer()
{
 if(document.regform.education.value=="")
{
alert( "Please provide your education." );
document.regform.education.focus();	
return false;
}
if(document.regform.educationarea.value=="")
{
alert( " Please provide your education area." );
document.regform.educationarea.focus();	
return false;
}
if(document.regform.occupation.value=="")
{
alert( "Please provide your occupation." );
document.regform.occupation.focus();	
return false;
}
if(document.regform.income.value == "")
{
alert( "Please provide your income." );
document.regform.income.focus();
return false;
}	
return true;
}


function checkFamilyDetails()
{
	 
if(document.regform.familyvalue.value=="")
{
alert( "Please provide your family values." );
document.regform.familyvalue.focus();	
return false;
}
 return true;
}

function checkResidences()
{
	
	if(document.regform.country.value=="")
	{
	alert("Please provide your Location(country)." );
	document.regform.country.focus();	
	return false;
	}
	
	if(document.regform.statesid.value==0 || document.regform.statesid.value=="" )
	{
	alert(" Please provide your state.");
	document.regform.statesid.focus();	
	return false;
	}

  return true;
}


function checkReligious()
{
if(document.regform.religion.value=="")
{
alert( " Please provide your religion." );
document.regform.religion.focus();	
return false;
}
if(document.regform.caste.value=="")
{
alert( " Please provide your community(caste)." );
document.regform.caste.focus();	
return false;
}

if(document.regform.mtongue.value=="")
{
alert( " Please provide your mother tongue." );
document.regform.mtongue.focus();	
return false;
}
 return true;
}


function checkContact()
{
	
	if(document.regform.telphone.value=="" && document.regform.comm_phone.value=="")
	{
	alert("Please provide either Telephone OR Mobile Number" );	
	return false;	
	}	
	if(document.regform.telphone.value!="")
	{
	
		if(document.regform.countrycode.value=="")
		{
		alert(" Please provide country code." );
		document.regform.countrycode.focus();	
		return false;
		}
		
		if(document.regform.areacode.value=="")
		{
		alert( " Please provide area code." );
		document.regform.areacode.focus();	
		return false;
		}
	
	}
	
	if(document.regform.comm_phone.value!="" )
	{
		if(document.regform.countrycode.value=="")
		{
		alert(" Please provide country code." );
		document.regform.countrycode.focus();	
		return false;
		}
	}
	
	
		
	

var emailID=document.regform.comm_email;
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
}


function checkLifestyle()
{
	return true;
}

function echeck(str) {
		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					
	}

function textCounter(field,cntfield,maxlimit)
{
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else

cntfield.value = maxlimit - field.value.length;
}

function checkForgotPasswordForm(forgotpassword)
{
	  var why = "";

	  why += isEmpty(forgotpassword.resetpssw.value,' Email is empty.\n');
	  why += checkEmail(forgotpassword.resetpssw.value);
          why += isEmpty(forgotpassword.password.value,' Password is empty.\n');
          why += isEmpty(forgotpassword.confirm_password.value,' Confirm Password is empty.\n');

          if (why != "")
	  {
	    alert(why);
	    return false;
	  }
	
	  return true;
}

function checkextn(img){
	if(img == 'jpg'){
		return true;
	}else if(img == 'gif'){
		//alert("The file should be image like i.e('jpg','jpeg','png').");
		return true;
	}else if(img == 'png'){
		//alert("The file should be image like i.e('jpg','jpeg','png').");
		return true;
	}else{
		 alert("The file should be image like i.e('jpg','jpeg','png').");
		 return false;
	}
	
}

function submitsucessstroy(){
	  var title = document.sucess_story.title.value;
	  var description = document.sucess_story.description.value;
	  var weddingphoto1 = document.sucess_story.weddingphoto1.value;
	  var weddingphoto2 = document.sucess_story.weddingphoto2.value;
	  var weddingphoto3 = document.sucess_story.weddingphoto3.value;
	  var photarray= new Array();
	  var photarray1= new Array();
	  var photarray2= new Array();
	  
	  
	  
		  if(title == ""){
			alert("PLease Fill Mandatory Fields");
			document.sucess_story.title.focus();
			return false;
		  }
		  
		   if(description == ""){
			alert("PLease Fill Mandatory Fields");
			document.sucess_story.description.focus();
			return false;
		  }
		  
		 if(description.length<100){
			   alert("Description should be 200 character");
			   return false;
		  } 
		 
		 if(weddingphoto1 == ""){
			alert("PLease Fill Mandatory Fields");
			document.sucess_story.weddingphoto1.focus();
			return false;
		  }
		  
		  if(weddingphoto1 != ''){
			  photarray = weddingphoto1.split('.');
			  var imagename = photarray[1];
			  var img = imagename.toLowerCase();
			  checkextn(img);
			  if(checkextn(img) == false){
				  return false;
			  }
		  }
		  
		  if(weddingphoto2 != ''){
			  photarray1 = weddingphoto2.split('.');
			  var imagename1 = photarray1[1];
			  var img1 = imagename.toLowerCase();
			  if(checkextn(img1) == false){
				  return false;
			  }
		 }
		 
		 if(weddingphoto3 != ''){
			  photarray2 = weddingphoto3.split('.');
			  var imagename2 = photarray2[1];
			  var imag2 = imagename2.toLowerCase();
			  if(checkextn(imag2) == false){
				return false;  
			  }
			  
		 }	
		 
		
}

function update() {
   var limit = 200;
   var old = document.sucess_story.counter.value;
   document.sucess_story.counter.value=document.sucess_story.description.value.length;
   if(document.sucess_story.counter.value > limit) {
     if(document.styleSheets) {
       document.sucess_story.counter.style.fontWeight = 'bold';
       document.sucess_story.counter.style.color = '#ff0000'; } }
   else if(document.sucess_story.counter.value <= limit && old > limit
	   && document.styleSheets ) {
       document.sucess_story.counter.style.fontWeight = 'normal';
       document.sucess_story.counter.style.color = '#000000'; } 


   }
	
	


////////////////////////////////////////////////////////////////////////////
