// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

function countWords(){
	document.form1.wordcount.value = document.form1.inputString.value.split(' ').length;
}


function validate(form) {
 
 var prof_id = form.prof_id.value;
 var secondary_prof_id = form.secondary_prof_id.value;
 var email = form.email.value;
 email = trim(email);
 var email = email.replace(/^\s+|\s+$/g, '') ;
 var vemail = form.vemail.value;  
 vemail = trim(vemail);
 var alt_email = form.alt_email.value; 
 alt_email = trim(alt_email);
 var username = form.username.value;  
  username = trim(username);
  var fname = form.fname.value; 
  fname = trim(fname);
  var lname = form.lname.value;  
  lname = trim(lname);
  var country = form.country_id.value; 
  var date = form.date.value;
  var month = form.month.value;
  var year = form.year.value;
  var city = form.city_name.value;  
  city = trim(city);
  var passport = form.passport.value;

	
  
      
   var freg = /(^\d\d*$)/;
  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
 //var trimmed = emailRegex.replace(/^\s+|\s+$/g, '') ;
  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
    
  if(prof_id == "") {
  form.prof_id.style.background = '#E66C2C'; 
  inlineMsg('prof_id','<strong>Error</strong><br />Select Primary Career Interest ',2);
  return false;
  }
                                                             
                                                                        
    myOption = -1;
  	for (i=form.gender.length-1; i > -1; i--) {
	if (form.gender[i].checked) {
	myOption = i; i = -1;
	}
	}
	if (myOption == -1) {
		inlineMsg('gender','Please select your gender',2);
		return false;
	}
   
	 if(username == "") {
		  form.username.style.background = '#E66C2C'; 
	  inlineMsg('username','<strong>Error</strong><br />Enter Member Id',2);
	  return false;
	  }
	 
	 if(form.username.value.split(' ').length>1) {
		  form.username.style.background = '#E66C2C'; 
	  inlineMsg('username','<strong>Error</strong><br />Enter only one word. Not allowed space',2);
	  return false;
	  }
	

  if(fname == "") {
	  form.fname.style.background = '#E66C2C'; 
  inlineMsg('fname','<strong>Error</strong><br />Enter First name',2);
  return false;
  }
  if(lname == "") {
	  form.lname.style.background = '#E66C2C'; 
  inlineMsg('lname','<strong>Error</strong><br />Enter Last name',2);
  return false;
  }
  
  if(date == "0") {
	  form.date.style.background = '#E66C2C'; 
	    inlineMsg('date','<strong>Error</strong><br />Please select valid date',2);
	    return false;
	  }
  if(month == "0") {
	  form.month.style.background = '#E66C2C'; 
	    inlineMsg('month','<strong>Error</strong><br />Please select valid date',2);
	    return false;
	  }
  if(year == "0") {
	  form.year.style.background = '#E66C2C'; 
	    inlineMsg('year','<strong>Error</strong><br />Please select valid date',2);
	    return false;
	  }
  if(country == "0") {
	  form.country_id.style.background = '#E66C2C'; 
	    inlineMsg('country_id','<strong>Error</strong><br />Please select your country',2);
	    return false;
	  }
  if(city=="")
	{
	  form.city_name.style.background = '#E66C2C'; 
	inlineMsg('city_name','<strong>Error</strong><br />Enter City',2);
  return false;

	}                                                                      
                                                                        
if(email=="")
	{
	form.email.style.background = '#E66C2C'; 
	inlineMsg('email','<strong>Error</strong><br />Enter email',2);
    return false;

	}
  if(!email.match(emailRegex)) {
	  form.email.style.background = '#E66C2C'; 
    inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email',2);
    return false;
  }
  if(vemail == "") {
	  form.vemail.style.background = '#E66C2C'; 
    inlineMsg('vemail','<strong>Error</strong><br />Retype your email',2);
    return false;
  }
   if(email != vemail)
      {
	   form.vemail.style.background = '#E66C2C'; 
          inlineMsg('vemail','Email ID not matching',2);
    return false;
      
  }
   if(alt_email!="")
   {
   if(!alt_email.match(emailRegex)) {
		  form.alt_email.style.background = '#E66C2C'; 
	    inlineMsg('alt_email','<strong>Error</strong><br />You have entered an invalid email',2);
	    return false;
	  }
   }
  
   if(passport == "") {
		  form.passport.style.background = '#E66C2C'; 
	    inlineMsg('passport','<strong>Error</strong><br />Do you have valid passport?.',2);
	    return false;
	  }
  
 
  
  return true;
}

function editContact(form) {
	 
	 var prof_id = form.prof_id.value;
	 var secondary_prof_id = form.secondary_prof_id.value;
	 var email = form.email.value;
	 email = trim(email);
	 var email = email.replace(/^\s+|\s+$/g, '') ;
	 var vemail = form.vemail.value;  
	 vemail = trim(vemail);
	 var alt_email = form.alt_email.value; 
	 alt_email = trim(alt_email);
	 var username = form.username.value;  
	  username = trim(username);
	  var fname = form.fname.value; 
	  fname = trim(fname);
	  var lname = form.lname.value;  
	  lname = trim(lname);
	  var country = form.country_id.value; 
	  var date = form.date.value;
	  var month = form.month.value;
	  var year = form.year.value;
	  var city = form.city_name.value;  
	  city = trim(city);
	  var passport = form.passport.value;

		
	  
	      
	   var freg = /(^\d\d*$)/;
	  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	 //var trimmed = emailRegex.replace(/^\s+|\s+$/g, '') ;
	  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
	    
		                                                             
	                                                                        
	    myOption = -1;
	  	for (i=form.gender.length-1; i > -1; i--) {
		if (form.gender[i].checked) {
		myOption = i; i = -1;
		}
		}
		if (myOption == -1) {
			inlineMsg('gender','Please select your gender',2);
			return false;
		}
	   
	
	
		

	  if(fname == "") {
		  form.fname.style.background = '#E66C2C'; 
	  inlineMsg('fname','<strong>Error</strong><br />Enter First name',2);
	  return false;
	  }
	  if(lname == "") {
		  form.lname.style.background = '#E66C2C'; 
	  inlineMsg('lname','<strong>Error</strong><br />Enter Last name',2);
	  return false;
	  }
	  
	  if(date == "0") {
		  form.date.style.background = '#E66C2C'; 
		    inlineMsg('date','<strong>Error</strong><br />Please select valid date',2);
		    return false;
		  }
	  if(month == "0") {
		  form.month.style.background = '#E66C2C'; 
		    inlineMsg('month','<strong>Error</strong><br />Please select valid date',2);
		    return false;
		  }
	  if(year == "0") {
		  form.year.style.background = '#E66C2C'; 
		    inlineMsg('year','<strong>Error</strong><br />Please select valid date',2);
		    return false;
		  }
	  if(country == "0") {
		  form.country_id.style.background = '#E66C2C'; 
		    inlineMsg('country_id','<strong>Error</strong><br />Please select your country',2);
		    return false;
		  }
	  if(city=="")
		{
		  form.city_name.style.background = '#E66C2C'; 
		inlineMsg('city_name','<strong>Error</strong><br />Enter City',2);
	  return false;

		}                                                                      
	                                                                        
	if(email=="")
		{
		form.email.style.background = '#E66C2C'; 
		inlineMsg('email','<strong>Error</strong><br />Enter email',2);
	    return false;

		}
	  if(!email.match(emailRegex)) {
		  form.email.style.background = '#E66C2C'; 
	    inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email',2);
	    return false;
	  }
	  if(vemail == "") {
		  form.vemail.style.background = '#E66C2C'; 
	    inlineMsg('vemail','<strong>Error</strong><br />Retype your email',2);
	    return false;
	  }
	   if(email != vemail)
	      {
		   form.vemail.style.background = '#E66C2C'; 
	          inlineMsg('vemail','Email ID not matching',2);
	    return false;
	      
	  }
	   if(alt_email!="")
	   {
	   if(!alt_email.match(emailRegex)) {
			  form.alt_email.style.background = '#E66C2C'; 
		    inlineMsg('alt_email','<strong>Error</strong><br />You have entered an invalid email',2);
		    return false;
		  }
	   }
	  
	   if(passport == "") {
			  form.passport.style.background = '#E66C2C'; 
		    inlineMsg('passport','<strong>Error</strong><br />Do you have valid passport?.',2);
		    return false;
		  }
	  
	 
	  
	  return true;
	}

function loginValidate(form) {
	var member_id = form.member_id.value;  
	var password = form.pword.value; 	   
	if(member_id == "") {
	form.member_id.style.background = '#E66C2C'; 
	//inlineMsg('member_id','<strong>Error</strong><br />Enter Member Id',2);
	return false;
  }
	if(password == "") {
	form.pword.style.background = '#E66C2C'; 
	//inlineMsg('password','<strong>Error</strong><br />Enter Password.',2);
	return false;
	  }
	  
	  
	 
	  
	  return true;
	}

function modelMaleValidate(form) {
	var height = form.height.value;
	var weight = form.weight.value;
	var chest = form.chest.value;
	chest = trim(chest);
	var waist = form.waist.value;
	waist = trim(waist);
	var eyecolor = form.eyecolor.value;
	eyecolor = trim(eyecolor);
	var haircolor = form.haircolor.value;
	haircolor = trim(haircolor);
	var shoesize = form.shoesize.value;
	shoesize = trim(shoesize);
	var biceps = form.biceps.value;
	biceps = trim(biceps);
	var experience = form.experience.value;
	var travel = form.travel.value;
	var note = form.note.value;
	note = trim(note);
	
	
	

	if(height=="") {
		form.height.style.background = '#E66C2C'; 
		inlineMsg('height','<strong>Error</strong><br />Select your height',2);
		return false;
		}
	if(weight=="") {
		form.weight.style.background = '#E66C2C'; 
		inlineMsg('weight','<strong>Error</strong><br />Select your weight',2);
		return false;
		}
	if(chest=="" || !chest) {
		form.chest.style.background = '#E66C2C'; 
		inlineMsg('chest','<strong>Error</strong><br />Enter your chest',2);
		return false;
		}
	if(waist=="") {
		form.waist.style.background = '#E66C2C'; 
		inlineMsg('waist','<strong>Error</strong><br />Enter your waist',2);
		return false;
		}
	if(eyecolor=="") {
		form.eyecolor.style.background = '#E66C2C'; 
		inlineMsg('eyecolor','<strong>Error</strong><br />Enter your eyecolor',2);
		return false;
		}
	if(haircolor=="") {
		form.haircolor.style.background = '#E66C2C'; 
		inlineMsg('haircolor','<strong>Error</strong><br />Enter your haircolor',2);
		return false;
		}
	
	if(biceps=="") {
		form.biceps.style.background = '#E66C2C'; 
		inlineMsg('biceps','<strong>Error</strong><br />Enter your biceps',2);
		return false;
		}
	if(experience=="") {
		form.experience.style.background = '#E66C2C'; 
		inlineMsg('experience','<strong>Error</strong><br />Select your experience',2);
		return false;
		}
	if(travel=="") {
		form.travel.style.background = '#E66C2C'; 
		inlineMsg('travel','<strong>Error</strong><br />Select your travel',2);
		return false;
		}
 
	
	if(note=="") {
		form.note.style.background = '#E66C2C'; 
		inlineMsg('note','<strong>Error</strong><br />Enter note',2);
		return false;
		}
	  
	 
	  
	  return true;
	}

function modelFemaleValidate(form) {
	var height = form.height.value;
	var weight = form.weight.value;
	var bust = form.bust.value;
	bust = trim(bust);
	var waist = form.waist.value;
	waist = trim(waist);
	var eyecolor = form.eyecolor.value;
	eyecolor = trim(eyecolor);
	var haircolor = form.haircolor.value;
	haircolor = trim(haircolor);
	var shoesize = form.shoesize.value;
	shoesize = trim(shoesize);
	var hip = form.hip.value;
	hip = trim(hip);
	var experience = form.experience.value;
	var travel = form.travel.value;
	var note = form.note.value;
	note = trim(note);
	
	

	if(height=="") {
		form.height.style.background = '#E66C2C'; 
		inlineMsg('height','<strong>Error</strong><br />Select your height',2);
		return false;
		}
	if(weight=="") {
		form.weight.style.background = '#E66C2C'; 
		inlineMsg('weight','<strong>Error</strong><br />Select your weight',2);
		return false;
		}
	if(bust=="" || !bust) {
		form.bust.style.background = '#E66C2C'; 
		inlineMsg('bust','<strong>Error</strong><br />Enter your bust',2);
		return false;
		}
	if(waist=="") {
		form.waist.style.background = '#E66C2C'; 
		inlineMsg('waist','<strong>Error</strong><br />Enter your waist',2);
		return false;
		}
	if(eyecolor=="") {
		form.eyecolor.style.background = '#E66C2C'; 
		inlineMsg('eyecolor','<strong>Error</strong><br />Enter your eyecolor',2);
		return false;
		}
	if(haircolor=="") {
		form.haircolor.style.background = '#E66C2C'; 
		inlineMsg('haircolor','<strong>Error</strong><br />Enter your haircolor',2);
		return false;
		}
	
	if(hip=="") {
		form.hip.style.background = '#E66C2C'; 
		inlineMsg('hip','<strong>Error</strong><br />Enter your hip',2);
		return false;
		}
	if(experience=="") {
		form.experience.style.background = '#E66C2C'; 
		inlineMsg('experience','<strong>Error</strong><br />Select your experience',2);
		return false;
		}
	if(travel=="") {
		form.travel.style.background = '#E66C2C'; 
		inlineMsg('travel','<strong>Error</strong><br />Select your travel',2);
		return false;
		}
	/*if(!form.negotiable.checked && !form.photo.checked && !form.pay.checked){
		alert("Check your Types of Compensation");
		//form.negotiable.style.background = '#E66C2C'; 
		//inlineMsg('negotiable','<strong>Error</strong><br />Select your negotiable',2);
		return false; 
		} 
	if(!form.print.checked && !form.digital.checked && !form.hands_legs_feet.checked && !form.spokesmodel.checked && !form.trade_show_hosting.checked){
		alert("Check your Modeling Assignments of Interest");
		//form.negotiable.style.background = '#E66C2C'; 
		//inlineMsg('negotiable','<strong>Error</strong><br />Select your negotiable',2);
		return false; 
		} 
	if(!form.swimwear.checked && !form.lingerie.checked && !form.sheer.checked && !form.others.checked){
		alert("Check your Glamour Assignments of Interest");
		//form.negotiable.style.background = '#E66C2C'; 
		//inlineMsg('negotiable','<strong>Error</strong><br />Select your negotiable',2);
		return false; 
		} 
		*/
	if(note=="") {
		form.note.style.background = '#E66C2C'; 
		inlineMsg('note','<strong>Error</strong><br />Enter note',2);
		return false;
		}
	  
	 
	  
	  return true;
	}
function actorMaleValidate(form) {
	var height = form.height.value;
	var weight = form.weight.value;
	var chest = form.chest.value;
	chest = trim(chest);
	var waist = form.waist.value;
	waist = trim(waist);
	var eyecolor = form.eyecolor.value;
	eyecolor = trim(eyecolor);
	var haircolor = form.haircolor.value;
	haircolor = trim(haircolor);
	var shoesize = form.shoesize.value;
	shoesize = trim(shoesize);
	var biceps = form.biceps.value;
	biceps = trim(biceps);
	var experience = form.experience.value;
	var travel = form.travel.value;
	var note = form.note.value;
	note = trim(note);
	
	
	

	if(height=="") {
		form.height.style.background = '#E66C2C'; 
		inlineMsg('height','<strong>Error</strong><br />Select your height',2);
		return false;
		}
	if(weight=="") {
		form.weight.style.background = '#E66C2C'; 
		inlineMsg('weight','<strong>Error</strong><br />Select your weight',2);
		return false;
		}
	if(chest=="" || !chest) {
		form.chest.style.background = '#E66C2C'; 
		inlineMsg('chest','<strong>Error</strong><br />Enter your chest',2);
		return false;
		}
	if(waist=="") {
		form.waist.style.background = '#E66C2C'; 
		inlineMsg('waist','<strong>Error</strong><br />Enter your waist',2);
		return false;
		}
	if(eyecolor=="") {
		form.eyecolor.style.background = '#E66C2C'; 
		inlineMsg('eyecolor','<strong>Error</strong><br />Enter your eyecolor',2);
		return false;
		}
	if(haircolor=="") {
		form.haircolor.style.background = '#E66C2C'; 
		inlineMsg('haircolor','<strong>Error</strong><br />Enter your haircolor',2);
		return false;
		}
	
	if(biceps=="") {
		form.biceps.style.background = '#E66C2C'; 
		inlineMsg('biceps','<strong>Error</strong><br />Enter your biceps',2);
		return false;
		}
	if(experience=="") {
		form.experience.style.background = '#E66C2C'; 
		inlineMsg('experience','<strong>Error</strong><br />Select your experience',2);
		return false;
		}
	if(travel=="") {
		form.travel.style.background = '#E66C2C'; 
		inlineMsg('travel','<strong>Error</strong><br />Select your travel',2);
		return false;
		}
	
	if(note=="") {
		form.note.style.background = '#E66C2C'; 
		inlineMsg('note','<strong>Error</strong><br />Enter note',2);
		return false;
		}
	  
	 
	  
	  return true;
	}

function actorFemaleValidate(form) {
	var height = form.height.value;
	var weight = form.weight.value;
	var bust = form.bust.value;
	bust = trim(bust);
	var waist = form.waist.value;
	waist = trim(waist);
	var eyecolor = form.eyecolor.value;
	eyecolor = trim(eyecolor);
	var haircolor = form.haircolor.value;
	haircolor = trim(haircolor);
	var shoesize = form.shoesize.value;
	shoesize = trim(shoesize);
	var hip = form.hip.value;
	hip = trim(hip);
	var experience = form.experience.value;
	var travel = form.travel.value;
	var note = form.note.value;
	note = trim(note);
	
	

	if(height=="") {
		form.height.style.background = '#E66C2C'; 
		inlineMsg('height','<strong>Error</strong><br />Select your height',2);
		return false;
		}
	if(weight=="") {
		form.weight.style.background = '#E66C2C'; 
		inlineMsg('weight','<strong>Error</strong><br />Select your weight',2);
		return false;
		}
	if(bust=="" || !bust) {
		form.bust.style.background = '#E66C2C'; 
		inlineMsg('bust','<strong>Error</strong><br />Enter your bust',2);
		return false;
		}
	if(waist=="") {
		form.waist.style.background = '#E66C2C'; 
		inlineMsg('waist','<strong>Error</strong><br />Enter your waist',2);
		return false;
		}
	if(eyecolor=="") {
		form.eyecolor.style.background = '#E66C2C'; 
		inlineMsg('eyecolor','<strong>Error</strong><br />Enter your eyecolor',2);
		return false;
		}
	if(haircolor=="") {
		form.haircolor.style.background = '#E66C2C'; 
		inlineMsg('haircolor','<strong>Error</strong><br />Enter your haircolor',2);
		return false;
		}
	
	if(hip=="") {
		form.hip.style.background = '#E66C2C'; 
		inlineMsg('hip','<strong>Error</strong><br />Enter your hip',2);
		return false;
		}
	if(experience=="") {
		form.experience.style.background = '#E66C2C'; 
		inlineMsg('experience','<strong>Error</strong><br />Select your experience',2);
		return false;
		}
	if(travel=="") {
		form.travel.style.background = '#E66C2C'; 
		inlineMsg('travel','<strong>Error</strong><br />Select your travel',2);
		return false;
		}
	
	if(note=="") {
		form.note.style.background = '#E66C2C'; 
		inlineMsg('note','<strong>Error</strong><br />Enter note',2);
		return false;
		}
	  
	 
	  
	  return true;
	}
function hostesMaleValidate(form) {
	var height = form.height.value;
	var weight = form.weight.value;
	var chest = form.chest.value;
	chest = trim(chest);
	var waist = form.waist.value;
	waist = trim(waist);
	var eyecolor = form.eyecolor.value;
	eyecolor = trim(eyecolor);
	var haircolor = form.haircolor.value;
	haircolor = trim(haircolor);
	var shoesize = form.shoesize.value;
	shoesize = trim(shoesize);
	var biceps = form.biceps.value;
	biceps = trim(biceps);
	var experience = form.experience.value;
	var travel = form.travel.value;
	var note = form.note.value;
	note = trim(note);
	
	
	

	if(height=="") {
		form.height.style.background = '#E66C2C'; 
		inlineMsg('height','<strong>Error</strong><br />Select your height',2);
		return false;
		}
	if(weight=="") {
		form.weight.style.background = '#E66C2C'; 
		inlineMsg('weight','<strong>Error</strong><br />Select your weight',2);
		return false;
		}
	if(chest=="" || !chest) {
		form.chest.style.background = '#E66C2C'; 
		inlineMsg('chest','<strong>Error</strong><br />Enter your chest',2);
		return false;
		}
	if(waist=="") {
		form.waist.style.background = '#E66C2C'; 
		inlineMsg('waist','<strong>Error</strong><br />Enter your waist',2);
		return false;
		}
	if(eyecolor=="") {
		form.eyecolor.style.background = '#E66C2C'; 
		inlineMsg('eyecolor','<strong>Error</strong><br />Enter your eyecolor',2);
		return false;
		}
	if(haircolor=="") {
		form.haircolor.style.background = '#E66C2C'; 
		inlineMsg('haircolor','<strong>Error</strong><br />Enter your haircolor',2);
		return false;
		}
	
	if(biceps=="") {
		form.biceps.style.background = '#E66C2C'; 
		inlineMsg('biceps','<strong>Error</strong><br />Enter your biceps',2);
		return false;
		}
	if(experience=="") {
		form.experience.style.background = '#E66C2C'; 
		inlineMsg('experience','<strong>Error</strong><br />Select your experience',2);
		return false;
		}
	if(travel=="") {
		form.travel.style.background = '#E66C2C'; 
		inlineMsg('travel','<strong>Error</strong><br />Select your travel',2);
		return false;
		}
	
	if(note=="") {
		form.note.style.background = '#E66C2C'; 
		inlineMsg('note','<strong>Error</strong><br />Enter note',2);
		return false;
		}
	  
	 
	  
	  return true;
	}

function hostesFemaleValidate(form) {
	var height = form.height.value;
	var weight = form.weight.value;
	var bust = form.bust.value;
	bust = trim(bust);
	var waist = form.waist.value;
	waist = trim(waist);
	var eyecolor = form.eyecolor.value;
	eyecolor = trim(eyecolor);
	var haircolor = form.haircolor.value;
	haircolor = trim(haircolor);
	var shoesize = form.shoesize.value;
	shoesize = trim(shoesize);
	var hip = form.hip.value;
	hip = trim(hip);
	var experience = form.experience.value;
	var travel = form.travel.value;
	var note = form.note.value;
	note = trim(note);
	
	

	if(height=="") {
		form.height.style.background = '#E66C2C'; 
		inlineMsg('height','<strong>Error</strong><br />Select your height',2);
		return false;
		}
	if(weight=="") {
		form.weight.style.background = '#E66C2C'; 
		inlineMsg('weight','<strong>Error</strong><br />Select your weight',2);
		return false;
		}
	if(bust=="" || !bust) {
		form.bust.style.background = '#E66C2C'; 
		inlineMsg('bust','<strong>Error</strong><br />Enter your bust',2);
		return false;
		}
	if(waist=="") {
		form.waist.style.background = '#E66C2C'; 
		inlineMsg('waist','<strong>Error</strong><br />Enter your waist',2);
		return false;
		}
	if(eyecolor=="") {
		form.eyecolor.style.background = '#E66C2C'; 
		inlineMsg('eyecolor','<strong>Error</strong><br />Enter your eyecolor',2);
		return false;
		}
	if(haircolor=="") {
		form.haircolor.style.background = '#E66C2C'; 
		inlineMsg('haircolor','<strong>Error</strong><br />Enter your haircolor',2);
		return false;
		}

	if(hip=="") {
		form.hip.style.background = '#E66C2C'; 
		inlineMsg('hip','<strong>Error</strong><br />Enter your hip',2);
		return false;
		}
	if(experience=="") {
		form.experience.style.background = '#E66C2C'; 
		inlineMsg('experience','<strong>Error</strong><br />Select your experience',2);
		return false;
		}
	if(travel=="") {
		form.travel.style.background = '#E66C2C'; 
		inlineMsg('travel','<strong>Error</strong><br />Select your travel',2);
		return false;
		}
	
	if(note=="") {
		form.note.style.background = '#E66C2C'; 
		inlineMsg('note','<strong>Error</strong><br />Enter note',2);
		return false;
		}
	  
	 
	  
	  return true;
	}

function photographerValidate(form) {

	var experience = form.experience.value;
	var travel = form.travel.value;
	var reference = form.reference.value;
	var travel = form.travel.value;
	var makeup_artist = form.makeup_artist.value;
	var hair_stylist = form.hair_stylist.value;
	var note = form.note.value;
	note = trim(note);
	
	
	

	
	if(experience=="") {
		form.experience.style.background = '#E66C2C'; 
		inlineMsg('experience','<strong>Error</strong><br />Select your experience',2);
		return false;
		}
	if(travel=="") {
		form.travel.style.background = '#E66C2C'; 
		inlineMsg('travel','<strong>Error</strong><br />Select your travel',2);
		return false;
		}
	if(reference=="") {
		form.reference.style.background = '#E66C2C'; 
		inlineMsg('reference','<strong>Error</strong><br />Select your reference',2);
		return false;
		}
	if(makeup_artist=="") {
		form.makeup_artist.style.background = '#E66C2C'; 
		inlineMsg('makeup_artist','<strong>Error</strong><br />Select your makeup_artist',2);
		return false;
		}
	if(hair_stylist=="") {
		form.hair_stylist.style.background = '#E66C2C'; 
		inlineMsg('hair_stylist','<strong>Error</strong><br />Select your hair_stylist',2);
		return false;
		}
	
	
	if(note=="") {
		form.note.style.background = '#E66C2C'; 
		inlineMsg('note','<strong>Error</strong><br />Enter note',2);
		return false;
		}
	  
	 
	  
	  return true;
	}

//START OF MESSAGE SCRIPT //

var MSGTIMER = 20;
var MSGSPEED = 5;
var MSGOFFSET = 3;
var MSGHIDE = 3;

// build out the divs, set attributes and call the fade function //
function inlineMsg(target,string,autohide) {
  var msg;
  var msgcontent;
  if(!document.getElementById('msg')) {
    msg = document.createElement('div');
    msg.id = 'msg';
    msgcontent = document.createElement('div');
    msgcontent.id = 'msgcontent';
    document.body.appendChild(msg);
    msg.appendChild(msgcontent);
    msg.style.filter = 'alpha(opacity=0)';
    msg.style.opacity = 0;
    msg.alpha = 0;
  } else {
    msg = document.getElementById('msg');
    msgcontent = document.getElementById('msgcontent');
  }
  msgcontent.innerHTML = string;
  msg.style.display = 'block';
  var msgheight = msg.offsetHeight;
  var targetdiv = document.getElementById(target);
  targetdiv.focus();
  var targetheight = targetdiv.offsetHeight;
  var targetwidth = targetdiv.offsetWidth;
  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
  msg.style.top = topposition + 'px';
  msg.style.left = leftposition + 'px';
  clearInterval(msg.timer);
  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
  if(!autohide) {
    autohide = MSGHIDE;  
  }
  window.setTimeout("hideMsg()", (autohide * 1000));
}

// hide the form alert //
function hideMsg(msg) {
  var msg = document.getElementById('msg');
  if(!msg.timer) {
    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
  }
}

// face the message box //
function fadeMsg(flag) {
  if(flag == null) {
    flag = 1;
  }
  var msg = document.getElementById('msg');
  var value;
  if(flag == 1) {
    value = msg.alpha + MSGSPEED;
  } else {
    value = msg.alpha - MSGSPEED;
  }
  msg.alpha = value;
  msg.style.opacity = (value / 100);
  msg.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(msg.timer);
    msg.timer = null;
  } else if(value <= 1) {
    msg.style.display = "none";
    clearInterval(msg.timer);
  }
}

// calculate the position of the element in relation to the left of the browser //
function leftPosition(target) {
  var left = 0;
  if(target.offsetParent) {
    while(1) {
      left += target.offsetLeft;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.x) {
    left += target.x;
  }
  return left;
}

// calculate the position of the element in relation to the top of the browser window //
function topPosition(target) {
  var top = 0;
  if(target.offsetParent) {
    while(1) {
      top += target.offsetTop;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.y) {
    top += target.y;
  }
  return top;
}

// preload the arrow //
if(document.images) {
  arrow = new Image(7,80); 
  arrow.src = "../images/msg_arrow.gif"; 
}

/*
function validateFormOnSubmit(form) {
	var reason = "";
	var checkemail;
	//reason += validateGender(form.gender);
	reason += validateMemberId(form.member_id);
	reason += validateFirstName(form.fname);
	reason += validateLastName(form.lname);
	reason += validateCountry(form.country_id);
	reason += validateCity(form.city_name);
    reason += validateEmail(form.email);
    reason += validateVerifyEmail(form.vemail,form.email);
    reason += validatePassword(form.password);
    reason += validateVerifyPassword(form.vpassword,form.password);
   
  if (reason != "") {
	 return false;
  }
  return true
}


/*
function validateGender(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    myOption = -1;
    for (i=form.gender.length-1; i > -1; i--) {
    if (form.gender[i].checked) {
    myOption = i; i = -1;
    }
    }
    if (myOption == -1) {
    	fld.style.background = 'Red'; 
        error = "Gender required.\n";
    	return false;
    }
    return error;
}

function validateFirstName(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = 'Orange'; 
        error = "First Name required.\n";
    } 
		else {
        fld.style.background = 'White';
    }
    return error;
}

function validateLastName(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = 'Red'; 
        error = "Last Name required.\n";
    } 
		else {
        fld.style.background = 'White';
    }
    return error;
}

function validateMemberId(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = 'Red'; 
        error = "Member Id required.\n";
    } 
		else {
        fld.style.background = 'White';
    }
    return error;
}

function validateCountry(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "0") {
        fld.style.background = 'Red'; 
        error = "Select Country.\n";
    } 
	else {
        fld.style.background = 'White';
    }
    return error;
}
function validateCity(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = 'Red'; 
        error = "City required.\n";
    } 
		else {
        fld.style.background = 'White';
    }
    return error;
}
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}
function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);  
    checkemail = tfld; // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = 'Red';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Red';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Red';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validateVerifyEmail(fld1, fld2) {
    var error="";
    var tfld = trim(fld1.value); 
    var tfld2 = trim(fld2.value); // value of field with whitespace trimmed off
   if (tfld != tfld2 || fld1.value == "") {
        fld1.style.background = 'Red';
        error = "The email address contains illegal characters.\n";
    } else {
        fld1.style.background = 'White';
    }
    return error;
}
function validatePassword(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = 'Red'; 
        error = "Password required.\n";
    } 
		else {
        fld.style.background = 'White';
    }
    return error;
}
function validateVerifyPassword(fld1,fld2) {
	 var error="";
	    var tfld = trim(fld1.value); 
	    var tfld2 = trim(fld2.value); // value of field with whitespace trimmed off
	   if (tfld != tfld2 || fld1.value == "") {
        fld1.style.background = 'Red'; 
        error = "Same as password.\n";
    } 
		else {
        fld1.style.background = 'White';
    }
    return error;
}
*/
