// JavaScript Document for Search Results Page.
function _uTrim(s) {
  if (!s || s=="") return "";
  while ((s.charAt(0)==' ') || (s.charAt(0)=='\n') || (s.charAt(0,1)=='\r')) s=s.substring(1,s.length);
  while ((s.charAt(s.length-1)==' ') || (s.charAt(s.length-1)=='\n') || (s.charAt(s.length-1)=='\r')) s=s.substring(0,s.length-1);
  return s;
}

function get_file(url, div) {
document.getElementById(div).innerHTML="<img src=images/pw.gif>";
	new Ajax(url, {	method: 'get', update: $(div)}).request();
}

function send_to_friend_listing_aj(listid, action_, ltype) {
 if(listid=='') {
   return false;
 }
 
 if(action_ == 'prepare') {
	get_file('stf_util_box.php?id='+listid+'&action='+action_+'&type='+ltype, 'box_'+listid);
 }
 
 if(action_ == 'send') {
    if(document.getElementById('txtfriendmail' + listid).value=='') {
       document.getElementById('stfmsg'+listid).innerHTML='No empty fields';
       return false; 
    }

  if(document.getElementById('txtyourname' + listid).value=='') {
     document.getElementById('stfmsg'+listid).innerHTML='No empty fields';
     return false; 
  }

  var femail = document.getElementById('txtfriendmail' + listid).value;
  var yname = document.getElementById('txtyourname' + listid).value;

  get_file('stf_util_box.php?id='+listid+'&femail='+femail+'&yname='+yname+'&action=send&type='+ltype, 'box_'+listid);
 }
}

function add_to_favorite_listings_aj(userid, listid, action_, ltype) {
if(listid=='') {
   return false;
}

if(action_ == 'prepare') {
   get_file('add_to_fav_util_box.php?id='+listid+'&userid='+userid+'&action='+action_+'&type='+ltype, 'box_'+listid);
}

if(action_ == 'add') {
   if(document.getElementById('txtfavname' + listid).value=='') {
      document.getElementById('stfmsg'+listid).innerHTML='Please name this listing!';
      return false; 
   }
   var lname = document.getElementById('txtfavname' + listid).value;
   get_file('add_to_fav_util_box.php?id='+listid+'&userid='+userid+'&lname='+lname+'&action='+action_+'&type='+ltype, 'box_'+listid);
} // end action
} // end func

function add_to_favorite_searches (userid, crturl, num, fsql) {
var name = document.getElementById("txtname").value;
if(name=='') {
     errmsg="Please enter name";
     document.getElementById('fnme').innerHTML=errmsg;
     return 0;
  }
if(userid=='') {
     errmsg="Please Login or <a href=signup.php>Sign Up!</a>";
     document.getElementById('fnme').innerHTML=errmsg;
     return 0;
  }   
var cr = document.getElementById("iscroneoen").checked;
var iscrone = '0';
if(cr==true) {
   iscrone = '1';
} else {
   iscrone = '0';
}
  get_file('favor_search_util.php?name='+name+'&userid='+userid+'&clk='+crturl+'&num='+num+'&fsql='+fsql+'&iscron='+iscrone, 'fnme');
}
function search_next(s) {
document.getElementById("s").value = s;
document.forms.frmsearchresult.action = "sresults.php";
document.forms.frmsearchresult.submit();
}


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 fcr(s) {
var HTMLObject=document.getElementById('fcron');

     if (HTMLObject) 
          {
          var Open = HTMLObject.style.display;
          // 
          if (s==0) {
		     HTMLObject.style.visibility="hidden";
		  } else {
		     document.getElementById("fcron").style.display="block";
			 //get_file('cities_list.php?cid='+cid+'&cntid='+cntid, 'cities');
		     HTMLObject.style.display="block";
             HTMLObject.style.visibility="visible";
		  }
          }
}

