// form validation function //

function validate(form) {

  var first_name = trim(form.first_name.value);

  var email = trim(form.email.value);

  var password = trim(form.password.value);

  var vpassword = trim(form.vpassword.value);

  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;

  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

  var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);

  if(first_name == "") {

    inlineMsg('first_name','You must enter your first name.',2);

    return false;

  }

  if(!first_name.match(nameRegex)) {

    inlineMsg('first_name','You have entered an invalid first name.',2);

    return false;

  }

  if(email == "") {

    inlineMsg('email','You must enter your email.',2);

    return false;

  }

  if(!email.match(emailRegex)) {

    inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2);

    return false;

  }

  if(password == "") {

    inlineMsg('password','You must enter password.',2);

    return false;

  }

  if(vpassword == "") {

    inlineMsg('vpassword','You must enter verify password.');

    return false;

  }

 if(vpassword != password) {

    inlineMsg('vpassword','Password and verify Password are different.');

    return false;

  }



  return true;

}





// Function To Validating Article Submission Form  //

function validateAddArticle(form) {

  var article_name = trim(form.article_name.value);

  var permaLink = trim(form.permaLink.value);

   

 if(article_name == "") {

    inlineMsg('article_name','Please Fill The Article Title.',2);

    return false;

  }



  if(permaLink == "") {

    inlineMsg('permaLink','Please Fill The Perma Link.',2);

    return false;

  }

  

  return true;

}





// Function To Validating Link Submission Form  //

function validateAddLinkPartner(form) {

  var link_name = trim(form.link_name.value);

  var link_text = trim(form.link_text.value);

  var link_url = trim(form.link_url.value);

  var first_name = trim(form.first_name.value);

  var last_name = trim(form.last_name.value);

  var email = trim(form.email.value);

  var phone = trim(form.phone.value);

  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

  var recip_link = trim(form.recip_link.value);

 if(first_name == "") {

    inlineMsg('first_name','Please Fill The First Name.',2);

    return false;

  }

 if(last_name == "") {

    inlineMsg('last_name','Please Fill The Last Name.',2);

    return false;

  }

 if(email == "") {

    inlineMsg('email','Please Fill The Email.',2);

    return false;

  }

  if(!email.match(emailRegex)) {

    inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2);

    return false;

  }

 if(phone == "") {

    inlineMsg('phone','Please Fill The Phone.',2);

    return false;

  }

 if(phone.length > 13) {

    inlineMsg('phone','Please Correct The Phone.',2);

    return false;

  }

 if(link_name == "") {

    inlineMsg('link_name','Please Fill The Link Title.',2);

    return false;

  }

  

  if(link_text == "") {

    inlineMsg('link_text','Please Fill The Link Text.',2);

    return false;

  }

  if(link_url == "") {

    inlineMsg('link_url','Please Fill The Link URL.',2);

    return false;

  }

  if(recip_link == "") {

    inlineMsg('recip_link','Please Fill The Reciprocal Link URL.',2);

    return false;

  }



  return true;

}



// Function To Validating Banner Ads Form 	//

// 			By Pradeep Saxena 				//

function validateCreateBanner(form) {

  var first_name =trim(form.first_name.value);

  var last_name = trim(form.last_name.value);

  var country = form.lcountry1.value;

  var state = form.lstate1.value;

  var city = form.lcity1.value;

  var country1 = form.lcountry3.value;

  var state1 = form.lstate3.value;

  var city1 = form.lcity3.value;

  var zip = form.zip.value;



  var name_on_card = trim(form.name_on_card.value);

  var card_number = trim(form.card_number.value);

  var CVV_number = trim(form.CVV_number.value);

  //var expiration_date = form.expiration_date.value;



  var banner_url = trim(form.banner_url.value);

    //var banner_image = form.banner_image.value;








  if(first_name == "") {

    inlineMsg('first_name','Please Fill The First Name.',2);

    return false;

  }

   if(last_name == "") {

    inlineMsg('last_name','Please Fill The Last Name.',2);

    return false;

  }

   if(country == "") {

    inlineMsg('lcountry0','Please Fill The Country Name.',2);

    return false;

  }

 if(state == "") {

    inlineMsg('lstate0','Please Fill The State.',2);

    return false;

  }



  if(city == "") {

    inlineMsg('lcity0','Please Fill The City.',2);

    return false;

  }

 if(zip == "") {

    inlineMsg('zip','Please Fill The Zip Code.',2);

    return false;

  }



 if(name_on_card == "") {

    inlineMsg('name_on_card','Please Fill The Name On Card.',2);

    return false;

  }





 if(card_number == "") {

    inlineMsg('card_number','Please Fill The Card Number.',2);

    return false;

  }





 if(CVV_number == "") {

    inlineMsg('CVV_number','Please Fill The CVV Number.',2);

    return false;

  }



 if(banner_url == "") {

    inlineMsg('banner_url','Please Fill The Banner URL.',2);

    return false;

  }



if(country1 == "" ) {

    inlineMsg('lcountry3','Please Select The Search Location .',2);

    return false;

  }

 if(state1 == "" ) {

    inlineMsg('lstate3','Please Select The Search Location .',2);

    return false;

  }

 if(city1 == "" ) {

    inlineMsg('lcity3','Please Select The Search Location .',2);

    return false;

  }





return true;

}





// Function To Validating Agent Add Form  //

function validateAddAgent(form) {

  var companyName = form.companyName.value;

  var firstName = form.firstName.value;

  var lastName = form.lastName.value;

  var website = form.website.value;

  var email = form.email.value;

  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

  var country = form.lcountry0.value;

  var state = form.lstate0.value;

  var city = form.lcity0.value;

  var zip = form.zip.value;

  var address1 = form.address1.value;

  var address2 = form.address2.value;

  var phone = form.phone.value;

  var fax = form.fax.value;

  var mobile1 = form.mobile1.value;

  var mobile1length = form.mobile1.value.length;

  var mobile2 = form.mobile2.value;

  var mobile2length = form.mobile2.value.length;

  var mobile3 = form.mobile3.value;

  var mobile3length = form.mobile3.value.length;

  var action = form.action.value;



 if(companyName == "") {

    inlineMsg('companyName','Please Fill The Company Name.',2);

    return false;

  }

  

  if(firstName == "") {

    inlineMsg('firstName','Please Fill The First Name.',2);

    return false;

  }

   if(lastName == "") {

    inlineMsg('lastName','Please Fill The Last NAme.',2);

    return false;

  }

 /* if(website == "") {

    inlineMsg('website','Please Fill The WebSite.',2);

    return false;

  }
*/
   if(email == "") {

    inlineMsg('email','Please Fill The Email Address.',2);

    return false;

  }

  if(!email.match(emailRegex)) {

    inlineMsg('email','Please Fill Valic Email address.',2);

    return false;

  }

  if(country == "") {

    inlineMsg('lcountry0','Please Fill The Country Name.',2);

    return false;

  }

 if(state == "") {

    inlineMsg('lstate0','Please Fill The State.',2);

    return false;

  }



  if(city == "") {

    inlineMsg('lcity0','Please Fill The City.',2);

    return false;

  }

 if(zip == "") {

    inlineMsg('zip','Please Fill The Zip Code.',2);

    return false;

  }

  
/*
  if(address1 == "" && address2 == "") {

    inlineMsg('address1','Please Fill The Address.',2);

    return false;

  }
*/
 if(phone == "") {

    inlineMsg('phone','Please Fill The Phone Number.',2);

    return false;

  }

  /*

  if(fax == "") {

    inlineMsg('fax','Please Fill The Fax Number.',2);

    return false;

  }
*/
/*
 if(mobile1 == "") {

    inlineMsg('mobile1','Please Fill The Mobile Number.',2);

    return false;

  }



  if(mobile1length < 3) {

    inlineMsg('mobile1','Please Fill Right Mobile Number.',2);

    return false;

  }

  if(mobile2 == "") {

    inlineMsg('mobile2','Please Fill The Mobile Number.',2);

    return false;

  }

   if(mobile2length < 3) {

    inlineMsg('mobile2','Please Fill Right Mobile Number.',2);

    return false;

  }

 if(mobile3 == "") {

    inlineMsg('mobile3','Please Fill The Mobile Number.',2);

    return false;

  }

   if(mobile3length < 4) {

    inlineMsg('mobile3','Please Fill Right Mobile Number.',2);

    return false;

  }
*/


  if(action == "Add")

  {

  	var password = form.password.value;

  	var confirmPassword = form.confirmPassword.value;

 



  if(password == "") {

    inlineMsg('password','Please Fill The Password.',2);

    return false;

  }

 if(confimrPassword == "") {

    inlineMsg('confimrPassword','Please Fill The Confirm Password.',2);

    return false;

  }



  if(confimrPassword != password) {

    inlineMsg('confimrPassword','Please Verify the Password.',2);

    return false;

  }



  }

  return true;

}



// Function To Validating Agent Add Form  //

function validateEditAgent(form) {

  var company = trim(form.companyName.value);

  var firstName = trim(form.firstName.value);

  var lastName = trim(form.lastName.value);

  var email = trim(form.email.value);

  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

  var country = trim(form.lcountry1.value);

  var state = trim(form.lstate1.value);

  var city = trim(form.lcity1.value);

  var zip = trim(form.zip.value);

  var address1 = trim(form.address1.value);

  var phone = trim(form.phone.value);

  var fax = trim(form.fax.value);

  var mobile1 = trim(form.mobile1.value);

  var mobile2 = trim(form.mobile2.value);

  var mobile3 = trim(form.mobile3.value);

  var action = trim(form.action.value);

  var listingFullDesc = trim(form.listingFullDesc.value);

  var yearFirstLicenced = trim(form.yearFirstLicenced.value);

  var personalProfessional = trim(form.personalProfessional.value);

  var specialities = trim(form.specialities.value);

  if(company == "") {

    inlineMsg('companyName','Please Fill The Company.',2);

    return false;

  }


  if(firstName == "") {

    inlineMsg('firstName','Please Fill The First Name.',2);

    return false;

  }

   if(lastName == "") {

    inlineMsg('lastName','Please Fill The Last NAme.',2);

    return false;

  }


   if(email == "") {

    inlineMsg('email','Please Fill The Email Address.',2);

    return false;

  }

  if(!email.match(emailRegex)) {

    inlineMsg('email','Please Fill Valic Email address.',2);

    return false;

  }

  if(country == "") {

    inlineMsg('lcountry1','Please Fill The Country Name.',2);

    return false;

  }

 if(state == "") {

    inlineMsg('lstate1','Please Fill The State.',2);

    return false;

  }



  if(city == "") {

    inlineMsg('lcity1','Please Fill The City.',2);

    return false;

  }

 if(zip == "") {

    inlineMsg('zip','Please Fill The Zip Code.',2);

    return false;

  }



  if(address1 == "" ) {

    inlineMsg('address1','Please Fill The Address.',2);

    return false;

  }

 if(phone == "") {

    inlineMsg('phone','Please Fill The Phone Number.',2);

    return false;

  }



  if(fax == "") {

    inlineMsg('fax','Please Fill The Fax Number.',2);

    return false;

  }

 if(mobile1 == "") {

    inlineMsg('mobile1','Please Fill The Mobile Number.',2);

    return false;

  }



  if(mobile2 == "") {

    inlineMsg('mobile2','Please Fill The Mobile Number.',2);

    return false;

  }

 if(mobile3 == "") {

    inlineMsg('mobile3','Please Fill The Mobile Number.',2);

    return false;

  }

 if(listingFullDesc == "") {

    inlineMsg('listingFullDesc','Please Fill Listing Full Description.',2);

    return false;

  }
/*
 if(yearFirstLicenced == "") {

    inlineMsg('yearFirstLicenced','Please Fill Year First Licensed.',2);

    return false;

  }

 if(personalProfessional == "") {

    inlineMsg('personalProfessional','Please Fill Personal and Professional Distinctions.',2);

    return false;

  }

 if(specialities == "") {

    inlineMsg('specialities','Please Fill Specialities.',2);

    return false;

  }
*/
  if(action == "Add")

  {

  	var password = form.password.value;

  	var confirmPassword = form.confirmPassword.value;





  if(password == "") {

    inlineMsg('password','Please Fill The Password.',2);

    return false;

  }

 if(confimrPassword == "") {

    inlineMsg('confimrPassword','Please Fill The Confirm Password.',2);

    return false;

  }



  if(confimrPassword != password) {

    inlineMsg('confimrPassword','Please Verify the Password.',2);

    return false;

  }



  }

  return true;

}


function validateSignUp(form, free) {

  var company = trim(form.companyName.value);

  var firstName = trim(form.firstName.value);

  var lastName = trim(form.lastName.value);

  var email = trim(form.email.value);

  var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

  var country = trim(form.lcountry1.value);

  var state = trim(form.lstate1.value);

  var city = trim(form.lcity1.value);

  var zip = trim(form.zip.value);

  var address1 = trim(form.address1.value);

  var phone = trim(form.phone.value);

  var fax = trim(form.fax.value);

  var mobile1 = trim(form.mobile1.value);

  var mobile2 = trim(form.mobile2.value);

  var mobile3 = trim(form.mobile3.value);

  var listingFullDesc = trim(form.listingFullDesc.value);

  var yearFirstLicenced = trim(form.yearFirstLicenced.value);

  var personalProfessional = trim(form.personalProfessional.value);

  var specialities = trim(form.specialities.value);

  var pass = trim(form.pass.value);

  var confirmPass = trim(form.confirmPass.value);


   if(email == "") {

    inlineMsg('email','Please Fill The Email Address.',2);

    //return false;

  }

  else if(!email.match(emailRegex)) {

    inlineMsg('email','Please Fill Valid Email address.',2);

    //return false;

  }

  else if(pass == "") {

    inlineMsg('pass','Please Fill The Password.',2);

   // return false;

  }

else  if(confirmPass == "") {

    inlineMsg('confirmPass','Please Fill The Confirm Password.',2);

    return false;

  }



  if(confirmPass != pass) {

    inlineMsg('confirmPass','Please Verify the Password.',2);

    return false;

  }

  if(company == "") {

    inlineMsg('companyName','Please Fill The Company.',2);

    return false;

  }


  if(firstName == "") {

    inlineMsg('firstName','Please Fill The First Name.',2);

    return false;

  }

   if(lastName == "") {

    inlineMsg('lastName','Please Fill The Last NAme.',2);

    return false;

  }



  if(country == "") {

    inlineMsg('lcountry1','Please Fill The Country Name.',2);

    return false;

  }

 if(state == "") {

    inlineMsg('lstate1','Please Fill The State.',2);

    return false;

  }



  if(city == "") {

    inlineMsg('lcity1','Please Fill The City.',2);

    return false;

  }

 if(zip == "") {

    inlineMsg('zip','Please Fill The Zip Code.',2);

    return false;

  }



  if(address1 == "" ) {

    inlineMsg('address1','Please Fill The Address.',2);

    return false;

  }

 if(phone == "") {

    inlineMsg('phone','Please Fill The Phone Number.',2);

    return false;

  }

  if(fax == "") {

    inlineMsg('fax','Please Fill The Fax Number.',2);

    return false;

  }

 if(mobile1 == "") {

    inlineMsg('mobile1','Please Fill The Mobile Number.',2);

    return false;

  }



  if(mobile2 == "") {

    inlineMsg('mobile2','Please Fill The Mobile Number.',2);

    return false;

  }

 if(mobile3 == "") {

    inlineMsg('mobile3','Please Fill The Mobile Number.',2);

    return false;

  }

 if(listingFullDesc == "") {

    inlineMsg('listingFullDesc','Please Fill Listing Full Description.',2);

    return false;

  }
/*
 if(yearFirstLicenced == "") {

    inlineMsg('yearFirstLicenced','Please Fill Year First Licensed.',2);

    return false;

  }

 if(personalProfessional == "") {

    inlineMsg('personalProfessional','Please Fill Personal and Professional Distinctions.',2);

    return false;

  }

 if(specialities == "") {

    inlineMsg('specialities','Please Fill Specialities.',2);

    return false;

  }
*/


  if (free != "yes")
  {
   if(form.nameOnCard.value == "") {

    inlineMsg('nameOnCard','Please Fill The Name On Card.',2);

    return false;

  }





 if(form.cardNo.value == "") {

    inlineMsg('cardNo','Please Fill The Card Number.',2);

    return false;

  }





 if(form.cvvNo.value == "") {

    inlineMsg('cvvNo','Please Fill The CVV Number.',2);

    return false;

  }





  }
  

  
		
  return true;
 
}


/*******   ********************************************************************

		validate function for gre Setting form fields edited by Rajeev Achra

********************************************************************************/

function validateGreSetting(form) {

/*  document.getElementById("service_article").value = FCKeditorAPI.GetInstance( 'fckeditor1' ).GetData();
  document.getElementById("privacy_policy").value = FCKeditorAPI.GetInstance( 'fckeditor2' ).GetData();
  document.getElementById("billing_terms").value = FCKeditorAPI.GetInstance( 'fckeditor3' ).GetData();
*/
  var r_submission_period 	= trim(form.r_submission_period.value);

  var promotion_code 		= trim(form.promotion_code.value);

  var expire 				= trim(form.expire.value);

//  var display_ex_add		= form.display_ex_add.checked;

//  var area_list				= trim(form.area_list.value);

  var listing_id 			= trim(form.listing_id.value);

  var sender_name 			= trim(form.sender_name.value);

  var email 				= trim(form.email.value);

  var emailRegex 			= /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

  var email_server 			= trim(form.email_server.value);

  var fax_server 			= form.fax_server.value;

  var sales_force_acc_no 	= form.sales_force_acc_no.value;

  var login 				= trim(form.login.value);

  var password 				= trim(form.password.value);

/*
  if(r_submission_period == "") {

    inlineMsg('r_submission_period','Please Fill The Resubmissions Period.',2);

    return false;

  }

   if(promotion_code == "") {

    inlineMsg('promotion_code','Please Fill The Promotion Code.',2);

    return false;

  }

  if(expire == "") {

    inlineMsg('website','Please Fill The Minimum Ad Setting Expire.',2);

    return false;

  }
  if(display_ex_add==true){

	  area_list.disabled=true;

  	if(area_list == "") {

    inlineMsg('area_list','Please Select Area Listing.',2);

    return false;

  	}

  }
*/

  if(listing_id == "") {

    inlineMsg('listing_id','Please Fill The Default Listing ID.',2);

    return false;

  }

 if(sender_name == "") {

    inlineMsg('sender_name','Please Fill The Default Sender Name.',2);

    return false;

  }

  if(email == "") {

    inlineMsg('email','Please Fill The Default Email Address.',2);

    return false;

  }

  if(!email.match(emailRegex)) {

    inlineMsg('email','Please Fill Valid Email address.',2);

    return false;

  }

  if(email_server == "") {

    inlineMsg('email_server','Please Fill The Default E-mail Server.',2);

    return false;

  }

  if(fax_server == "") {

    inlineMsg('fax_server','Please Fill The Default Fax Server.',2);

    return false;

  }

  if(sales_force_acc_no == "") {

    inlineMsg('sales_force_acc_no','Please Fill The Default Sales Force Account No.',2);

    return false;

  }

 if(login == "") {

    inlineMsg('login','Please Fill The User Login Name.',2);

    return false;

  }



  if(password == "") {

    inlineMsg('password','Please Fill The User Password.',2);

    return false;

  }


  return true;

}

//for auto email respone page

function validateemailForwardingMsg(form) {



  var page_name 		= trim(form.page_name.value);

  var title 			= trim(form.title.value);

  var user_type 		= trim(form.user_type.value);

  var email 			= trim(form.email.value);

  var email_from 		= trim(form.email_from.value);

  var optional_subject 	= trim(form.optional_subject.value);





  if(page_name == "") {

    inlineMsg('page_name','Please Select The From Page.',2);

    return false;

  }

   if(title == "") {

    inlineMsg('title','Please Fill The Title.',2);

    return false;

  }

  if(user_type == "") {

    inlineMsg('user_type','Please Select Email.',2);

    return false;

  }

  if(user_type == "other") {

	  if(email == "") {

    inlineMsg('email','Please Fill The Default Email Address.',2);

    return false;

  	}

  }

  if(email_from == "") {

    inlineMsg('email_from','Please Fill The E-mail From.',2);

    return false;

  }

  if(optional_subject == "") {

    inlineMsg('optional_subject','Please Fill The Optional Subject.',2);

    return false;

  }



  return true;

}

// for completion page

function validateCompletionResponse(form) {



  var page_name 		= trim(form.page_name.value);

  var uge_page			= trim(form.uge_page.value);

  var response_page		= trim(form.response_page.value);

  if(page_name == "") {

    inlineMsg('page_name','Please Select The From Page.',2);

    return false;

  }

  if((uge_page =="" && response_page =="")) {

	   inlineMsg('uge_page','Please Fill One Entry.',2);

    	return false;

  }

  return true;

}

function validateCountryForm(frm)
{
  return true;

}

function validateInsertCountryForm(form) {



  var country_name 		= trim(form.country_name.value);

  var ISO2 		        = trim(form.ISO2.value);

  var ISO3 		        = trim(form.ISO3.value);

  var status			= trim(form.status.value);

  if(country_name == "") {

    inlineMsg('country_name','Please Fill The Country Name.',2);

    return false;

  }

  if(ISO2 == "") {

    inlineMsg('ISO2','Please Fill The Country Name.',2);

    return false;

  }

  if(ISO3 == "") {

    inlineMsg('ISO3','Please Fill The Country Name.',2);

    return false;

  }

  if(status =="") {

	   inlineMsg('status','Please Select The Status.',2);

    	return false;

  }

  return true;

}


function validateEditCountryForm(form) {



  var country_name 		= trim(form.country_name.value);

  var status			= trim(form.status.value);

  if(country_name == "") {

    inlineMsg('country_name','Please Fill The Country Name.',2);

    return false;

  }

  if(status =="") {

	   inlineMsg('status','Please Select The Status.',2);

    	return false;

  }

  return true;

}





function validateEditCityForm(form) {



  var city_name 		= trim(form.city_name.value);

  var status			= trim(form.status.value);

  if (form.lcountry0.selectedIndex == '')
 {

    inlineMsg('lcountry0','Please select country.',2);

    return false;

  }

  if (form.lstate0.value == '')
 {

    inlineMsg('lstate0','Please select state.',2);

    return false;

  }

  if(city_name == "") {

    inlineMsg('city_name','Please Fill The City Name.',2);

    return false;

  }

  if (isNaN(parseInt(form.pop.value)))
 {

    inlineMsg('pop','Population should be a number.',2);

    return false;

  }

  if(status =="") {

	   inlineMsg('status','Please Select The Status.',2);

    	return false;

  }

  return true;

}



function validateEditStateForm(form) {



  var state_name 		= trim(form.state_name.value);

  var status			= trim(form.status.value);

  if (form.lcountry0.value == "")
 {

    inlineMsg('lcountry0','Please select country.',2);

    return false;

  }
  if(state_name == "") {

    inlineMsg('state_name','Please Fill The City Name.',2);

    return false;

  }

  if(status =="") {

	   inlineMsg('status','Please Select The Status.',2);

    	return false;

  }

  return true;

}

/*******************************************************************************

	here end my editing  (Rajeev Achra)

********************************************************************************/



// START OF MESSAGE SCRIPT //



var MSGTIMER = 60;

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, offst) {

  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;

  if (offst)
  {
     leftposition += offst;
  }

  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 * 2000));

}



// hide the form alert //

function hideMsg(msg) {

  var msg = document.getElementById('msg');

  if(msg && !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 = "msg_arrow.gif";

}

// agent profile validation coded by anil

function validateServiceAreaForm(form) {

  //var city1 = trim(form.city1.value);



 /*if(city1 == "") {

    inlineMsg('city1','Please Fill The city.',2);

    return false;

  }*/



  return true;

}



// Function To Validating Agent profile Add Form  //

function validateListingDetailForm(form) {

  var agentIdValue= trim(form.agentId.value);

  var firstName = trim(form.firstName.value);

  var lastName = trim(form.lastName.value);

  var country = trim(form.lcountry0.value);

  var state = form.lstate0.value;

  var city = form.lcity0.value;

  var zip = form.zip.value;

  /*var mobile1 = form.mobile1.value;

  var mobile1length = form.mobile1.value.length;

  var mobile2 = form.mobile2.value;

  var mobile2length =form.mobile2.value.length;

  var mobile3 = form.mobile3.value;

  var mobile3length = form.mobile3.value.length;*/

  var address1=trim(form.address1.value);

  var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;



if(agentIdValue=='')

 {

  if(firstName == "") {

    inlineMsg('firstName','Please Fill The First Name.',2);

    return false;

  }

 if(!firstName.match(nameRegex)) {

    inlineMsg('firstName','You have entered an invalid first name.',2);

    return false;

  }

   if(lastName == "") {

    inlineMsg('lastName','Please Fill The Last NAme.',2);

    return false;

  }

  if(!lastName.match(nameRegex)) {

    inlineMsg('lastName','You have entered an invalid first name.',2);

    return false;

  }

  if(country == "") {

    inlineMsg('lcountry0','Please Fill The Country Name.',2);

    return false;

  }

 if(state == "") {

    inlineMsg('lstate0','Please Fill The State.',2);

    return false;

  }



  if(city == "") {

    inlineMsg('lcity0','Please Fill The City.',2);

    return false;

  }

 if(zip == "") {

    inlineMsg('zip','Please Fill The Zip Code.',2);

    return false;

  }
/*
if(address1 == "") {

    inlineMsg('address1','Please Fill The Zip Code.',2);

    return false;

  }
*/
/*if(mobile1 == "") {

    inlineMsg('mobile1','Please Fill The Mobile Number.',2);

    return false;

  }



  if(mobile1length < 3) {

    inlineMsg('mobile1','Please Fill Right Mobile Number.',2);

    return false;

  }

  if(mobile2 == "") {

    inlineMsg('mobile2','Please Fill The Mobile Number.',2);

    return false;

  }

   if(mobile2length < 3) {

    inlineMsg('mobile2','Please Fill Right Mobile Number.',2);

    return false;

  }

 if(mobile3 == "") {

    inlineMsg('mobile3','Please Fill The Mobile Number.',2);

    return false;

  }

   if(mobile3length < 4) {

    inlineMsg('mobile3','Please Fill Right Mobile Number.',2);

    return false;

  }*/

 }

   return true;

}

//to validate billing information form

function validateBillingDetailForm(form) {

  var billing_fname = trim(form.billing_fname.value);

  var billing_lname = trim(form.billing_lname.value);

  var billing_country = form.lcountry0.value;

  var billing_state = form.lstate0.value;

  var billing_city = form.lcity0.value;

  var billing_zip = form.billing_zip.value;

    var billing_address1 = trim(form.billing_address1.value);

 /* var billing_mobile1 = form.billing_mobile1.value;

  var billing_mobile1length = form.billing_mobile1.value.length;

  var billing_mobile2 = form.billing_mobile2.value;

  var billing_mobile2length = form.billing_mobile2.value.length;

  var billing_mobile3 = form.billing_mobile3.value;

  var billing_mobile3length = form.billing_mobile3.value.length;*/

  // var nameOnCard = trim(form.nameOnCard.value);

  //var cardNo = form.cardNo.value;

  //var cvvNo = trim(form.cvvNo.value);

 // var expirationDate = trim(form.expirationDate.value);


/*
  if(billing_fname == "") {

    inlineMsg('billing_fname','Please Fill the First Name.',2);

    return false;

  }

   if(billing_lname == "") {

    inlineMsg('billing_lname','Please Fill the Last NAme.',2);

    return false;

  }



  if(billing_country == "") {

    inlineMsg('billing_country','Please Fill the Country Name.',2);

    return false;

  }

 if(billing_state == "") {

    inlineMsg('billing_state','Please Fill the State.',2);

    return false;

  }

  

  if(billing_city == "") {

    inlineMsg('billing_city','Please Fill the City.',2);

    return false;

  }

 if(billing_zip == "") {

    inlineMsg('billing_zip','Please Fill the Zip Code.',2);

    return false;

  }

 if(billing_address1 == "") {

    inlineMsg('billing_address1','Please Fill billing address.',2);

    return false;

  }



if(billing_mobile1 == "") {

    inlineMsg('billing_mobile3','Please Fill The Mobile Number.',2);

    return false;

  }



  if(billing_mobile1length < 3) {

    inlineMsg('billing_mobile3','Please Fill Right Mobile Number.',2);

    return false;

  }

  if(billing_mobile2 == "") {

    inlineMsg('billing_mobile3','Please Fill The Mobile Number.',2);

    return false;

  }

   if(billing_mobile2length < 3) {

    inlineMsg('billing_mobile3','Please Fill Right Mobile Number.',2);

    return false;

  }

 if(billing_mobile3 == "") {

    inlineMsg('billing_mobile3','Please Fill The Mobile Number.',2);

    return false;

  }

   if(billing_mobile3length < 4) {

    inlineMsg('billing_mobile3','Please Fill Right Mobile Number.',2);

    return false;

  }

if(nameOnCard == "") {

    inlineMsg('nameOnCard','Please Fill The Name On Card.',2);

    return false;

  }





 if(cardNo == "") {

    inlineMsg('cardNo','Please Fill The Card Number.',2);

    return false;

  }





 if(cvvNo == "") {

    inlineMsg('cvvNo','Please Fill The CVV Number.',2);

    return false;

  }



 if(expirationDate == "") {

    inlineMsg('expirationDate','Please Fill The Expiration Date.',2);

    return false;

  }*/

   return true;

}

//validation of agent account form

function agentAccountForm(form)

 {

	var email = trim(form.email.value);

    var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;

	var verifyEmail=trim(form.verifyEmail.value);

	var pass =trim(form.pass.value);

	var confirmPass =trim(form.confirmPass.value);

    var passValidCheck=trim(form.passValidCheck.value);



	  if(email == "") {

        inlineMsg('email','You must enter your email.',2);

        return false;

	    }

	  if(!email.match(emailRegex)) {

		inlineMsg('email','<strong>Error</strong><br />You have entered an invalid email.',2);

		return false;

	  }

	 if(verifyEmail == "") {

        inlineMsg('verifyEmail','You must enter verify email.',2);

        return false;

	    }

	 if(verifyEmail != email) {

		inlineMsg('verifyEmail','Email and verify Email are different.');

		return false;

      }	



	  if(pass == "") {

		inlineMsg('pass','You must enter password.',2);

		return false;

	  }

	  if(confirmPass == "") {

		inlineMsg('confirmPass','You must enter verify password.');

		return false;

	  }

	 if(confirmPass != pass) {

		inlineMsg('confirmPass','Password and verify Password are different.');

		return false;

     }

return true;

 }

//validation for listing detail 

function listingSettingForm(form)

 {

	var publishOn=trim(form.publishOn.value);

	var publishOff=trim(form.publishOff.value);

	if(publishOn=="")

	  {

		   inlineMsg('publishOn','you must enter publish start date');

		   return false;

	  }

   if(publishOff=="")

	  {

		   inlineMsg('publishOff','you must enter publish end date');

		   return false;

	  }

	  return true;

 }

//end of  agent profile validation coded by anil

// Function To Validating Export csv and excel Form  //

function validateExport(form) {

  var status = form.status.value;

  var detail = form.detail.value;

 if(status == "") {

    inlineMsg('status','Please Select The Agent Status.',2);

    return false;

  }

 if(detail == "") {

    inlineMsg('detail','Please Select The Export Detail.',2);

    return false;

  }

  

  return true;

}

// for  only numeric key

function isNumberKey(evt)

      {

         var charCode = (evt.which) ? evt.which : evt.keyCode ;

/*          if (charCode > 31 && charCode != 40 && charCode != 41 && charCode != 43 && charCode != 46 && (charCode < 48 || charCode > 57)) */
            if (!sNaN(parseInt(String.fromCharCode(charCode))))
            return false;



            return true;

      }

function trim(str) {

  return str.replace(/^\s+|\s+$/g, '');

}

//for check email or phone format - , . ( ) 0-9 accept

function checkPhoneMail(evt)

 {

	 var charCode = (evt.which) ? evt.which : evt.keyCode ;

     if (charCode > 31 && charCode != 40 && charCode != 41 && charCode != 43 && charCode != 44 && charCode != 45 && charCode != 46 && (charCode < 48 || charCode > 57))

            return false;

	return true;

 }



function validateTemplate(form)
{
  var title 	= trim(form.title.value);
  var path 		= trim(form.path.value);
  var min 		= trim(form.min.value);
  var desc 		= trim(form.desc.innerHTML);

if(title == "") {
    inlineMsg('title','Please Enter Title.',2);
    return false;
}

if(desc == "") {
//    inlineMsg('desc','Please Enter Description.',2);
    alert('Description must be defined');
    return false;
}


if(path == "") {
    inlineMsg('path','Please Enter Path.',2);
    return false;
}

if(isNaN(parseInt(min))) {
    inlineMsg('min','Please Enter Minimum Agents.',2);
    return false;
}
 for (cnt = 0; cnt < document.getElementsByName("files[]").length; cnt++)
 {
      if (document.getElementById("file"+cnt) && document.getElementById("file"+cnt).value == "")
      {
         inlineMsg("file"+cnt,'Please Enter File Name.',2, 50);
         return false;
      }
   }


 for (cnt = 0; cnt < document.getElementsByName("pages[]").length; cnt++)
 {
      if (document.getElementById("page"+cnt) && document.getElementById("page"+cnt).value == "")
      {
         inlineMsg("page"+cnt,'Please Enter Page Name.',2);
         return false;
      }
   }

 for (cnt = 0; cnt < document.getElementsByName("urls[]").length; cnt++)
 {
      if (document.getElementById("url"+cnt) && document.getElementById("url"+cnt).value == "")
      {
         inlineMsg("url"+cnt,'Please Enter Url.',2);
         return false;
      }
   }

}




