
	var numb = "0123456789";
	
	function isValid(parm, value)
	{
		if(parm == "")
			return true;
		for(i=0;i<parm.length;i++)
		{
			if(value.indexOf(parm.charAt(i),0) == -1)
				return false
		}
		return true;
	}

	function isNum(parm)
	{
		return isValid(parm,numb);
	}
	

	function selectLand(value)
	{
		if(value=="")
			return false;

		var re = new RegExp("[0-9]{1,2}\,[0-9]{1,2}");


		if(value.match(re))
		{
			var strArray = value.split(",");
			var land = strArray[1];
			var taalgebied = strArray[0];
			var landnum = strArray[2];

			var fileLocation = location.pathname.split("/");
			var filename = fileLocation[fileLocation.length-1];

			var queryString = location.search;
			var queryRegex = new RegExp(/\?(.*tid=)([0-9]{1,2})(.*lid=)([0-9]{1,2})(.*)/);
			location.href="index.php?action=changeland&tid="+taalgebied+"&lid="+land+'&land='+landnum;
		}
		else
		{
			var land = document.getElementById("land");
			window.open(value);
			land.options[curLand].selected=true;
		}
	}

	function selectMerk(model,taalgebied,land)
	{
		if(model!="")
		{
			location.href='modellen.php?tid='+taalgebied+'&lid='+land+'&mid='+model;
		}
	}

	var prevId;
	function showMenu(id1)
	{
		var element1 = document.getElementById(id1);
		var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;

		if(element1)
		{
			try
			{
				element1.style.display = 'table-row';

			}
			catch (e)
			{
				element1.style.display = 'block';
			}
		}
		if(IE6)
		{
			document.getElementById("automerk").style.visibility='hidden';
		}


	}

	function hideMenu(id1)
	{
		var element1 = document.getElementById(id1);
		var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
		
		if(element1)
		{
			try
			{
				element1.style.display = 'none';
			}
			catch (e)
			{
				element1.style.display = 'none';
			}
		}
		if(IE6)
		{
			document.getElementById("automerk").style.visibility='visible';
		}
	}

	function showSubMenu(id)
	{
		var element = document.getElementById(id);

		if(element)
		{
			try
			{
				element.style.display = 'table-row';
			}
			catch (e)
			{
				element.style.display = 'block';
			}
		}
	}

	function hideSubMenu(id)
	{
		var element = document.getElementById(id);
		if(element)
			element.style.display = 'none';
	}

	function hideSub(showId)
	{
		var elements = document.getElementsByTagName("DIV");
		
		for(i=0;i<elements.length;i++)
		{
			if(elements[i].id.match("subcat"))
			{
				elements[i].style.display = 'none';
				if(elements[i].id==showId)
					elements[i].style.display = 'table-row';
			}
		}
	}

	function numbersOnly(myfield, e)
	{
		var key;
		var keychar;

		if (window.event)
			key = window.event.keyCode;
		else if (e)
			key = e.which;
		else
			return true;

		keychar = String.fromCharCode(key);
		//alert(keychar);

		// control keys
		if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) || (key>=96 && key<=105) )
			return true;

		if ((("0123456789").indexOf(keychar) > -1))
		{
			//alert("test");
			return true;
		}
		else
			return false;
	}   
	function openwindow(details, output, w, h, scroll,set_x, move_y) 
	{
		
		if(typeof(move_y)=="undefined")
			move_y = 0;

		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;

		if(typeof(set_x)=="undefined")
			set_x = winl;

		
		winprops = 'height='+h+',width='+w+',top='+(wint+move_y)+',left='+set_x+',scrollbars='+scroll+',toolbar=no,menubar=no,resizable=no,location=no,directories=no,statusbar=no';
		win = window.open(details, output, winprops)
		
		if (parseInt(navigator.appVersion) >= 4) 
		{ 
			win.window.focus(); 
		}
	}

	function lsetup()
	{
		var loaderContainer = document.getElementById('loaderContainerWH');
		var body = document.getElementsByTagName('BODY')[0];
		loaderContainer.style.height = body.scrollHeight;
	}

	function lon()
	{
		document.getElementById('loaderContainer').style.display='';
	}

	function loff()
	{
		document.getElementById('loaderContainer').style.display='none';
	}

	if(window.attachEvent)
		window.attachEvent("onload",lsetup);

	//window.onload="lsetup()";

	function checkRegCode(formulier)
	{
		if(window.XMLHttpRequest)
		{
			try
			{
				req = new XMLHttpRequest();
			}
			catch (e)
			{
				req = false;
			}
			
		}
		else
		{	
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e) {
					req = false;
				}
			}
		}

		if(req)
		{
			req.onreadystatechange = processRegCode;
			req.open("GET","checkCode.php?id="+formulier.code.value, false);
			req.send("");
			return req.responseText;
		}
	}

	function processRegCode()
	{
		if(req.readyState == 4)
		{
			if(req.status == 200)
			{
				regCode = req.responseText;
				
			}
		}
	}

	function doDisplayRegion( regionName )
	{
	  var countieArrayIndex = -1;
	  for (var i = 0; i < countieArray.length; i++) {
		if (countieArray[i].name == regionName) {
		  countieArrayIndex = i;

		  document.regionForm.contactRegion.value=regionName;
		  break;
		}
	  } //einde for

	  with (document.regionForm.countie) {
		for (var i = options.length; i >= 0; i--) options[i] = null;

		if (countieArrayIndex >= 0) {
		  if (regionName.length > 0) {
		for (var i = 0; i < countieArray[countieArrayIndex].count; i++) {
		  options[i] = new Option(countieArray[countieArrayIndex][i].theLabel,
					  countieArray[countieArrayIndex][i].theValue);
		}
		  } 

		}
		else {
		  if (regionName.length == 0) {
		options[0] = new Option("please select a region", 0);
		  } else {
		options[0] = new Option("no dealers available", 0);
		  }
		}
	  } //einde with
	} //einde doDisplayRegion

	function openWindow(url,target,width,height,options)
    {
		var posX = (screen.width/2)-(width/2);
        var posY = (screen.height/2)-(height/2);

        win = window.open(url,target,options+",width="+width+",height="+height+",left="+posX+",top="+posY);
		win.focus();
    }

	function doSubmitDealer(formulier)
	{
		if(formulier.zipcode.value=='Uw postcode' || formulier.zipcode.value=='')
		{
			alert("U dient uw postcode in te voeren.");
			formulier.zipcode.focus();
		}
		else
		{
			formulier.target = "maplayer";
			
			openWindow('',"maplayer",695,465,'scrollbars=yes,status=no,resizable=no');
			//formulier.action = action;
			//formulier.task.value = task;
			formulier.submit();
		}
	}

	function doSubmitCountie()
	{
	  if (document.regionForm.countie.value != 0) {
		document.regionForm.submit();
	  }

	} //einde doSubmitCountie

	function openBackLink(url) 
	{ 
		try 
		{
			if (top.location == window.location) 
			{ // geen frames
				window.location.href = url
			}
			else
				if (top.location.href.indexOf('locator.locatienet.com') != -1) 
				{ // framing  binnen locator
					top.location.href = url;
				}
		} 
		catch(e) 
		{
			location.href = url;
		}
	} 

	function toggle(id)
    {
		alert(id);
        switch(id)
        {
            case "street":
                document.locatieform.zipcode.value='';
                document.getElementById('street1').style.display='';
                document.getElementById('street2').style.display='';
                document.getElementById('zipcodetd').style.display = 'none';
                break;
            case "zipcodetd":
                document.locatieform.city.value='';
                document.locatieform.street.value='';
                document.getElementById('street1').style.display='none';
                document.getElementById('street2').style.display='none';
                document.getElementById('zipcodetd').style.display = '';
                break;
        }
        selectedId = id;
    }

    function openWindow(url,target,width,height,options)
    {
		var posX = (screen.width/2)-(width/2);
		var posY = (screen.height/2)-(height/2);

        win = window.open(url,target,options+",width="+width+",height="+height+",left="+posX+",top="+posY);
        win.focus();
    }
	
	function doSubmit(formulier)
	{
        formulier.target = "maplayer";
        openWindow('',"maplayer",695,465,'dialog,modal,scrollbars=yes,status=no,resizable=no');
	    //formulier.action = action;
	    //formulier.task.value = task;
	    formulier.submit();
	}


var img = new Image();
img.src="../images/bg_grijs.gif";
var img2 = new Image();
img.src="../images/schaduw_menu.gif";
var img3 = new Image();
img.src="../images/schaduw_menu.gif";

