function checkGratisInternet(){
 el = document.forms[0].gratisinternet;
 if(!el[0].checked){
   document.getElementById("gratisinterneterror").style.display="block";
 }else{
   document.getElementById("gratisinterneterror").style.display="none";
 }
}
function wis(){
  document.getElementById("title").value ="";
  document.getElementById("snelweg").selectedIndex =0;
	 document.getElementById("city").selectedIndex =0;
	/*document.getElementById("activity").selectedIndex =0;
  document.getElementById("totalpeople").selectedIndex =0;
	*/
	allel = document.getElementsByTagName("input");

	for(i=0;i<allel.length;i++){
	  if(allel[i].type.toUpperCase()=="CHECKBOX"
		||allel[i].type.toUpperCase()=="RADIO"){
		allel[i].checked=false;
		}
	}
  //document.getElementById("province").selectedIndex =0;
	setCookie("WIS","TRUE");
	
	document.location = "/index.php";
 // document.getElementById("sphere").selectedIndex =0;
}
function doProvinceChange(selbox){

selbox.form.action = document.location.href;
selbox.form.onsubmit = null;
selbox.form.submit();
}

function showPeople(selbox){
 people =  document.forms[0]["totalpeople"];
 //alert(people.style.backgroundColor);
 if(selbox.selectedIndex > 0){
  //document.getElementById('totalpeoplerow').style.backgroundColor='white';
	  people.style.backgroundColor='white';
 }else{
 
     people.selectedIndex=0;
	people.style.backgroundColor='#999999';
 }
}
function openLink(href){
 window.open(href.href);
 return false;
}

function editMe(type, id){
  window.open('/beheer/editors/popupeditor.php?func='+type+'&id='+id,'media','width=500,height=700,scrollbars=yes,resizable=yes');
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "; path=/") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "; path=/") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function setNewWindowLinks(){
  dlinks = document.links;
	for(i=0;i<dlinks.length;i++){
    hf=dlinks[i].href;
	if(hf.indexOf(document.location.hostname) <0 && hf.indexOf("javascript:") <0 ){
		dlinks[i].target="_blank";
	}
	if(hf.indexOf('?')>0){
	  hf=hf.substr(0,hf.indexOf('?'));
	}
	last4 =hf.substr(hf.length-4,4).toLowerCase();
	if(last4=='.txt' 
	   || last4=='.pdf' 
	   || last4=='.txt' 
	   || last4=='.jpg' 
	   || last4=='.gif' 
	   || last4=='.wmv' 
	   || last4=='.mp3'){
		dlinks[i].target="_blank";
	
	}
	//alert(last4); 
  }
}
/**********  google maps */
  
var map = null;
    var geocoder = null;
    var notfound = ""; 
	var cindex = 0;  
    var mtype= 'a';
    var loaded =0;
function setUpLatLong(){
 //alert('hoi') ;
 el = document.forms[0]['googlepoint'];
 
 var p1 = document.createElement('p');
 //p1.style.float="left";
 var theNewA = document.createElement('a');
 theNewA.href="javascript:void(getLatLong())";
 //theNewA.onclick="";
 theNewA.innerHTML="zoek google voor Google point";
 p1.appendChild(theNewA);
 //alert(p1.outerHTML);
 el.parentNode.appendChild(p1);
}		
function getLatLong(){
  geocoder = new GClientGeocoder();
       
 straat = document.forms[0]['street'].value;
 nummer = document.forms[0]['housenumber'].value;
 stad = document.forms[0]['city'].value;
  postcode = document.forms[0]['postcode'].value;
 if(straat !="" && nummer !="" && stad !=""){
 geocoder.getLatLng(straat+" "+nummer+","+postcode+" "+stad+",Netherlands ",setAdminPoint);
 }else{
   alert("Straat, huisnummer, en stad is verplicht om te zoeken");
 }
 //longi = document.forms[0]['latitude'];
 
 return false;
}
function setAdminPoint( point) {
	lati = document.forms[0]['googlepoint'];
  //longi = document.forms[0]['latitude'];
  if (!point) {
	   alert("Geen locatie gevonden.");
	} else {
    lati.value=point;
	}
}
function resetMapCenter( point) {
	if (!point) {
	  // alert("Geen locatie gevonden.");
	} else {
   //lati.value=point;
	 map.setCenter(point, 12);
					
	}
}
 function initializeMap() {
 //alert('called');
     if (GBrowserIsCompatible()) {
		      map = new GMap2(document.getElementById("map_canvas"));
          map.addControl(new GSmallMapControl());
          map.addControl(new GMapTypeControl());
             map.setCenter(new GLatLng(52.5, 5.5), 7);
					if(fcity){
					  
              geocoder = new GClientGeocoder();
            geocoder.getLatLng(fcity+",Netherlands ",resetMapCenter);
          }	 
          geocoder = new GClientGeocoder();
          showAddress();
     }
 }
      
 function initializeMapDetail() {
 //alert('called');
     if (GBrowserIsCompatible()) {
          map = new GMap2(document.getElementById("map_canvas"));
          map.addControl(new GSmallMapControl());
          map.addControl(new GMapTypeControl());
           geocoder = new GClientGeocoder();
					cindex = 0;
					 var latlong = mapitems[cindex][0];
		      latlong = latlong.replace("(","");
		      latlong = latlong.replace(")","");
		      var latlongarr= latlong.split(",");
		       var latlongpoint =new  GLatLng(parseFloat(latlongarr[0]),parseFloat(latlongarr[1]));
	         var marker = new GMarker(latlongpoint);
	         map.setCenter(latlongpoint, 14);
         var desc = mapitems[cindex][1];
		//alert(marker);
	  map.addOverlay(marker);
	  GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(desc);});
	 
         // showDetailAddress();
     }
 }
      
	
 function showAddress() {
  if(cindex <mapitems.length){
	   var latlong = mapitems[cindex][0];
		latlong = latlong.replace("(","");
		latlong = latlong.replace(")","");
		var latlongarr= latlong.split(",");
		//alert(parseFloat(latlongarr[1]));
		var latlongpoint =new  GLatLng(parseFloat(latlongarr[0]),parseFloat(latlongarr[1]));
	  //	var latlongpoint = new GPoint(52,5);
	  //var latlongpoint = GPoint(parseFloat(latlongarr[0]),parseFloat(latlongarr[1]),true);
		//alert(latlongpoint.x);
	  var marker = new GMarker(latlongpoint);
	  var desc = mapitems[cindex][1];
		//alert(marker);
	  map.addOverlay(marker);
	  GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(desc);});
	  cindex++;
	  showAddress();
	}
}

function body_onload(){
   setNewWindowLinks();
}
function showPlaats(){
 document.getElementById("trplaats").className='isblock';
 document.getElementById("trsnelweg").className='isnone';
}
function showSnelweg(){

 document.getElementById("trplaats").className='isnone';
 document.getElementById("trsnelweg").className='isblock';
}
/** ajax details **/
function getAjaxDetails(link){
//alert('get ajax details');
if(getJaxUrl(link)){
  return false;
	}else{
	return true;
	}
}
var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
}

function getJaxUrl(link) { 
 if(http){
  http.open("GET", link.href+"?jax=true", true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      var rip = http.responseText;
			 var offset =rip.indexOf('<!--endxml-->')-(rip.indexOf('<!--startxml-->')+15);
      rip = rip.substr(rip.indexOf('<!--startxml-->')+15,offset);
      document.getElementById('dynResultText').innerHTML = "<div class=\"clear\"><br/></div>"+rip+"<div class=\"clear\"><br/></div>" ;
      window.location = String(window.location).replace(/\#.*$/, "") + "#dynResultText";
    }
  }
  http.send(null);
  
	return true;
	}else{
	return false;
	}
}

