function allTrim(s) {
    for(i=0;i<s.length;i++) {
	if(s.charAt(i)!=' ') {
	     break;
	}
    }
    s = s.substr(i)
    if(s.length>0) {
	for(i=s.length-1,j=0;i>=0;i--,j++) {
	    if(s.charAt(i)!=' ') {
		break;
	    }
	}
	s=s.substr(0,s.length-j)
    }
    return s;
}

function showhide(v)
{
  var s=document.getElementById(v);
  //alert(s.style.display);
  if(s.style.display=="none")
  {
    s.style.display="inline";
    return true;
  }
  else
  {
    s.style.display="none";
    return true;
  }
  return false;

}


function change_language() {
	document.languagefrm.submit();
}

function popupWindow(url){
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=550,screenX=100,screenY=100,top=100,left=100');
}

    function agreecheck(){
        if(document.agree.f_terms.checked==false){
        alert('You Must Agree to the Terms and Conditions before Proceeding');
        return false;
          }
        else if(document.agree.f_age.checked==false){
        alert('You Must be Over 18  before Proceeding');
        return false;
        }
        else
        return true;
    }
    
    function forgotpass(){
        if(document.forgot.f_email.value==''){
        alert('Email Address required to send the Password');
        document.forgot.f_email.focus();
        return false;
        }
        else
        return true;
    }
    
    function checklogin(){

      if(document.login.f_username.value==''){
        alert('Enter Your Username to Login');
        document.login.f_username.focus();
        return false;
      }
        else if(document.login.f_password.value==''){
        alert('Enter Your password to Login');
        document.login.f_password.focus();
        return false;
      }
      else
      return true;
    }
    
    function checkemail(){
        if(document.emailchg.f_email.value==''){
        alert('Email id should not be empty');
        document.emailchg.f_email.focus();
        return false;
      }
        else
        return true;
    }
    
      function checkpwd(){
        if(document.pwdchg.f_oldpass.value==''){
        alert('You have to enter your old password');
        document.pwdchg.f_oldpass.focus();
        return false;
      }
        else if(document.pwdchg.f_newpass.value==''){
        alert('You have to enter your New password');
        document.pwdchg.f_newpass.focus();
        return false;
       }
        else if(document.pwdchg.f_newpass.value!=document.pwdchg.f_confpass.value){
        alert('New password and Confirmation password mismatches');
        document.pwdchg.f_newpass.focus();
        return false;
       }

        else
        return true;
    }
function check_compose()
{

  if(document.mailbox.f_subject.value=="")
  {
    alert("Message subject should not be empty");
    document.mailbox.f_subject.focus();
    return false;
  }

  if(document.mailbox.f_message.value=="")
  {
    alert("Message content should not be empty");
    document.mailbox.f_message.focus();
    return false;
  }
  return true;
}

function check_send_mail(){

  if(document.mailbox.f_tousername.value==""){
    alert("To Username should not be empty");
    document.mailbox.f_tousername.focus();
    return false;
  }


  if(document.mailbox.f_subject.value==""){
    alert("Message subject should not be empty");
    document.mailbox.f_subject.focus();
    return false;
  }

  if(document.mailbox.f_message.value=="")
  {
    alert("Message content should not be empty");
    document.mailbox.f_message.focus();
    return false;
  }
  return true;
}

function check_reply_mail(){

  if(document.mailbox.f_subject.value==""){
    alert("Message subject should not be empty");
    document.mailbox.f_subject.focus();
    return false;
  }

  if(document.mailbox.f_message.value=="")
  {
    alert("Message content should not be empty");
    document.mailbox.f_message.focus();
    return false;
  }
  return true;
}

function assignprocess(a){
document.form.pro.value=a;
form.submit();
}

function selectall(form){
         count=form.elements.length;
             for (i=0;i<count;i++){
                 if(form.elements[i].name == 'f_selchk[]')
                 {
                    form.elements[i].checked=true;
                 }
              }
}

function deselectall(){
      count=document.form.elements.length;
              for (i=0;i<count;i++){
                 if(document.form.elements[i].name == 'f_selchk[]'){
                    document.form.elements[i].checked=false;
                 }
             }
}


function form_check(){

       flagmail=false;
       count=document.form.elements.length;
         for (i=0;i<count;i++){
             if(document.form.elements[i].name == 'f_selchk[]')    {
                if(document.form.elements[i].checked==true) {
                  flagmail=true;
                  break;
                }
             }
         }
         
        if (flagmail==false) {
        alert ("Select atleast one Message");
        flag=false;
        return flag;
        }
        else{
        form.submit();
        }
}

function textCounter(field, maxlimit) {
    if (field.value.length >= maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    }
}

function textCounterUpdate(fieldName, maxlimit) {
    field = document.getElementById(fieldName+'_txt');
    txt_field = document.getElementById(fieldName+'_char_count');
    txt_field.innerText = field.value.length;
    txt_field.innerHTML = field.value.length;
    textCounter(field, maxlimit);
}
function descWordCount(fieldName, init) {
    if (!init) {
        textCounterUpdate(fieldName, 1500);
    } else {
        document.write("Your message contains <b id=\""+fieldName+"_char_count\">0</b> characters.");
    }
}

function check_change_city(){
  if(document.form.f_countryid.value=="0"){
    alert("You have to select a Country");
    return false;
  }
  if(document.form.f_stateid.value=="0"){
    alert("You have to select a State");
    return false;
  }
    if(document.form.f_cityid.value=="0"){
    alert("You have to select a city");
    return false;
  }
  return true;
}

function check_party_add(){
  if(document.form.f_countryid.value=="0"){
    alert("You have to select a Country");
    return false;
  }
  if(document.form.f_stateid.value=="0"){
    alert("You have to select a State");
    return false;
  }
  if(document.form.f_cityid.value=="0"){
    alert("You have to select a city");
    return false;
  }
  if(document.form.f_partytitle.value==""){
    alert("You have to enter the Party title");
    document.form.f_partytitle.focus();
    return false;
  }
  if(document.form.f_partydesc.value==""){
    alert("You have to enter the Party title");
    document.form.f_partydesc.focus();
    return false;
  }
  document.form.pro.value='';
  return true;
}

function check_video_add(){
  if(document.videofrm.f_videoname.value==""){
    alert("You have to enter a Name to Your file");
    document.videofrm.f_videoname.focus();
    return false;
  }
  if(document.videofrm.f_videofile.value==""){
    alert("You have to select a file to Upload");
    return false;
  }
  return true;
}

function check_audio_add(){
  if(document.audiofrm.f_audioname.value==""){
    alert("You have to enter a Name to Your file");
    document.audiofrm.f_audioname.focus();
    return false;
  }
  if(document.audiofrm.f_audiofile.value==""){
    alert("You have to select a file to Upload");
    return false;
  }
  return true;
}

function searchval(){

  if(document.form.f_fromage.value > document.form.f_toage.value ){
    alert("To age cannot be lesser than the From age");
    return false;
  }
  if(document.form.f_frmheight.value > document.form.f_toheight.value ){
    alert("To height cannot be lesser than the From height");
    return false;
  }
  
  return true;
}

function check_promemsel(){
  k=0;
  
  if(document.form1.f_memid.length > 1){

    for(i=0;i<document.form1.f_memid.length;i++){
      if(document.form1.f_memid[i].checked)
        k=1;
      }
  }else {
    if(document.form1.f_memid.checked)
    k=1;
  }
  if(k==0){
    alert("Please select a Membership Plan");
    return false;
  }
  else{
    document.form1.submit();
  }
}

function sbClock() {
 self.status=(new Date()).toString().substring(0,19);
 setTimeout("sbClock()",200);
}

function createCookie(name,value,days){
 if(days) {
  var date = new Date();
  date.setTime(date.getTime()+(days*24*60*60*1000));
  var expires = "; expires="+date.toGMTString();
 }
 else var expires = "";
 document.cookie = name+"="+value+expires+"; path=/";
}

function confirmdel() {
    return confirm('Are You sure to Delete?');
}

function showUpload(id,img){

  t1 = window.open("modules.php?name=view_image&id="+id+"&img="+img,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=500");
		t1.focus();


}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function LTrim(str){
	var whitespace = new String(" \t\n\r");
	var s	         = new String(str);

	if(whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
		while ( j < i && whitespace.indexOf(s.charAt(j)) != -1)
		j++;
		        s  = s.substring(j,i);
	}
	return s;
}

function RTrim(str){

	var whitespace = new String(" \t\n\r");
	var s	         = new String(str);

	if(whitespace.indexOf(s.charAt(s.length -1)) != -1) {
		var i = s.length - 1;
		while( i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
		    i--;
			s = s.substring(0, i+1);
	}
	return s;
}

function Trim(str){

	return RTrim(LTrim(str));
}

function echeck(str) {

	var at = "@"
	var dot = "."
	var lat = str.indexOf(at)
	var lstr = str.length
	var ldot = str.indexOf(dot)
	if(str.indexOf(at) == -1){
		alert("Invalid Email Id");
		return false
	}

	if(str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr){
		alert("Invalid Email Id");
		return false
	}
	if(str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr){
		alert("Invalid Email Id");
		return false
	}
	if(str.indexOf(at,(lat+1)) != -1){
		alert("Invalid Email Id");
		return false
	}
	if(str.substring(lat-1,lat) == dot || str.substring(lat+1,lat+2) == dot){
		alert("Invalid Email Id");
		return false
	}
	if(str.indexOf(dot,(lat+2)) == -1){
		alert("Invalid Email Id");
		return false
	}
	if(str.indexOf(" ") != -1){
		alert("Invalid Email Id");
		return false
	}
	return true
}

function escort_list(frm){

	var f_name 	= frm.f_name.value;
	var f_pass 	= frm.f_pass.value;
	var f_pass1 = frm.f_pass1.value;	

	var f_email	= frm.f_email.value;
	var f_gender = frm.f_gender.value;
	var f_web 	= frm.f_web.value;


 var url_filter  ="/^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)$/";


	if(Trim(f_name) == ""){
		alert("Please enter the  name of the escort");
		frm.f_name.focus();
		return false;
	}
	if(Trim(f_pass) == ""){
        	alert("Please enter the password for the escort");
	        frm.f_pass.focus();
	        return false;
    	}
	if(Trim(f_pass1) == ""){
        	alert("Please enter the confirm password");
	        frm.f_pass1.focus();
	        return false;
	}
	if(f_pass != f_pass1){
        	alert("Please enter correct confirm password");
	        frm.f_pass.focus();
	        return false;
	}


	
	if(Trim(f_email) == ""){
		alert("Please enter the escort email address");
		frm.f_email.focus();
		return false;
	}
	if(echeck(f_email) == false){
		frm.f_email.value = " ";
		frm.f_email.focus();
		return false;
	}
	if(Trim(f_gender) == "0"){
                alert("Please select any one gender");
                frm.f_gender.focus();
                return false;
        }
	
     if(frm.captcha_avail.value=="1"){
       if(frm.f_captcha.value ==""){
            alert("Validation Code should not be empty");
	      	frm.f_captcha.focus();
	       	return false;


       }
     }

}


function agency_list(frm){

    var f_agencyName   = frm.f_agencyName.value;
    var f_pass = frm.f_pass.value;
    var f_pass1 = frm.f_pass1.value;
    var nameClient     = frm.nameClient.value;
    var f_agencyEmail  = frm.f_agencyEmail.value;
    var f_agencyWeb    = frm.f_agencyWeb.value;
    var f_linkurl      = frm.f_linkurl.value;
    var f_agency_banner= frm.f_agency_banner.value;
//    var url_filter  = /^(file|http):\/\/\S+\.(com|net|org|info|biz|ws|us|tv|cc|in|uk|sg)$/;
  var url_filter  ="/^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)$/";


	if(Trim(f_agencyName) == ""){
		alert("Please enter the agency name");
		frm.f_agencyName.focus();
		return false;
	}
	if(Trim(f_pass) == ""){
     	   	alert("Please enter the password for the agency");
        	frm.f_pass.focus();
       		return false;
        }
        if(Trim(f_pass1) == ""){
    		alert("Please enter the confirm password");
        	frm.f_pass1.focus();
        	return false;
        }
        if(f_pass != f_pass1){
        	alert("Please enter correct confirm password");
        	frm.f_pass.focus();
        	return false;
    	}
	if(Trim(nameClient) == ""){
                alert("Please enter the Client name");
                frm.nameClient.focus();
                return false;
        }
	if(Trim(f_agencyEmail) == ""){
                alert("Please enter the agency email");
                frm.f_agencyEmail.focus();
                return false;
        }
        if(echeck(f_agencyEmail) == false){
                frm.f_agencyEmail.value = " ";
                frm.f_agencyEmail.focus();
                return false;
        }
	if(Trim(f_agencyWeb) == ""){
		alert("Please enter the agency Web");
		frm.f_agencyWeb.focus();
		return false;
	}
	if (!url_filter.test(frm.f_agencyWeb.value)) {
		alert("Agency Web address should be a valid one");
		frm.f_agencyWeb.focus();
		return false;
        }


	if(Trim(f_linkurl) == ""){

                alert("Please enter the link back url");
                frm.f_linkurl.focus();
                return false;
        }
	 else if(!url_filter.test(frm.f_linkurl.value)){
		alert("Agency link back url should be a valid one");
                frm.f_linkurl.focus();
                return false;
        }

     if(frm.captcha_avail.value=="1"){
       if(frm.f_captcha.value ==""){
            alert("Validation Code should not be empty");
	      	frm.f_captcha.focus();
	       	return false;


       }
     }

	else{
		return true;
	}

}
function webserv_list(frm){

    var clientEmail    = frm.clientEmail.value;
    var f_pass         = frm.f_pass.value;
    var f_pass1        = frm.f_pass1.value;
    var f_busi_web     = frm.f_busi_web.value;
    var f_linkurl      = frm.f_linkurl.value;
    var f_banner       = frm.f_banner.value;



	if(Trim(clientEmail) == ""){
		alert("Please enter the email address");
		frm.clientEmail.focus();
		return false;
	}
	if(echeck(clientEmail) == false){
		frm.clientEmail.value = " ";
		frm.clientEmail.focus();
		return false;
	}
   if(Trim(f_pass) == ""){
     	alert("Please enter the password for the weblink");
      	frm.f_pass.focus();
      	return false;
   }
   if(Trim(f_pass1) == ""){
    	alert("Please enter the confirm password");
      	frm.f_pass1.focus();
      	return false;
   }
   if(f_pass != f_pass1){
     	alert("Please enter correct confirm password");
       	frm.f_pass1.focus();
       	return false;
   }

   if(Trim(f_busi_web) == ""){
  	    alert("Please enter the Web Address");
		frm.f_busi_web.focus();
		return false;
   }
   if(isURL(f_busi_web) == false){
		alert("Please enter the Web Address");
  	    frm.f_busi_web.value = " ";
		frm.f_busi_web.focus();
		return false;
   }
   if(Trim(f_linkurl) == ""){
  	    alert("Please enter the Link Url");
       	frm.f_linkurl.focus();
		return false;
   }
   if(isURL(f_linkurl) == false){
		alert("Please enter the valid Link Url");
  	    frm.f_linkurl.value = " ";
		frm.f_linkurl.focus();
		return false;
   }

  if(frm.captcha_avail.value=="1"){
       if(frm.f_captcha.value ==""){
            alert("Validation Code should not be empty");
	      	frm.f_captcha.focus();
	       	return false;
       }
  }
  else{
		return true;
	}

}

function isURL(s) {
 	var regexp = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
 	//alert(regexp.test(s));
 	return regexp.test(s);
}


function banner_new1(frm)
{

        var text    		= frm.text.value;
        var email  		  	= frm.email.value;
        var link_url	 	= frm.link_url.value;
        var password		= frm.password.value;
	    var pic1     		= frm.pic1.value;	 
	    var f_pos   		= frm.f_pos.value;
	    var display_page  	= frm.display_page.value;

       var ExtArray = new Array(2);
       ExtArray[0] = '.jpg';
       ExtArray[1] = '.JPG';
       ExtArray[2] = '.PNG';
       ExtArray[3] = '.png';
       ExtArray[4] = '.gif';
       ExtArray[5] = '.GIF';


       if(Trim(text) == ""){
          alert("Please enter Banner text");
          frm.text.focus();
          return false;
       }
       if(Trim(email)==""){
         alert("Please Enter Email Address");
         frm.email.focus();
         return false;
       }
       if(echeck(email)==false){
          frm.email.value="";
          frm.email.focus();
          return false;
       }
       if(Trim(link_url) ==""){
          alert("Please enter the web url");
          frm.link_url.focus();
          return false;
       }
       if(!isURL(frm.link_url.value)) {
	     alert("Banner Web address should be a valid one");
		 frm.link_url.focus();
		 return false;
       }
      if(Trim(password) ==""){
          alert("Please enter the password");
          frm.password.focus();
          return false;
     }

        if(pic1==""){
          alert("Please select your favourite image")
          frm.pic1.focus();
          return false;
        }
     if(display_page=="0"){
          alert("Please select your banner display page")
          frm.display_page.focus();
          return false;
        }
	if(f_pos=="0"){
          alert("Please select your banner position")
          frm.f_pos.focus();
          return false;
        }
        
     
   

    if(frm.captcha_avail.value=="1"){
           if(frm.f_captcha.value ==""){
            alert("Validation Code should not be empty");
	      	frm.f_captcha.focus();
	       	return false;


       }
     }
}

function check_form(frm){
	if(Trim(frm.f_description.value) == ""){

                alert("Message Content should not be empty");
                frm.f_description.focus();
                return false;
     }
     if(frm.captcha_avail.value=="1"){
       if(frm.f_captcha.value ==""){
            alert("Validation Code should not be empty");
	      	frm.f_captcha.focus();
	       	return false;


       }
     }

	else{
		return true;
	}

}

function MM_swapImgRestore(){

  var i,x,a=document.MM_sr;
     for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages(){
        var d=document;
	if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function list(frm){


    var searchname     = frm.searchname.value;

      if((searchname) == ""){
		alert("Please enter the name");
		frm.searchname.focus();
		return false;
	}
	else{
      return true;
 }
}

t_url = document.location.href;
xend = t_url.lastIndexOf("/") + 1;
var base_url = t_url.substring(0, xend);
var sArray = new Object;
sArray[0] = new Image;
sArray[0].src = base_url+"escorts_images/star.jpg";
for (var i=1; i<6; i++) {
	sArray[i] = new Image();
	sArray[i].src = base_url+"escorts_images/star_" + i + ".jpg";
}
var starTimer;
function showStars(starNum) {
	clearStarTimer();
	greyStars();
	colorStars(starNum);
}
function colorStars(starNum) {

	for (var i=1; i <= starNum; i++) {
		var tmpStar = document.getElementById('star_' + i);
		tmpStar.src = sArray[starNum].src;
	}
}
function greyStars() {
	for (var i=1; i<6; i++) {
		var tmpStar = document.getElementById('star_' + i);
		tmpStar.src = sArray[0].src;
	}
}
function setStars(starNum) {
  	clearStarTimer();
	var rating = document.getElementById('rating');
	var rate = document.getElementById('f_rate');
	rate.value = starNum;
	rating.value = starNum;
	showStars(starNum);
}
function clearStars() {
	starTimer = setTimeout("resetStars()", 300);
}
function resetStars() {
	clearStarTimer();
	var rating = document.getElementById('rating');
	if (rating.value != '') {
		setStars(rating.value);
	} else {
		greyStars();
	}
}
function clearStarTimer() {
	if (starTimer) {
		clearTimeout(starTimer);
		starTimer = null;
	}
}


function review_form(frm){

	var escort_name 	= frm.escort_name.value;
	var location 	    = frm.location.value;
	var f_rate   	= frm.f_rate.value;
	var content    =frm.content.value;

	if(Trim(escort_name) == ""){
		alert("Please enter the reviewer name");
		frm.escort_name.focus();
		return false;
	}
	if(Trim(location) == ""){
        	alert("Please enter the location");
	        frm.location.focus();
	        return false;
    	}

	if(Trim(f_rate) == ""){
		alert("Please enter the rating");
		frm.f_rate.focus();
		return false;
	}
	if(Trim(content) == ""){
		alert("Please enter the content");
		frm.content.focus();
		return false;
	}
	 return true;
}


