function changeDiv(mIndex) {
  var div = document.getElementById("hiddenDiv");
	if (mIndex=="Huurauto"){
		div.style.display = '';
	}else{
		div.style.display = 'none';
	}
}

function ShowMenu(mNr) {
  var div0 = document.getElementById("menuvert0");
  var div1 = document.getElementById("menuvert1");
  var div2 = document.getElementById("menuvert2");
  var div = document.getElementById("menuvert"+mNr);
  
	div0.style.display = 'none';
	div1.style.display = 'none';
	div2.style.display = 'none';
	div.style.display = '';
}	

function ShowHideDiv(DoWhat,NameDiv) {
  var div = document.getElementById(NameDiv);
  if (DoWhat=="show"){
		div.style.display = '';
  }else{
		div.style.display = 'none';
  }
}	
	
function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {
	var i = "";
	var x = Math.round(num * Math.pow(10,dec));
	if (x >= 0) n1=n2='';
	var y = (''+Math.abs(x)).split('');
	var z = y.length - dec;
	y.splice(z, 0, pnt);
	while (z > 3) {
		z-=3; 
		y.splice(z,0,thou);
	}
	if (num==0) {
		i = "0,00";
	}else{ i = y.join('');
	}
	var r = curr1+n1+i+n2+curr2;
	return r;
}

function NieuwVenster(URL, w, h)	{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left=200,top=150,width=' + w + ',height=' + h);");
}

function ShowFoto(URL, title) {
   w=window.open('','newwin','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300');
   w.document.write('<html>');
   w.document.write('<head>');
   w.document.write('<title>'+title+'</title>');
   w.document.write('</head>');
   w.document.write('<body topmargin=0 leftmargin=0><img border=0 src=' + URL + '></body>');
   w.document.write('</html>');
   w.document.close();
}

function WritetoDiv(name, message) {
    if (document.layers) {
        document.layers[name].document.close();
        document.layers[name].document.write(message);
        document.layers[name].document.close();
    } else {
        if (document.all) {
            eval("document.all." + name + ".innerHTML='" + message + "'");
        } else {
            document.getElementById(name).innerHTML = message;
        }
    }
}

function ShopCheck(artId, artnr, catId, naam, aantal, prijs, foto){
	aantal = aantal.toString();
	//alert (aantal);
	if (aantal == '0' || aantal == ''){
		//artikel verwijderd
		top.cart ['' + artId] = new top.Item(artId, artnr, catId, naam, aantal, prijs, foto, false);
	}else	{
		//artikel toegevoegd
		top.cart ['' + artId] = new top.Item(artId, artnr, catId, naam, aantal, prijs, foto, true);
	}
}

function CartUpdate(artId, aantal){
	mAantalOud = Number(top.cart['' + artId].aantal);
	mAantalNew = mAantalOud + aantal;
	if (mAantalNew <= 0) aantal = 0;
	
	//artikel verwijderen
	if (aantal == 0) {
		top.cart['' + artId].doorgaan = false;
		
	//artikel updaten
	}else	{
		top.cart['' + artId].aantal = mAantalNew;
	}
}

function validate_inruil() {
  validity = true; 
  if (!check_empty(document.form.kenteken.value))
        { validity = false; alert('U heeft geen kenteken ingevuld!'); }
	else if (!check_empty(document.form.kmstand.value))
        { validity = false; alert('U heeft geen kilometerstand ingevuld!'); }
	else if (!check_empty(document.form.naam.value))
        { validity = false; alert('U heeft geen naam ingevuld!'); }
	else if (!check_email(document.form.email.value))
        { validity = false; alert('Het E-mail adres is ongeldig!'); }
	else if (!check_empty(document.form.telefoon.value))
        { validity = false; alert('U heeft geen telefoonnr ingevuld!'); }
	return validity;
}

function validate_form_net() {
  validity = true; 
  var myMsg;

  if (!check_empty(document.form.naam.value))
        { validity = false; myMsg = "U heeft geen naam ingevuld!"; }  
  if (!check_email(document.form.email.value))
        { validity = false; myMsg = "Het Email adres is ongeldig!"; }
  if (!check_tel1(document.form.tel.value))
        { validity = false; myMsg = "U dient een telefoonnummer in te vullen!"; }  
  if (validity == false)
  		 {alert(myMsg);}
  		 
  return validity;
}

function validate_form_shop() {
  validity = true; 
  var myMsg;

  if (!check_empty(document.form.naam.value))
        { validity = false; myMsg = "U heeft geen naam ingevuld!"; }  
  else if (!check_empty(document.form.adres.value))
        { validity = false; myMsg = "U heeft geen adres ingevuld!"; }       
  else if (!check_empty(document.form.postcode.value))
        { validity = false; myMsg = "U heeft geen postcode ingevuld!"; }
  else if (!check_empty(document.form.woonplaats.value))
        { validity = false; myMsg = "U heeft geen woonplaats ingevuld!"; }       
  else if (!check_empty(document.form.telefoon.value))
        { validity = false; myMsg = "U dient een telefoonnummer in te vullen!"; }  
  else if (!check_email(document.form.email.value))
        { validity = false; myMsg = "Het Email adres is ongeldig!"; }

  if (validity == false)
  		 {alert(myMsg);}
  		 
  return validity;
}

function validate_form_uitgebreid() {
  validity = true; 
  var myMsg;

  if (!check_telefoon(document.form.telprive.value,document.form.telwerk.value,document.form.mobiel.value))
        { validity = false; myMsg = "U dient tenminste 1 telefoonnummer in te vullen!"; }  
  if (!check_email(document.form.email.value))
        { validity = false; myMsg = "Het Email adres is ongeldig!"; }
  if (!check_empty(document.form.PC_plaats.value))
        { validity = false; myMsg = "U heeft geen postcode/plaatsnaam ingevuld!"; }
  if (!check_empty(document.form.adres.value))
        { validity = false; myMsg = "U heeft geen adres ingevuld!"; }       
  if (!check_empty(document.form.naam.value))
        { validity = false; myMsg = "U heeft geen naam ingevuld!"; }  
  if (!check_empty(document.form.model.value))
        { validity = false; myMsg = "U heeft geen model ingevuld!"; }       
  if (!check_empty(document.form.merk.value))
        { validity = false; myMsg = "U heeft geen merk ingevuld!"; }       
  if (document.form.vervangendvervoer.value=="Huurauto")
        { if (!check_box(document.form.bovag.checked)){validity = false; myMsg = "U dient akkoord te gaan met de huurvoorwaarden.";}  }     

  if (validity == false)
  		 {alert(myMsg);}
  		 
  return validity;
}

function validate_callform() {
  validity = true; 
  if (!check_empty(document.form.naam.value))
        { validity = false; alert('U heeft geen naam ingevuld!'); }
 
  if (!check_empty(document.form.telefoon.value))
        { validity = false; alert('U heeft geen telefoonnummer ingevuld!'); }
return validity;
}

function validate_form() {
  validity = true; 
  if (!check_empty(document.form.naam.value))
        { validity = false; alert('U heeft geen naam ingevuld!'); }
 
  if (!check_email(document.form.email.value))
        { validity = false; alert('Het E-mail adres is ongeldig!'); }
return validity;
}

function check_empty(text) {
  return (text.length > 0); 
}

function check_email(adres) {
  if ((adres == "")
    || (adres.indexOf ('@') == -1)
    || (adres.indexOf ('.') == -1))
      return false;
  return true;
}

function check_tel1(nr) {
  if ((nr == ""))
		{return false;}
  else
		{return true;}
}

function check_telefoon(nr1,nr2,nr3) {
  if ((nr1 == "") && (nr2  == "") && (nr3  == ""))
		{return false;}
  else
		{return true;}
}

function check_box(mchecked) {
  if (mchecked == 0){
  	return false;
  }else{
  	return true;
	}
}
function showhide(what,what2,aantal){
	OpenSrc = "images/algemeen/open.gif";
	ClosedSrc = "images/algemeen/closed.gif";
		
	if (aantal > 0) menu1outline.style.display='none';
	if (aantal > 1) menu2outline.style.display='none';
	if (aantal > 2) menu3outline.style.display='none';
	if (aantal > 3) menu4outline.style.display='none';
	if (aantal > 4) menu5outline.style.display='none';
	if (aantal > 0) menu1sign.src=ClosedSrc;
	if (aantal > 1) menu2sign.src=ClosedSrc;
	if (aantal > 2) menu3sign.src=ClosedSrc;
	if (aantal > 3) menu4sign.src=ClosedSrc;
	if (aantal > 4) menu5sign.src=ClosedSrc;

	if (what.style.display=='none'){
		what.style.display='';
		what2.src=OpenSrc;
	}else{
		what.style.display='none';
		what2.src=ClosedSrc;
	}
}

function DirectFoto(fotoId, title) {
   w=window.open('','newwin','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=510,height=306');
   w.document.write('<html>');
   w.document.write('<head>');
   w.document.write('<title>'+title+'</title>');
   w.document.write('</head>');
   w.document.write('<body topmargin=0 leftmargin=0><img border=0 src=images/content/direct/fotos/'+fotoId+'.jpg></body>');
   w.document.write('</html>');
   w.document.close();
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
{
	for(var i=0; i<document.images.length; i++)
	{
		var img = document.images[i];
		var imgName = img.src.toUpperCase();
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			var imgID = (img.id) ? "id='" + img.id + "' " : "";
			var imgClass = (img.className) ? "class='" + img.className + "' " : "";
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
			var imgStyle = "display:inline-block;" + img.style.cssText;
			if (img.align == "left") 
				imgStyle = "float:left;" + imgStyle;
			if (img.align == "right") 
				imgStyle = "float:right;" + imgStyle;
			if (img.parentElement.href) 
				imgStyle = "cursor:hand;" + imgStyle;
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
			img.outerHTML = strNewHTML;
			i = i-1;
		}
	}
}
window.attachEvent("onload", correctPNG);


