var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
document.getElementById("date").innerHTML = (curr_date + "-" + curr_month + "-" + curr_year);
    //<![CDATA[
    if (GBrowserIsCompatible()) {
      var sidebar_html = "";
      var gmarkers = [];
	  var gmarkerst = [];
	  var gmarkerstt = [];
	  var gmarkersttt = [];
	  var gmarkerstv = [];
	  var gmarkersv = [];
	  var gmarkersvt = [];
      var htmls = [];
	  var ohtml= [];
	  var astar =[];
	  var iialt =[];
	  var aimiss =[]; 
	  var aprice =[];
	  var aname =[];
	  var aurl =[];
      var thums = [];
	  var sider=[];
	  var i =0;
	  var loh =0;

	  var oneIcon = new GIcon();
      oneIcon.image = "markers/marker1.png";
      oneIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
      oneIcon.iconSize = new GSize(20, 34);
      oneIcon.shadowSize = new GSize(37, 34);
      oneIcon.iconAnchor = new GPoint(9, 34);
      oneIcon.infoWindowAnchor = new GPoint(9, 2);
      oneIcon.infoShadowAnchor = new GPoint(18, 25);
      oneIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
      oneIcon.printImage = "markers/marker1.gif";
      oneIcon.mozPrintImage = "markers/marker1.gif";

	  var twoIcon = new GIcon();
      twoIcon.image = "markers/marker2.png";
      twoIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
      twoIcon.iconSize = new GSize(20, 34);
      twoIcon.shadowSize = new GSize(37, 34);
      twoIcon.iconAnchor = new GPoint(9, 34);
      twoIcon.infoWindowAnchor = new GPoint(9, 2);
      twoIcon.infoShadowAnchor = new GPoint(18, 25);
      twoIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
      twoIcon.printImage = "markers/marker2.gif";
      twoIcon.mozPrintImage = "markers/marker2.gif";

	  var threeIcon = new GIcon();
      threeIcon.image = "markers/marker3.png";
      threeIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
      threeIcon.iconSize = new GSize(20, 34);
      threeIcon.shadowSize = new GSize(37, 34);
      threeIcon.iconAnchor = new GPoint(9, 34);
      threeIcon.infoWindowAnchor = new GPoint(9, 2);
      threeIcon.infoShadowAnchor = new GPoint(18, 25);
      threeIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
      threeIcon.printImage = "markers/marker3.gif";
      threeIcon.mozPrintImage = "markers/marker3.gif";

	  var fourIcon = new GIcon();
      fourIcon.image = "markers/marker4.png";
      fourIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
      fourIcon.iconSize = new GSize(20, 34);
      fourIcon.shadowSize = new GSize(37, 34);
      fourIcon.iconAnchor = new GPoint(9, 34);
      fourIcon.infoWindowAnchor = new GPoint(9, 2);
      fourIcon.infoShadowAnchor = new GPoint(18, 25);
      fourIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
      fourIcon.printImage = "markers/marker4.gif";
      fourIcon.mozPrintImage = "markers/marker4.gif";

	  var fiveIcon = new GIcon();
      fiveIcon.image = "markers/marker5.png";
      fiveIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
      fiveIcon.iconSize = new GSize(20, 34);
      fiveIcon.shadowSize = new GSize(37, 34);
      fiveIcon.iconAnchor = new GPoint(9, 34);
      fiveIcon.infoWindowAnchor = new GPoint(9, 2);
      fiveIcon.infoShadowAnchor = new GPoint(18, 25);
      fiveIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
      fiveIcon.printImage = "markers/marker5.gif";
      fiveIcon.mozPrintImage = "markers/marker5.gif";

	  var sixIcon = new GIcon();
      sixIcon.image = "markers/marker6.png";
      sixIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
      sixIcon.iconSize = new GSize(20, 34);
      sixIcon.shadowSize = new GSize(37, 34);
      sixIcon.iconAnchor = new GPoint(9, 34);
      sixIcon.infoWindowAnchor = new GPoint(9, 2);
      sixIcon.infoShadowAnchor = new GPoint(18, 25);
      sixIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png";
      sixIcon.printImage = "markers/marker6.gif";
      sixIcon.mozPrintImage = "markers/marker6.gif";

      var icons = [];
      icons[0] = oneIcon;
      icons[1] = twoIcon;
      icons[2] = threeIcon;
      icons[3] = fourIcon;
      icons[4] = fiveIcon;
      icons[5] = sixIcon;


      // A function to create the marker and set up the event window
      function markerdata(dmarker, bounds){         
              // obtain the attribues of each marker
              var lat = parseFloat(dmarker.getAttribute("lat"));
              var lng = parseFloat(dmarker.getAttribute("lng"));
              var point = new GLatLng(lat,lng);
			  bounds.extend(point)
              var html = dmarker.getAttribute("html");
              var label = dmarker.getAttribute("label");
              var price = dmarker.getAttribute("price");
			  comp=parseInt(price)
			  if (comp<36)
			  {var icontype = 5
			  }
			  else if (comp<51)
			  {var icontype = 4
			  }
			  else if (comp<66)
			  {var icontype = 3
			  }
			  else if (comp<76)
			  {var icontype = 2
			  }
			  else if (comp<86)
			  {var icontype = 1
			  }
			  else{
			  var icontype = 0
			  }
              var uadd = dmarker.getAttribute("url");
              var stars = dmarker.getAttribute("stars");
              var ims = dmarker.getAttribute("ims");
              var hid = dmarker.getAttribute("hid");
              var ialt = dmarker.getAttribute("ialt");
			  if (loh >50)
			  {html = html.substring(0,300)+".....";
			  ialt = ialt.substring(0,50);
			  }
			  var imss = ''
			  var thum =''
			  var ids=hid.substring(1)
			  if(ims.charAt(0) =='y'){
			  imss = "<img src='/Images/email.gif' alt='Office Services' width=23 height=23 >&nbsp;&nbsp;&nbsp; ";}
			  if(ims.charAt(1) =='y'){
			  imss = imss + "<img src='/Images/parking.gif' alt='Parking' width=23 height=23 >&nbsp;&nbsp;&nbsp; ";}
			  if(ims.charAt(2) =='y'){
			  imss = imss + "<img src='/Images/swim.gif' alt='Sports Facilities' width=23 height=23>";}
			  if(hid.charAt(0) =='a'){
			  thum ="<img src='http://www.activehotels.com/photos/"+ids+"/AAB"+ids +".jpg' height=150>";}
			  if(hid.charAt(0) =='s'){
			  thum="<img src='http://www.superbreak.com/hotelnet/superbreak/pictures/"+ids+"_BRO.jpg' height=150>";}
              // create the marker
              var marker = createMarker(point,label,html, price,uadd, stars, imss, thum, ialt, icontype);
			  return marker

            }

	function allMap(surl) {
		var bounds = new GLatLngBounds();
		url1 = surl +'_vt.xml'
		url2 = surl +'_v.xml'
		url3 = surl +'_tv.xml'
		url4 = surl +'_ttt.xml'
		url5 = surl +'_tt.xml'
		url6 = surl +'_t.xml'
           // hide the info window, otherwise it still stays open where the removed marker used to be
		map.getInfoWindow().hide();
            
        map.clearOverlays();
            
         // empty the array
        gmarkers = [];

            // reset the sidebar
        sidebar_html="<h3>All Hotels  </H3><HR>";
		geturl1(url1, bounds, 5)
		geturl1(url2, bounds, 4)
		geturl1(url3, bounds, 3)
		geturl1(url4, bounds, 2)
		geturl1(url5, bounds, 1)
		geturl1(url6, bounds, 0)
            // put the assembled sidebar_html contents into the sidebar div
		map.setZoom(map.getBoundsZoomLevel(bounds));
        var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
        var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
		map.setCenter(new GLatLng(clat,clng));
		setTimeout("document.getElementById('sidebar').innerHTML = sidebar_html", 1500); 
		
        }

	function geturl1(url, bounds , icontype){
	    var request = GXmlHttp.create();
        request.open("GET", url, true);
        request.onreadystatechange = function() {
          if (request.readyState == 4) {
            var xmlDoc = request.responseXML;
            // obtain the array of markers and loop through it
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");
			for (var i = 0; i < markers.length; i++) {
			marker = markerdata(markers[i], bounds, icontype);
			map.addOverlay(marker);}
			return 
			}
		}
		request.send(null);
		
		}






      // A function to create the marker and set up the event window
      function createMarker(point,name,html, price, uadd, stars, imss, thum, ialt, icontype) {
        var marker = new GMarker(point, icons[icontype]);
		var nhtml=''
		nhtml= '<table><TR><TD width=200 align=left><font color=red><B>'+stars+'</B></font>&nbsp;&nbsp;<img src="/Images/info.gif" alt="'+ialt+'"> '+imss+' &nbsp;&nbsp;£'+price+'<BR><font color=#0000CC face=verdana><A href="'+uadd+'" target=info>'+name+'</A><BR>'+html.substring(0,60)+'....<BR><I>Click on link for more info</I></TD></TR></TABLE>';
		GEvent.addListener(marker, "click", function() {
		  nhtml= '<table><TR><TD width=200 align=left><font color=red><B>'+stars+'</B></font>&nbsp;&nbsp;<img src="/Images/info.gif" alt="'+ialt+'"> '+imss+' &nbsp;&nbsp;£'+price+'<BR><font color=#0000CC face=verdana><A href="'+uadd+'" target=info>'+name+'</A><BR>'+html.substring(0,60)+'....<BR><I>Click on link for more info</I></TD></TR></TABLE>';
		  document.getElementById("thumbs").innerHTML='<A HREF="'+uadd+'" target=info>'+thum+'</A>'
		  document.getElementById("sfg").innerHTML="<B>"+name+"</B><BR>"+html+"....<BR><I>Click on photo for more info</I>"
		  marker.openInfoWindowHtml(nhtml);
        });
		gmarkers[i]=marker;
		if (icontype==0)
		{gmarkerst[gmarkerst.length]=i;
		}
		else if (icontype==1)
		{gmarkerstt[gmarkerstt.length]=i;
		}
		else if (icontype==2)
		{gmarkersttt[gmarkersttt.length]=i;
		}
		else if (icontype==3)
		{gmarkerstv[gmarkerstv.length]=i;
		}
		else if (icontype==4)
		{gmarkersv[gmarkersv.length]=i;
		}
		else 
		{gmarkersvt[gmarkersvt.length]=i;
		}
		ohtml[i]=html
		astar[i]=stars
		iialt[i] =ialt
		aimiss[i]=imss
		aprice[i]=price
		aname[i]=name
		aurl[i]=uadd
		thums[i]='<A HREF="'+uadd+'"target=info>'+thum+'</A>'
		sider[i]= stars+'<BR><a href="javascript:myclick(' + i + ')">' + name + '</a>  £'+price+'&nbsp;&nbsp;&nbsp;&nbsp;<HR>';
        sidebar_html += stars+'<BR><a href="javascript:myclick(' + i + ')">' + name + '</a>  £'+price+'&nbsp;&nbsp;&nbsp;&nbsp;<HR>';
		i++
        return marker;
      }
      function myclick(i) {
		nhtml= '<table><TR><TD width=200 align=left><font color=red><B>'+astar[i]+'</B></font>&nbsp;&nbsp;<img src="/Images/info.gif" alt="'+iialt[i]+'"> '+aimiss[i]+' &nbsp;&nbsp;£'+aprice[i]+'<BR><font color=#0000CC face=verdana><A href="'+aurl[i]+'" target=info>'+aname[i]+'</A><BR>'+ohtml[i].substring(0,60)+'....<BR><I>Click on link for more info</I></TD></TR></TABLE>';
        gmarkers[i].openInfoWindowHtml(nhtml);
		document.getElementById("thumbs").innerHTML = thums[i];
		document.getElementById("sfg").innerHTML="<B>"+aname[i]+"</B><BR>"+ohtml[i]+"....<BR><I>Click on photo for more info</I>"
      }


      function clicky(rang, htms) {
		var bounds = new GLatLngBounds();
        var icontype = parseInt(rang)
            // hide the info window, otherwise it still stays open where the removed marker used to be
        map.getInfoWindow().hide();
        map.clearOverlays();
        sidebar_html="Hotels priced " + htms+" <BR><BR>";
		if (icontype==0){
		var lo =gmarkerst.length;
		for (var i = 0; i < lo; i++) {
              map.addOverlay(gmarkers[gmarkerst[i]]);
			  point =gmarkers[gmarkerst[i]].getPoint();
			  bounds.extend(point);
			  sidebar_html +=sider[gmarkerst[i]]}
		}
		else if (icontype==1){
		var lo =gmarkerstt.length;
		for (var i = 0; i < lo; i++) {
              map.addOverlay(gmarkers[gmarkerstt[i]]);
			  point =gmarkers[gmarkerstt[i]].getPoint();
			  bounds.extend(point);
			  sidebar_html +=sider[gmarkerstt[i]]}
		}
		else if (icontype==2){
		var lo =gmarkersttt.length
		for (var i = 0; i < lo; i++) {
              map.addOverlay(gmarkers[gmarkersttt[i]]);
			  point =gmarkers[gmarkersttt[i]].getPoint();
			  bounds.extend(point);
			  sidebar_html +=sider[gmarkersttt[i]]}
		}
		else if (icontype==3){
		var lo =gmarkerstv.length
		for (var i = 0; i < lo; i++) {
              map.addOverlay(gmarkers[gmarkerstv[i]]);
			  point =gmarkers[gmarkerstv[i]].getPoint();
			  bounds.extend(point);
			  sidebar_html +=sider[gmarkerstv[i]]}
		}
		else if (icontype==4){
		var lo =gmarkersv.length;
		for (var i = 0; i < lo; i++) {
              map.addOverlay(gmarkers[gmarkersv[i]]);
			  point =gmarkers[gmarkersv[i]].getPoint();
			  bounds.extend(point);
			  sidebar_html +=sider[gmarkersv[i]]}
		}
		else if (icontype==5){
		var lo =gmarkersvt.length
		for (var i = 0; i < lo; i++) {
              map.addOverlay(gmarkers[gmarkersvt[i]]);
			  point =gmarkers[gmarkersvt[i]].getPoint();
			  bounds.extend(point);
			  sidebar_html +=sider[gmarkersvt[i]]}
		}
		else {
		var lo =gmarkers.length
        sidebar_html="<BR> " + htms+" <BR><BR>";
		for (var i = 0; i < lo; i++) {
              map.addOverlay(gmarkers[i]);
			  point =gmarkers[i].getPoint();
			  bounds.extend(point);
			  sidebar_html +=sider[i]}
		}
		if (lo > 1)
		{if (document.getElementById('zoom').checked==true)
		{
		
		map.setZoom(map.getBoundsZoomLevel(bounds));
		var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
        var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
        map.setCenter(new GLatLng(clat,clng));
		}}
		else if(lo == 1){
		if (document.getElementById('zoom').checked==true)
		{
        map.setCenter(point, 12);
		}}
		else{sidebar_html="There are no hotels priced<BR><BR>"+htms }
        document.getElementById("sidebar").innerHTML = sidebar_html;
     }










      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng( xu,yu), 12);

     // A function to read the data
      function readMap(url, htms) {
		var bounds = new GLatLngBounds();
        var request = GXmlHttp.create();
        request.open("GET", url, true);
        request.onreadystatechange = function() {
          if (request.readyState == 4) {
            var xmlDoc = request.responseXML;
            // obtain the array of markers and loop through it
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");
            
            // hide the info window, otherwise it still stays open where the removed marker used to be
            map.getInfoWindow().hide();
            
            map.clearOverlays();
            
            // empty the array
            gmarkers = [];

            // reset the sidebar
            sidebar_html="<BR><B>" + htms+" </B><BR><BR>";
            loh =markers.length
			if (markers.length>1){
            for (var i = 0; i < markers.length; i++) {
              marker = markerdata(markers[i], bounds);
			  map.addOverlay(marker);}
            // put the assembled sidebar_html contents into the sidebar div
			map.setZoom(map.getBoundsZoomLevel(bounds));
			var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
            var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
            map.setCenter(new GLatLng(clat,clng));
            document.getElementById("sidebar").innerHTML = sidebar_html;
			}
			else if (markers.length==1){
            for (var i = 0; i < markers.length; i++) {
              marker = markerdata(markers[i], bounds);
			  map.addOverlay(marker);}
			  map.setCenter(marker.getPoint());
			document.getElementById("sidebar").innerHTML = sidebar_html;
			  }
			else{
			document.getElementById("sidebar").innerHTML = "There are no <BR>hotels priced <BR>"+htms;
			}
			}
        }
        request.send(null);
      }
    }



