// JavaScript Document


function PrintThisPage(obj) 
{ 
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

   var sWinHTML = document.getElementById(obj).innerHTML; 
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write('<html><LINK href=/site/css/default.css rel=Stylesheet><body>'); 
       winprint.document.write(sWinHTML);          
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
       winprint.focus(); 
	   winprint.print();
}


/* CONFIRM DELETE*/	
function confirmDelete(id, ask, url) //confirm order delete
{
	temp = window.confirm(ask);
	if (temp) //delete
	{
		window.location=url+id;
	}
}

/*#### De onderstaande code is voor de ProductViewer ####*/
function approachEnlargement(el) 
{
	var tbody = el.parentNode.parentNode.parentNode;
	
	for(i=0;i<tbody.childNodes.length;i++) 
	{	
		if(tbody.childNodes[i].nodeName == 'TR') 
		{		
			for(j=0;j<tbody.childNodes[i].childNodes.length;j++) 
			{				
				if(tbody.childNodes[i].childNodes[j].nodeName == 'TD') 
				{
					if(tbody.childNodes[i].childNodes[j].className == 'tableleft') 
					{						
						for(k=0;k<tbody.childNodes[i].childNodes[j].childNodes.length;k++) 
						{							
						    if(tbody.childNodes[i].childNodes[j].childNodes[k].nodeName == 'IMG') 
							{								
								var img = tbody.childNodes[i].childNodes[j].childNodes[k];
								return img;
							} 
						}
					}
				}
			}
		}
	}
}

function getThumbSource(el)
{
	for(i=0;i<el.childNodes.length;i++) 
	{
		if(el.childNodes[i].nodeName == 'IMG') 
		{
			var img = el.childNodes[i].getAttributeNode('src').nodeValue;
			return img;
		}
	}
}


function alterImage(el) 
{
	// Vergroting links:
	var enlargement = approachEnlargement(el)
	// Aangeklikte thumbnail:
	var thumb = getThumbSource(el);	
	// Nieuw sourceattribuut:
	var newAtt = document.createAttribute("src");
	newAtt.value = thumb;	
	// Verwijder bestaand attribuut:
	enlargement.removeAttribute("src");
	// Plaats nieuw attribuut:
	enlargement.setAttributeNode(newAtt);	
}
/*#### Einde ProductViewer ####*/



/*#### Gastenboek ####*/
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
/*#### Einde Gastenboek ####*/


/*#### Inputfields restrictie: ####*/

/* Beperk de invoer van de inputfields in de formulieren:  */

//Beperk tot alphabetische invoer:
function restrictAlph(o, type) {
	if(IE_ArrowKey()) { 
		return; 
	}	
	
	//In deze array alternatieve karakters plaatsen:
	var last = "";
	var charReplacements = 
		[
			{char: 'è', code: 232, rep: 'e'},
			{char: 'é', code: 233, rep: 'e'},		
			{char: 'ë', code: 234, rep: 'e'},		
			{char: 'ë', code: 235, rep: 'e'},
			{char: 'ï', code: 239, rep: 'i'},			
			{char: 'ö', code: 246, rep: 'o'}
		]	
	
	//Het laatste ingevoerde karakter:
	if(o.value) {
		arr = o.value.split("");
		arr.reverse();
		last = arr[0].charCodeAt(arr[0].length-1);
	}
	
	//Controleren op alternatieve karakters:
	for(var i=0; i<charReplacements.length; i++) {
		  if(charReplacements[i].code == last) {
				o.value=o.value.substring(0, o.value.length-1) + charReplacements[i].rep;
		  }
	}
	//Verwijder illegale karakters:	
	if(type == 'email') {
		//in email mogen meer karakters voorkomen
		o.value=o.value.replace(/([^A-Za-z -._@])/g,"");	
		o.value=o.value.replace("@@", "@");
	} else {
		o.value=o.value.replace(/([^A-Za-z -.])/g,"");
	}
	
	//Verwijder dubbele spaties:
	o.value=o.value.replace("  ", " ");
	o.value=o.value.replace("..", ".");
}

//Beperk tot numerieke invoer:
function restrictNumb(o){
	if(IE_ArrowKey()) { 
		return; 
	}
	o.value=o.value.replace(/([^0-9])/g,"");
}






/*#### Einde Inputfields restrictie: ####*/












