    function XHConn()
    {
    	var xmlhttp, bComplete = false;
    	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    	catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
    	catch (e) { try { xmlhttp = new XMLHttpRequest(); }
    	catch (e) { xmlhttp = false; }}}
    	if (!xmlhttp) return null;
    	this.connect = function(sURL, sMethod, sVars, fnDone, bAsynch)
    	{
   		if (!xmlhttp) return false;
    		bComplete = false;
    		sMethod = sMethod.toUpperCase();
    
    		if (bAsynch == null) bAsynch = true; //treat asynch as an optional argument
    
    		try {
   			if (sMethod == "GET")
    			{
    				xmlhttp.open(sMethod, sURL+"?"+sVars, (bAsynch == true));
    				sVars = "";
    			}
    			else
    			{
    				xmlhttp.open(sMethod, sURL, (bAsynch == true));
    				xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
    				xmlhttp.setRequestHeader("Content-Type",
    					"application/x-www-form-urlencoded");
   			}
    
    			xmlhttp.onreadystatechange = function(){
    				if (xmlhttp.readyState == 4 && !bComplete)
    				{
    					bComplete = true;
    					fnDone(xmlhttp);
    				}
    			};
    			xmlhttp.send(sVars);
    
    			/**
    			 * Firefox <= 2.0.0 doesn't fire onreadystatechange for synchronous requests.
    			 * See http://lukav.com/wordpress/2007/04/12/firefox-firebug-and-synchronos-calls-problem/
    			 */
    			var isGecko = (document.addEventListener) ? true : false;
    			try {
    				if (!bAsynch && isGecko && xmlhttp.onreadystatechange == null) {
    					bComplete = true;
    					fnDone(xmlhttp);
    					return true;
    				}
    			}
    			catch (e) { return false; }
    			/**
    			 * End synchronous request patch
    			 */
    		}
    		catch(z) { return false; }
    		return true;
    	};
   	return this;
    }





function newXMLHttpRequest() {
  var xmlreq = false;
  if (window.XMLHttpRequest) {
    // Create XMLHttpRequest object in non-Microsoft browsers
    xmlreq = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    var avers = [
      "Microsoft.XmlHttp",
      "MSXML2.XmlHttp",
      "MSXML2.XmlHttp.3.0",
      "MSXML2.XmlHttp.4.0",
      "MSXML2.XmlHttp.5.0"
    ];
    for (var i = avers.length -1; i >= 0; i--) {
      try {
        xmlreq = new ActiveXObject(avers[i]);
      } catch(e) {}
    }
    if (!xmlreq) {
      alert("Unable to create AJAX request object.");
    }
  }
  return xmlreq;
}




var ajaxdestination="";

function getdata(what,where) { // get data from source (what)
 
  if (window.XMLHttpRequest) {              
        AJAX=new XMLHttpRequest();              
      } else {                                  
        AJAX=new ActiveXObject("Microsoft.XMLHTTP");
      }
	  document.getElementById(where).innerHTML ="";
	   ajaxdestination=where;
      if (AJAX) {
         AJAX.open("GET", what, false);                             
         AJAX.send(null);
          document.getElementById(ajaxdestination).innerHTML =AJAX.responseText;
		                                 
      } else {
         return false;
      }     
 
}



function triggered() { // put data returned by requested URL to selected DIV
  if (xmlhttp.readyState == 4)
  { if (xmlhttp.status == 200) {
    document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
	
    }	
	else {
		 setTimeout ( "triggered()", 100 );

	}
  }else {
		 setTimeout ( "triggered()", 100 );

	}
}

function hideans(pass) {
var boxes = document.getElementsByTagName("div");

for(var i=0;i<boxes.length;i++) {
var boxClass = boxes[i].className;

if(boxClass.match("restodiv")) {
if(boxes[i].id.match(pass)){//if they are 'see' divs
if (document.getElementById) // DOM3 = IE5, NS6
boxes[i].style.visibility="visible";// show/hide
else
if (document.layers) // Netscape 4
document.layers[boxes[i]].display = 'visible';
else // IE 4
document.all.boxes[i].visibility = 'visible';
} else  {
	
	
	
if (document.getElementById)
{
boxes[i].innerHTML='';
boxes[i].style.visibility="hidden";

}
else
if (document.layers) // Netscape 4
document.boxes[i].visibility = 'hidden';
else // IE 4
document.all.boxes[i].visibility = 'hidden';

	

}


}
}
}





function hideDiv(elemShow,  newhtml, editlinkname) {
if (document.getElementById) { // DOM3 = IE5, NS6

document.getElementById(editlinkname).href='javascript:showDiv(\''+elemShow+'\',\''+newhtml+'\',\''+editlinkname+'\')';
document.getElementById(elemShow).style.visibility = 'hidden';
getdata('',elemShow);



}
else {
if (document.layers) { // Netscape 4
document.elemShow.visibility = 'hidden';
}
else { // IE 4
document.all.elemShow.style.visibility = 'hidden';
}
}
}

function showDiv(elemShow, newhtml, editlinkname) {
if (document.getElementById) { // DOM3 = IE5, NS6
hideans(elemShow);
document.getElementById(elemShow).style.visibility = 'visible';
getdata(newhtml,elemShow);
document.getElementById(editlinkname).href='javascript:hideDiv(\''+elemShow+'\',\''+newhtml+'\',\''+editlinkname+'\')';

}
else {
if (document.layers) { // Netscape 4
document.elemShow.visibility = 'visible';
}
else { // IE 4
document.all.elemShow.style.visibility = 'visible';
}
}
}


function check(elemshow)
  {
	if   (document.getElementById(elemshow).checked) 
	{
	document.getElementById(elemshow).value='yes';
	}
	else {
		document.getElementById(elemshow).value='non';
	}
  
  }



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}

function getdatawithselect(what,where,elementid) { // get data from source (what)
 rowselect=document.getElementById(elementid);

if (rowselect.className.indexOf("selected") != -1) {
					//this.className = this.oldClassName;
					rowselect.className = "";
}
else { addClass(rowselect,"selected");
}

 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }

 document.getElementById(where).innerHTML ="";
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 ajaxdestination=where;
 xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
 xmlhttp.open("GET", what);
 xmlhttp.send(null);
  return false;
}

function stripeTables() {
	var tbodies = document.getElementsByTagName("tbody");
	for (var i=0; i<tbodies.length; i++) {
		var odd = true;
		var rows = tbodies[i].getElementsByTagName("tr");
		for (var j=0; j<rows.length; j++) {
			if (odd == false) {
				odd = true;
			} else {
				addClass(rows[j],"odd");
				odd = false;
			}
		}
	}
}
function highlightRows() {
  if(!document.getElementsByTagName) return false;
  var tbodies = document.getElementsByTagName("tbody");
  for (var j=0; j<tbodies.length; j++) {
     var rows = tbodies[j].getElementsByTagName("tr");
     for (var i=0; i<rows.length; i++) {
           rows[i].oldClassName = rows[i].className
           rows[i].onmouseover = function() {
              if( this.className.indexOf("selected") == -1)
                 addClass(this,"highlight");
           }
           rows[i].onmouseout = function() {
              if( this.className.indexOf("selected") == -1)
//                 this.className = this.oldClassName
				  this.className = "";
           }
     }
  }
}



function Deselectallrow(bodyindex)
{
  // var tbodies = document.getElementsByTagName("tbody");
   	var tbodies = document.getElementById(bodyindex);
	//for (var j=0; j<tbodies.length; j++) {
//		var rows = tbodies[j].getElementsByTagName("tr");
		var rows = tbodies.getElementsByTagName("tr");
		for (var i=0; i<rows.length; i++) {
    		rows[i].className = "";

		}
	
	//}	
}


function lockRow() {
	var tbodies = document.getElementsByTagName("tbody");

	
	for (var j=0; j<tbodies.length; j++) {
		var rows = tbodies[j].getElementsByTagName("tr");
		for (var i=0; i<rows.length; i++) {
			
			rows[i].oldClassName = rows[i].className
			rows[i].onclick = function() {
				if (this.className.indexOf("selected") != -1) {
					//this.className = this.oldClassName;
					this.className = "";
					
					
					getdata('loadfiltername.php?id='+this.id+'&isadd=0',"divmetro");
					 
					getdata('loadfilternamecuisine.php?id='+this.id+'&isadd=0',"divcuisine");
					 
					
					getdata('loadfilter.php?id='+this.id+'&isadd=0',"restoResultRow");
					
					
					
				} else {
					
					Deselectallrow("bodydistrict");
					getdata('loadfilternameclear.php?typefilter=0',"divrandomresto");
					addClass(this,"selected");
	       		    
					 getdata('loadfiltername.php?id='+this.id+'&isadd=1',"divmetro");
					
					 getdata('loadfilternamecuisine.php?id='+this.id+'&isadd=1',"divcuisine");
					 
					 
					
					 
					 
				    getdata('loadfilter.php?id='+this.id+'&isadd=1',"restoResultRow");
					 
					// getdata('searchadvert.php',"divrandomresto");
					 
					//window.location='loadfilter.php?id='+this.id+'&isadd=1';
				    
				}
				

			}
		}
	
	}
}

function lockRowMetro() {
	var tbodies = document.getElementsByTagName("tbody");
	
	for (var j=0; j<tbodies.length; j++) {
		var rows = tbodies[j].getElementsByTagName("tr");
		for (var i=0; i<rows.length; i++) {
			
			rows[i].oldClassName = rows[i].className
			rows[i].onclick = function() {
				if (this.className.indexOf("selected") != -1) {
					//this.className = this.oldClassName;
					this.className = "";
				   getdata('loadfilternamecuisine.php?id='+this.id+'&isadd=0',"divcuisine");
					getdata('loadfilter.php?id='+this.id+'&isadd=0',"restoResultRow");
					//getdata('searchadvert.php',"divrandomresto");
					//window.location='loadfilter.php?id='+this.id+'&isadd=0';
					
				} else {
					Deselectallrow("bodymetro");
					getdata('loadfilternameclear.php?typefilter=1',"divrandomresto");
					
					addClass(this,"selected");
	       		   
				     getdata('loadfilternamecuisine.php?id='+this.id+'&isadd=1',"divcuisine");
				     getdata('loadfilter.php?id='+this.id+'&isadd=1',"restoResultRow");
					// getdata('searchadvert.php',"divrandomresto");
					//window.location='loadfilter.php?id='+this.id+'&isadd=1';
				    
				}
				

			}
		}
	
	}
}


function lockRowCuisine() {
	var tbodies = document.getElementsByTagName("tbody");
	
	for (var j=0; j<tbodies.length; j++) {
		var rows = tbodies[j].getElementsByTagName("tr");
		for (var i=0; i<rows.length; i++) {
			
			rows[i].oldClassName = rows[i].className
			rows[i].onclick = function() {
				if (this.className.indexOf("selected") != -1) {
					//this.className = this.oldClassName;
					this.className = "";
				
					getdata('loadfilter.php?id='+this.id+'&isadd=0',"restoResultRow");
				//	getdata('searchadvert.php',"divrandomresto");
					//window.location='loadfilter.php?id='+this.id+'&isadd=0';
					
				} else {
						Deselectallrow("bodycuisine");
					getdata('loadfilternameclear.php?typefilter=2',"divrandomresto");
					addClass(this,"selected");
	       		   
				 
				     getdata('loadfilter.php?id='+this.id+'&isadd=1',"restoResultRow");
					// getdata('searchadvert.php',"divrandomresto");
					//window.location='loadfilter.php?id='+this.id+'&isadd=1';
				    
				}
				

			}
		}
	
	}
}

addLoadEvent(highlightRows);
//addLoadEvent(lockRow);


