﻿var xmlHttp

function showResult_livesearch(str,sprache,color,country)
{

if (str.length==0)
{ 
  document.getElementById("livesearch").
  innerHTML="";
  document.getElementById("livesearch").
  style.border="none";
  document.getElementById("livesearch").
  style.backgroundColor="transparent";
  return
}

xmlHttp=GetXmlHttpObject_livesearch()

if (xmlHttp==null)
{
  alert ("HTTP-Request Fehler")
  return
} 


if (sprache == "DE") {
  document.getElementById("livesearch").
  innerHTML="<div id='searchvorschlag'>Suchresultate werden gesucht...</div><div><img src='http://41shirts.com/images/loading_ajax.gif' width='24px' height='24' /></div>";
}
else {
  document.getElementById("livesearch").
  innerHTML="<div id='searchvorschlag'>Loading searchresults...</div><div><img src='http://41shirts.com/images/loading_ajax.gif' width='24px' height='24' /></div>";
}

document.getElementById("livesearch").
style.border="1px solid rgb(180,180,180)";
document.getElementById("livesearch").
style.backgroundColor="rgb(255,255,255)";


var url="http://41shirts.com/livesearch.php"
url=url+"?q="+str
url=url+"&sprache="+sprache
url=url+"&color="+color
url=url+"&country="+country
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged_livesearch 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function stateChanged_livesearch() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("livesearch").
innerHTML=xmlHttp.responseText;
document.getElementById("livesearch").
style.border="1px solid rgb(180,180,180)";
document.getElementById("livesearch").
style.backgroundColor="rgb(255,255,255)";
} 
}

function GetXmlHttpObject_livesearch()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

//Schreibt den Wert/Parameter ins Feld, wird beim Klick auf ein Ergebnis aufgerufen
function setValueInSearchField (wert) {
    document.getElementById ('searchfield').value = wert;
}







function showResult_ok(str,sprache,color,country)
{

  if (str.length==0)
  { 
    document.getElementById("livesearch").
    innerHTML="";
    document.getElementById("livesearch").
    style.border="none";
    document.getElementById("livesearch").
    style.backgroundColor="transparent";
    return
  }

  xmlHttp=GetXmlHttpObject_livesearch_ok()

  if (xmlHttp==null)
  {
    alert ("HTTP-Request Fehler")
    return
  }


  if (sprache == "DE") {
    document.getElementById("livesearch").
    innerHTML="Suchresultate werden geladen...<br/><img src='http://41shirts.com/images/loading_ajax.gif' width='24px' height='24' />";
  }
  else {
    document.getElementById("livesearch").
    innerHTML="Loading searchresults...<br/><img src='http://41shirts.com/images/loading_ajax.gif' width='24px' height='24' />";
  }

  document.getElementById("livesearch").
  style.border="1px solid rgb(180,180,180)";
  document.getElementById("livesearch").
  style.backgroundColor="rgb(255,255,255)";
 

  var url="http://41shirts.com/livesearch_ok.php"
  url=url+"?q="+str
  url=url+"&sprache="+sprache
  url=url+"&color="+color
  url=url+"&country="+country
  url=url+"&sid="+Math.random()
  xmlHttp.onreadystatechange=stateChanged_livesearch_ok
  xmlHttp.open("GET",url,true)
  xmlHttp.send(null)
} 


function stateChanged_livesearch_ok() 
{ 
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
    document.getElementById("dummy_for_search_results").
    innerHTML=xmlHttp.responseText;

    document.getElementById("livesearch").
    innerHTML="";
    document.getElementById("livesearch").
    style.border="none";
    document.getElementById("livesearch").
    style.backgroundColor="transparent";
  } 
}

function GetXmlHttpObject_livesearch_ok()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}