function showHideDiv(elementen){
	divelement = document.getElementById(elementen);
	if(divelement.style.display == 'block'){
		divelement.style.display = 'none';
	}else{
		divelement.style.display = 'block';				
	}
}

self.name='payopener';
function pay(){
	if (!document.pform.pchoice[0].checked && !document.pform.pchoice[1].checked){
		inlineMsg('paybutton','Kies eerst de gewenste betaalmethode',2);
		return false;
		//alert("Kies eerst de gewenste betaalmethode");
		//return;
	}
	if (document.pform.pchoice[1].checked && document.pform.BPE_Issuer.value=="X"){
		inlineMsg('paybutton','U heeft geen bank ingevuld.',2);
		return false;
		//alert("U kunt uitsluitend met iDeal betalen\nals u bankiert bij één van de genoemde banken.\nSelecteer creditcard of neem contact met ons op...");
		//document.pform.pchoice[0].checked=true;
		//return;
	}
	if (document.pform.pchoice[0].checked){
		window.open('','_pay','toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, width=300, height=300, top=150, left=300');
		document.pform.action="https://payment.buckaroo.nl/sslplus/request_for_authorization.asp"
	}
	if (document.pform.pchoice[1].checked){
		window.open('','_pay','toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=800, height=600, top=100, left=150');
		document.pform.action="https://payment.buckaroo.nl/gateway/ideal_payment.asp"
	}
	document.pform.target="_pay"
	document.pform.submit();
}

function create_http_object(){ 
	var ActiveXTypes = ["Microsoft.XMLHTTP", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP"]; 

	for( var i = 0; i < ActiveXTypes.length; i++ ) { 
		try { 
			return new ActiveXObject( ActiveXTypes[i] ); 
		} catch( e ) { } 
	} 

	try { 
		return new XMLHttpRequest(); 
	} catch( e ) { } 

	return false; 
} 

var ajax = create_http_object();

function getWinkelwagen(product, aantal, inputid){
	if(aantal == '' || aantal < 1 || !isInteger(aantal) || aantal > 1000){
		alert('Dit is geen correct aantal!');	
		document.getElementById(inputid).className='active';
		document.getElementById(inputid).focus();
	}else{
		document.getElementById(inputid).className='';
		ajax.open("GET", "/v2/webwinkel-ajax.php?module=winkelwagen&product=" + product + "&aantal=" + aantal + "&rand=" + Math.random(), true);
	    ajax.onreadystatechange = setWinkelwagen;
	    ajax.send('');
	}
}

function setWinkelwagen(){
	if(ajax.readyState == 4){
		if(document.all){
			document.getElementById('winkelwagenform').innerHTML = '';
			window.location=window.location;
		}else{
			document.getElementById('winkelwagenform').innerHTML = ajax.responseText;
		}
	}	
}

function isInteger(s) {
	return (s.toString().search(/^-?[0-9]+$/) == 0);
}
