var d=document; 
 
 function SetCookie( Name, Value, Expire ) 
 { 
 document.cookie = Name + "=" + escape( Value ) ; 
 } 
 
 function WriteCookies() 
 { 
var d=document; 

SetCookie( "searching_for", d.getElementById('searching_for').value ); 
SetCookie( "min_bedrooms", d.getElementById('min_bedrooms').value ); 
SetCookie( "location",  d.getElementById('location').value ); 
SetCookie( "price_gt",  d.getElementById('price_gt').value ); 
SetCookie( "price_lt",  d.getElementById('price_lt').value ); 

 } 
 
  
 function GetValue( Offset ) 
 { 
 var End = document.cookie.indexOf (";", Offset); 
 if( End == -1 ) 
 End = document.cookie.length; 
  
 return unescape( document.cookie.substring( Offset, End) ); 
 } 
  
 function GetCookie( Name ) 
 { 
 var Len = Name.length; 
  
 var i = 0; 
 while( i < document.cookie.length ) 
 { 
 var j = i + Len + 1; 
 if( document.cookie.substring( i, j) == (Name + "=") ) 
 return GetValue( j ); 
 i = document.cookie.indexOf( " ", i ) + 1; 
 if( i == 0) 
 break; 
 } 
 var a = ""; 
 return a; 
 } 
 
function GetCookies() 
 { 
 var tmpsearching_for = GetCookie( "searching_for" ); 
 var tmpmin_bedrooms = GetCookie( "min_bedrooms" ); 
 var tmplocation = GetCookie( "location" ); 
 var tmpprice_gt = GetCookie( "price_gt" ); 
 var tmpprice_lt = GetCookie( "price_lt" ); 
 
 if (tmpsearching_for) {  
 d.getElementById('searching_for').value = tmpsearching_for; 
 }
 if (tmpprice_gt) { 
 d.getElementById('price_gt').value = tmpprice_gt; 
 } 
 if (tmpprice_lt) { 
 d.getElementById('price_lt').value = tmpprice_lt; 
 } 
 if (tmpmin_bedrooms) { 
 d.getElementById('min_bedrooms').value = tmpmin_bedrooms; 
 } 

  if (tmplocation) { 
 d.getElementById('location').value = tmplocation; 
 } 
   
 }