// W2Search Javascript
// Florian Roth
// 2010

var q_fresh = 1;
var p_fresh = 1;
var s_fresh = 1;
var count = 0;

function doDropDown() {
   count = count+1;
   setTimeout("doDropDownGo("+count+")",2000);
}

function doDropDownGo(currCount) {
   if(currCount == count) {
      	count = 0;
	showResult();
   }	
}

function showResult() {

var str = document.getElementById("query").value;
var price = document.getElementById("price").value;
var size = document.getElementById("size").value;

if ( str.length<4 && price.charAt(0) == 'z' && ! str.match(/[0-9]+/) )
  { 
  //document.getElementById("main_content").innerHTML="";
  //document.getElementById("main_content").style.border="0px";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("main_content").style.opacity=1;
    document.getElementById("main_content").innerHTML=xmlhttp.responseText;
    document.getElementById("loadimage").innerHTML="";
    }
  }
document.getElementById("loadimage").innerHTML="<img src=\"/wrap/w2search/loading.gif\" />";
xmlhttp.open("GET","/wrap/w2search/livesearch.php?q="+str+"&p="+price+"&s="+size,true);
xmlhttp.send();
document.getElementById("main_content").style.opacity=0.5;
}

function clicked(id) {
	
	if ( id == "query" && q_fresh > 0 ) { 
		document.getElementById("query").value = "";
		document.getElementById("query").style.color = '#000000';
		q_fresh = 0; 
	}
	if ( id == "price" && p_fresh > 0) { 
		document.getElementById("price").value = "";
		document.getElementById("price").style.color = '#000000';
		p_fresh = 0; 
	}
	if ( id == "size" && s_fresh >0 ) { 
		document.getElementById("size").value = "";
		document.getElementById("size").style.color = '#000000';
		s_fresh = 0; 
	}

}

function showhelp() {
	document.getElementById("main_content").innerHTML = "<iframe border=\"0\" src=\"http://www.tierralinda.de/live-suche-hilfe.html\"></iframe>";
}


