
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function  showHideLayers(mdiv,mimg,imgup,imgdown) { //v6.0
    var obj,imgobj;
	obj=MM_findObj(mdiv);
	imgobj = MM_findObj(mimg); 
	obj=obj.style;
	 
    if (obj.visibility=='visible' || obj.visibility==''){ 
			imgobj.src=imgdown;//"img/button_down.gif"; 
			obj.visibility= "hidden"; 
			obj.overflow = "hidden";
			obj.height="1px";}
    else{
		imgobj.src=imgup;//"img/button_up.gif";
		obj.visibility= "visible";     		
		obj.overflow = "";
		obj.height="";}
}


var doPlaatsen = true;
	document.onkeypress = function(e) {

		if (window.event) {e=event;} //IE	
		if (e.keyCode==13 && document.getElementById("showPlaatsen").style.visibility == 'visible') {
			document.getElementById("getPlaats").value = document.getElementById("selectlistPlaats").options[document.getElementById("selectlistPlaats").selectedIndex].value;
			document.getElementById("showPlaatsen").innerHTML = '';
			document.getElementById("showPlaatsen").style.visibility = "hidden";
		}
	}
	
function selectPlaats(plaats) {
 
	document.getElementById("getPlaats").value = plaats;
	document.getElementById("showPlaatsen").innerHTML = '';
	document.getElementById("showPlaatsen").style.visibility = "hidden";
	document.formcity.submit();
}

	
function handleArrowKeys(evt) {
    evt = (evt) ? evt : ((window.event) ? event : null);
    if (evt) {
        switch (evt.keyCode) {
            case 40:
				if (document.getElementById("showPlaatsen").style.visibility == 'visible') {	
					 
					if (document.getElementById("selectlistPlaats").selectedIndex + 1 != document.getElementById("selectlistPlaats").options.length) {
						document.getElementById("selectlistPlaats").selectedIndex = document.getElementById("selectlistPlaats").selectedIndex + 1;
					} 
				}
                break;    
            case 38:
				if (document.getElementById("showPlaatsen").style.visibility == 'visible') {	
				 
						if (document.getElementById("selectlistPlaats").selectedIndex != '0') {
								document.getElementById("selectlistPlaats").selectedIndex = document.getElementById("selectlistPlaats").selectedIndex - 1;
							}
				}
                break;   
			default:
				plaatsen();
				break;
         }
    }
}

var selectlistPlaats_hor;
var selectlistPlaats_ver;

function getselectlistPlaatsPositions() {
	selectlistPlaats_hor = document.getElementById("selectlistPlaats").style.left;
	selectlistPlaats_ver = document.getElementById("selectlistPlaats").style.top;
}

document.formcity.City.onkeyup = handleArrowKeys;

function hideDiv() {
	if (document.getElementById("selectlistPlaats")) {
		document.getElementById("selectlistPlaats").style.visibility = 'hidden';
	}
}

function plaatsen() {
	 
if (doPlaatsen == true) {
	 
	var xmlHttpReq = false;
	var self = this;
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	 
	self.xmlHttpReq.open('POST', "cities.asp", true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
	if (self.xmlHttpReq) {
		 
	if (self.xmlHttpReq.readyState == 4) {
		
		if (self.xmlHttpReq.responseText == 'plaats_volledig_ingevuld') {
			document.getElementById("showPlaatsen").innerHTML = '';
			document.getElementById("showPlaatsen").style.visibility = "hidden";
		} else if (self.xmlHttpReq.responseText != '') {
			document.getElementById("showPlaatsen").innerHTML = self.xmlHttpReq.responseText;
			document.getElementById("showPlaatsen").style.visibility = "visible";
		} else if (document.getElementById("getPlaats").value == '') {
			document.getElementById("showPlaatsen").innerHTML = '';
			document.getElementById("showPlaatsen").style.visibility = "hidden";
		}
	}
}
}
	self.xmlHttpReq.send("plaats=" + document.getElementById("getPlaats").value);
	}
}
	



//____________________________________________________________________________________________________ 
function moveYbySlicePos (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = par.offsetParent;
		}		
	} else if (img.y >= 0) y += img.y;
	return y;
}
//____________________________________________________________________________________________________ 
function moveXbySlicePos (x, img) { 
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = par.offsetParent;
		}
	} else if (img.x) x += img.x;
	return x;
}
//____________________________________________________________________________________________________ 
function moveDiv(mdiv,mimg){
	var objdiv = MM_findObj(mdiv);
	var objimg = MM_findObj(mimg);
	var cX , cY;
	cX = moveXbySlicePos(0,objimg);
    cY= moveYbySlicePos(0,objimg);
	objdiv.style.left = cX  - 2 ; 
	objdiv.style.top = cY  + 5;	
}
//____________________________________________________________________________________________________ 

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}



