function showHint(str)
{
window.document.forms.form1.category.options[0].selected=true
if (str.length==0)
  { 
  document.getElementById("PlaceList").innerHTML="Type in a search term<br>or<br>Select a Category<br>To retrieve a list of places matching your search."
  return
  }
document.getElementById("PlaceDetails").innerHTML="Select a place from the list to see details here."
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="populateplaces.php"
url=url+"?searchtext="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function showCat(str)
{
window.document.forms.form1.searchtext.value=""
if (str.length==0)
  { 
  document.getElementById("PlaceList").innerHTML="Type in a search term<br>or<br>Select a Category<br>To retrieve a list of places matching your search."
  return
  }
  document.getElementById("PlaceDetails").innerHTML="Select a place from the list to see details here."
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="populateplaces.php"
url=url+"?category="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showCatAdvert(str)
{
xmlHttp2=GetXmlHttpObject()
if (xmlHttp2==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="populatead.php"
url=url+"?category="+str
url=url+"&sid="+Math.random()
url=url+"&ad=Yes"
xmlHttp2.onreadystatechange=AdvertstateChanged 
xmlHttp2.open("GET",url,true)
xmlHttp2.send(null)
}

function showPlace(str)
{
if (str.length==0)
  { 
  document.getElementById("PlaceDetails").innerHTML="Select a place from the list to see details here."
  return
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="populateplaces.php"
url=url+"?place="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=PlacestateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function addFavourite(str)
{
if (str.length==0)
  { 
  document.getElementById("PlaceDetails").innerHTML="Select a place from the list to see details here."
  return
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="populateplaces.php"
url=url+"?favourite="+str
url=url+"&favourites="+document.getElementById("FaveList").innerHTML
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=FavouritestateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
alert ("Location added to favourites")
}

     


function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("PlaceList").innerHTML=xmlHttp.responseText
 var PrintableL=xmlHttp.responseText;
 //PrintableL = PrintableL.replace("<select name=\"place\" onchange=\"readMap('','',this.value,'')\">", "");
 //PrintableL = PrintableL.replace("<option value=\"\">Select from the List", "");
 //PrintableL = PrintableL.replace("<option value=\"", "");
 //PrintableL = PrintableL.replace("\">", "");
 PrintableL=stripHTML(PrintableL);
 PrintableL = PrintableL.replace("Select from the List", "");
 PrintableL = PrintableL.replace("ReviewsView Printable Version", "");
 document.getElementById("PrintableList").innerHTML=PrintableL;
 } 
} 

function AdvertstateChanged() 
{ 
if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
 { 
 document.getElementById("BannerAddLayer").innerHTML=xmlHttp2.responseText 
 } 
}

function PlacestateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("PlaceDetails").innerHTML=xmlHttp.responseText 
 } 
}

function FavouritestateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
document.getElementById("FaveList").innerHTML=xmlHttp.responseText 
 } 
}
   
function GetXmlHttpObject()
{
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;
}

function stripHTML(oldString) {

   var newString = "";
   var inTag = false;
   for(var i = 0; i < oldString.length; i++) {
   
        if(oldString.charAt(i) == '<') inTag = true;
        if(oldString.charAt(i) == '>') {
              if(oldString.charAt(i+1)=="<")
              {
              		//dont do anything
	}
	else
	{
		inTag = false;
		i++;
	}
        }
   
        if(!inTag) newString += oldString.charAt(i);

   }

   return newString;
}
