/* internetlenzen.be js file */
$(function() {
	window.lightbox?lightbox():null;
	window.checkbril?checkbril():null;
	window.enhanceIntFields?enhanceIntFields():null;
	window.autoSubmit?autoSubmit():null;
	window.balloon?balloon():null;
	window.submitInBackground?submitInBackground():null;
	window.askConfirmation?askConfirmation():null;	//ask for confirmation before submiting 'dangerous' forms
	});

function lightbox(){
	if($.browser.msie && jQuery.browser.version.substr(0,1) == 6){
	browsersucks=true;
	}else{
	browsersucks=false;
	}
	
	/* technische fiche */
	$('#fiche').hide();
	$('#fichelink').click(function(){
		$("#fiche").slideToggle("slow");
		});
	
	/* my own private lightbox, because I'm suffering from NIH syndrome today */
	$('.zoom').click(function(){
		var imagePreloader = new Image();
		imagePreloader.onload = function(){
			$('#imgcontainer').css({
						"width": parseInt(this.width)+'px',
						"height": parseInt(this.height)+'px',
						"margin-left": "-"+parseInt(this.width)/2+'px',
						'top': (parseInt($(window).height())-parseInt(this.height))/2+'px'
					});
			};
		$('body').append('<div id="lightbox"><div id="imgcontainer"><div id="close"></div><img src="'+this.href+'" alt="loading..."/></div></div>');
		imagePreloader.src=this.href;
		  
		  if(!browsersucks){
			  $('#lightbox').hide();
			  $('#lightbox').fadeIn(500);
			 }
		  $('#lightbox').click(function(){
		  	 $('#lightbox').remove();
		  	 if(browsersucks){
		 		$('select').show();
			}
		  	});
		  	if($('#lightbox').height()<$('#wrapper').height()){
		 	 	$('#lightbox').height($('#wrapper').height()); /*fix height issues */
			}
			/* hide select boxes in IE 6 */
		 	if(browsersucks){
		 		$('select').hide();
			}
		return false;
		});
	}

	/* adds arrows that allow you to increment/decrement an int field*/
	var incrementImage='_images/js/increment.png';
	var decrementImage='_images/js/decrement.png';
	function enhanceIntFields()
		{
		var intFields = $('input.int');
		for(i=0;i<intFields.length;i++)
			{
			
				if( intFields[i].getAttribute('class', 2)!='int disabled' ) {
					/* add - */
					img = document.createElement("img");
					img.setAttribute("src",decrementImage);
					img.setAttribute("alt","-");
					img.setAttribute("title","less");
					img.setAttribute("class","fieldmodify"); //good browsers
					img.setAttribute("className","fieldmodify"); //IE
					
					img.onclick = function(){incrementField(this.previousSibling.previousSibling,-1);};
					intFields[i].parentNode.insertBefore(img,intFields[i].nextSibling);
					
					/* add + */
					img = document.createElement("img");
					img.setAttribute("class","fieldmodify"); //good browsers
					img.setAttribute("className","fieldmodify"); //IE
					img.setAttribute("src",incrementImage);
					img.setAttribute("alt","+");
					img.setAttribute("title","more");
					
					img.onclick = function(){incrementField(this.previousSibling,1);};
					intFields[i].parentNode.insertBefore(img,intFields[i].nextSibling);
					
					intFields[i].onfocus = function(){this.select();}
					
				}
				
			}
		}
		
function incrementField(field,amount,negative)
{

	if(field.getAttribute('class', 2)!='int disabled') {

		if((negative!=true && (parseInt(field.value)+amount)<0) ||isNaN(parseInt(field.value)))
			{
			field.value=0;
			field.setAttribute("value",0);
			if(field.onchange)
				{
				field.onchange();
				}
			return;
			}
		field.value=parseInt(field.value)+amount;
		field.setAttribute("value",parseInt(field.value));
		if(field.onchange)
		{
			field.onchange(); // force the onchange event
		}
		
		// Check if this field also changes another field
		if( field.getAttribute('class', 2)=='int keepequal' ) {
		
			var classToCheckFor = field.getAttribute('class', 2);
		
			// Loop trough all fields and increment that one too
			var arr = document.getElementsByTagName('input');
			for(i=0;i<arr.length;i++) {
				if(arr[i].getAttribute('class', 2)==classToCheckFor && field!=arr[i]) {
					arr[i].value = field.value;
				}
			}
		}
	
	}
	
}


function checkbril(){
	$('#brilform').submit(function(){
		/* check if the fields are empty */
		if($('#brilform select[name=sterkte]').length>0 && $('#brilform select[name=sterkte]').val()==''){
			window.alert($('#brilerrormessage').text());
			return false;
			}
		if($('#brilform select[name=kleur]').length>0 && $('#brilform select[name=kleur]').val()==''){
			window.alert($('#brilerrormessage').text());
			return false;
			}
		});
	}

function autoSubmit()	{
	if($('.autosubmit').size()>0){
		$('.autosubmit').hide();
		$('.autosubmit_loading').show();
		timeout = window.setTimeout(function(){
			$('.autosubmit').submit();
			},3000);
		}
	}

function balloon(){
	$('.balloon').click(function(event){
		event.preventDefault();
		if($('.balloontip.'+$(this).attr('rel')).size()==0){
			var balloon = $('<div><div/></div>');
			balloon.addClass('balloontip').addClass($(this).attr('rel'));
			balloon.children('div').load($(this).attr('href'),{'ajax':'true'},function(response, status, xhr) {
				if(status=='success'){
					$('#wrapper').append(balloon);
					balloon.hide().fadeIn();
					balloon.find('input[type=text]:eq(0)').focus();
					balloon.find('button').click(function(){
						//submit form
						});
					balloon.click(function(ev){
						ev.stopPropagation();
						});
					$('body').click(function(event){
						balloon.fadeOut(function(){$(this).remove()});
						$('body').unbind(event);
						});
					}
				});
			}
		});
	}
function submitInBackground(){
	$('form.addtocart').submit(function(ev){
		$.post($(this).attr('action'), $(this).serialize()); 
		var buttontodisable = $(this).children('button')
		buttontodisable.addClass('disabled');
		window.setTimeout(function(){buttontodisable.removeClass('disabled');},1500);
		sendNotification($(this).children('input.balloontip').val(),'shoppingcart');
		return false;
		});
		
	}
function sendNotification(text,name){
		if($('.balloontip.'+name).size()>0){
			$('.balloontip.'+name).remove();
			}
		var balloon = $('<div><div/></div>');
		balloon.addClass('balloontip').addClass(name);
		balloon.children('div').html(text);
		var movedown = $(document).scrollTop();
		$('#wrapper').append(balloon);
		if(parseInt(balloon.css('top'))<movedown){
			balloon.css('top',movedown);
			}
		balloon.hide().fadeIn().delay(5000).fadeOut(function(){$(this).remove();});
	}
/* ************************************************************************************************
ask confirmation before submitting a form (<form class="confirm" title="are you sure you want to drop this database?">)
************************************************************************************************ */
function askConfirmation()
	{
	confirmations = $('form.confirm');
	for(i=0;i<confirmations.length;i++)
		{
		//inventing new attributes
		confirmations[i].setAttribute('confirm',confirmations[i].title);
		confirmations[i].title="";
		confirmations[i].onsubmit = function(){return window.confirm(this.getAttribute('confirm'));};
		
		}
	}

/* formcheck stuff 
 * warning: legacy crap, and this really should have been done server-side instead
 * */
		function checkLensForm(){
			/* get current language
			 * (language is a 2-letter code stored as a class attribute for the body 
			 *  */
			lang = $('body').attr("class");
			if(lang==''){
				lang='nl';
				}
		  aantalLinks = document.getElementById('aantal_links').value;
		  aantalRechts = document.getElementById('aantal_rechts').value;
		  
		  if (aantalLinks == '') {
		    aantalLinks = 0;
		  }
		  
		  if (aantalRechts == '') {
		    aantalRechts = 0;
		  }
		  
		  if ((aantalLinks < 1) && (aantalRechts < 1)) {
			if(lang!='fr') {
			    alert("Om een bestelling te plaatsen moet u minstens 1 product bestellen.");
			} else {
				alert(unescape("Vous n'avez pas s%E9lectionn%E9 un produit."));
			} 
		  } else {
		    allesinorde = true;
		    
	        for (formIndex = 0; formIndex < document.productform.length ; formIndex++) { 
	          if(document.productform.elements[formIndex].type=='select-one') {
	            name = document.productform.elements[formIndex].name;
	            name = name.substring(name.lastIndexOf("_") + 1);
	            
	            if (((name == "rechts") && (aantalRechts != 0)) || ((name == "links") && (aantalLinks != 0))) {
	              if(document.productform.elements[formIndex].selectedIndex == 0) {
                    allesinorde = false;
                  }
	            }
			  }
	        }
		    
		    if (allesinorde == true) {
		      buildLensData(aantalLinks,aantalRechts);
		    } else {
				if(lang!='fr') {
					alert("Gelieve alle velden te selecteren.");
				} else {
					alert(unescape("Remplissez toutes les cases du formulaire, s'il vous pla%eet."));
				}
		    }
		  }
		}
		
		
		function buildLensData(a_links,a_rechts) {
			document.getElementById('rechts_aantal').value = a_rechts;
			document.getElementById('links_aantal').value = a_links;
			
			// clear param fields
			document.getElementById('rechts_params').value = "";
			document.getElementById('links_params').value = "";
			
			paramslinks = "";
			paramsrechts = "";
			
	        for (formIndex = 0; formIndex < document.productform.length ; formIndex++) { 
	        
	          if(document.productform.elements[formIndex].type=='select-one') {
	          
	            name = document.productform.elements[formIndex].name;
	            kant = name.substring(name.lastIndexOf("_") + 1);
	            veld = name.substring(0,name.indexOf("_"));
	            waarde = document.productform.elements[formIndex].options[document.productform.elements[formIndex].selectedIndex].value;
	            
	            if ((kant == "rechts") && (a_rechts != 0)) {
	              document.getElementById('rechts_params').value += veld + ' : ' + waarde + '\n';
	              paramsrechts += veld + ' : ' + waarde + '\n';
	            }
	            
	            if ((kant == "links") && (a_links != 0)) {
	            	document.getElementById('links_params').value += veld + ' :' + waarde + '\n';
	            	paramslinks += veld + ' : ' + waarde + '\n';
	            }
	            
			  }
			  
	        }
	        
	        //alert("RECHTERLENS\n\naantal : " + a_rechts + "\n\n" + paramsrechts);
	        //alert("LINKERLENS\n\naantal : " + a_links + "\n\n" + paramslinks);
	        
	        document.addtoshopform.submit();
		}

		function checkVloeistofForm(){
		  var aantal = parseInt(document.getElementById('aantal').value,10);
  			/* get current language
			 * (language is a 2-letter code stored as a class attribute for the body )
			 *  */
			lang = $('body').attr("class");
			if(lang==''){
				lang='nl';
				}
		  if(aantal>0) {
			 //window.alert(aantal+' > '+0);
			return true;
			} else {
		    if(lang=='nl') {
			    window.alert("Om een bestelling te plaatsen moet u minstens 1 product bestellen.");
			} else if(lang=='fr') {
				window.alert(unescape("Vous n'avez pas s%E9lectionn%E9 un produit."));
			}else{
				window.alert("please fill in all subjects");
			}
			return false; 
		  
		   // buildVloeistofData(aantal);
	
		  }
		  return false;
		}
		
		function buildVloeistofData(aantal) {
			document.getElementById('productaantal').value = aantal;
			
			//alert("VLOEISTOF\n\naantal : " + aantal);
			
			document.addtoshopform.submit();
		}
		

		function checkAndereForm(){
		  aantal = document.getElementById('aantal').value;
		  
		  if (aantal == '') {
		    aantal = 0;
		  }
		  
		  if (aantal == 0) {
			if(lang=='nl') {
			    alert("Om een bestelling te plaatsen moet u minstens 1 product bestellen.");
			} else if(lang=='fr'){
				alert(unescape("Vous n'avez pas s%E9lectionn%E9 un produit."));
			}else{
				alert("please fill in all subjects");
			} 
		  } else {
		    buildAndereData(aantal);
		  }
		}
		
		function buildAndereData(aantal) {
			document.getElementById('productaantal').value = aantal;
			document.addtoshopform.submit();
		}
		
		
		function checkBrilForm(){
		  aantal = document.getElementById('aantal').value;
		  
		  if (aantal == '') {
		    aantal = 0;
		  }
		  		  
		  if (aantal == 0) {
			if(lang=='nl') {
			    alert("Om een bestelling te plaatsen moet u minstens 1 product bestellen.");
			} else if(lang=='fr'){
				alert(unescape("Vous n'avez pas s%E9lectionn%E9e un produit."));
			} else {
				 alert('please fill in all subjects');
			} 
		  } else {
		    allesinorde = true;
		    
	        for (formIndex = 0; formIndex < document.productform.length ; formIndex++) { 
	          if(document.productform.elements[formIndex].type=='select-one') {
	            name = document.productform.elements[formIndex].name;
	            name = name.substring(name.lastIndexOf("_") + 1);
  
                if(document.productform.elements[formIndex].selectedIndex == 0) {
                  allesinorde = false;
                }
			  }
	        }
		    
		    if (allesinorde == true) {
		      buildBrilData(aantal);
		    } else {
			if(lang!='fr') {
			     alert("Gelieve alle velden te selecteren");
			} else {
				alert(unescape("Vous n'avez pas s%E9lectionn%E9e un produit."));
			} 
		     
		    }
		  }
		}
		
		
		function buildBrilData(aantal) {
			document.getElementById('productaantal').value = aantal;
			
			// clear param fields
			document.getElementById('productparams').value = "";
			
			params = "";
			
	        for (formIndex = 0; formIndex < document.productform.length ; formIndex++) { 
	        
	          if(document.productform.elements[formIndex].type=='select-one') {
	          
	            name = document.productform.elements[formIndex].name;
	            veld = name;
	            waarde = document.productform.elements[formIndex].options[document.productform.elements[formIndex].selectedIndex].value;
	            
	            if (aantal != 0) {
	              document.getElementById('productparams').value += veld + ' : ' + waarde + '\n';
	              params += veld + ' : ' + waarde + '\n';
	            }
	            
			  }
			  
	        }
	        
	        
	        
	        document.addtoshopform.submit();
		}
		
		//change acuevue 23 options
		function redoAcuvueTwentyThree(what) {
		  val = "";
		  
		  if (what == 'rechts') {
		    val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
		
		    document.productform.cilinder_rechts.options.length = 0;
		    document.productform.as_rechts.options.length = 0;
		  
		    switch(val) {
		      case "+0.25":
		      case "+0.50":
		      case "+0.75":
		      case "+1.00":
		      case "+1.25":
		      case "+1.50":
		      case "+1.75":
		      case "+2.00":
		      case "+2.25":
		      case "+2.50":
		      case "+2.75":
		      case "+3.00":
		      case "+3.25":
		      case "+3.50":
		      case "+3.75":
		      case "+4.00":
		        // stel cilinder in
		        cilinder = new Array('Kies...','-1.00','-1.75');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
		      
		        for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		      default:

	        // stel cilinder in
		        cilinder = new Array('Kies...','-1.00','-1.75','-2.50');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','0°','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		      
		        for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		    }
		  } else {
		    val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
		
		    document.productform.cilinder_links.options.length = 0;
		    document.productform.as_links.options.length = 0;
		  
		    switch(val) {
		      case "+0.25":
		      case "+0.50":
		      case "+0.75":
		      case "+1.00":
		      case "+1.25":
		      case "+1.50":
		      case "+1.75":
		      case "+2.00":
		      case "+2.25":
		      case "+2.50":
		      case "+2.75":
		      case "+3.00":
		      case "+3.25":
		      case "+3.50":
		      case "+3.75":
		      case "+4.00":
		        // stel cilinder in
		        cilinder = new Array('Kies...','-1.00','-1.75');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');

	      
	        for (i=0; i < as.length; i++) {
		          document.productform.as_links.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		      default:
		        // stel cilinder in
		        cilinder = new Array('Kies...','-1.00','-1.75','-2.50');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','0°','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		      
		        for (i=0; i < as.length; i++) {
		          document.productform.as_links.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		    }
		  }
		}

		//change acuevue11 options
		function redoAcuvue11(what) {
		  val = "";
		  if (what == 'rechts') {
		    val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
		    document.productform.cilinder_rechts.options.length = 0;
		    document.productform.as_rechts.options.length = 0;
		  
		    if(val.indexOf('+')!=-1)
		        // stel cilinder in
				{
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
					}
		        // stel as in
		        as = new Array('Kies...','0°','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		        for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
					}
				}else{
				// stel cilinder in
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25','-2.75');
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','0°','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		      
		        for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
		        }
		    }
		  } else {
				val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
			    document.productform.cilinder_links.options.length = 0;
				document.productform.as_links.options.length = 0;
		    if(val.indexOf('+')!=-1)
				{
		        // stel cilinder in
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		        // stel as in
		        as = new Array('Kies...','0°','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
	        for (i=0; i < as.length; i++) {
		          document.productform.as_links.options[i] = new Option(as[i],as[i]);
		        }
		       }else{
				// stel cilinder in
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25','-2.75');
		        for (i=0; i < cilinder.length; i++) {
					document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
					}
		        // stel as in
		        as = new Array('Kies...','0°','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		        for (i=0; i < as.length; i++) {
					document.productform.as_links.options[i] = new Option(as[i],as[i]);
					}
		    }
		  }
		}
	//change acuevue103 options
	function redoAcuvue103(what) {
		  val = "";
		  if (what == 'rechts') {
		    val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
		    document.productform.cilinder_rechts.options.length = 0;
		    document.productform.as_rechts.options.length = 0;
			valint=val*1;
		    if(valint<(-6)) /* -9.00 tem -6.50 */
		        // stel cilinder in
				{
		        cilinder = new Array('Kies...','-1.25','-1.75','-2.25');
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
					}
		        // stel as in
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
		        for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
					}
			}else if(valint<=0){	/* -6.00 tem 0.00 */
				// stel cilinder in
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        cilinderval=document.productform.cilinder_rechts.options[document.productform.cilinder_rechts.selectedIndex].value;
		        if(cilinderval == '-2.25'){
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
				}else{
				as = new Array('Kies...','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		        }
		        for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
		        }
		    }else	{/* 0.00 tem ... */
			cilinder = new Array('Kies...','-0.75','-1.25','-1.75');
			for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
			 for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
		        }
			}
			
		  } else {
				val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
			    document.productform.cilinder_links.options.length = 0;
				document.productform.as_links.options.length = 0;
				valint=(val*1);
		    if(valint<(-6)) /* -9.00 tem -6.50 */
				{
		        // stel cilinder in
		        cilinder = new Array('Kies...','-1.25','-1.75','-2.25');
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		        // stel as in
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
				for (i=0; i < as.length; i++) {
					  document.productform.as_links.options[i] = new Option(as[i],as[i]);
					}
		       }else if(valint<=0){	/* -6.00 tem 0.00 */
				// stel cilinder in
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
		        for (i=0; i < cilinder.length; i++) {
					document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
					}
		        // stel as in
		        cilinderval=document.productform.cilinder_links.options[document.productform.cilinder_links.selectedIndex].value;
		        if(cilinderval == '-2.25'){
					as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
				}else{
					as = new Array('Kies...','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		        }
		        for (i=0; i < as.length; i++) {
					document.productform.as_links.options[i] = new Option(as[i],as[i]);
					}
		    		    }else	{ /* 0.00 tem ... */
						cilinder = new Array('Kies...','-0.75','-1.25','-1.75');
			for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
			 for (i=0; i < as.length; i++) {
		          document.productform.as_links.options[i] = new Option(as[i],as[i]);
		        }
		  }
		}
	}
	function redoAcuvue103as(what) {
		if(what=='rechts'){
			/* get selected options */
			val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
			valint=val*1;
			if(valint<(-6)){
				cilinderval=document.productform.cilinder_rechts.options[document.productform.cilinder_rechts.selectedIndex].value;
		        if(cilinderval == '-2.25'){
					as = new Array('Kies...','10°','20°','90°','160°','170°','180°');
				}else{
					as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
		        }
		        document.productform.as_rechts.options.length = 0;
		         for (i=0; i < as.length; i++) {
					document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
					}
			}
			else if(valint<=(0)){
				cilinderval=document.productform.cilinder_rechts.options[document.productform.cilinder_rechts.selectedIndex].value;
		        if(cilinderval == '-2.25'){
					as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
				}else{
					as = new Array('Kies...','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		        }
		        document.productform.as_rechts.options.length = 0;
		         for (i=0; i < as.length; i++) {
					document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
					}
			}
		}else{
			/* get selected options */
			val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
			valint=val*1;
			if(valint<(-6)){
				cilinderval=document.productform.cilinder_links.options[document.productform.cilinder_links.selectedIndex].value;
		        if(cilinderval == '-2.25'){
					as = new Array('Kies...','10°','20°','90°','160°','170°','180°');
				}else{
					as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
		        }
		        document.productform.as_links.options.length = 0;
		         for (i=0; i < as.length; i++) {
					document.productform.as_links.options[i] = new Option(as[i],as[i]);
					}
			}
			else if(valint<=(0)){
				cilinderval=document.productform.cilinder_links.options[document.productform.cilinder_links.selectedIndex].value;
		        if(cilinderval == '-2.25'){
					as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
				}else{
					as = new Array('Kies...','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		        }
		        document.productform.as_links.options.length = 0;
		         for (i=0; i < as.length; i++) {
					document.productform.as_links.options[i] = new Option(as[i],as[i]);
					}
			}
		}
	}
//change options of lens 119
function redoLens119(what) {
	  val = "";
	  if (what == 'rechts') {
		val = document.productform.cilinder_rechts.options[document.productform.cilinder_rechts.selectedIndex].value;
		/* get currently selected sterkte */
		currentsterkte = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
		document.productform.sterkte_rechts.options.length = 0;
		 valint=val*1;
		if(val=='-0.75')
			{
				//original array
				sterktes = new Array('Kies...','-6.00','-5.75','-5.50','-5.25','-5.00','-4.75','-4.50','-4.25','-4.00','-3.75','-3.50','-3.25','-3.00','-2.75','-2.50','-2.25','-2.00','-1.75','-1.50','-1.25','-1.00','-0.75','-0.50','-0.25','0.00');
			}else{
				// stel sterkte in
				sterktes = new Array('Kies...','-9.00','-8.50','-8.00','-7.50','-7.00','-6.50','-6.00','-5.75','-5.50','-5.25','-5.00','-4.75','-4.50','-4.25','-4.00','-3.75','-3.50','-3.25','-3.00','-2.75','-2.50','-2.25','-2.00','-1.75','-1.50','-1.25','-1.00','-0.75','-0.50','-0.25','0.00');
			}
			for (i=0; i < sterktes.length; i++) {
			  document.productform.sterkte_rechts.options[i] = new Option(sterktes[i],sterktes[i]);
			  	if(sterktes[i]==currentsterkte){
					document.productform.sterkte_rechts.options[i].selected=true;
					}
				}
		
	  } else {
			val = document.productform.cilinder_links.options[document.productform.cilinder_links.selectedIndex].value;
			/* get currently selected sterkte */
			currentsterkte = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
			 document.productform.sterkte_links.options.length = 0;
			 valint=val*1;
			if(val=='-0.75')
				{
					//original array
					sterktes = new Array('Kies...','-6.00','-5.75','-5.50','-5.25','-5.00','-4.75','-4.50','-4.25','-4.00','-3.75','-3.50','-3.25','-3.00','-2.75','-2.50','-2.25','-2.00','-1.75','-1.50','-1.25','-1.00','-0.75','-0.50','-0.25','0.00');
				}else{
					// stel cilinder in
					sterktes = new Array('Kies...','-9.00','-8.50','-8.00','-7.50','-7.00','-6.50','-6.00','-5.75','-5.50','-5.25','-5.00','-4.75','-4.50','-4.25','-4.00','-3.75','-3.50','-3.25','-3.00','-2.75','-2.50','-2.25','-2.00','-1.75','-1.50','-1.25','-1.00','-0.75','-0.50','-0.25','0.00');
				}
				for (i=0; i < sterktes.length; i++) {
				  document.productform.sterkte_links.options[i] = new Option(sterktes[i],sterktes[i]);
					  if(sterktes[i]==currentsterkte){
						document.productform.sterkte_links.options[i].selected=true;
						}
					}
	  }
	}
function redoSterkteLens119(what) {
	val = "";
	 if (what == 'rechts') {
			val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
			document.productform.cilinder_rechts.options.length = 0;
			valint=val*1;
			if(val<(-6))
				{
					cilinders = new Array('Kies...','-1.25','-1.75');
				}else{
					cilinders = new Array('Kies...','-0.75','-1.25','-1.75');
				}
			for (i=0; i < cilinders.length; i++) {
				  document.productform.cilinder_rechts.options[i] = new Option(cilinders[i],cilinders[i]);
					}
	 	}else{
			val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
			document.productform.cilinder_links.options.length = 0;
			valint=val*1;
			if(val<(-6))
				{
					cilinders = new Array('Kies...','-1.25','-1.75');
				}else{
					cilinders = new Array('Kies...','-0.75','-1.25','-1.75');
				}
			for (i=0; i < cilinders.length; i++) {
				  document.productform.cilinder_links.options[i] = new Option(cilinders[i],cilinders[i]);
				}
		 }
	}
//change options of lens 120
function redoLens120(what) {
	val = "";
	if (what == 'rechts') {
	    val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
	    document.productform.cilinder_rechts.options.length = 0;
	    document.productform.as_rechts.options.length = 0;
		valint=val*1;
		if(valint<(-9)){
			cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
			as = new Array('Kies...','20°','90°','160°','180°');
			} else if(valint<(-6) && valint>(-9)) /* -9.00 tem -6.50 */
	        // stel cilinder & as in
			{
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
			}else if(valint>0){
				cilinder = new Array('Kies...','-0.75','-1.25','-1.75');
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
			}else{
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
				as = new Array('Kies...','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
			}
		for (i=0; i < cilinder.length; i++) {
		    document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
			}
		for (i=0; i < as.length; i++) {
		    document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
			}
	  } else {
		val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
	    document.productform.cilinder_links.options.length = 0;
	    document.productform.as_links.options.length = 0;
		valint=val*1;
			if(valint<(-9)){
			cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
			as = new Array('Kies...','20°','90°','160°','180°');
			} else if(valint<(-6) && valint>(-9)) /* -9.00 tem -6.50 */
	        // stel cilinder & as in
			{
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
			}else if(valint>0){
				cilinder = new Array('Kies...','-0.75','-1.25','-1.75');
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
			}else{
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
				as = new Array('Kies...','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
			}
		for (i=0; i < cilinder.length; i++) {
		    document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
			}
		for (i=0; i < as.length; i++) {
		    document.productform.as_links.options[i] = new Option(as[i],as[i]);
			}
	  }
	}
function redoLens120as(what){
	if(what=='rechts'){
		val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
		cilinderval=document.productform.cilinder_rechts.options[document.productform.cilinder_rechts.selectedIndex].value;
	}else{
		val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
		cilinderval=document.productform.cilinder_links.options[document.productform.cilinder_links.selectedIndex].value;
	}
		valint=val*1;
		if(valint<(-6.00) && valint>=(-9.00)){
			if(cilinderval=='-0.75' || cilinderval=='-2.25'){
				as = new Array('Kies...','20°','90°','160°','180°');
			}else{
				as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
			}
			if(what=='rechts'){
				document.productform.as_rechts.options.length = 0;
				for (i=0; i < as.length; i++) {
					document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
				}
			}else{
				document.productform.as_links.options.length = 0;
				for (i=0; i < as.length; i++) {
					document.productform.as_links.options[i] = new Option(as[i],as[i]);
				}
			}
		}
		
	}

function redoSterkteLens168(what){
		val = "";
		if(what == 'rechts') {
			val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
			document.productform.cilinder_rechts.options.length = 0;
			valint=val*1;
			if(val<=0)
				{
					cilinders = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
				}else{
					cilinders = new Array('Kies...','-0.75','-1.25','-1.75');
				}
			for (i=0; i < cilinders.length; i++) {
				  document.productform.cilinder_rechts.options[i] = new Option(cilinders[i],cilinders[i]);
					}
		} else {
			val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
			document.productform.cilinder_links.options.length = 0;
			valint=val*1;
			if(val<=0)
				{
					cilinders = new Array('Kies...','-0.75','-1.25','-1.75','-2.25');
				}else{
					cilinders = new Array('Kies...','-0.75','-1.25','-1.75');
				}
			for (i=0; i < cilinders.length; i++) {
				  document.productform.cilinder_links.options[i] = new Option(cilinders[i],cilinders[i]);
					}
		}
	}

function redoLens168as(what){
	if(what=='rechts'){
		val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
		cilinderval=document.productform.cilinder_rechts.options[document.productform.cilinder_rechts.selectedIndex].value;
	}else{
		val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
		cilinderval=document.productform.cilinder_links.options[document.productform.cilinder_links.selectedIndex].value;
	}
		valint=val*1;
		if(valint<=0){
			if(cilinderval=='-2.25'){
				as = new Array('Kies...','20°','90°','160°','180°');
			}else{
				as = new Array('Kies...','10°','20°','60°','70°','80°','90°','100°','110°','120°','160°','170°','180°');
			}
		} else{
				as = new Array('Kies...','20°','70°','90°','110°','160°','180°');
		}
	if(what=='rechts'){
		document.productform.as_rechts.options.length = 0;
		for (i=0; i < as.length; i++) {
			document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
		}
	}else{
		document.productform.as_links.options.length = 0;
		for (i=0; i < as.length; i++) {
			document.productform.as_links.options[i] = new Option(as[i],as[i]);
		}
	}
}
		
function redoAcuvue(what) {
		}
		
		function redoAcuvueToo(what) {
		  val = "";
		  
		  if (what == 'rechts') {
		    val = document.productform.sterkte_rechts.options[document.productform.sterkte_rechts.selectedIndex].value;
		
		    document.productform.cilinder_rechts.options.length = 0;
		    document.productform.as_rechts.options.length = 0;
		  
		    switch(val) {
		      case "-9.00":
	  	      case "-8.50":
		      case "-8.00":
		      case "-7.50":
		      case "-7.00":
		      case "-6.50":
		        // stel cilinder in
		        cilinder = new Array('Kies...','-1.25','-1.75');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
		      
		        for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		      case "+0.25":
		      case "+0.50":
		      case "+0.75":
		      case "+1.00":
		      case "+1.25":
		      case "+1.50":
		      case "+1.75":
		      case "+2.00":
		      case "+2.25":
		      case "+2.50":
		      case "+2.75":
		      case "+3.00":
		      case "+3.25":
		      case "+3.50":
		      case "+3.75":
		      case "+4.00":
		      case "+4.25":
		      case "+4.50":
		      case "+4.75":
		      case "+5.00":
		      case "+5.25":
		      case "+5.50":
		      case "+5.75":
		      case "+6.00":
		        // stel cilinder in
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
		      
		        for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		      default:

	        // stel cilinder in
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_rechts.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','0°','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		      
		        for (i=0; i < as.length; i++) {
		          document.productform.as_rechts.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		    }
		  } else {
		    val = document.productform.sterkte_links.options[document.productform.sterkte_links.selectedIndex].value;
		
		    document.productform.cilinder_links.options.length = 0;
		    document.productform.as_links.options.length = 0;
		  
		    switch(val) {
		      case "-9.00":
	  	      case "-8.50":
		      case "-8.00":
		      case "-7.50":
		      case "-7.00":
		      case "-6.50":
		        // stel cilinder in
		        cilinder = new Array('Kies...','-1.25','-1.75');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');
		      
		        for (i=0; i < as.length; i++) {
		          document.productform.as_links.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		      case "+0.25":
		      case "+0.50":
		      case "+0.75":
		      case "+1.00":
		      case "+1.25":
		      case "+1.50":
		      case "+1.75":
		      case "+2.00":
		      case "+2.25":
		      case "+2.50":
		      case "+2.75":
		      case "+3.00":
		      case "+3.25":
		      case "+3.50":
		      case "+3.75":
		      case "+4.00":
		      case "+4.25":
		      case "+4.50":
		      case "+4.75":
		      case "+5.00":
		      case "+5.25":
		      case "+5.50":
		      case "+5.75":
		      case "+6.00":
		        // stel cilinder in
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','10°','20°','70°','80°','90°','100°','110°','160°','170°','180°');

	      
	        for (i=0; i < as.length; i++) {
		          document.productform.as_links.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		      default:
		        // stel cilinder in
		        cilinder = new Array('Kies...','-0.75','-1.25','-1.75');
		      
		        for (i=0; i < cilinder.length; i++) {
		          document.productform.cilinder_links.options[i] = new Option(cilinder[i],cilinder[i]);
		        }
		      
		        // stel as in
		        as = new Array('Kies...','0°','10°','20°','30°','40°','50°','60°','70°','80°','90°','100°','110°','120°','130°','140°','150°','160°','170°','180°');
		      
		        for (i=0; i < as.length; i++) {
		          document.productform.as_links.options[i] = new Option(as[i],as[i]);
		        }
		      
		        break;
		    }
		  }
		}
		
		function openPopup(url,w,h) {
		  var windowleft = (screen.width - w) / 2;
		  var windowtop = (screen.height - h) / 2;
		
		  var parString = "width=" + w + ",height=" + h
		    + ",toolbar=0,location=0,directories=0"
		    + ",top=" + windowtop + ",left=" + windowleft
		    + ",status=0,menuBar=0,scrollBars=1,resizable=0";
		  var winPop = window.open(url,"",parString);
		}
			
		function lensFiche(id) {
		  openPopup("tech_fiche.lasso?id="+id,540,580);
		}
		
		function shopCheckOut() {
			lang = $('body').attr("class");

			if(lang==''){
				lang='nl';
			}
			var port = document.getElementById('portkostenvalue').value;
			
			if (port == '') {
				if(lang=='nl')	{
					alert("Gelieve eerst de verzendingskosten te definieren");
				} else if(lang=='fr'){
					alert(unescape("Voudriez-vous d%E9finier les frais d'envoi"));
				}else{
					alert('please fill in the delivery costs');
				}
			} else {
				document.forms.checkoutform.submit();
			}
		}
	
		function copyGegevens() {
			if (document.getElementById("copydata").checked == true) {
				document.getElementById("leveringnaam").value = document.getElementById("naam").value;
				document.getElementById("leveringvoornaam").value = document.getElementById("voornaam").value;
				document.getElementById("leveringtel").value = document.getElementById("tel").value;
				document.getElementById("leveringstraat").value = document.getElementById("straat").value;
				/*document.getElementById("leveringnummer").value = document.getElementById("nummer").value;*/
				document.getElementById("leveringpostcode").value = document.getElementById("postcode").value;
				document.getElementById("leveringplaats").value = document.getElementById("plaats").value;
				document.getElementById("leveringprovincie").value = document.getElementById("provincie").value;
				(document.getElementById("leveringland")!=null?document.getElementById("leveringland").value = document.getElementById("land").value:null);
				
				document.getElementById("leveringnaam").disabled = true;
				document.getElementById("leveringvoornaam").disabled = true;
				document.getElementById("leveringtel").disabled = true;
				document.getElementById("leveringstraat").disabled = true;
				/*document.getElementById("leveringnummer").disabled = true;*/
				document.getElementById("leveringpostcode").disabled = true;
				document.getElementById("leveringplaats").disabled = true;
				document.getElementById("leveringprovincie").disabled = true;
				(document.getElementById("leveringland")!=null?document.getElementById("leveringland").disabled = true:null);

				$('#leveringnaam').addClass("disabled");
				$('#leveringvoornaam').addClass("disabled");
				$('#leveringtel').addClass("disabled");
				$('#leveringstraat').addClass("disabled");
				/*$('#leveringnummer').addClass("disabled");*/
				$('#leveringpostcode').addClass("disabled");
				$('#leveringplaats').addClass("disabled");
				$('#leveringprovincie').addClass("disabled");
				$('#leveringland').addClass("disabled");
				
			} else {
				document.getElementById("leveringnaam").value = "";
				document.getElementById("leveringvoornaam").value = "";
				document.getElementById("leveringtel").value = "";
				document.getElementById("leveringstraat").value = ""
				/*document.getElementById("leveringnummer").value = "";*/
				document.getElementById("leveringpostcode").value = "";
				document.getElementById("leveringplaats").value = "";
				document.getElementById("leveringprovincie").value = "";
				(document.getElementById("leveringland")!=null?document.getElementById("leveringland").value = "":null);
				
				document.getElementById("leveringnaam").disabled = false;
				document.getElementById("leveringvoornaam").disabled = false;
				document.getElementById("leveringtel").disabled = false;
				document.getElementById("leveringstraat").disabled = false;
				/*document.getElementById("leveringnummer").disabled = false;*/
				document.getElementById("leveringpostcode").disabled = false;
				document.getElementById("leveringplaats").disabled = false;
				document.getElementById("leveringprovincie").disabled = false;
				(document.getElementById("leveringland")!=null?document.getElementById("leveringland").disabled = false:null);
			
				$('#leveringnaam').removeClass("disabled");
				$('#leveringvoornaam').removeClass("disabled");
				$('#leveringtel').removeClass("disabled");
				$('#leveringstraat').removeClass("disabled");
				/*$('#leveringnummer').removeClass("disabled");*/
				$('#leveringpostcode').removeClass("disabled");
				$('#leveringplaats').removeClass("disabled");
				$('#leveringprovincie').removeClass("disabled");
				$('#leveringland').removeClass("disabled");
			}			
		}
		//http://www.regular-expressions.info/email.html
		var mailregex=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
		function checkPaymentForm() {
			lang = $('body').attr("class");
			if(lang==''){
				lang='nl';
				}
			if (document.getElementById("naam").value == "") {
				if(lang!='fr') {
					alert("Gelieve uw naam in te vullen");
				} else {
					alert(unescape("vous avez oubli%E9 d'entrer votre nom"));
				} 
				document.getElementById("naam").focus();
				return false;
			}
		
			if (document.getElementById("voornaam").value == "") {
				if(lang!='fr') {
					alert("Gelieve uw voornaam in te vullen");
				} else {
					alert(unescape("vous avez oubli%E9 d'entrer votre pr%E9nom"));
				} 				
				document.getElementById("voornaam").focus();
				return false;
			}
		
			if(document.getElementById("emailadres").value == "") {
				if(lang!='fr') {
					alert("Gelieve uw e-mailadres in te vullen");
				} else {
					alert(unescape("vous avez oubli%E9 d'entrer votre adresse e-mail"));
				} 	
				document.getElementById("emailadres").focus();
				return false;
			}
			
			if(!mailregex.test(document.getElementById("emailadres").value)){
				if(lang!='fr') {
					alert("Gelieve een geldig e-mailadres in te vullen");
				} else {
					alert(unescape("vous avez oubli%E9 d'entrer une adresse e-mail valide"));
				} 	
				document.getElementById("emailadres").focus();
				return false;
				}
				
			if (document.getElementById("straat").value == "") {
				if(lang!='fr') {
					alert("Gelieve uw straat in te vullen");
				} else {
					alert(unescape("vous avez oubli%E9 d'entrer votre rue"));
				} 								
				document.getElementById("straat").focus();
				return false;
			}
		
			/*if (document.getElementById("nummer").value == "") {
				if(lang!='fr') {
					alert("Gelieve uw huisnummer in te vullen");
				} else {
					alert(unescape("vous avez oubli%E9 d'entrer votre n°"));
				} 			
				document.getElementById("nummer").focus();
				return;
			}*/
		
			if (document.getElementById("postcode").value == "") {
				if(lang!='fr') {
					alert("Gelieve uw postcode in te vullen");
				} else {
					alert(unescape("vous avez oubli%E9 d'entrer votre code postal"));
				} 								
				document.getElementById("postcode").focus();
				return false;
			}
		
			if (document.getElementById("plaats").value == "") {
				if(lang!='fr') {
					alert("Gelieve uw woonplaats in te vullen");
				} else {
					alert(unescape("vous avez oubli%E9 d'entrer votre ville"));
				} 
				document.getElementById("plaats").focus();
				return false;
			}
		
			if (document.getElementById("land").value == "") {
				if(lang!='fr') {
					alert("Gelieve uw land in te vullen");
				} else {
					alert(unescape("vous avez oubli%E9 d'entrer votre pays"));
				} 
				document.getElementById("land").focus();
				return false;
			}
			
			if (document.getElementById("copydata").checked == false) {
				if (document.getElementById("leveringnaam").value == "") {
					if(lang!='fr') {
						alert("Gelieve uw naam bij de leveringsgegevens in te vullen");
					} else {
						alert(unescape("vous avez oubli%E9 d'entrer votre nom dans les donn%E9es de livraison"));
					}
					document.getElementById("leveringnaam").focus();
					return false;
				}
			
				if (document.getElementById("leveringvoornaam").value == "") {
					if(lang!='fr') {
						alert("Gelieve uw voornaam bij de leveringsgegevens in te vullen");
					} else {
						alert(unescape("vous avez oubli%E9 d'entrer votre pr%E9nom dans les donn%E9es de livraison"));
					}
					document.getElementById("leveringvoornaam").focus();
					return false;
				}
			
				if (document.getElementById("leveringtel").value == "") {
					if(lang!='fr') {
						alert("Gelieve uw telefoonnummer bij de leveringsgegevens in te vullen");
					} else {
						alert(unescape("vous avez oubli%E9 d'entrer votre n) de t%E9l%E9phone dans les donn%E9es de livraison"));
					}
					document.getElementById("leveringtel").focus();
					return;
				}
			
				if (document.getElementById("leveringstraat").value == "") {
					if(lang!='fr') {
						alert("Gelieve uw straat bij de leveringsgegevens in te vullen");
					} else {
						alert(unescape("vous avez oubli%E9 d'entrer votre rue dans les donn%E9es de livraison"));
					}
					document.getElementById("leveringstraat").focus();
					return;
				}
			
				/*if (document.getElementById("leveringnummer").value == "") {
					if(lang!='fr') {
						alert("Gelieve uw huisnummer bij de leveringsgegevens in te vullen");
					} else {
						alert(unescape("vous avez oubli%E9 d'entrer votre n° dans les donn%E9es de livraison"));
					}
					document.getElementById("leveringnummer").focus();
					return;
				}*/
			
				if (document.getElementById("leveringpostcode").value == "") {
					if(lang!='fr') {
						alert("Gelieve uw postcode bij de leveringsgegevens in te vullen");
					} else {
						alert(unescape("vous avez oubli%E9 d'entrer votre code postal dans les donn%E9es de livraison"));
					}
					document.getElementById("leveringpostcode").focus();
					return;
				}
			
				if (document.getElementById("leveringplaats").value == "") {
					if(lang!='fr') {
						alert("Gelieve uw woonplaats bij de leveringsgegevens in te vullen");
					} else {
						alert(unescape("vous avez oubli%E9 d'entrer votre ville dans les donn%E9es de livraison"));
					}
					document.getElementById("leveringplaats").focus();
					return;
				}
			
				/*if (document.getElementById("leveringland").value == "") {
					if(lang!='fr') {
						alert("Gelieve uw land bij de leveringsgegevens in te vullen");
					} else {
						alert(unescape("vous avez oubli%E9 d'entrer votre pays dans les donn%E9es de livraison"));
					}
					document.getElementById("leveringland").focus();
					return;
				}*/
			}
			
			var checkedpayment = false;
			var checkedval = "";
			
			for (i=0;i<document.checkoutform.betalingswijze.length;i++) {
				if (document.checkoutform.betalingswijze[i].checked) {
					checkedpayment = true;
					checkedval = document.checkoutform.betalingswijze[i].value;
				}
			}
			
			if (checkedpayment == false) {
				if(lang=='fr')
					{
					alert("Selectez une methode de paiement");
					} else {				
					alert("Gelieve uw betalingsmethode te selecteren");
					}
				return false;
			}
			
			/* check if there's a housenumber in the address field because
			 * sometimes people forget they should enter one */
			if(document.getElementById("copydata").checked == false){
				var straat = document.getElementById('leveringstraat').value;
			}else{
				var straat = document.getElementById('straat').value;
				}
			// check if it matches the regex [0-9]+
			var addressregex = /[0-9]+/;
			if(!addressregex.test(straat)){
				if(lang=='fr'){
						window.alert('Vouillez ajouter votre num%E9ro de maison dans le champs d\'addresse');
					}else{
						window.alert('Gelieve ook uw huisnummer in te voeren in het adresveld');
					}
					return false;
				}
				document.checkoutform.submit();
		}

