// JavaScript Document

function SelecteerKleurLinks(Id, url_start) {
	if (Id != "") {
		if (document.getElementById('KleurLinks' + Id).className == "color") {
			document.getElementById('KleurLinks' + Id).className = "color_aan";
			sendRequest(url_start + "Include/Ajax/KleurSessie.php?Id=" + Id);
		} else {
			document.getElementById('KleurLinks' + Id).className = "color";
			sendRequest(url_start + "Include/Ajax/KleurSessieVerwijderen.php?Id=" + Id);
		}
	} 
	LaadProducten(url_start);
}
function LaadProducten(url_start) {
	if (document.getElementById('Loading')) {
		document.getElementById('Loading').style.display = "block";
	}
	sendRequestToDiv(url_start + "Include/Ajax/LaadProducten.php",'ProductenContent');
	if (window.location != "http://www.luqi.nl/Producten/Overzicht.php" && window.location != "http://luqi.nl/Producten/Overzicht.php" && window.location != "http://www.luqi.be/Producten/Overzicht.php" && window.location != "http://luqi.be/Producten/Overzicht.php") {
		document.location = url_start + 'Producten/Overzicht.php';
	}
	
}
function ProductGroepenSessie(Id, url_start) {
	if (Id != "") {
		if (document.getElementById('ProductGroepen' + Id).checked) {
			sendRequest(url_start + "Include/Ajax/ProductGroepenSessie.php?Id=" + Id);
		} else {
			sendRequest(url_start + "Include/Ajax/ProductGroepenSessieVerwijderen.php?Id=" + Id);
		}
	} 
	LaadProducten(url_start);
}

function MatenSessie(Id, url_start) {
	if (Id != "") {
		if (document.getElementById('Maten' + Id).checked) {
			sendRequest(url_start + "Include/Ajax/MatenSessie.php?Id=" + Id);
		} else {
			sendRequest(url_start + "Include/Ajax/MatenSessieVerwijderen.php?Id=" + Id);
		}
	} 
	LaadProducten(url_start);
}


function MerkenSessie(Id, url_start) {
	if (Id != "") {
		if (document.getElementById('Merken' + Id).checked) {
			sendRequest(url_start + "Include/Ajax/MerkenSessie.php?Id=" + Id);
		} else {
			sendRequest(url_start + "Include/Ajax/MerkenSessieVerwijderen.php?Id=" + Id);
		}
	} 
	LaadProducten(url_start);
}



function SoortenSessie(Id, url_start) {
	if (Id != "") {
		if (document.getElementById('Soorten' + Id).checked) {
			sendRequest(url_start + "Include/Ajax/SoortenSessie.php?Id=" + Id);
		} else {
			sendRequest(url_start + "Include/Ajax/SoortenSessieVerwijderen.php?Id=" + Id);
		}
	} 
	LaadProducten(url_start);
}




function UpdateWinkelwagen(url_start,i,prijs){
	var Aantal = document.getElementById("Aantal"+i).value;
	sendRequestToDiv(url_start + "Include/Ajax/UpdateWinkelwagen.php?Prijs=" + prijs +"&i=" +i+"&aantal="+Aantal,'WinkelwagenPrijs' + i);
}

function UpdateWinkelwagenCombinatie(url_start,i,prijs){
	var Aantal = document.getElementById("Aantal"+i).value;
	sendRequestToDiv(url_start + "Include/Ajax/UpdateWinkelwagenCombinatie.php?Prijs=" + prijs +"&i=" +i+"&aantal="+Aantal,'WinkelwagenPrijsCombinatie' + i);
}

function LaadKleuren(url_start, prijs) {
	var Product = document.getElementById('ProductId').value;
	var Maat = document.getElementById('Maten').options[document.getElementById('Maten').selectedIndex].value;
	var Kleur = document.getElementById("GeselecteerdeKleur").value;
	var url = url_start + "Producten/Ajax/LaadKleuren.php?Maat=" + Maat + "&Product=" + Product ;
	sendRequestToDiv(url, 'Kleuren');
	document.getElementById('Kleuren_container').style.display = 'block';
}

function LaadPrijs(url_start) {
	var Product = document.getElementById('ProductId').value;
	var Maat = document.getElementById('Maten').value;
	var Kleur = document.getElementById("GeselecteerdeKleur").value;
	
	//document.getElementById("Mandje").innerHTML = "";
	
	var url = url_start + "Producten/Ajax/LaadPrijs.php?Maat=" + Maat +"&Kleur=" + Kleur + "&Product=" + Product ;
	//sendRequestToDiv(url, 'Prijs');
	$('#Prijs').load(url, null, function() {
		ShowMandje();
	});
	
	var url = url_start + "Producten/Ajax/LaadOudePrijs.php?Maat=" + Maat +"&Kleur=" + Kleur + "&Product=" + Product ;
	//sendRequestToDiv(url, 'OudePrijs');
	$('#OudePrijs').load(url);

	document.getElementById("Combinatie").href = url_start + 'Producten/Meer_opties.php?proId='+Product+'&kleId='+Kleur+'&maaId='+Maat;
	var url = url_start + "Producten/Ajax/LaadCombinatie.php?Maat=" + Maat +"&Kleur=" + Kleur + "&Product=" + Product ;
	//sendRequestToDiv(url, 'Combinatie');
	$('#Combinatie').load(url);
	//setTimeout("ShowMandje();", 300);	
}

function WinkelNaarMandje(skipMatenCheck) {
	if(skipMatenCheck == true || document.getElementById('Maten').value != 'Empty') {
		document.form.submit();
	} else {
		alert('Selecteer een maat!');
	}
}

function ShowMandje() {
	if (document.getElementById("Prijs").innerHTML != "" && document.getElementById("Prijs").innerHTML != " ") {
		document.getElementById("Mandje").innerHTML = "In mandje plaatsen";
	} else {
		document.getElementById("Mandje").innerHTML = "";
	}
}

function SelecteerKleur(Id, Count) {
	var Border2 = "";
	for (var i=1;document.getElementById("Kleur" + i);i++) {
		Border2 = document.getElementById("Kleur"+i).style.border;
		if (Border2.match(/#90a2d8/) && i != Count || Border2.match(/144/)  && i != Count) {
			document.getElementById("Kleur"+i).style.border = "#fff 3px solid";
		}
	}
	
	var Border = document.getElementById("Kleur"+Count).style.border;
	if (Border.match(/#fff/) || Border.match(/255/)) {
		document.getElementById("Kleur"+Count).style.border = "#90a2d8 3px solid";
		document.getElementById("GeselecteerdeKleur").value = Id;
	} 
}

function AlleKleuren() {
	if (document.getElementById('color_picker_extra').style.display == "none") {
		document.getElementById('color_picker_extra').style.display = "block";
		document.getElementById('AlleKleuren').innerHTML= "Minder kleuren";
	} else {
		document.getElementById('color_picker_extra').style.display = "none";
		document.getElementById('AlleKleuren').innerHTML= "Alle kleuren";
	}
}

function ZoekVeldFocus() {
	if (document.getElementById('Zoeken').value == "Zoekterm...") { 
		document.getElementById('Zoeken').value = "";
	} 
}


function ZoekVeldBlur() {
	if (document.getElementById('Zoeken').value == "") { 
		document.getElementById('Zoeken').value = "Zoekterm...";
	} 
}

// Functie om het KLEINE formulier te controleren.
function KleinControleer(){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	var Foutmelding = '';
	submitOK = 'True';

	
	if (document.KleinFormulier.Name.value.length == 0){
		Foutmelding = Foutmelding + '- Name.\n';
		document.KleinFormulier.Name.style.border = '1px solid #ff0000';
		submitOK = 'False';
	}
	else{
		document.KleinFormulier.Name.style.border = '1px solid #000000';
	}
	
	if (submitOK == 'False'){
		alert('You have to fill the next fields:\n' + Foutmelding);
		return false;
	}
}

function controleerNieuwsbrief(){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	var Foutmelding = '';
	submitOK = 'True';
	if (document.form_nws.nieuwsbrief_naam.value.length == 0){
		Foutmelding = Foutmelding + '- Naam.\n';
		document.form_nws.nieuwsbrief_naam.style.border = '1px solid #ff0000';
		submitOK = 'False';
	}
	else{
		document.form_nws.nieuwsbrief_naam.style.border = '1px solid #000000';
	}
	var email = document.form_nws.nieuwsbrief_email.value;
	if (!filter.test(email)) {
		Foutmelding = Foutmelding + '- Email.\n';
		document.form_nws.nieuwsbrief_email.style.border = '1px solid #ff0000';
		submitOK = 'False';
	}
	else{
		document.form_nws.nieuwsbrief_email.style.border = '1px solid #000000';
	}
	
	if (submitOK == 'False'){
		alert('De volgende velden moeten ingevuld zijn voor aanmelding:\n' + Foutmelding);
		return false;
	} else {
		document.form_nws.submit();
	}
}
// Einde van deze functie.


function submenu(ID){
if (document.getElementById(ID).className == 'puldown_uit')
	{
	document.getElementById(ID).className = 'puldown';
	}
	else 
	{
	document.getElementById(ID).className = 'puldown_uit';
	}
}

function submenu_wit(ID){
if (document.getElementById(ID).className == 'puldown_wit_uit')
	{
	document.getElementById(ID).className = 'puldown_wit';
	}
	else 
	{
	document.getElementById(ID).className = 'puldown_wit_uit';
	}
}