var W3CDOM = (document.createElement && document.getElementsByTagName);

function ChangeItemColor(artikelcode, lang){
	
	ImageChange()
	document.getElementById('thumbnail').src = "http://212.79.244.173/thumbnailer.php?src=./media/products/" + artikelkleur_code + ".jpg&lang="+ lang + "";
	document.getElementById('thumbnail').alt = artikelkleur_code;
	
	document.getElementById('imagepopup').href = "javascript:ShowImage('http://212.79.244.173/media/products/" + artikelkleur_code + ".jpg')";
	
	document.getElementById('order').href = "/ankyshop/?open=shop&productid=" + artikelcode + "&bestel=1&color=" + document.getElementById('colors').value;
}

function ShowImage(src){
	iLeft = (screen.width - 300) / 2;
	iTop = (screen.height - 150) / 2;

	popup = window.open("http://212.79.244.173/showimage.php?src=" + src,"","scrollbars=yes,resizable=0,height=150,width=300,top=" + iTop + ",left=" + iLeft);
}

function AddOne(id,form){
	if (parseInt(document.getElementById(id).value) < 999) {
		document.getElementById(id).value = parseInt(document.getElementById(id).value) + 1;
		document.getElementById(form).submit();
	}
}

function SubOne(id, form){
	if (parseInt(document.getElementById(id).value) > 1) {
		document.getElementById(id).value = parseInt(document.getElementById(id).value) - 1;
		document.getElementById(form).submit();
	}
}

function betalingtype(){
	document.getElementById(id).value = parseInt(document.getElementById(id).value) - 1;
	document.getElementById(form).submit();
}

function ShowMenu(id){
	document.getElementById('group_men').style.display = "none";
	document.getElementById('group_women').style.display = "none";
	document.getElementById('group_accessoires').style.display = "none";
	document.getElementById('men').className = "";
	document.getElementById('women').className = "";
	document.getElementById('accessoires').className = "";
	
	if (id == "group_men"){
		document.getElementById("men").className  = "men_selected";
	}
	else if (id == "group_women"){
		document.getElementById("women").className  = "women_selected";
	}
	else if (id == "group_accessoires"){
		document.getElementById("accessoires").className  =  "accessoires_selected";
	}
	
	document.getElementById(id).style.display = "block";
}

function CheckFormnl () { 
	//Initialise variables
	var errorMsg = "";
	
		//Check for an e-mail address and that it is valid
	if ((document.Aanmelden.Email.value == "") || (document.Aanmelden.Email.value.length > 0 && (document.Aanmelden.Email.value.indexOf("@",0) == - 1 || document.Aanmelden.Email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tEmail           \t- Vul een (geldig) Email adres in";
	}	
		
				//Check for an e-mail address and that it is valid
	if ((document.Aanmelden.Email.value == "jenaam@adres.nl") || (document.Aanmelden.Email.value.length > 0 && (document.Aanmelden.Email.value.indexOf("@",0) == - 1 || document.Aanmelden.Email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tEmail           \t- Vul een (geldig) Email adres in";
	}	
		
		
	//If there is aproblem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Uw formulier kan niet worden behandeld. \n";
		msg += "Corrigeer a.u.b. de volgende velden en probeer het opnieuw.\n";
		msg += "______________________________________________________________\n\n";
		msg += "De volgende problemen zijn gecontstateerd: -\n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	return true;
}

function CheckFormen () { 
	//Initialise variables
	var errorMsg = "";
	
	//Check for an e-mail address and that it is valid
	if ((document.Aanmelden.Email.value == "") || (document.Aanmelden.Email.value.length > 0 && (document.Aanmelden.Email.value.indexOf("@",0) == - 1 || document.Aanmelden.Email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tEmail           \t- Enter a valid email address";
	}	
		
				//Check for an e-mail address and that it is valid
	if ((document.Aanmelden.Email.value == "yourname@address.com") || (document.Aanmelden.Email.value.length > 0 && (document.Aanmelden.Email.value.indexOf("@",0) == - 1 || document.Aanmelden.Email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tEmail           \t- Enter a valid email address";
	}	
		
		
	//If there is aproblem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "There is something wrong with the entered values. \n";
		msg += "Check if you entered it right..\n";
		msg += "______________________________________________________________\n\n";
		msg += "The following problems occurred: -\n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	return true;
}	


// Functie voor snelzoeken
function removeStartText(obj) 
{
	if (obj.value != ""){
		obj.value = "";
	}
}

function AddOne(id,form){
	if (parseInt(document.getElementById(id).value) < 999) {
		document.getElementById(id).value = parseInt(document.getElementById(id).value) + 1;
		document.getElementById(form).submit();
	}
}

function SubOne(id, form){
	if (parseInt(document.getElementById(id).value) > 1) {
		document.getElementById(id).value = parseInt(document.getElementById(id).value) - 1;
		document.getElementById(form).submit();
	}
}

function openWindow(width,height) {
    x = (640 - width)/2, y = (480 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }

    window.open('http://www.badhoevese.nl/login/wachtwoordvergeten/','newWin','width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
}



