var xmlHttp;

/*function openDetailedWin(id, table)
 {
 	window.open ("http://www.euro-scooters.co.uk/model.php?id="+id+"&table="+table, "_blank", 
 	"resizable=no, scrollbars=1, status=1, menubar=0, location=0, left=100, top=100, height=600, width=620");
 }*/
 function reloadWin()
{
	window.location.reload();
}

/*function closeWin()
{
	window.close();
}*/

function toggle(object)
{
	var ul=document.getElementById("ul_"+object.id);
	if (ul)
	{
		//number of lists available
		var numOfList=2;
		var str="ul_"+object.id;
		var pos=str.length;
		//get the last character
		var num=str.substr(pos-1, 1);
		if (ul.className=="closed")
		{
			for (var i=1; i<numOfList+1; i++)
			{
				//open the list which was pressed on
				if (num==i)
				{
					ul.className="open";
				}
				//close all other lists
				else
				{
					var ulTmp=document.getElementById("ul_item"+i);
					ulTmp.className="closed";
				}
			}
				
		}
		else
		{
			ul.className="closed";
		}
	}

}

function addNumbers()//for form validation
{
	var as=document.getElementById("field7").value;
	noOfImg++;
	document.getElementById("field7").value=noOfImg;
}



//Google maps
   var geocoder;
   var map;

   var company = "Euro Scooters";
   var address = "35 Watford Way NW4 3JH";
   var content = "<table><tr><td>35 Watford Way<br/>Hendon<br/>London, NW4 3JH <br/>United Kingdom <br/>Tel: 020 8203 8003</td></tr></table>";

   // On page load, call this function

   function load()
   {
      // Create new map object
      map = new GMap2(document.getElementById("map"));

      // Create new geocoding object
      /*geocoder = new GClientGeocoder();*/
      map.addControl(new GLargeMapControl());
	  map.addControl(new GMapTypeControl());

      var point=new GLatLng(51.583777, -0.228567);
      // Center the map on this point
      map.setCenter(point,13);
      // Create a marker
      marker = new GMarker(point);

      // Add the marker to map
      map.addOverlay(marker);

      // Add address information to marker
      marker.openInfoWindowHtml(content);

   }

  //

function displayPage(id, page)//id=element which will be changed, page=page which will be used
{
	xmlHttp=GetXmlHttpObject ();
	if (xmlHttp==null)
	{
		alert("Your browser doesn\'t support AJAX");
		return false;
	}
	var url=page;
	//url=url+"&bla="+ Math.random ();
	xmlHttp.onreadystatechange=function()
	{
		stateChanged(id);
	}
	xmlHttp.open("GET" ,url,true);
	xmlHttp.send(null);
}
	

function stateChanged (id)
{
	   //alert(xmlHttp.readyState);
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
			document.getElementById(id).innerHTML=xmlHttp.responseText;
			if (document.getElementById("map"))
			{
				load();
			}
		}
}
			
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;
}
