// JavaScript Document
	function clickOnMap(){
		_hbSet('c4',document.title+'+Label+Click');
		//alert(document.title+'+Label+Click');
		_hbSend();
	 }
function initMap() {
//<![CDATA[
	var map = new GMap2(document.getElementById("google_map"));
	map.addControl(new GLargeMapControl());
	// Old style:
	//	map.addControl(new GMapTypeControl());
	// New style
		map.addControl(new GHierarchicalMapTypeControl());
	// terrain view:
		map.addMapType(G_PHYSICAL_MAP);
	
// initialise the map 51.165691,10.451526
var initialLat = "51.165691";
var initialLng = "10.451526";
var initialZoom = "6";
//map.setCenter(new GLatLng(initialLat,initialLng), initialZoom);
map.setCenter(new GLatLng(initialLat,initialLng), 6);

     var bounds = new GLatLngBounds( ); 
      // Creates a marker whose info window displays the given number
function createMarker(point, data) {
			var marker = new GMarker(point);
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(data);
				});

        return marker;
      }
/* ________________________________________ */
/* **************************     SPLIT LL ************/	

/* start loop */
//alert(total_);
function CreateMap(x) {
//var myCount=1
// increase the limit value each time a new clinic is inserted
var limit =total_;
	
for (var x = 1; x <= limit; x++)
 {
	myTest=window['city_' + x];
		if (myTest==null){
			//alert("empty: "+x);
		}
	 else {
	//alert("not empty: "+x);
    var myString=window['latlong_' + x];
	var myclinic=window['clinic_' + x];
	var myclinicSpec=window['clinicSpec_' + x];
	var mystreet=window['street_' + x];
	var mynumber=window['number_' + x];
	var mycity=window['city_' + x];
	var myprovince=window['province_' + x];
	var mycountry=window['country_' + x];
	var mywebsite=window['website_' + x];
	var mymail=window['mail_' + x];
	var mypostcode=window['postcode_' + x];
	var mytel = window['tel_' + x];
	var myfax = window['fax_' + x];
	//alert("City: "+mycity+x+" , myCount: "+myCount);
	//myCount++;
	
var mySplitResult = myString.split(",");
	
var lat=mySplitResult[0]; 
var long=mySplitResult[1]; 

/* ***************************************** */

/*
	var data = "<div  class='GlossBox' style='width:200px'><h3 class='TxGlossHead'><b>"+myclinic+"</b></h3><br />"+myclinicSpec+"<br />"+mystreet+" "+mynumber+"<br /><b>"+mypostcode+" "+mycity+", "+myprovince+",</b> <br /> "+mycountry+"<br /><a href='"+mywebsite+"' target='blank'>Website</a><br /><a href='mailto:"+mymail+"'>e-mail</a></div>";
*/
	var part1 = "<div   id='Gmap_Popup' class='container'><div  ><p  class='title' >"+myclinic+"</p>";


if ((mywebsite !="") && (mymail !="")){
	var theBox = "<div class='sideBox' id='InLinxBox'><h5 >Links</h5><div ><div class='sideInnerBox'><a href='"+mywebsite+"' target='blank' name='&lid="+mywebsite+"&lpos=googleMap' title='"+mywebsite+"'>Website</a><a href='mailto:"+mymail+"' name='&lid="+mymail+"&lpos=googleMap' title='"+mymail+"'>e-mail</a></div></div></div>";
//alert(myclinic+"  mail and web BOTH not empty "+mymail+mywebsite);

}

if ((mywebsite !="") && (mymail =="")){
//alert(myclinic+"  WEB not empty "+mywebsite);
var theBox = "<div class='sideBox' id='InLinxBox'><h5>Links</h5><div ><div class='sideInnerBox'><a href='"+mywebsite+"' target='blank' name='&lid="+mywebsite+"&lpos=googleMap'  title='"+mywebsite+"'>Website</a></div></div></div>";
}

if ((mywebsite =="") && (mymail !="")){
//alert(myclinic+"  MAIL not empty "+mymail);
var theBox = "<div class='sideBox' id='InLinxBox'><h5 >Links</h5><div ><div class='sideInnerBox'><a href='mailto:"+mymail+"' name='&lid="+mymail+"&lpos=googleMap' title='"+mymail+"'>e-mail</a></div></div></div>";
}

if ((mywebsite =="") && (mymail ==""))

{//alert(myclinic+"  MAIL and WEB EMPTY ");
var theBox = "";
}



if (myfax == ""){
theFax = "";
}
else
{
theFax = "<br>Fax.: "+myfax;
}

	var data = part1+theBox+"<table width='170' border='0' cellpadding='0' cellspacing='0'><tr><td><div class='clinic_spec' >"+myclinicSpec+"</div><div class='clinic_loc'>"+mystreet+" "+mynumber+"<br /><b>"+mypostcode+" "+mycity+"</b> <br />"+myprovince+""+mycountry+"</div></td></tr></table></div><div   class='clinic_comm' > Tel.: "+mytel+theFax+"</div></div><span style='display:none'><a href='#' onClick='javascript:zoomIn(12)'>Zoomin</a><br><a href='#' onClick='javascript:zoomOut(6);'>Zoom out</a></span></div>";
/*	
//<a href='#' onClick='javascript:zoomIn(12)'>Zoomin</a><br><a href='#' onClick='javascript:zoomOut(6);'>Zoom out</a>
*/	



//alert(myString);
	var point = new GLatLng(lat,long);
	var marker = createMarker(point, data);
        map.addOverlay(marker);
        bounds.extend(point);
/*  *****  */
            
GEvent.addListener(marker, "click", function() {
			     //alert("click");
				 clickOnMap();
		/*		 // define zoomin - zoom out coordinates relative to the selected label
			if (map.getZoom() < 16) {
			map.setCenter(marker.getPoint(), 9); 
			//map.setZoom(9);
	   			marker.openInfoWindowHtml(data+'<div class="text"><img src="mg.jpg" width="18" height="18" alt="" /><a href="#" class="iw" onclick="javascript:zoomIn('+i2+')">Zoom in</a></div>');
	  		} else {
	   			marker.openInfoWindowHtml(data+'<div class="text"><img src="mg.jpg" width="18" height="18" alt="" /><a href="#" class="iw" onclick="javascript:zoomOut('+i2+')">Zoom out</a></div>');
	  		}*/
	    })	
		};
			
/*  *****  */
      // ==================================================
	  /*
      function zoomIn(i){
	  		map.setCenter(gmarkers[i].getPoint(), 18); 
			map.setMapType(G_SATELLITE_TYPE);
			GEvent.trigger(gmarkers[i], "click");

		}
	  function zoomOut(i){
	  		map.setCenter(gmarkers[i].getPoint(), 10); 
			map.setMapType(G_NORMAL_MAP);
			GEvent.trigger(gmarkers[i], "click");

		}
		*/
	  // ==================================================
}
}


CreateMap();
/* __________________________ */
//            map.setZoom(map.getBoundsZoomLevel(bounds));
//      map.setCenter(bounds.getCenter());

     //]]>  
   }

    if (window.addEventListener) {
        window.addEventListener("load", initMap, false);
    } else if (window.attachEvent) {
        document.attachEvent("onreadystatechange", initMap);
    }

			
			       
