
function chkbericht()
{
    if(document.Formular.Naam.value == ""){alert("Vul a.u.b. uw naam in");document.Formular.Naam.focus();return false;}
	if(document.Formular.Email.value == ""){alert("Graag Uw E-mail invullen ?");document.Formular.Email.focus();return false;}
}
 

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImagesArray(array) {
	
		var d = document; var img;
		for (var i=0; i<array.length; i+=2) {
			img = null; var n = array[i];
			if (d.images) {img = d.images[n];}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (img) {img.src = array[i+1];}
		}
	
}

function changeImages() {
	changeImagesArray(changeImages.arguments);
}

function ShowImage(aimage,anr,anaam,aprijs){
	var BigImage = document.getElementById('aktie_big');
	var BigNr = document.getElementById('aktie_nr');
	var BigNaam = document.getElementById('aktie_naam');
	var BigPrijs = document.getElementById('aktie_prijs');
	BigImage.src = aimage;
	BigNr.value= anr;
	BigNaam.value = anaam;
    BigPrijs.value = aprijs;
}

function BigImagePopup(Thumb){
	var sfile = Thumb;
	var s="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no, resizable=no,width=640,height=480,curmbox=ACTIVE";
	var hWnd = window.open(sfile,"CA",s);
	
	if ((document.window != null) && (!hWnd.opener))
		hWnd.opener = document.window;
	hWnd.focus();	
}

function ArtikelNr()
{

var aimage = document.getElementById('image').value;
var fname=prompt("Type de artikel nummer om te zoeken:", aimage);
document.getElementById('image').value = fname;

}

function showArtikel(str)
{

if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_artikel.php?q="+str+'&t='+ new Date().getTime(),true);
xmlhttp.send();
}

/* Copyright Soft2Connect 2006 */

/*
 * The standard S2C getElement function
 */
function S2C_GetElement(id){
	if(document.layers) {
		return document.layers[id];
	}
	//gecko(NN6) + IE 5+
	else if(document.getElementById) {
		return document.getElementById(id);
		obj.style.display = display;
	}
	// IE 4
	else if(document.all) {
		return document.all[id];
	}
	return null;
}

function scrollBar() {	
	/*
	 *  Initial Values
	 */
	this.scrollerwidth  	= 1024;		// Scrollers width here (in pixels)
	this.scrollerheight 	= 100;		// Scrollers height here
	this.scrollerspeed  	= 1;			// Scrollers speed here (larger is faster 1-10)
	this.scrollercontent = '';		// Scrollers content goes here! Keep all of the message on the same line!
	this.htmlContentHeight	= '';	// Height of the HTML content
	this.actualWidth	= '';			// Width of the HTML content
	this.sliderDelta = 1;				// Delta the slider should move per pixel top moved
	
	this.pauseit=1;
	
	/*
	 *  Initial Constants
	 *  Do not change!
	 */
	this.scrollerspeed=(document.all)? this.scrollerspeed : Math.max(1, this.scrollerspeed-1); //slow speed down by 1 for NS
	//er
	this.copyspeed=this.scrollerspeed;
	this.iedom =	document.all||document.getElementByid;
	
	this.cross_scroller;
	this.cross_scroller2;
	this.ns_scroller;
	this.slider;
	this.pausespeed=(this.pauseit==0)? this.copyspeed: 0;
	this.id = 0;
	
	/*
	 *  Function to pass the variables
	 * Pay attention: overlap when scrollerWthis.idth < actualWthis.idth 
	 */
	 
	this.initScrollArea = function(id, scrollAreaWidth, scrollAreaHeight, contentHeight, contentWidth, initScrollercontent, initScrollerspeed){
		this.id = id;
		this.scrollerwidth		= scrollAreaWidth;
		this.scrollerheight		= scrollAreaHeight;
		this.htmlContentHeight	= contentHeight;
		this.actualWidth		= contentWidth;
		this.scrollercontent	= initScrollercontent; 
		this.scrollerspeed		= initScrollerspeed;
		
		/* Initially the text does not scroll */
		this.copyspeed			= this.pausespeed;				
		/* 
		 * Arrow height  = 2*22 = 44
		 * Slider height 		= 100
		 */
		this.sliderDelta			= (scrollAreaHeight - 44 - 100) / (contentHeight - scrollAreaHeight) ;
	}
	
	/*
	 *  Function to start scroller
	 */
	this.populateScrollArea = function(){	
			this.cross_scroller = S2C_GetElement("scrollArea"+this.id);
			this.cross_scroller.style.top= 0;          			// Start with Text aligned at the top
			this.cross_scroller.style.left= 0;          			// Start with Text aligned at the top
			this.cross_scroller.width = this.actualWidth;
			this.cross_scroller.innerHTML= this.scrollercontent;		// Pass HTML to scrollArea
			
			this.cross_scroller2= S2C_GetElement("scrollArea2"+this.id);
			this.cross_scroller2.style.top= 0; 
			this.cross_scroller2.style.left= this.actualWidth;          			// Start with Text aligned at the top
			this.cross_scroller2.width = this.actualWidth;
			this.cross_scroller2.innerHTML= this.scrollercontent;		// Pass HTML to scrollArea
		
			this.slider	= S2C_GetElement("slider"+this.id);
	}
	
		/*
	 *  Function to start scroller
	 */
	this.populateScrollAreaVWS = function(){	
			this.cross_scroller = S2C_GetElement("scrollArea"+this.id);
			this.cross_scroller.style.top= 0;          			// Start with Text aligned at the top
			this.cross_scroller.style.left= 0;          			// Start with Text aligned at the top
			this.cross_scroller.width = this.actualWidth;
			this.cross_scroller.innerHTML= this.scrollercontent;		// Pass HTML to scrollArea

			this.slider	= S2C_GetElement("slider"+this.id);
	}
	
	/*
	 *	Function to keep scrolling horizontal
	 */
	
	this.scrollScrollAreaHorizontal = function(){		/* First check if the box is not with his right sthis.ide on the left side of the view box */
		if (parseInt(this.cross_scroller.style.left) > (this.actualWidth*(-1))){
			// Not out of the view box. So move one step to the left.
			
			/* PROBLEM IS HE CAN NOT FIND cross_scroller*/
			this.cross_scroller.style.left 	=	parseInt(this.cross_scroller.style.left)-this.copyspeed+"px";
		}
		else {
			// Out of the viewing box. Place after the other box so on actualWidth
			this.cross_scroller.style.left	=	parseInt(this.actualWidth)+"px";
		}
		
		/*
		 * OK The same for the second bar
		 */
		if (parseInt(this.cross_scroller2.style.left) > (this.actualWidth*(-1))){
			this.cross_scroller2.style.left 	=	parseInt(this.cross_scroller2.style.left)-this.copyspeed+"px";
		}
		else {
			this.cross_scroller2.style.left 	=	parseInt(this.actualWidth)+"px";
		}
		
		if(parseInt(this.cross_scroller.style.left) > 0){
			/* now if scrolling to the right */
			this.cross_scroller2.style.left 	=	parseInt(this.cross_scroller.style.left) - this.actualWidth+"px";
		}
		if(parseInt(this.cross_scroller2.style.left) > 0){
			/* now if scrolling to the right */
			this.cross_scroller.style.left 	=	parseInt(this.cross_scroller2.style.left) - this.actualWidth+"px";
		} 
	}
	
	/*
	 *  Function to keep scrolling normal vertical window
	 */
	
	this.scrollScrollArea = function(){
		/* Calculate new position of slider */
		//if(document.getElementByid? document.getElementByid("slider"+this.id) : document.all.slider1 != null){
		if(S2C_GetElement("scrollArea"+this.id) != null) {
				var test = parseInt(this.cross_scroller.style.top) * this.sliderDelta * -1+"px";
		}

		/* calculate new position */
		this.cross_scroller.style.top = parseInt(this.cross_scroller.style.top)-this.copyspeed+"px";
		
		
		
		/* Upper boundary */
		if (parseInt(this.cross_scroller.style.top) < (this.htmlContentHeight*(-1) + this.scrollerheight)){
			this.cross_scroller.style.top = (this.htmlContentHeight*(-1) + this.scrollerheight);
			this.copyspeed=this.pausespeed;
		}
		/* Lower boundary */
		else if (parseInt(this.cross_scroller.style.top) > 0){
			this.cross_scroller.style.top = 0;
			this.copyspeed=this.pausespeed;
		}
		
	}
	
	this.scrollScrollAreaWS = function(){
		/* Calculate new position of slider */
		//if(document.getElementByid? document.getElementByid("slider"+this.id) : document.all.slider1 != null){
		this.slider.style.top = parseInt(this.cross_scroller.style.top) * this.sliderDelta * -1+"px";
		/* calculate new position */
		this.cross_scroller.style.top = parseInt(this.cross_scroller.style.top)-this.copyspeed+"px";
		
		
		
		/* Upper boundary */
		if (parseInt(this.cross_scroller.style.top) < (this.htmlContentHeight*(-1) + this.scrollerheight)){
			this.cross_scroller.style.top = (this.htmlContentHeight*(-1) + this.scrollerheight);
			this.copyspeed=this.pausespeed;
		}
		/* Lower boundary */
		else if (parseInt(this.cross_scroller.style.top) > 0){
			this.cross_scroller.style.top = 0;
			this.copyspeed=this.pausespeed;
		}
		
	}
	
	/*
	 *  Function to write scrollarea to screen
	 */
	this.writeScrollAreaHorizontal = function(scrollArea){
		
		with (document){			
			write('<table width'+this.scrollerwidth+' height='+this.scrollerheight+' >')
			write(	'<tr>')
			write(		'<td class="text" colspan="3" height="10px"></td>')			
			write(	'</tr>')
			write(	'<tr>')
			
			this.scrollerwidth  = this.scrollerwidth - 20; 	//width  of arrow
			write(		'<td valign="top" width="7%">')											  
			write(			'<div align="center"><img src="images/arrow_left.jpg" width="10" alt="" onMouseover="'+scrollArea+'.copyspeed=-1*'+scrollArea+'.scrollerspeed" onMouseout="'+scrollArea+'.copyspeed='+scrollArea+'.pausespeed" /></div>')
			write(		'</td>')
			write(		'<td class="text" width="'+this.scrollerwidth+'px" height="'+this.scrollerheight+'px">')
			write(			'<div style="position:relative;width:'+this.scrollerwidth+'px;height:'+this.scrollerheight+'px;overflow:hidden" >')
			write(			'<div id="scrollArea'+this.id+'"  style="position:absolute;left:0px;top:0px;width:'+ this.actualWidth +'px;text-align:left;"></div>') //background-color:#00ff00;
			write(			'<div id="scrollArea2'+this.id+'" style="position:absolute;left:0px;top:0px;width:'+ this.actualWidth +'px;text-align:left;"></div>') //background-color:#0000ff;
			write(			'</div>')
			write(		'</td>')
			write(		'<td valign="top" width="7%" >')
			write(			'<div align="center"><img src="images/arrow_right.jpg" width="10" alt="" onMouseover="'+scrollArea+'.copyspeed='+scrollArea+'.scrollerspeed" onMouseout="'+scrollArea+'.copyspeed='+scrollArea+'.pausespeed" /></div>')
			write(		'</td>')
			write(	'</tr>')
			write('</table >')
		}
		lefttime=setInterval(scrollArea+'.scrollScrollAreaHorizontal()',20)		// Evaluate function every 20 ms
		
	}
	
	/*
	 *  Function to write scrollarea to screen
	 */
	this.writeSimpleScrollAreaHorizontal = function(scrollArea){
		
		with (document){			
			
		
			write(			'<div style="position:relative;width:'+this.scrollerwidth+'px;height:'+this.scrollerheight+'px;overflow:hidden;" >')
			write(			'<div id="scrollArea'+this.id+'"  style="position:absolute;left:0px;top:0px;width:'+ this.actualWidth +'px;text-align:left;"></div>') //background-color:#00ff00;
			write(			'<div id="scrollArea2'+this.id+'" style="position:absolute;left:0px;top:0px;width:'+ this.actualWidth +'px;text-align:left;"></div>') //background-color:#0000ff;
			write(			'</div>')
			
		}
		lefttime=setInterval(scrollArea+'.scrollScrollAreaHorizontal()',20)		// Evaluate function every 20 ms
		
	}
	
	/*
	 *  Function to write scrollarea to screen with scroller
	 */
	this.writeScrollAreaWS = function(scrollArea){
		with (document){			
			write('<table width'+this.scrollerwidth+' height='+this.scrollerheight+' >')
			write(	'<tr>')
			this.scrollerwidth  = this.scrollerwidth - 22; 	//width  of arrow
			write(		'<td class="text" rowspan="3" width="'+this.scrollerwidth+'px" height="'+this.scrollerheight+'px" valign=\"center\">')
			write(			'<div style="position:relative;width:'+this.scrollerwidth+'px;height:'+this.scrollerheight+'px;overflow:hidden;" >')
			write(			'<div id="scrollArea'+this.id+'"  style="position:absolute;left:0px;top:0px;width:'+ this.actualWidth +'px;text-align:left;"></div>') //background-color:#00ff00;
			write(			'</div>')
			write(		'</td>')
			write(		'<td valign="top">')
			write(			'<img src="images/arrow_up.jpg" width="22" height="22" alt="" onMouseover="'+scrollArea+'.copyspeed=-1*'+scrollArea+'.scrollerspeed" onMouseout="'+scrollArea+'.copyspeed='+scrollArea+'.pausespeed" />')
			write(		'</td>')
			write(	'</tr>')
	
			
			write(	'<tr>')
			this.sliderBarHeight = this.scrollerheight - 44;
			write(		'<td height="'+this.sliderBarHeight+'" valign="top">')  
			write(			'<div style="position:relative;top:0px;" id="slider'+this.id+'"><img src="images/slider.gif" width="22" height="100" alt="" /></ div>')
			write(		'</td>')
			write(	'</tr>')
			
			write(	'<tr>')
			write(		'<td valign="bottom">')
			write(			'<img src="images/arrow_down.jpg" width="22" height="22" alt="" onMouseover="'+scrollArea+'.copyspeed='+scrollArea+'.scrollerspeed" onMouseout="'+scrollArea+'.copyspeed='+scrollArea+'.pausespeed" />')
			write(		'</td>')
			write(	'</tr>')
			write('</table >')
		}
		lefttime=setInterval(scrollArea+'.scrollScrollAreaWS()',20)		// Evaluate function every 20 ms
	}
	
	this.automateScroll = function(){
		this.copyspeed = this.scrollerspeed;
	}
}
/* Selectie winkel profukten in produkt.php */
function addbasket (addbasketid){				
	//var antw=confirm("Items " +addbasketid+ " toevoegen in het winkelmanje !");
	//if (antw==true){
				new Ajax.Request('produkt.php?addbasket='+addbasketid+'&t='+ new Date().getTime(), {
				onSuccess: function(response) {
					
					alert(response.responseText);
					
					dummytext=response.responseText;
					textarray=dummytext.split("-");
					document.getElementById('aantalinbasket').value= textarray[1] + " items in de winkelmand !";
				}
			});

			}
	//}
/* Selectie winkelmand in winkel.php */			
function deletebasket (addbasketid){
		var antw=confirm("Items " +addbasketid+ " uit winkelmand verwijderd !");
			if (antw==true){
				new Ajax.Request('winkel.php?deletebasket='+addbasketid+'&t='+ new Date().getTime(), {
					onSuccess: function(response) {

						$("basket").innerHTML = response.responseText;
						new Ajax.Request('winkel.php?subtotaal=1&t='+ new Date().getTime(), {
							onSuccess: function(response) {
								dummytext=response.responseText;
								textarray=dummytext.split("-");
								
								document.getElementById('subtotaal').value= "€ "+cent(textarray[0]);
								document.getElementById('aantal').value= textarray[1];
								document.getElementById('porto').value= "€ "+cent(textarray[2]);
								document.getElementById('totaal').value= "€ "+cent(textarray[3]);
							}
						});
						
						
					}
				});

			}else{
			
				alert ("Items " +addbasketid+ " steeds in het uit winkelmand !");
			
			}	
			
		}
		
/*Items verkocht*/
function verkocht(items)
{

  alert(items + " is verkocht / optie sorry !");

}
		
/* Getal omzetten in value*/
function cent(amount) {
			return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
		}
/* Check Webshop winkelmand en klant gevens */
function chkWebshopFormular(){
			var opmerking="";
			var compleet="waar";
			var foutemail="onwaar";

			
			var aemail=document.formular.email.value;
			
			var at="@";
			var dot=".";
			var lstr=aemail.length;
			var lat=aemail.indexOf(at);
			var ldot=aemail.indexOf(dot);
	
	if (document.formular.avv.checked == true){
		
		if(document.formular.aantal.value == "0"){ 
				alert("Winkelmand is leeg !!");
				return false;
		}else{
			if(document.formular.voorletters.value == ""){compleet="onwaar" ;opmerking = opmerking + "voorletters \n";}
			if(document.formular.achternaam.value == ""){compleet="onwaar" ;opmerking = opmerking + "achternaam \n";}
			if(document.formular.email.value == ""){compleet="onwaar" ;opmerking = opmerking + "email \n";}
			if(document.formular.straat.value == ""){compleet="onwaar"; opmerking = opmerking + "straat \n";}
			if(document.formular.huisnummer.value == ""){compleet="onwaar" ;opmerking = opmerking + "huisnummer \n";}
			if(document.formular.postcode.value == ""){compleet="onwaar"; opmerking = opmerking + "postcode \n";}
			
			if(document.formular.plaats.value == ""){compleet="onwaar" ;opmerking = opmerking + "plaats \n";}
			if(document.formular.land.value == ""){compleet="onwaar"; opmerking = opmerking + "land \n";}
			if (compleet=="onwaar"){
				alert("Alle velden invullen ! \n" + opmerking);
				return false;
			}else{
				if (aemail.indexOf(at) == -1){foutemail= "waar";}
				if (aemail.indexOf(at) == -1 || aemail.indexOf(at)==0 || aemail.indexOf(at)==lstr){foutemail= "waar";}
				if (aemail.indexOf(dot) == -1 || aemail.indexOf(dot)==0 || aemail.indexOf(dot)==lstr){foutemail= "waar";}
				if (aemail.indexOf(at,(lat+1))!=-1){foutemail= "waar";}
				if (aemail.substring(lat-1,lat)== dot || aemail.substring(lat+1,lat+2)==dot){foutemail= "waar";}
				if (aemail.indexOf(dot,(lat+2))== -1){foutemail= "waar";}
				if (aemail.indexOf(" ")!= -1){foutemail= "waar";}
				if (foutemail=="waar"){
					alert("Verkeerde email !");
					return false;
				}else{
					

				
					return true;
				} // endif foutive emailadres
			} //endif imcompleet velden
		} //endif leegmand
	}else{
		alert("Accepteert u de algemene voorwaarden !!");
		return false;
	} // algemeen voorwaarden	
}
// Algeneem verkoop voorwaarden
function voorwaarden(){
				
		avwtxt = "Algemene Voorwaarden: \n";
		avwtxt = avwtxt + "Goederen \n";	
		alert(avwtxt);
	}
// Show rekeningen
function showReken(str)
{

if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_rekening.php?q="+str+'&t='+ new Date().getTime(),true);
xmlhttp.send();
}
// Show Klanten
function showKlanten(str)
{

if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_klanten.php?q="+str+'&t='+ new Date().getTime(),true);
xmlhttp.send();
}	
