function showpic(imgno) {
  var tmp=imgno;
  document.getElementById('pic').src=tmp;
}


over = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" over";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("over"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", over);


function commify(pricetopass) {
    var Num = pricetopass;
    var newNum = "";
    var newNum2 = "";
    var count = 0;
    
    //check for decimal number
    if (Num.indexOf('.') != -1){  //number ends with a decimal point
        if (Num.indexOf('.') == Num.length-1){
            Num += "00";
        }
        if (Num.indexOf('.') == Num.length-2){ //number ends with a single digit
            Num += "0";
        }
        
        var a = Num.split("."); 
        Num = a[0];   //the part we will commify
        var end = a[1] //the decimal place we will ignore and add back later
    }
    else {var end = "";}  
 
    //this loop actually adds the commas   
    for (var k = Num.length-1; k >= 0; k--){
      var oneChar = Num.charAt(k);
      if (count == 3){
        newNum += ",";
        newNum += oneChar;
        count = 1;
        continue;
      }
      else {
        newNum += oneChar;
        count ++;
      }
   }  //but now the string is reversed!
   
  //re-reverse the string
  for (var k = newNum.length-1; k >= 0; k--){
      var oneChar = newNum.charAt(k);
      newNum2 += oneChar;
  }
   
   // add dollar sign and decimal ending from above
   newNum2 =  newNum2 + "" + end;
 return newNum2;
}




var d=document; 
 
 function SetCookie( Name, Value, Expire ) 
 { 
 document.cookie = Name + "=" + escape( Value ) ; 
 } 
 
 function WriteCookies() 
 { 
var d=document; 
SetCookie( "Country", d.getElementById('Country').value ); 
SetCookie( "Region",  d.getElementById('Region').value );
SetCookie( "PropertyType",  d.getElementById('PropertyType').value );
SetCookie( "Min_Bedrooms",  d.getElementById('Min_No_of_Bedrooms-gt').value ); 
SetCookie( "Max_Bedrooms",  d.getElementById('Max_No_of_Bedrooms-lt').value ); 
SetCookie( "Min_Price",  d.getElementById('Price-gt').value ); 
SetCookie( "Max_Price",  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 tmpCountry = GetCookie( "Country"); 
var tmpRegion = GetCookie( "Region"); 
var tmpPropertyType = GetCookie( "PropertyType"); 
var tmpMin_Bedrooms = GetCookie( "Min_Bedrooms"); 
var tmpMax_Bedrooms = GetCookie( "Max_Bedrooms"); 
var tmpMin_Price = GetCookie( "Min_Price"); 
var tmpMax_Price = GetCookie( "Max_Price"); 






 if (tmpCountry) {  
 d.getElementById('Country').value = tmpCountry; 
 }

 if (tmpRegion) { 
 d.getElementById('Region').value = tmpRegion; 
 } 

 if (tmpPropertyType) { 
 d.getElementById('PropertyType').value = tmpPropertyType; 
 } 

 if (tmpMin_Bedrooms) { 
 d.getElementById('Min_No_of_Bedrooms-gt').value = tmpMin_Bedrooms; 
 } 
   
 if (tmpMax_Bedrooms) { 
 d.getElementById('Max_No_of_Bedrooms-lt').value = tmpMax_Bedrooms; 
 } 

   
 if (tmpMin_Price) { 
 d.getElementById('Price-gt').value = tmpMin_Price; 
 } 
 
    
  if (tmpMax_Price) { 
  d.getElementById('Price-lt').value = tmpMax_Price; 
 } 
 
 

 }




