// JavaScript Document

var object;
var count;
var val;


function isEmail(emailIn){
	var isEmailOk = false;
	var filter =/^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9-]+(\.[a-zA-Z][a-zA-Z-]+)+$/
	//var filter = /^[a-zA-Z0-9][a-zA-Z0-9._-]*\@sfu\.ca+$/
	if(emailIn.search(filter) != -1)
		isEmailOk = true;
	if(emailIn.indexOf("..") != -1)
		isEmailOk = false;
	if(emailIn.indexOf(".@") != -1)
		isEmailOk = false;

	return isEmailOk;
}
  	 
function trim(instr)
{
	var reFirst = /\S/;		// regular expression for first non-white char
	var reLast = /\s+$/;	// regular expression for first white char after last non-white char
	var firstChar = instr.search(reFirst);
	var lastChar = instr.search(reLast);
	
	if( lastChar == -1 ) 
		lastChar = instr.length;    	
	outstr = instr.substring( firstChar, lastChar );
	return outstr;
}
 	
	   
	   
   
  
function checkIt(evt) {
	evt = (evt) ? evt : window.event;
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	if (charCode > 31 && (charCode < 48 || charCode > 57)) 
	{
		status = "This field accepts numbers only."
		return false
	}
	status = ""
	return true
}



function show_other_option(val,object){
	if(val=='Other'||val=='other'){
		document.getElementById(object).style.display='block';
	}else{
		document.getElementById(object).style.display='none';
	}
}



function check_value(object,count,val){
if(object.value==''||object.value==null){
count++;
object.style.border='1px solid #A81731';
document.getElementById(val).style.display='block';
}else{
document.getElementById(val).style.display='none';	
object.style.border='1px solid #08a9ef';
}
return count;
}


function check_select_value(object,object1,count,val){
if(object.options[object.selectedIndex].value==''||object.options[object.selectedIndex].value==null){
count++;
object.style.border='1px solid #A81731';
document.getElementById(val).style.display='block';
}else{
	document.getElementById(val).style.display='none';	
	object.style.border='1px solid #08a9ef';
	if(object.options[object.selectedIndex].value=='Other'){
	val='other_'+val;
	count=check_value(object1,count,val);
	
	}else{
	document.getElementById(val).style.display='none';	
	object.style.border='1px solid #08a9ef';
	}
}
return count;
}


function check_other(object,object1,count,val){
	if(object.options[object.selectedIndex].value=='Other'){
	val='other_'+val;
	count=check_value(object1,count,val);
	}
return count;	
}







function check_select_pair_value(object1,object2,count,val){
var newcount=count;	
if(object1.options[object1.selectedIndex].value==''||object1.options[object1.selectedIndex].value==null){
count++;
object1.style.border='1px solid #A81731';

}else{
	
	object1.style.border='1px solid #08a9ef';
	
}

if(object2.options[object2.selectedIndex].value==''||object2.options[object2.selectedIndex].value==null){
count++;
object2.style.border='1px solid #A81731';

}else{
	
	object2.style.border='1px solid #08a9ef';
	
}

if(newcount==count){
	document.getElementById(val).style.display='none';	
}else{
	document.getElementById(val).style.display='block';
}

return count;
}



function check_checked_value(object,count,val){
if(object.checked==false){
count++;
object.style.border='1px solid #A81731';
document.getElementById(val).style.display='block';
}else{
document.getElementById(val).style.display='none';	
object.style.border='1px solid #08a9ef';
}
return count;
}








var object1;
var object2;
var message1;
var message2;

function MustBeSame(object1,object2,count,val,message1,message2){
if((object1.value!=object2.value)&&(object1.value!="")){
count++;
object2.style.border='1px solid #A81731';
document.getElementById(val).style.display='block';
document.getElementById(val).innerHTML=message1;

}else{
document.getElementById(val).innerHTML=message2;	
document.getElementById(val).style.display='none';	
object2.style.border='1px solid #08a9ef';

}
return count;
}

function MustBeGreater(object1,object2,count,val){
if(object1.value>object2.value){
count++;
object2.style.border='1px solid #A81731';
document.getElementById(val).style.display='block';
}else{
document.getElementById(val).style.display='none';	
object2.style.border='1px solid #08a9ef';
}
return count;
}




function MustBeGreater_select(object1,object2,count,val,message1,message2){
	var age1=object1.options[object1.selectedIndex];
	var age2=object2.options[object2.selectedIndex];
	
	
if(age1.value!=""&&age2.value!=""){
if(parseInt(age1.value)<=parseInt(age2.value)){
document.getElementById(val).innerHTML=message2;
object2.style.border='1px solid #08a9ef';
document.getElementById(val).style.display='none';	

}else{
count++;
document.getElementById(val).style.display='block';
object2.style.border='1px solid #A81731';
document.getElementById(val).innerHTML=message1;
}
}

return count;
}






function enquiry_validation(){
	var flage=0;
	var obj=document.enquiry;
	flage=check_value(obj.name,flage,'message_name');
	flage=check_value(obj.city,flage,'message_city');
	flage=check_value(obj.country,flage,'message_country');
	flage=check_value(obj.phone,flage,'message_phone');
	flage=check_value(obj.email,flage,'message_email');
	
	
	if(obj.email.value!=""){
		if(!isEmail(trim(obj.email.value))){
		document.getElementById("email_enquiry").innerHTML='E-mail should be like a@b.c';
		obj.email.style.border='1px solid #A81731';
		obj.email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("email_enquiry").innerHTML='';
		obj.email.style.border='1px solid #08a9ef';
		obj.email.style.color='#000000';
		}
	
	}
	
	flage=check_value(obj.comment,flage,'message_comment');
	
	if(flage==0){
		return true;
	}else{
		return false;
	}
}








function candidate_login_validation(){
	var flage=0;
	var obj=document.login;
	flage=check_value(obj.candidate_username,flage,'message_username');
	flage=check_value(obj.candidate_password,flage,'message_password');
	
	/*if(obj.candidate_email.value!=""){
		if(!isEmail(trim(obj.candidate_email.value))){
		document.getElementById("email_check_login").innerHTML='E-mail should be like a@b.c';
		obj.candidate_email.style.border='1px solid #A81731';
		obj.candidate_email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("email_check_login").innerHTML='';
		obj.candidate_email.style.border='1px solid #08a9ef';
		obj.candidate_email.style.color='#000000';
		}
	
	}*/
	if(flage==0){
		return true;
	}else{
		return false;
	}
}



function candidate_forget_password_validation(){
	var flage=0;
	var obj=document.forget_password;
	flage=check_value(obj.candidate_email,flage,'message_email');
	
	if(obj.candidate_email.value!=""){
		if(!isEmail(trim(obj.candidate_email.value))){
		document.getElementById("email_check_login").innerHTML='E-mail should be like a@b.c';
		obj.candidate_email.style.border='1px solid #A81731';
		obj.candidate_email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("email_check_login").innerHTML='';
		obj.candidate_email.style.border='1px solid #08a9ef';
		obj.candidate_email.style.color='#000000';
		}
	
	}
	if(flage==0){
		return true;
	}else{
		return false;
	}
}


function candidate_signup_validation(){
	var flage=0;
	var obj=document.signup;
	flage=check_value(obj.candidate_email,flage,'message_email');
	if(obj.candidate_email.value!=""){
		if(!isEmail(trim(obj.candidate_email.value))){
		document.getElementById("message_email").style.display='block';	
		document.getElementById("message_email").innerHTML='E-mail should be like a@b.c';
		obj.candidate_email.style.border='1px solid #A81731';
		obj.candidate_email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("message_email").style.display='none';	
		document.getElementById("message_email").innerHTML='Please Specify Your Email Id. ';
		obj.candidate_email.style.border='1px solid #08a9ef';
		obj.candidate_email.style.color='#000000';
		}
	
	}
	flage=check_value(obj.candidate_username,flage,'message_username');
	flage=check_value(obj.candidate_password,flage,'message_password');
	flage=check_value(obj.candidate_confirm_password,flage,'message_confirm_password');
	if(obj.candidate_confirm_password.value!=""){
	flage=MustBeSame(obj.candidate_password,obj.candidate_confirm_password,flage,'message_confirm_password','Please confirm your password same as password.','Please Confirm Your Password.');	
	}
	
	flage=check_value(obj.candidate_name,flage,'message_name');
	flage=check_value(obj.candidate_prefered_location,flage,'message_prefered_location');
	flage=check_select_value(obj.candidate_country,obj.other_candidate_country,flage,'message_country')
	flage=check_select_value(obj.candidate_location,obj.other_candidate_location,flage,'message_location')
	flage=check_value(obj.candidate_contact_number,flage,'message_contact_number');
	
	flage=check_select_value(obj.candidate_industry,obj.other_candidate_industry,flage,'message_industry');
	flage=check_select_pair_value(obj.candidate_expyear,obj.candidate_expmonth,flage,'message_exp');
	
	flage=check_select_pair_value(obj.candidate_cas_lakhs,obj.candidate_cas_thousands,flage,'message_cas');
	
	flage=check_value(obj.candidate_keyskills,flage,'message_keyskills');
	flage=check_value(obj.candidate_resume_headline,flage,'message_resume_headline');
	
	flage=check_select_value(obj.candidate_functional_area,obj.other_candidate_functional_area,flage,'message_functional_area');
	
		
		
	flage=check_select_value(obj.candidate_graduation,obj.other_candidate_graduation,flage,'message_graduation');
	
	flage=check_select_value(obj.candidate_post_graduation,obj.other_candidate_post_graduation,flage,'message_post_graduation');
	
	flage=check_select_value(obj.candidate_diploma,obj.other_candidate_diploma,flage,'message_diploma');
	
	flage=check_select_value(obj.candidate_phd,obj.other_candidate_phd,flage,'message_phd');
	
	
	
	
	
	
	if(flage==0){
		return true;
	}else{
		return false;
	}
}




function post_resume_validation(){
	var flage=0;
	var obj=document.post_resume;
	flage=check_value(obj.candidate_resume_headline,flage,'message_resume_headline');
	if(flage==0){
		return true;
	}else{
		return false;
	}
}


function change_password_validation(){
	var flage=0;
	var obj=document.change_password;
	flage=check_value(obj.current_password,flage,'message_current_password');
	flage=check_value(obj.password,flage,'message_password');
	flage=check_value(obj.confirm_password,flage,'message_confirm_password');
	if(obj.confirm_password.value!=""){
	flage=MustBeSame(obj.password,obj.confirm_password,flage,'message_confirm_password','Please confirm your password same as password.','Please Confirm Your Password.');	
	}
	if(flage==0){
		return true;
	}else{
		return false;
	}
}





function consultant_login_validation(){
	var flage=0;
	var obj=document.login;
	flage=check_value(obj.consultant_username,flage,'message_username');
	flage=check_value(obj.consultant_password,flage,'message_password');
	
	/*if(obj.consultant_email.value!=""){
		if(!isEmail(trim(obj.consultant_email.value))){
		document.getElementById("email_check_login").innerHTML='E-mail should be like a@b.c';
		obj.consultant_email.style.border='1px solid #A81731';
		obj.consultant_email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("email_check_login").innerHTML='';
		obj.consultant_email.style.border='1px solid #08a9ef';
		obj.consultant_email.style.color='#000000';
		}
	
	}*/
	if(flage==0){
		return true;
	}else{
		return false;
	}
}


function consultant_forget_password_validation(){
	var flage=0;
	var obj=document.forget_password;
	flage=check_value(obj.consultant_email,flage,'message_email');
	
	if(obj.consultant_email.value!=""){
		if(!isEmail(trim(obj.consultant_email.value))){
		document.getElementById("email_check_login").innerHTML='E-mail should be like a@b.c';
		obj.consultant_email.style.border='1px solid #A81731';
		obj.consultant_email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("email_check_login").innerHTML='';
		obj.consultant_email.style.border='1px solid #08a9ef';
		obj.consultant_email.style.color='#000000';
		}
	
	}
	if(flage==0){
		return true;
	}else{
		return false;
	}
}

function consultant_signup_validation(){
	var flage=0;
	var obj=document.signup;
	flage=check_value(obj.consultant_email,flage,'message_email');
	
	if(obj.consultant_email.value!=""){
		if(!isEmail(trim(obj.consultant_email.value))){
		document.getElementById("message_email").style.display='block';	
		document.getElementById("message_email").innerHTML='E-mail should be like a@b.c';
		obj.consultant_email.style.border='1px solid #A81731';
		obj.consultant_email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("message_email").style.display='none';	
		document.getElementById("message_email").innerHTML='Please Specify Your Email Id. ';
		obj.consultant_email.style.border='1px solid #08a9ef';
		obj.consultant_email.style.color='#000000';
		}
	
	}
	flage=check_value(obj.consultant_username,flage,'message_username');
	flage=check_value(obj.consultant_password,flage,'message_password');
	flage=check_value(obj.consultant_confirm_password,flage,'message_confirm_password');
	if(obj.consultant_confirm_password.value!=""){
	flage=MustBeSame(obj.consultant_password,obj.consultant_confirm_password,flage,'message_confirm_password','Please confirm your password same as password.','Please Confirm Your Password.');	
	}
	
	flage=check_value(obj.consultant_company_name,flage,'message_company_name');
	flage=check_value(obj.consultant_contact_person_name,flage,'message_contact_person_name');
	
	if(document.getElementById("consultant_company_type1").checked==false&&document.getElementById("consultant_company_type2").checked==false){
		flage++;
	document.getElementById("message_company_type").style.display='block';		
	}else{
		document.getElementById("message_company_type").style.display='none';	
	}
	
	flage=check_select_value(obj.consultant_industry,obj.other_consultant_industry,flage,'message_industry');
	flage=check_value(obj.consultant_address1,flage,'message_address1');
	flage=check_select_value(obj.consultant_country,obj.other_consultant_country,flage,'message_country')
	flage=check_select_value(obj.consultant_location,obj.other_consultant_location,flage,'message_location')
	flage=check_value(obj.consultant_contact_number,flage,'message_contact_number');
	
	
	if(flage==0){
		return true;
	}else{
		return false;
	}
}







function associate_login_validation(){
	var flage=0;
	var obj=document.login;
	flage=check_value(obj.associate_username,flage,'message_username');
	flage=check_value(obj.associate_password,flage,'message_password');
	
	/*if(obj.associate_email.value!=""){
		if(!isEmail(trim(obj.associate_email.value))){
		document.getElementById("email_check_login").innerHTML='E-mail should be like a@b.c';
		obj.associate_email.style.border='1px solid #A81731';
		obj.associate_email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("email_check_login").innerHTML='';
		obj.associate_email.style.border='1px solid #08a9ef';
		obj.associate_email.style.color='#000000';
		}
	
	}*/
	if(flage==0){
		return true;
	}else{
		return false;
	}
}


function associate_forget_password_validation(){
	var flage=0;
	var obj=document.forget_password;
	flage=check_value(obj.associate_email,flage,'message_email');
	
	if(obj.associate_email.value!=""){
		if(!isEmail(trim(obj.associate_email.value))){
		document.getElementById("email_check_login").innerHTML='E-mail should be like a@b.c';
		obj.associate_email.style.border='1px solid #A81731';
		obj.associate_email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("email_check_login").innerHTML='';
		obj.associate_email.style.border='1px solid #08a9ef';
		obj.associate_email.style.color='#000000';
		}
	
	}
	if(flage==0){
		return true;
	}else{
		return false;
	}
}

function associate_signup_validation(){
	var flage=0;
	var obj=document.signup;
	flage=check_value(obj.associate_email,flage,'message_email');
	
	if(obj.associate_email.value!=""){
		if(!isEmail(trim(obj.associate_email.value))){
		document.getElementById("message_email").style.display='block';	
		document.getElementById("message_email").innerHTML='E-mail should be like a@b.c';
		obj.associate_email.style.border='1px solid #A81731';
		obj.associate_email.style.color='#A81731';
		flage++;
		}else{
		document.getElementById("message_email").style.display='none';	
		document.getElementById("message_email").innerHTML='Please Specify Your Email Id. ';
		obj.associate_email.style.border='1px solid #08a9ef';
		obj.associate_email.style.color='#000000';
		}
	
	}
	flage=check_value(obj.associate_username,flage,'message_username');
	flage=check_value(obj.associate_password,flage,'message_password');
	flage=check_value(obj.associate_confirm_password,flage,'message_confirm_password');
	if(obj.associate_confirm_password.value!=""){
	flage=MustBeSame(obj.associate_password,obj.associate_confirm_password,flage,'message_confirm_password','Please confirm your password same as password.','Please Confirm Your Password.');	
	}
	
	flage=check_value(obj.associate_company_name,flage,'message_company_name');
	flage=check_value(obj.associate_contact_person_name,flage,'message_contact_person_name');
	
	
	
	flage=check_select_value(obj.associate_industry,obj.other_associate_industry,flage,'message_industry');
	flage=check_value(obj.associate_address1,flage,'message_address1');
	flage=check_select_value(obj.associate_country,obj.other_associate_country,flage,'message_country')
	flage=check_select_value(obj.associate_location,obj.other_associate_location,flage,'message_location')
	flage=check_value(obj.associate_contact_number,flage,'message_contact_number');
	
	
	if(flage==0){
		return true;
	}else{
		return false;
	}
}






function post_new_job_validation(){
	var flage=0;
	var obj=document.post_new_job;
		
	
	flage=check_value(obj.job_title,flage,'message_job_title');
	
	
	//flage=check_value(obj.job_description,flage,'message_job_description');
	
	
	flage=check_select_pair_value(obj.job_min_experience,obj.job_max_experience,flage,'message_job_min_experience');
	
	
	flage=MustBeGreater_select(obj.job_min_experience,obj.job_max_experience,flage,'message_job_min_experience','Second Value must be greater','Please Select Work Experience.');
	
	
	
	flage=check_select_value(obj.functional_area,obj.other_functional_area,flage,'message_functional_area');
	
	
	flage=check_select_value(obj.industry,obj.other_industry,flage,'message_industry');
	
	
	flage=check_value(obj.keywords,flage,'message_keywords');
	
	
	
	flage=check_select_value(obj.job_national_location,obj.other_job_national_location,flage,'message_job_national_location');
    
	
    flage=check_select_pair_value(obj.annual_min_salary,obj.annual_max_salary,flage,'message_currency');
	
	flage=MustBeGreater_select(obj.annual_min_salary,obj.annual_max_salary,flage,'message_currency','Second Value must be greater','Please Specify Your Annual Salary.');
	
	
	//flage=check_value(obj.desired_candidate_profile,flage,'message_desired_candidate_profile');
	
	
	flage=check_select_value(obj.diploma,obj.other_diploma,flage,'message_diploma');
	
	flage=check_select_value(obj.basic_qualification,obj.other_basic_qualification,flage,'message_basic_qualification');
	
	
	flage=check_select_value(obj.advance_qualification,obj.other_advance_qualification,flage,'message_advance_qualification');
	
	
	flage=check_value(obj.emp_company_name,flage,'message_emp_company_name');
	
	
	//flage=check_value(obj.emp_company_about,flage,'message_emp_company_about');
	
	
	flage=check_value(obj.recruiter_contact_person,flage,'message_recruiter_contact_person');
	
	
	flage=check_value(obj.recruiter_contact_address,flage,'message_recruiter_contact_address');	
	
	
	if(flage==0){
	   return true;
	}else{
		 return false;
	}
}





var on;
var off;
function toggle(on, off){
document.getElementById(on).style.display='block';
document.getElementById(off).style.display='none';
}

function change_box(on,off){
document.getElementById(on).style.display='block';
document.getElementById(off).style.display='none';
}


function advance_search_validation(){
	var flage=0;
	var obj=document.advance_search;
	flage=check_other(obj.location,obj.other_location,flage,'message_location');
	flage=check_other(obj.country,obj.other_country,flage,'message_country');
	flage=check_other(obj.industry,obj.other_industry,flage,'message_industry');
	flage=check_other(obj.functional_area,obj.other_functional_area,flage,'message_functional_area');
	flage=check_other(obj.graduation,obj.other_graduation,flage,'message_graduation');
    flage=check_other(obj.post_graduation,obj.other_post_graduation,flage,'message_post_graduation');
	flage=check_other(obj.phd,obj.other_phd,flage,'message_phd');
	if(flage==0){
		return true;
	}else{
		return false;
	}
}






function select_read(form){
	var selet=null;
	for (i = 0; i < form.elements.length; i++)
	 {
		var element = form.elements[i];
		if(element.type == 'checkbox'&&element.id == 'read')
		{									
			element.checked=true;						
		}else{
		element.checked=false;
		}
	}
	}
	
function select_unread(form){
	var selet=null;
	for (i = 0; i < form.elements.length; i++)
	 {
		var element = form.elements[i];
		if(element.type == 'checkbox'&&element.id == 'unread')
		{									
			element.checked=true;						
		}else{
		element.checked=false;
		}
	}
	}	
	




function select_checked(form){
	var selet=null;
	for (i = 0; i < form.elements.length; i++)
	 {
		var element = form.elements[i];
		if(element.type == 'checkbox')
		{									
			element.checked=true;						
		}
	}
	}
	
	function select_unchecked(form)	{
	var selet=null;
	for (i = 0; i < form.elements.length; i++)
	 {
		var element = form.elements[i];
		if (element.type == 'checkbox')
		{											
				element.checked=false;
		}
	}
	}
















































function checkvalue(object,count,val){
if(object.value==''||object.value==null||object.value==val){
count++;
object.style.color='#ab0009';
}else{
object.style.color='#000000';
}
return count;
}





function MustNotBeSame(object1,object2,count,val){
if(object1.value==object2.value){
count++;

object2.style.color='#FF0000';
}else{

object2.style.color='#000000';
}
return count;
}


















function checkvalue(object,count,val){
if(object.value==''||object.value==null||object.value==val){
count++;
object.style.color='#ab0009';
}else{
object.style.color='#000000';
}
return count;
}












function registration_form_validation(){
	var flage=0;
	var obj=document.registration;
	flage=check_value(obj.first_name,flage);
	flage=check_value(obj.last_name,flage);
	flage=check_value(obj.username,flage);
	flage=check_value(obj.password,flage);
	flage=check_value(obj.confirm_password,flage);
	flage=check_value(obj.email,flage);
	flage=check_value(obj.confirm_email,flage);
	/*flage=check_value(obj.gender,flage);*/
	/*flage=check_value(obj.birthdate,flage);*/
	flage=check_select_value(obj.month,flage,'MM');
	flage=check_select_value(obj.day,flage,'DD');
	flage=check_select_value(obj.year,flage,'YYYY');
/*	flage=check_value(obj.ethinicity,flage);*/
	flage=check_value(obj.captcha,flage);
	flage=MustBeSame(obj.password,obj.confirm_password,flage,'id');
	flage=MustBeSame(obj.email,obj.confirm_email,flage,'id');
	flage=MustBeSame(obj.captcha_answer,obj.captcha,flage,'id');
	
	if(obj.email.value!=""){
		if(!isEmail(trim(obj.email.value))){
		//document.getElementById("email_check_registration").innerHTML='E-mail should be like something@gmail.com';
		document.getElementById("email_check_registration").innerHTML='E-mail should be like a@b.c';
		obj.email.style.color='#FF0000';
		flage++;
		}
		else{
		document.getElementById("email_check_registration").innerHTML='';
		obj.email.style.color='#000000';
		}
	
	}
	
	if(flage==0){
		return true;
	}else{
		return false;
	}
}



function account_form_validation(){
	var flage=0;
	var obj=document.account_form_setting;
	flage=check_value(obj.first_name,flage);
	flage=check_value(obj.last_name,flage);
	/*flage=check_value(obj.email,flage);*/
	flage=check_select_value(obj.month,flage,'MM');
	flage=check_select_value(obj.day,flage,'DD');
	flage=check_select_value(obj.year,flage,'YYYY');
	
	
	
	
	
	
	if(obj.sec_email.value!=""){
		//flage=MustBeSame(obj.email,obj.confirm_email,flage,'id');
		
		if(!isEmail(trim(obj.sec_email.value))){
		//document.getElementById("email_check_registration").innerHTML='E-mail should be like something@gmail.com';
		document.getElementById("email_check_registration").innerHTML='E-mail should be like a@b.c';
		obj.sec_email.style.color='#FF0000';
		flage++;
		}else{
		document.getElementById("email_check_registration").innerHTML='';
		obj.sec_email.style.color='#000000';
		}
	
	}
	/*
	if(obj.confirm_username.value!=""){
	flage=MustBeSame(obj.username,obj.confirm_username,flage,'id');
	}
	*/
	if(obj.password.value!=""){
		flage=check_value(obj.confirm_password,flage);
		flage=MustBeSame(obj.password,obj.confirm_password,flage,'id');
		
	}
	
	
	
	if(flage==0){
		return true;
	}else{
		return false;
	}
}



function relogin_form_validation(){
	var flage=0;
	var obj=document.relogin;
	flage=checkvalue(obj.username,flage,'User Name...');
	flage=checkvalue(obj.password,flage,'Password...');
	if(flage==0){
		return true;
	}else{
		return false;
	}
}


function search_form_validation(){
	var flage=0;
	var obj=document.simplesearch;
	flage=checkvalue(obj.searchvalue,flage,'search...');
	if(flage==0){
		return true;
	}else{
		return false;
	}
}






function advance_search_form_validation(){
	var flage=0;
	var obj=document.advance_search;
	flage=MustBeGreater_select(obj.agesmall,obj.agelager,flage,'id');
	/*flage=MustNotBeSame(obj.gender1,obj.gender2,flage,'id');
	flage=check_value(obj.email,flage);
	flage=check_value(obj.confirm_email,flage);
	flage=check_value(obj.states,flage);
	flage=check_value(obj.city,flage);
	flage=check_value(obj.displaytype,flage);
	flage=check_value(obj.sorting,flage);*/
	
	if(flage==0){
		return true;
	}else{
		return false;
	}
}


function check_username(){
	var flage=0;
	var obj=document.user_search;
	
	flage=check_value(obj.username,flage);
	
	if(flage==0){
		return true;
	}else{
		return false;
	}
}


function check_mail(){
	var flage=0;
	var obj=document.mail_search;
	flage=check_value(obj.email,flage);
	if(obj.email.value!=""){
		if(!isEmail(trim(obj.email.value))){
	//	document.getElementById("email_check_search").innerHTML='E-mail should be like something@gmail.com';
	document.getElementById("email_check_search").innerHTML='E-mail should be like a@b.c';
		obj.email.style.color='#FF0000';
		flage++;
		}
		else{
		document.getElementById("email_check_search").innerHTML='';
		obj.email.style.color='#000000';
		}
	
	}
	
	
	
	if(flage==0){
		return true;
	}else{
		return false;
	}
}




//check availability
var xmlHttp;
var str;
var username;
function check_username_availability(username)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="check_username.php?sid=" + Math.random() + "&q=" + username;
	xmlHttp.onreadystatechange=usernameStateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function usernameStateChanged() 
{ 
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
	document.getElementById("username_check_result").innerHTML="Checking ..."
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("username_check_result").innerHTML=xmlHttp.responseText;
	} 
} 

var handler;
function GetXmlHttpObject(handler){ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest){
	objXMLHttp=new XMLHttpRequest();
	}else if (window.ActiveXObject){
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}



var email_address;

function check_email_availability(email_address)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	
	var url="check_useremail.php?sid=" + Math.random() + "&q=" + email_address;
	xmlHttp.onreadystatechange=emailStateChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function emailStateChanged() 
{ 
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
	document.getElementById("email_check_result").innerHTML="Checking ..."
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("email_check_result").innerHTML=xmlHttp.responseText;
	} 
} 



var addressid;
function fetchaddress(addressid){
	 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
	alert ("Browser does not support HTTP Request")
	return
	} 
	
	var url="address.php?sid=" + Math.random() + "&id=" + addressid;
	xmlHttp.onreadystatechange=fetchaddressChanged; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function fetchaddressChanged(){ 
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading"){ 
	document.getElementById("auto_address").innerHTML="<li>Checking ...</li>";
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	document.getElementById("auto_address").innerHTML=xmlHttp.responseText;
	} 
} 
