var xmlhttp;
var http;
var browser = navigator.appName;
var geenajax=false;

function getHttpObject(){
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	} 
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (f) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (g) {
				var geenajax=true;
				//alert("Your browser does not support AJAX technology!");
				return false;
			}
		}
	}
	return xmlHttp;
}
xmlhttp=getHttpObject();

function showImage(id,product,productid) {
if (xmlhttp) { 
	xmlhttp.open("GET", "/module/productafbeeldingen.php?id="+id+"&product="+product+"&productid="+productid);
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4){
			var response = xmlhttp.responseText;
		    document.getElementById('fotogroot').innerHTML = response;
		}
	};
	xmlhttp.send(null);
 }
}

function emailDealer(id,email) {
if(geenajax===false)
	{
		if (xmlhttp)
			{ 
				xmlhttp.open("GET", "/module/dealer_info.php?id="+id+"&soort=email");
				xmlhttp.onreadystatechange = function()
					{
						if(xmlhttp.readyState == 4)
							{
								var response = xmlhttp.responseText;
								window.open("mailto:"+email);
							}							
					};
				xmlhttp.send(null);
			 }
	}
else
	{
		document.getElementById('setdealerinfo').location.href="/module/dealer_info.php?id="+id+"&soort=email";
		window.open("mailto:"+email);
	}
}

function websiteDealer(id,website) {
if(geenajax===false)
	{
		if (xmlhttp) { 
			xmlhttp.open("GET", "/module/dealer_info.php?id="+id+"&soort=website");
			xmlhttp.onreadystatechange = function() {
				if(xmlhttp.readyState == 4){
					window.open("http://"+website);
				}
			};
			xmlhttp.send(null);
		 }
	}
else
	{
		document.getElementById('setdealerinfo').location.href="/module/dealer_info.php?id="+id+"&soort=website";
		window.open("http://"+website);
	}
}

function checkSubmit(taal) 
	{
		var empty = "";	
		var e = document.getElementById('zoeken');
		if(taal=='nl'){if (e.key.value === "" || e.key.value == "Typ hier uw zoekwoord") { empty +="U heeft geen juist zoekwoord ingevoerd\n";}}
		//if(taal=='en'){if (e.key.value == "" || e.key.value == "Search") { empty +="The search request you sent is nog right\n";}}
		//if(taal=='de'){if (e.key.value == "" || e.key.value == "Suchen") { empty +="Ihrer Suchanfrage is nicht richtig\n";}}
		if ( empty === "")
			{
				e.submit();
                return true;
			}
		else
			{
				alert(empty); return false;
			}
	}

function checkSubmit2(taal) 
	{
		var empty = "";	
		var e = document.getElementById('form2');
		if(taal=='nl'){if (e.key2.value === "" || e.key2.value == "Typ hier uw zoekwoord") { empty +="U heeft geen juist zoekwoord ingevoerd\n";}}
		//if(taal=='en'){if (e.key2.value == "" || e.key2.value == "Search") { empty +="The search request you sent is nog right\n";}}
		//if(taal=='de'){if (e.key2.value == "" || e.key2.value == "Suchen") { empty +="Ihrer Suchanfrage is nicht richtig\n";}}
		if ( empty === "")
			{
				e.submit();
			}
		else
			{
				alert(empty); return false;
			}
	}

function zoekCheck(){
        
		var e = document.getElementById('postcodeform');
		var empty = "";	
		var pattern = /^[0-9]*$/;
		//var waarde = CheckPostcodeCijfers(e.postcode.value);
		if (e.postcode.value === "" || e.postcode.length<'4' || pattern.test(e.postcode.value)===false)
			{
				empty +="U moet de 4 cijfers van uw postcode invoeren.\n";
				e.postcode.value='';
			}
		if (e.postcode.value < 1000)
			{
				empty +="U heeft een ongeldige postcode ingevoerd.\n";
				e.postcode.value='';
			}	
		
		straalCheck=false; 
		for (i=0; i<e.straal.length; i++){ 
			if (e.straal[i].checked){ 
				straalCheck=true; 
			} 
		} 
		
		if (!straalCheck){empty +="U bent vergeten om de straal aan te geven\n";}
	
		if ( empty === "")
			{
				e.submit();
			}
		else
			{
				alert(empty); return false;
			}
}

function checkField(){
	var e = document.getElementById('zoeken');
	if(e.key.value == "Typ hier uw zoekwoord")
		{
			e.key.value = "";
		}
	else
		{
			return false;
		}
}

function thisMovie(movieName) {
  if(document.embeds[movieName]){
    return document.embeds[movieName];
  }
  if(window.document[movieName]){
    return window.document[movieName];
  }
  if(window[movieName]){
    return window[movieName];
  }
  if(document[movieName]){
    return document[movieName];
  }
}

function javas(targ) {
    var flashObj = thisMovie("menu_alpha");
    flashObj.javaSwitch(targ);
} 

function testje() {
    alert("test");
}

