// JavaScript Document

function Zoek_Focus(){
	var Zoek = document.getElementById('Header_Zoek');
	if(Zoek.value == "Zoek"){
		Zoek.value = "";
		Zoek.style.color = "#000000";
	}	
}

function Zoek_blur(){
	var Zoek = document.getElementById('Header_Zoek');
	if(Zoek.value == ""){
		Zoek.value = "Zoek";
		Zoek.style.color = "#CCCCCC";
	}
}

//AJAX DINGSKE
function makeXmlHttp(){
	var xmlhttp = null;
	if(window.XMLHttpRequest){
	xmlhttp = new XMLHttpRequest();
	}else{
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){
			window.alert("Uw browser ondersteunt het XMLHttpRequest object niet!");
		}
	}
	
	return xmlhttp;
}

//CONTROLEERD EMAIL
function validate_email(field){
	with (field)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2){
			return false;
		}
		else{
			return true;
		}
	}
}

//FUNCTIE wordt aangeroepen op contact pagina voor controleren van waardes.
function Contact_checkForm(){
	//Reset vorgige waardes
	var FoutGevonden = 0;
	document.getElementById('contact_Vnaam').style.borderColor 		= '#CCCCCC';
	document.getElementById('contact_Anaam').style.borderColor 		= '#CCCCCC';
	document.getElementById('contact_Tel').style.borderColor		= '#CCCCCC';
	document.getElementById('contact_Email').style.borderColor 		= '#CCCCCC';
	document.getElementById('contact_Bericht').style.borderColor 	= '#CCCCCC';
	document.getElementById('contact_FoutMelding').style.display 	= "none" ;
	
	if(document.getElementById('contact_Vnaam').value == ""){
		document.getElementById('contact_Vnaam').style.borderColor = '#FF0000';
		FoutGevonden = 1;
	}
	if(document.getElementById('contact_Anaam').value == ""){
		document.getElementById('contact_Anaam').style.borderColor = '#FF0000';
		FoutGevonden = 2;
	}
	if(document.getElementById('contact_Tel').value == ""){
		document.getElementById('contact_Tel').style.borderColor = '#FF0000';
		FoutGevonden = 3;
	}
	if(document.getElementById('contact_Email').value == ""){
		document.getElementById('contact_Email').style.borderColor = '#FF0000';
		FoutGevonden = 4;
	}
	if(validate_email(document.getElementById('contact_Email')) == false){
		document.getElementById('contact_Email').style.borderColor = '#FF0000';	
		FoutGevonden = 5;
	}
	if(document.getElementById('contact_Bericht').value == ""){
		document.getElementById('contact_Bericht').style.borderColor = '#FF0000';
		FoutGevonden = 6;
	}
	
	if(FoutGevonden == 0){
		Contact_VerstuurForm()
	}else{
		document.getElementById('contact_FoutMelding').style.display = "block" ;
	}	
}

function Contact_VerstuurForm()
{
	var xmlhttp = makeXmlHttp(); 		
	xmlhttp.open("post", "VerzendEmail.php", true); 
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function() { 
		if(xmlhttp.readyState == 4){		
			document.getElementById('contact_message1').style.display = "none" ;
			document.getElementById('contact_message2').style.display = "block" ;					
		}
	}
	document.getElementById('contact_tabel').style.display = "none" ;
	document.getElementById('contact_message1').style.display = "block" ;
	submitstring = 'contact_Vnaam=' + document.getElementById('contact_Vnaam').value + '&contact_Anaam=' + document.getElementById('contact_Anaam').value + '&contact_Tel=' + document.getElementById('contact_Tel').value + '&contact_Email=' + document.getElementById('contact_Email').value + '&contact_Bericht=' + document.getElementById('contact_Bericht').value;
	xmlhttp.send(submitstring);
			
}

function showImage(id){
    var toonImage = document.getElementById('big_' + id);
    toonImage.style.display = 'block';

    toonImage.onclick = function(){
       toonImage.style.display = 'none'
    };
}

//product dingskes goed weergen
function DisplayExtraInfo(id){
	var DivExtraInfo		= document.getElementById('ExtraInfoId_' + id);
	var DivExtraInfoKnop	= document.getElementById('extraInfo_knopId_' + id);

	if(DivExtraInfo.style.display == 'block'){
		DivExtraInfo.style.display 					= 'none';
		DivExtraInfoKnop.style.backgroundImage 		= "URL(Images/ico_rondje_2.png)";
	}else{
		document.getElementById('Opties_' + id).style.display 			= 'none';
		document.getElementById('Opties_knopId_' + id).style.backgroundImage 	= "URL(Images/ico_rondje_2.png)";
		DivExtraInfo.style.display 										= 'block';	
		DivExtraInfoKnop.style.backgroundImage 							= "URL(Images/ico_rondje_1.png)";
	}
}

//product dingskes goed weergen
function Displayopties(id){
	var DivExtraInfo		= document.getElementById('Opties_' + id);
	var DivExtraInfoKnop	= document.getElementById('Opties_knopId_' + id);

	if(DivExtraInfo.style.display == 'block'){
		DivExtraInfo.style.display 					= 'none';
		DivExtraInfoKnop.style.backgroundImage 		= "URL(Images/ico_rondje_2.png)";
	}else{
		document.getElementById('ExtraInfoId_' + id).style.display 			= 'none';
		document.getElementById('extraInfo_knopId_' + id).style.backgroundImage 	= "URL(Images/ico_rondje_2.png)";
		DivExtraInfo.style.display 											= 'block';	
		DivExtraInfoKnop.style.backgroundImage 								= "URL(Images/ico_rondje_1.png)";
	}
}




