



var de_location = "Azie";
var vipsite = 0;
var adcou = 0;
var locations = [];
var locations2 = [];
var locations3 = [];
var org = [];
var hidetext = 0;

var map;
var geocoder;
var mx = 0;
var my = 0;

var lat = 0;
var lng = 0;
var zm = 1;
var st = "on";
var golf = 0;
var hotspots = 0;
var picker = 0;
var golfpicker = 0;
var locar = [];
var override = 0;
var setcol = "#798965";

var deficon = 'extravicon.png';
var route_image = 'extravicon2.png';
var route_image_shad = 'extravlogo_shadow2.png';
var route_image2 = 'extravicon3.png';


function goPage(){
	var prio = document.news_selector.news_id[document.news_selector.news_id.selectedIndex].value;
	window.location = 'index.php?id='+prio;
	
}


function setCo(e){

    if (!e) var e = window.event;
    if (e.pageX || e.pageY)
    {
        mx = e.pageX;
        my = e.pageY;
    }
    else if (e.clientX || e.clientY)
    {
		if(document.documentElement){
		mx = (e.clientX + document.documentElement.scrollLeft);
        my = (e.clientY + document.documentElement.scrollTop);
		}else{
		mx = (e.clientX + document.body.scrollLeft);
        my = (e.clientY + document.body.scrollTop);
		}

    }
	
	mx -= 5;
	my -= 22;

}

function openPop(withthis){

	var el = document.getElementById("infowin");
	var el2 = document.getElementById("infowin2");
	var dip = document.getElementById("popupwin");
	
	var st = el.style;
	
	if(el.style.display == "block"){
		el.style.display = "none";
		el2.style.display = "none";
	}
	
    if (!document.all){
		el.style.top = my+"px";
		el.style.left = mx+"px";
    }else{
		el.style.pixelTop = my;
		el.style.pixelLeft = mx;
    }
	
	dip.innerHTML = withthis;
	el.style.display = "block";
}

function openPop8(withthis){

	var el = document.getElementById("infowin");
	var el2 = document.getElementById("infowin2");
	var dip = document.getElementById("popupwin");
	
	var st = el.style;
	
	if(el.style.display == "block"){
		el.style.display = "none";
		el2.style.display = "none";
	}
	
    if (!document.all){
		el.style.top = my+"px";
		el.style.left = mx+"px";
    }else{
		el.style.pixelTop = my;
		el.style.pixelLeft = mx;
    }
	
	dip.innerHTML = withthis;
	el.style.display = "block";
}

function openPop3(){

	var el = document.getElementById("infowin");
	var el2 = document.getElementById("infowin2");
	var dip = document.getElementById("popupwin");
	
	var st = el.style;
	
	if(el.style.display == "block"){
		el.style.display = "none";
		el2.style.display = "none";
	}
	
	var mapst = document.getElementById("map_canvas");
	var mapw = 460/2;
	var maph = 380/2;
	var mapx = 0;
	var mapy = 0;

    if (!document.all){
		mapx = mapst.offsetLeft;
		mapy = mapst.offsetTop;
		//alert(mapy);
		el.style.top = (mapx+mapw)+"px";
		el.style.left = (mapy+maph)+"px";
    }else{
		mapx = mapst.style.pixelTop;
		mapy = mapst.style.pixelLeft;

		el.style.pixelTop = mapx+mapw;//my+document.body.scrollTop;
		el.style.pixelLeft = mapy+maph;//mx+document.body.scrollLeft;
    }
	
	dip.innerHTML = poptext;
	el.style.display = "block";
}

var golfx = 0;
var golfy = 0;
var golfname = "";

function openPop2(withthis){

	route_image = 'extravicon2.png';
	route_image_shad = 'extravlogo_shadow2.png';
	
	golfx = withthis[6];
	golfy = withthis[7];
	golfname = withthis[0];
	var lin = '<a href=\"index.php?action=3&go_id='+withthis[8]+'&id='+withthis[9]+'&lc_id='+withthis[10]+'&show='+withthis[12]+'\">edit</a>';
	var lin2 = '<a href=\"javascript:doAdmin2(\'index.php?action=5&go_id='+withthis[8]+'&id='+withthis[9]+'&lc_id='+withthis[10]+'&show='+withthis[12]+'\',1)\">delete</a>';
	var lin3 = '<a href=\"index.php?go_id='+withthis[8]+'&id='+withthis[9]+'&lc_id='+withthis[10]+'&show=5\">'+golfname+'</a>';
	var rat = "";
	if(withthis[13] != ''){
		rat = '<a href=\"index.php?go_id='+withthis[8]+'&id='+withthis[9]+'&lc_id='+withthis[10]+'&show=5\"><img src=\"'+withthis[13]+'\" width=\"'+withthis[14]+'\" height=\"'+withthis[15]+'\" border=\"0\"></a><br><br>';
	}
	var story = rat + withthis[5];
	
	
	var el = document.getElementById("infowin2");
	var el2 = document.getElementById("infowin");
	
	var dip0 = document.getElementById("val0");
	var dip1 = document.getElementById("val1");
	var dip2 = document.getElementById("val2");
	var dip3 = document.getElementById("val3");
	var dip4 = document.getElementById("val4");
	var dip5 = document.getElementById("val5");
	if(withthis[11] == 1){
	var dip6 = document.getElementById("val6");
	dip6.innerHTML = lin + ' | ' + lin2;
	}
	var st = el.style;
	if(el.style.display == "block"){
		el.style.display = "none";
		el2.style.display = "none";
	}
	
    if (!document.all){
		el.style.top = my+"px";
		el.style.left = mx+"px";
    }else{
		el.style.pixelTop = my;
		el.style.pixelLeft = mx;
    }
	
	dip0.innerHTML = lin3;
	dip1.innerHTML = withthis[1];
	dip2.innerHTML = withthis[2];
	dip3.innerHTML = withthis[3];
	dip4.innerHTML = withthis[4];
	dip5.innerHTML = story;
	
	el.style.display = "block";
}

  
 	
function openPop4(withthis){

//$golfarr .= "['".$hs_name."',".$hs_lat.",".$hs_lng.",'".$go_desc."',".$go_id.",".$id.",".$lc_id.",".$admin.",".$show.",'".$hot_ico[$hs_type]."']";

	golfx = withthis[1];
	golfy = withthis[2];
	golfname = withthis[0];
	var lin = '<a href=\"index.php?action=6&hs_id='+withthis[4]+'&id='+withthis[5]+'&lc_id='+withthis[6]+'&show='+withthis[8]+'\">edit</a>';
	var lin2 = '<a href=\"javascript:doAdmin2(\'index.php?action=8&hs_id='+withthis[4]+'&id='+withthis[5]+'&lc_id='+withthis[6]+'&show='+withthis[8]+'\',1)\">delete</a>';
	var lin3 = '<a href=\"index.php?hs_id='+withthis[4]+'&id='+withthis[5]+'&lc_id='+withthis[6]+'&show=6\">'+golfname+'</a>';
	
	var lin4 = "";
	var imag = withthis[10];
	
	var rat = '<img src=\"defimages/rating/rating'+withthis[13]+'.jpg\" width=\"70\" height=\"13\" border=\"0\"><br>';
	var story = rat + withthis[3];
	if(imag != ""){
		story = '<a href=\"index.php?hs_id='+withthis[4]+'&id='+withthis[5]+'&lc_id='+withthis[6]+'&show=6\"><img src=\"'+withthis[10]+'\" width=\"'+withthis[11]+'\" height=\"'+withthis[12]+'\" border=\"0\" align=\"right\"></a>'+story;
	}
	

	route_image = withthis[9];
	route_image_shad = 'shad_'+withthis[9];
	
	var el = document.getElementById("infowin3");
	var el2 = document.getElementById("infowin");
	var el3 = document.getElementById("infowin2");
	
	var dip0 = document.getElementById("vl0");
	var dip1 = document.getElementById("vl1");
	//var dip2 = document.getElementById("vl2");
	
	if(withthis[7] == 1){
	var dip6 = document.getElementById("vl6");
	dip6.innerHTML = lin + ' | ' + lin2;
	}
	var st = el.style;
	if(el.style.display == "block"){
		el.style.display = "none";
		el2.style.display = "none";
		el3.style.display = "none";
	}
	
    if (!document.all){
		el.style.top = my+"px";
		el.style.left = mx+"px";
    }else{
		el.style.pixelTop = my;
		el.style.pixelLeft = mx;
    }
	
	dip0.innerHTML = lin3;
	dip1.innerHTML = story;
	//dip2.innerHTML = lin4;
	
	el.style.display = "block";
}

function closePop(){
		var el = document.getElementById("infowin");
		var el2 = document.getElementById("infowin2");
		var el3 = document.getElementById("infowin3");
		el.style.display = "none";
		el2.style.display = "none";
		el3.style.display = "none";
		
}






var directionDisplay; 
var directionsService; 
var stepDisplay; 
var markerArray = [];
var markerArray2 = [];
var bounds = new google.maps.LatLngBounds;

var strokcol = "#006600";

var marker;
  
  
 function initializ() {
 
  startSlides();
  changeInputs();
  
 if(picker == 0){
 
	 if(document.getElementById("controls_1") && document.getElementById("controls_2")){
		 var ctrl1 = document.getElementById("controls_1");
	 	 var ctrl2 = document.getElementById("controls_2");
	 	 ctrl2.style.display = 'none';
	 	 ctrl1.style.display = 'block';
	 }
  }
  
  if(document.getElementById("map_canvas")){
  

	directionsService = new google.maps.DirectionsService();

  
  	de_location = locar[0];
	lat = locar[1];
	lng = locar[2];
	zm = locar[3];
  
  	if(hidetext == 1){
	st = "off";
	}else{
	st = "on"
	}
	var col1 = "#00ffc4";
	var col2 = "#00ffc4";
	var col3 = "#00ffc4";
	
	
	if(vipsite){
		col1 = "#173349";
		col2 = "#24445d";
		col3 = "#485b69";
		strokcol = "#446f90";
		setcol = "#446f90";
		route_image2 = 'extravicon3_p.png';
		deficon = 'extravicon_vip.png';
	}
	
 	var stylez =  [
	{ featureType: "all", elementType: "geometry", stylers: [ { hue: col1 } ] },
	{ featureType: "administrative", elementType: "all", stylers: [ { hue: col2 } ] },
	{ featureType: "all", elementType: "labels", stylers: [ { visibility: st },{ hue: col1 } , { lightness: 20} ] },
	{ featureType: "landscape.natural", elementType: "all", stylers: [ { hue: col3 } ] },
	{ featureType: "road", elementType: "geometry", stylers: [ { hue: col1 },{ lightness: 75 } ] },
	{ featureType: "road.highway", elementType: "all", stylers: [ { hue: col1 },{ lightness: 75 } ] },
	{ featureType: "water", elementType: "all", stylers: [ { hue: col1 }, { lightness: 30 } ] }
	];
 
 	var styledMapOptions = { map: map, name: "Extrav" } 
 
    var jayzMapType =  new google.maps.StyledMapType(stylez,styledMapOptions); 
 
 	geocoder = new google.maps.Geocoder();
	
	
	
	
    var myLatlng = new google.maps.LatLng(lat, lng);
    var myOptions = {
      center: myLatlng,
	  disableDefaultUI: true,
      mapTypeId: google.maps.MapTypeId.TERRAIN,
	  navigationControl: true,
	  navigationControlOptions: {style:google.maps.NavigationControlStyle.SMALL},
	  zoom:zm
    }

    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    map.mapTypes.set('extr', jayzMapType); 
    map.setMapTypeId('extr');
  
   	google.maps.event.addListener(map, 'bounds_changed', function(){ closePop();}); 
	google.maps.event.addListener(map, 'center_changed', function(){ closePop();}); 		
	google.maps.event.addListener(map, 'click', function(){ closePop();}); 			

	
	if(golf == 1 || hotspots == 1|| picker == 1){
	
	var image; 
	var shadow;
	var shape;
	
	 if(golfpicker == 0){
	 
	  image = new google.maps.MarkerImage('defimages/'+deficon, 
      new google.maps.Size(30, 30), 
      new google.maps.Point(0,0), 
      new google.maps.Point(15, 15)); 
	  
  	  shadow = new google.maps.MarkerImage('defimages/extravlogo_shadow.png', 
      new google.maps.Size(30, 30), 
      new google.maps.Point(0,0), 
      new google.maps.Point(13, 13)); 
	  
	  shape = { coord: [15, 15, 10], type: 'circle'};
	
	}else{
	
	  image = new google.maps.MarkerImage('defimages/extravicon2.png', 
      new google.maps.Size(30, 34), 
      new google.maps.Point(0,0), 
      new google.maps.Point(8, 26)); 
	  
  	  shadow = new google.maps.MarkerImage('defimages/extravlogo_shadow2.png', 
      new google.maps.Size(30, 30), 
      new google.maps.Point(0,0), 
      new google.maps.Point(8, 26));
	  
 	  shape = { coord: [6,2,21,2,21,13,10,13,10,26,6,26], type: 'polygon'};
	  }
		if(picker == 1){
		
			
		
		
		       marker = new google.maps.Marker({ 
		        position: new google.maps.LatLng(org[0], org[1]),
				draggable: true, 
		        map: map, 
		        shadow: shadow, 
		        icon: image, 
		        shape: shape, 
		        title: de_location, 
		        zIndex: 1 
				});
		}else{
		
				if(locations3.length == 0){
		        marker = new google.maps.Marker({ 
		        position: new google.maps.LatLng(org[0], org[1]), 
		        map: map, 
		        shadow: shadow, 
		        icon: image, 
		        shape: shape, 
		        title: de_location, 
		        zIndex: 3
				});
				}
		}
    
	 var rendererOptions = { 
    map: map ,
	suppressMarkers: true,
	polylineOptions: {strokeColor: strokcol}
  	} 
 	directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions) ;
	//directionsDisplay.setPanel(document.getElementById("directionsPanel")); 
  }
	
	
  	//codeAddress();
	if(locations.length > 0){
  		setMarkers(locations,0);
	}
	if(locations2.length > 0){
		setMarkers(locations2,1);
	}
	if(locations3.length > 0){
		setMarkers(locations3,2);
	}
	
  }
  }
  
  
  function resetMarker3(tname){
  var val = "hallo";
  if(tname != ""){
 	 val = document.textform[tname].value;
  }
  if(val == ""){
  	alert("Vul een naam in!");
  }else{
  
  	var point = map.getCenter();
	var xv = point.lat();
	var xy = point.lng();
 	var zm = map.getZoom();
  	
	document.textform.map_lat.value = xv;
  	document.textform.map_lng.value = xy;
	document.textform.map_zm.value = zm;
	
	var point2 = marker.getPosition();
	document.textform.lat.value = point2.lat();
	document.textform.lng.value = point2.lng();
	document.textform.submit();
	
	}
  }
  
  
  
  function resetMarker(tname){
  var val = "hallo";
  if(tname != ""){
 	 val = document.f_form[tname].value;
  }
  if(val == ""){
  	alert("Vul een naam in!");
  }else{
  
  	var point = map.getCenter();
	var xv = point.lat();
	var xy = point.lng();
 	var zm = map.getZoom();
  	
	document.f_form.map_lat.value = xv;
  	document.f_form.map_lng.value = xy;
	document.f_form.map_zm.value = zm;
	
	var point2 = marker.getPosition();
	document.f_form.lat.value = point2.lat();
	document.f_form.lng.value = point2.lng();

	
	document.f_form.submit();
	
	}
  }
  
  function centerMarker(){
  
 	var point = map.getCenter();
	var xv = point.lat();
	var xy = point.lng();
 	var zm = map.getZoom();
	
	marker.setPosition(point);
	
	//document.ha.val.value = xv+','+xy+','+zm;
	

  }
  
  
  function resets(){
  	var val = '';
	
	if(document.f_form){
		val = document.f_form.addressval.value;
	}else{
		val = document.textform.addressval.value;
	}
	
	if(val != ''){
		codeAddress(val);
	}
    
  }
  

  function codeAddress(adre) {
  
     
  
  	 if (geocoder) {
 			 geocoder.geocode( { 'address': adre}, function(results, status) {
  					if (status == google.maps.GeocoderStatus.OK) {
					
				 			var bnds = new google.maps.LatLngBounds(results[0].geometry.viewport.getSouthWest(), results[0].geometry.viewport.getNorthEast());
						    map.setCenter(bnds.getCenter()); 
							map.fitBounds(bnds); 
							centerMarker();
					} else {
					   alert("Geocode was not successful for the following reason: " + status);
      				}
  			 });
  	}
	
  }

 function reloadMap(){
  for (i = 0; i < markerArray.length; i++) { 
    markerArray[i].setMap(null); 
  } 
  mark1.setMap(null);
  
 var sub2 = document.getElementById("directionsPanel");
 var sub1 = document.getElementById("normal_sub");
 sub1.style.display = 'block';
 sub2.innerHTML = '';
 sub2.style.display = 'none';
 initializ();
 }
 
 
 
  function reloadMap2(){

	if(locations.length > 0){
			map.fitBounds(bounds);
	}else{
	var myLatlng = new google.maps.LatLng(lat, lng);
   	 var myOptions = {
     	 center: myLatlng,
	  	zoom:zm
		};
	map.setOptions(myOptions);
	}
	//setColor(0);
	
 }
 
 function resetMap(){
//if(locations.length > 0){
	//map.fitBounds(bounds);
	//}else{
	map.fitBounds(tbnds);
//}
	setColor(0);
 }

 
 
 
 
function setMarkers(loca,die) { 

var image;
var shadow;
var shape;
if(die == 2){

var flights = [];
//flights[0] = new google.maps.LatLng(org[0], org[1]);
  for (var i = 0; i < loca.length; i++) { 
    var beach = loca[i];
	flights[i] = new google.maps.LatLng(beach[1], beach[2]);
 }
 
 	var col1 = "009900";
	var col2 = "009900";
	var col3 = "009900";
	
	
	if(vipsite){
		col1 = "173349";
		col2 = "24445d";
		col3 = "485b69";
	}
 
  var flightPath = new google.maps.Polyline({     path: flights,     strokeColor: "#"+col3,     strokeOpacity: 0.3,     strokeWeight: 2   });    flightPath.setMap(map);



	  	  image = new google.maps.MarkerImage('defimages/'+deficon, 
		      new google.maps.Size(30, 30), 
		      new google.maps.Point(0,0), 
		      new google.maps.Point(15, 15),
			  new google.maps.Size(30, 30)); 
			  
		  shadow = new google.maps.MarkerImage('defimages/extravlogo_shadow.png', 
		      new google.maps.Size(30, 30), 
		      new google.maps.Point(0,0), 
		      new google.maps.Point(13, 13),
			  new google.maps.Size(30, 30));
			  
		 shape = { coord: [15, 15, 10], type: 'circle'};
		 
		 
		 

}else{
if(golf == 1){

  image = new google.maps.MarkerImage('defimages/extravicon2.png', 
      new google.maps.Size(30, 34), 
      new google.maps.Point(0,0), 
      new google.maps.Point(8, 26)); 
	  
  shadow = new google.maps.MarkerImage('defimages/extravlogo_shadow2.png', 
      new google.maps.Size(30, 30), 
      new google.maps.Point(0,0), 
      new google.maps.Point(8, 26));
	  
 shape = { coord: [6,2,21,2,21,13,10,13,10,26,6,26], type: 'polygon'};
 
}else{
	  if(die == 1){
	  
	  	  image = new google.maps.MarkerImage('defimages/'+deficon, 
		      new google.maps.Size(30, 30), 
		      new google.maps.Point(0,0), 
		      new google.maps.Point(15, 15),
			  new google.maps.Size(30, 30)); 
			  
		  shadow = new google.maps.MarkerImage('defimages/extravlogo_shadow.png', 
		      new google.maps.Size(30, 30), 
		      new google.maps.Point(0,0), 
		      new google.maps.Point(13, 13),
			  new google.maps.Size(30, 30));
			  
		 shape = { coord: [15, 15, 10], type: 'circle'}; 
		 
	
	  }else{
		  image = new google.maps.MarkerImage('defimages/'+deficon, 
		      new google.maps.Size(30, 30), 
		      new google.maps.Point(0,0), 
		      new google.maps.Point(15, 15),
			  new google.maps.Size(30, 30)); 
			  
		  shadow = new google.maps.MarkerImage('defimages/extravlogo_shadow.png', 
		      new google.maps.Size(30, 30), 
		      new google.maps.Point(0,0), 
		      new google.maps.Point(13, 13),
			  new google.maps.Size(30, 30));
			  
		 shape = { coord: [15, 15, 10], type: 'circle'}; 
	 }
 }
 }
 
 
  for (var i = 0; i < loca.length; i++) { 
   
    var beach = loca[i];
	
    var myLatLng = new google.maps.LatLng(beach[1],beach[2]); 
	bounds.extend(myLatLng);
	

	//marker.setDraggable(true);
	
	
	var contentString;
	
	if(die == 2){
	
		var marks = new google.maps.Marker({ 
        position: myLatLng, 
        map: map, 
        shadow: shadow, 
        icon: image, 
        shape: shape, 
        title: beach[0], 
        zIndex: i+1 
		}); 
		
		contentString = beach[3];//'<strong><a href="'+beach[3]+'">'+beach[0]+'</a></strong>';
		contentString = [beach[0],beach[3]];
		
		//placeWin8(marks,contentString);
	
	}else{
	if(golf == 1){
		
	 var marks = new google.maps.Marker({ 
        position: myLatLng, 
        map: map, 
        shadow: shadow, 
        icon: image, 
        shape: shape, 
        title: beach[0], 
        zIndex: i+1 
    }); 
		
		contentString = [beach[0],beach[3],beach[4],beach[5],beach[6],beach[7],beach[1],beach[2],beach[8],beach[9],beach[10],beach[11],beach[12],beach[13],beach[14],beach[15]];
		placeWin2(marks,contentString);
		
	}else if(hotspots == 1){
	
	
	
		  var image1 = new google.maps.MarkerImage('defimages/'+beach[9], 
		      new google.maps.Size(21, 23), 
		      new google.maps.Point(0,0), 
		      new google.maps.Point(10, 11),
			  new google.maps.Size(21, 23)); 
			  
		 var shadow1 = new google.maps.MarkerImage('defimages/shad_'+beach[9], 
		      new google.maps.Size(21, 23), 
		      new google.maps.Point(0,0), 
		      new google.maps.Point(9, 10),
			  new google.maps.Size(21, 23));  
			  
			  
		 var shape1 = { coord: [10, 11, 10], type: 'circle'};
		 
	    marks = new google.maps.Marker({ 
	        position: myLatLng, 
	        map: map,
			shadow: shadow1,
	        icon: image1, 
	        shape: shape1, 
	        title: beach[0], 
	        zIndex: i+1 
    	}); 
		
	//$golfarr .= "['".$hs_name."',".$hs_lat.",".$hs_lng.",'".$go_desc."',".$go_id.",".$id.",".$lc_id.",".$admin.",".$show.",'".$hot_ico[$hs_type]."']";
	
		contentString = [beach[0],beach[1],beach[2],beach[3],beach[4],beach[5],beach[6],beach[7],beach[8],beach[9],beach[10],beach[11],beach[12],beach[13]];
		placeWin4(marks,contentString);
	
	}else{
	
		 var marks = new google.maps.Marker({ 
        position: myLatLng, 
        map: map, 
        shadow: shadow, 
        icon: image, 
        shape: shape, 
        title: beach[0], 
        zIndex: i+1  
    }); 
	
		contentString = beach[3];//'<strong><a href="'+beach[3]+'">'+beach[0]+'</a></strong>';
		placeWin(marks,contentString);
	}
	}

	    markerArray2[i] = marks; 
 	//placeWin(marker,infowindow[i]);
	//placeWin(marker,contentString);

	
  } //end for
  
  if(loca.length > 1 && override == 0){
		map.setCenter(bounds.getCenter());
		map.fitBounds(bounds); 
  }
  
}
 
 function placeWin(mark,thiswin){
 				google.maps.event.addListener(mark, 'click', function(){ 
						//openPop(thiswin);
						window.location = thiswin;
                }); 
 }
 
 function placeWin2(mark,thiswin){
 				google.maps.event.addListener(mark, 'click', function(){ 
						openPop2(thiswin);
                }); 
 }
  function placeWin8(mark,thiswin){
 				google.maps.event.addListener(mark, 'click', function(){ 
						openPop8(thiswin);
                }); 
 }
 
  function placeWin3(mark,thiswin,id){
 				google.maps.event.addListener(mark, 'click', function(){ 
						openPop(thiswin);
						setColor(0);
						curSelect = id;
						setColor(1);
                }); 
 }
 
  function placeWin4(mark,thiswin){
 				google.maps.event.addListener(mark, 'click', function(){ 
						openPop4(thiswin);
                }); 
 }
 

 
 function contentMaker(cont){
 		var contentString = '<b>'+cont+'</b>'; 
 		return contentString;
 }
 
 function getCords(){
 	var point = map.getCenter();
	var xv = point.lat();
	var xy = point.lng();
 	var zm = map.getZoom();
	document.ha.val.value = xv+','+xy+','+zm;
 }
 
 
 
 var im;
 
 var mark1;
 function calculateRoute(zo,hots) { 
 
  
  if(zo == "DRIVING"){
  	im = "car.png";
  }else if(zo == "BICYCLING"){
 	im = "bike.png";
  }else{
  	im = "walk.png";
  }
 
 
 
 var ctrl1 = document.getElementById("controls_1");
 var ctrl2 = document.getElementById("controls_2");
 ctrl2.style.display = 'block';
 ctrl1.style.display = 'none';
	closePop();
     var myOptions = {
      mapTypeId: google.maps.MapTypeId.ROAD_MAP
    }
 	map.setOptions = myOptions;

  for (i = 0; i < markerArray2.length; i++) { 
    markerArray2[i].setMap(null); 
  } 
	
	
	
  // First, clear out any existing markerArray 
  // from previous calculations. 
  for (i = 0; i < markerArray.length; i++) { 
    markerArray[i].setMap(null); 
  } 
  

	
  // Retrieve the start and end locations and create 
  // a DirectionsRequest using WALKING directions. 
  var sx = document.hidform.lc_lat.value;
  var sy = document.hidform.lc_lng.value;
  var start = new google.maps.LatLng(sx, sy); 
  var end = new google.maps.LatLng(golfx, golfy); 
  
  if(hots == 1){
  
  var  image = new google.maps.MarkerImage('defimages/'+route_image, 
      new google.maps.Size(21, 23), 
      new google.maps.Point(0,0), 
      new google.maps.Point(10, 11)); 
	  
 var shadow = new google.maps.MarkerImage('defimages/'+route_image_shad, 
      new google.maps.Size(21, 23), 
      new google.maps.Point(0,0), 
      new google.maps.Point(9, 10));
	  
 var shape = { coord: [6,2,21,2,21,13,10,13,10,26,6,26], type: 'polygon'};
 
  }else{
  
   var  image = new google.maps.MarkerImage('defimages/'+route_image, 
      new google.maps.Size(30, 34), 
      new google.maps.Point(0,0), 
      new google.maps.Point(8, 26)); 
	  
 var shadow = new google.maps.MarkerImage('defimages/'+route_image_shad, 
      new google.maps.Size(30, 30), 
      new google.maps.Point(0,0), 
      new google.maps.Point(8, 26));
	  
 var shape = { coord: [6,2,21,2,21,13,10,13,10,26,6,26], type: 'polygon'};
 
  }
  
     var marks = new google.maps.Marker({ 
        position: end, 
        map: map, 
        shadow: shadow, 
        icon: image, 
        shape: shape, 
        title: golfname, 
        zIndex: 2 
    });
	
	markerArray2[0] = marks;
  
  var request = { 
      origin: start, 
      destination: end, 
	  unitSystem: google.maps.DirectionsUnitSystem.METRIC,
      travelMode: google.maps.DirectionsTravelMode[zo] 
  }; 
 
  // Route the directions and pass the response to a 
  // function to create markers for each step. 
  directionsService.route(request, function(response, status) { 
    if (status == google.maps.DirectionsStatus.OK) { 
 
      directionsDisplay.setDirections(response);  
      showSteps(response); 
    } else{
	     // var warnings = document.getElementById("warnings_panel"); 
     // warnings.innerHTML = "" + response.routes[0].warnings + "";
	 
	  document.getElementById("directionsPanel").innerHTML = "" + status + "";
 	  openInstr();
	}
  }); 
  
    var image2 = new google.maps.MarkerImage('defimages/'+route_image2, 
      new google.maps.Size(16, 16), 
      new google.maps.Point(0,0), 
      new google.maps.Point(8, 8),
	  new google.maps.Size(16, 16) ); 
	 
	  
     var shape2 = { coord: [8,8,8], type: 'circle'};
  
  
  	  	        mark1 = new google.maps.Marker({ 
		        position: new google.maps.LatLng(0,0), 
		        map: map, 
		        icon: image2, 
		        shape: shape2, 
		        title: "Stap", 
		        zIndex: 5 
				});
  
  
} 
var tresults;
var tbnds;
function showSteps(directionResult) { 
	var endsteps = "";
  // For each step, place a marker, and add the text to the marker's 
  // info window. Also attach the marker to an array so we 
  // can keep track of it and remove it when calculating new 
  // routes. 
  
  var image = new google.maps.MarkerImage('defimages/'+route_image2, 
      new google.maps.Size(12, 12), 
      new google.maps.Point(0,0), 
      new google.maps.Point(6, 6)); 
	 
	  
 var shape = { coord: [6,6,6], type: 'circle'};
  
  
  var myRoute = directionResult.routes[0].legs[0]; 
  

  	
    endsteps += '<div class=\"step\" onClick=\"resetMap()\">'+
	'<table border=0 cellspacing=0 cellpadding=0 width=\"100%\">'+
	'<tr>'+
	'<td colspan=2><strong>ROUTEPLANNER</strong></td>'+
	'</tr>'+
	'<tr>'+
	'<td colspan=2>Van:<strong>'+de_location+'</strong></td>'+
	'</tr>'+
	'<tr>'+
	'<td colspan=2>Naar:<strong>'+golfname+'</strong></td>'+
	'</tr>'+	
	'<tr>'+
	'<td><img src=\"defimages/icon1/'+im+'\" width=\"20\" height=\"20\" align=\"center\"></td>'+
	'<td width=\"100%\"><strong>'+myRoute.distance.text+'</strong> in <strong>'+myRoute.duration.text+'</strong></td>'+
	'</tr>'+
	'<tr>'+
	'<td colspan=2>[<a href=\"javascript:window.print()\">print route</a>]</strong></td>'+
	'</tr>'+	
	'</table>'+
	'</div>\n';
	
    endsteps += '<div class=\"stepline\"><img src=\"defimages/spacer.gif\" width=\"250\" height=\"1\" alt=\"\" border=\"0\"></div>\n';
	 
 
 var nums = myRoute.steps.length;
 
 tresults = myRoute;
 tbnds = directionResult.routes[0].bounds;
  for (var i = 0; i < nums; i++) { 

	  	        var markr = new google.maps.Marker({ 
		        position: myRoute.steps[i].start_point, 
		        map: map, 
		        icon: image, 
		        shape: shape, 
		        title: "Stap "+(i+1), 
		        zIndex: 4 
				});
	  
     // attachInstructionText(marker, myRoute.steps[i].instructions);
	// if(i == 0){
		// placeWin(markr, document.hidform.lc_name.value);
	// }else if(i == (nums-1)){
	// 	placeWin(markr, golfname);
	// }else{
	  	placeWin3(markr, (i+1)+". "+myRoute.steps[i].instructions,i);
	//  }
      markerArray[i] = markr; 
	  endsteps += '<div id=\"step'+i+'\" class=\"step\" onClick=\"showStep('+i+')\">'+(i+1)+'. '+myRoute.steps[i].instructions+'</div>\n';
	  //if(i < (nums-1)){
	 	endsteps += '<div class=\"stepline\"><img src=\"defimages/spacer.gif\" width=\"250\" height=\"1\" alt=\"\" border=\"0\"></div>\n';
	 //}
  } 
  
 document.getElementById("directionsPanel").innerHTML = endsteps;
 openInstr();

} 

function openInstr(){
 var sub2 = document.getElementById("directionsPanel");
 var sub1 = document.getElementById("normal_sub");
 sub2.style.display = 'block';
 sub1.style.display = 'none';
}
 
function attachInstructionText(marker, text) { 
  google.maps.event.addListener(marker, 'click', function() { 
    stepDisplay.setContent(text); 
    stepDisplay.open(map, marker); 
  }); 
} 
var poptext = "";
var curSelect = 0;
function showStep(die){


mark1.setPosition();

closePop();
var point = markerArray[die].getPosition();
var ltng = new google.maps.LatLng(point.lat(), point.lng());
map.setCenter(new google.maps.LatLng(point.lat(), point.lng()));
map.setZoom(18);
setColor(0);
curSelect = die;
setColor(1);
mark1.setPosition(point);
placeWin3(mark1,(die+1)+". "+tresults.steps[die].instructions,die);
//poptext = tresults.steps[die].instructions;
//var t2 = setTimeout("openPop3()", 500);

}
 

 function setColor(die){
 if(die == 0){
 document.getElementById("step"+curSelect).style.background = 'none';
 }else{
 document.getElementById("step"+curSelect).style.background = setcol;
 }
 }
 
 
 
 
 
var slideShowSpeed = 10000;
var difference = 1000;
var crossFadeDuration = 5;
var orderArr = [1,5,2,6,3,7,4,12,8,9,10,11];
 
 function startSlides(){
 	var timew = 0;
	
	
	 for(i=0;i<orderArr.length;i++){
	 	var tester = eval("lin"+orderArr[i]);
		if(tester != ""){
	 	document.images["SlideShow"+orderArr[i]].className = 'hand';
		}
		var ptest = eval("p"+orderArr[i]);
		if(ptest > 1){
			
			if(i == 0){
	  		 	runSlideShow(orderArr[i]);
			}else{
			  	eval("t"+orderArr[i]+" = setTimeout('runSlideShow("+orderArr[i]+")', timew);");
			}
			timew += difference;
	  	}
	 }
	
  

}
 
 

function runSlideShow(die) {
if (document.all) {
document.images["SlideShow"+die].style.filter="blendTrans(duration=2)";
document.images["SlideShow"+die].style.filter="blendTrans(duration=crossFadeDuration)";
document.images["SlideShow"+die].filters.blendTrans.Apply();
}
document.images["SlideShow"+die].src = eval("preLoad"+die+"[j"+die+"].src;");
eval("lin"+die+" = links"+die+"[j"+die+"];");
//lin1 = links1[j1];
var tlin = eval("lin"+die);
var im = document.images["SlideShow"+die];
if(tlin != ""){
im.className = 'hand';
}else{
im.className = 'no_hand';
}
if (document.all) {
document.images["SlideShow"+die].filters.blendTrans.Play();
}
eval("j"+die+" = j"+die+" + 1;");
//j1 = j1 + 1;
var ptester = eval("p"+die);
var jtester = eval("j"+die);
if (jtester > (ptester - 1)) eval("j"+die+" = 0;");
eval("t"+die+" = setTimeout('runSlideShow("+die+")', slideShowSpeed);");
}
 
 
 
 
 
function clickBan(daar){
lin = eval("lin"+daar);
if(lin != ""){
	if(lin.indexOf("http://",0) != -1){
		window.open(lin);
	}else{
		window.location = lin;
	}
}
}
 
 



function changeInputs(){
	if(document.getElementById("forms")){
	
	
	var els = document.getElementsByTagName('input');
	var elsLen = els.length;
	var i = 0;
	for ( i=0;i<elsLen;i++ ){
	
		if ( els[i].getAttribute('type') ){
		
			if (els[i].getAttribute('type') == "text"){
				els[i].className += 'text';
			}else if(els[i].getAttribute('type') == "radio"){
				els[i].className += 'radio';	
			}else if(els[i].getAttribute('type') == "button"){
				els[i].className += 'button';
			}
		
		}
		
	}
	}
}

