//Admin scripts//
var itemActive = 0;
function openAlbumWindow(chosentype,active,thefolder,whichfunc,thepage){
	if (typeof(thefolder) == "undefined"){
		thefolder =1;
	} 
	if (typeof(whichfunc) == "undefined"){
		whichfunc = "chooseImage";
	}
	if (typeof(thepage) == "undefined"){
		thepage = 1;
	}
	itemActive = active;
	var win = $('overlay');
	if (win)
	{
		openBack();
		win.style.display = '';
		win.innerHTML = '<div class="loading"><img src="'+ siteurl + 'img/layout/loader.gif" alt="Inhoud laden..." /><br/>'+ please_wait +'</div>'; 
		// ajax aanroepen
		new Ajax.Request(siteurl+'includes/ajax/images.php',   
			{     
				method:'get',     
				parameters: {type: chosentype, setActive: active, folder: thefolder, functionname: whichfunc, page: thepage},
				onSuccess: function(transport){       
					var response = transport.responseText || error_string;       
					win.innerHTML = response;    
					$('ajaxContainer').style.top = (getScrollY()+80) + 'px';
				},    
				onFailure: function(){ 
					win.innerHTML = error_string;
				}   
			}
		); 
	} else {
		alert(error_no_window +' 4');
	}
}
function openBlockWindow(chosentype,active){
	itemActive = active;
	var win = $('albumWindow');
	if (win)
	{
		$('albumWindow').style.top = (getScrollY()+80) + 'px';
		win.style.display = '';
		win.innerHTML = "<img src=\""+ siteurl + "img/loader.gif\" alt=\"Inhoud laden...\" />&nbsp;even geduld aub."; 
		// ajax aanroepen
		new Ajax.Request(siteurl+'includes/ajax/blocks.php',   
			{     
				method:'get',     
				parameters: {type: chosentype, setActive: active},
				onSuccess: function(transport){       
					var response = transport.responseText || "Error: #1";       
					win.innerHTML = response;     
				},    
				onFailure: function(){ 
					win.innerHTML = "<p>Er is een fout opgetreden in de Layout-module<br/><br/><a href=\"#\" onclick=\"closeAlbumWindow();return false;\">sluit venster</a></p>";
				}   
			}
		); 
	} else {
		alert("het blokvenster is op deze pagina niet aanwezig.");
	}
}
function openFotoWindow(chosentype,active){
	itemActive = active;
	var win = $('albumWindow');
	if (win)
	{
		$('albumWindow').style.top = (getScrollY()+80) + 'px';
		win.style.display = '';
		win.innerHTML = "<img src=\""+ siteurl + "img/loader.gif\" alt=\"Inhoud laden...\" />&nbsp;even geduld aub."; 
		// ajax aanroepen
		new Ajax.Request(siteurl+'includes/ajax/pics.php',   
			{     
				method:'get',     
				parameters: {type: chosentype, setActive: active},
				onSuccess: function(transport){       
					var response = transport.responseText || "Error: #1";       
					win.innerHTML = response;     
				},    
				onFailure: function(){ 
					win.innerHTML = "<p>Er is een fout opgetreden in de blokModule<br/><br/><a href=\"#\" onclick=\"closeAlbumWindow();return false;\">sluit venster</a></p>";
				}   
			}
		); 
	} else {
		alert("het blokvenster is op deze pagina niet aanwezig.");
	}
}

function chooseOldImage (imgid,imgurl,imgname,picnum){
	div		= $('image'+picnum);
	current = $('currentIMG'+picnum);
	edit	= $('editImage'+picnum);
	del		= $('deleteImage'+picnum);
	if (div && current && edit && del){
		div.value = imgid;
		current.innerHTML= "<img src=\""+ imgurl + "\" alt=\""+ imgname +"\" /><br/>"+ imgname;
		edit.innerHTML = change_image;
		del.style.display= '';
		closeWindow();
	} else {
		if (div){ alert("div ok");}
		if (current){ alert("current ok");}
		if (edit){ alert("edit ok");}
		if (del){ alert("del ok");}
		alert(error_string + " 5");
	}
}

function chooseBlock(imgid,imgurl,imgname,picnum,hastext,hasimage){
	div		= $('block'+picnum);
	current = $('curBlock'+picnum);
	edit	= $('editBlock'+picnum);
	del		= $('deleteBlock'+picnum);
	img		= $('imgUploadDiv'+picnum);
	title	= $('blockTitle'+picnum);
	text	= $('blockText'+picnum);
	editimg = $('editImage'+picnum);
	if (div && current && edit && del && img && editimg){
		if (hastext == "Y"){
			title.style.display = '';
			text.style.display = '';
		} else {
			title.style.display = 'none';
			text.style.display = 'none';
		}
		if (hasimage == "Y")
		{
			img.style.display= '';
			editimg.style.display = '';
		} else {
			img.style.display= 'none';
			
		}
		div.value = imgid;
		current.innerHTML= "<img src=\""+ imgurl + "\" alt=\""+ imgname +"\" /><br/>";
		edit.innerHTML = 'Wijzig layout';
		del.style.display= '';
		closeAlbumWindow();
	} else {
		alert("het element is op deze pagina niet aanwezig.");
	}
}
function chooseAlbumPic (imgid,imgurl,imgname,picnum,hastext){
	div		= $('block'+picnum);
	current = $('curBlock'+picnum);
	edit	= $('editBlock'+picnum);
	del		= $('deleteBlock'+picnum);
	img		= $('imgUploadDiv'+picnum);
	title	= $('blockTitle'+picnum);
	text	= $('blockText'+picnum);
	editimg = $('editImage'+picnum);
	if (div && current && edit && del){
		if (hastext == "Y"){
			title.style.display = 'none';
			text.style.display = 'none';
		} else {
			title.style.display = 'none';
			text.style.display = 'none';
		}
		div.value = imgid;
		current.innerHTML= "<img src=\""+ imgurl + "\" alt=\""+ imgname +"\" /><br/>";
		edit.innerHTML = 'Foto wijzigen';
		del.style.display= '';
		closeAlbumWindow();
	} else {
		alert("het element is op deze pagina niet aanwezig.");
	}
}
function closeAlbumWindow(){
	itemActive = 0;
	var win = $('overlay');
	if (win)
	{
		win.style.display = 'none';
		win.innerHTML = '';
		closeBack();
	} else {
		alert("het albumvenster is op deze pagina niet aanwezig.");
	}
}

function moveImage(item){
	select	= $('rep'+item);
	folder = select.options[select.selectedIndex].value;
	if (folder != 0){
		$('imageList'+item).style.display = 'none';
		new Ajax.Request(siteurl+'includes/ajax/images.php',  {     
				method:'get',     
				parameters: {type: "replace", uin: item, folder: folder},
				onSuccess: function(transport){       
					var response = transport.responseText || "Error"; 
					if (response != "success"){
						alert("Er is een fout opgetreden bij het verplaatsen van de afbeelding\r\n\r\n"+response);    
						$('imageList'+item).style.display = '';
					} 
				}
			}
		); 
	}
}
function quickRemoveImage(item){
	itemActive = item;
	div		= $('image'+itemActive);
	current = $('currentIMG'+itemActive);
	edit	= $('editImage'+itemActive);
	del		= $('deleteImage'+itemActive);
	if (div && current && edit && del)
	{
		current.innerHTML = '<em>-geen geselecteerd-<br/>(u dient alsnog op<br/> opslaan te klikken)</em>';
		div.value = 0;
		edit.innerHTML = 'Kies foto';
		del.style.display = 'none';
		itemActive = 0;
	} else {
		alert("het element is op deze pagina niet aanwezig.");
	}
}

function quickRemoveBlock(item){
	itemActive = item;
	div		= $('block'+itemActive);
	current = $('curBlock'+itemActive);
	edit	= $('editBlock'+itemActive);
	del		= $('deleteBlock'+itemActive);
	divimg	= $('image'+itemActive);
	curimg  = $('currentIMG'+itemActive);
	editimg	= $('editImage'+itemActive);
	delimg	= $('deleteImage'+itemActive);
	titlediv= $('blockTitle'+itemActive);
	textdiv = $('blockText'+itemActive);
	title	= $('title'+itemActive);
	text	= $('text'+itemActive);
	img		= $('imgUploadDiv'+itemActive);
	if (div && current && edit && del && divimg && curimg && editimg && delimg && title && text && img && titlediv && textdiv) {
		current.innerHTML = '<em>-geen geselecteerd-<br/></em>';
		curimg.innerHTML = '<em>-geen geselecteerd-<br/></em>';
		div.value = 0;
		divimg.value=0;

		edit.innerHTML = 'Kies layout';
		editimg.innerHTML = 'Kies foto';
		editimg.style.display = 'none';
		del.style.display = 'none';
		delimg.style.display = 'none';
		titlediv.style.display = 'none';
		textdiv.style.display = 'none';
		img.style.display = 'none';
		itemActive = 0;
	} else {
		alert("het element is op deze pagina niet aanwezig.");
	}
}
function quickRemoveFoto(item){
	itemActive = item;
	div		= $('block'+itemActive);
	current = $('curBlock'+itemActive);
	edit	= $('editBlock'+itemActive);
	del		= $('deleteBlock'+itemActive);
	titlediv= $('blockTitle'+itemActive);
	textdiv = $('blockText'+itemActive);
	title	= $('title'+itemActive);
	text	= $('text'+itemActive);
	if (div && current && edit && del && title && text && titlediv && textdiv) {
		current.innerHTML = '<em>-geen geselecteerd-<br/></em>';
		div.value = 0;
		edit.innerHTML = 'Kies foto';
		del.style.display = 'none';
		titlediv.style.display = 'none';
		textdiv.style.display = 'none';
		itemActive = 0;
	} else {
		alert("het element is op deze pagina niet aanwezig.");
	}
}

function uploadImages() {
	var win = $('overlay');
	if (win)
	{
		win.innerHTML = '<div class="loading"><img src="'+ siteurl + 'img/layout/loader.gif" alt="Inhoud laden..." /><br/>'+ please_wait +'</div>'; 
			new Ajax.Request(siteurl+'includes/ajax/upload.php',   
			{     
				method:'get',     
				onSuccess: function(transport){       
					var response = transport.responseText || error_string;       
					win.innerHTML = response; 
					var FO1 = { movie: siteurl + "flash/upload.swf?xmlurl="+ siteurl +"flash/xml.php", width:"480", height:"240", majorversion:"8", build:"0",wmode:"transparent"};
					UFO.create(FO1, "flashUpload");
					$('ajaxContainer').style.top = (getScrollY()+80) + 'px';
				},    
				onFailure: function(){ 
					win.innerHTML = error_string;   
				}   
			}
		); 
	} else {
		alert(error_string + " 7");
	}
}
function openCropWindow() {
	var win = $('overlay');
	if (win)
	{
		win.innerHTML = '<div class="loading"><img src="'+ siteurl + 'img/layout/loader.gif" alt="Inhoud laden..." /><br/>'+ please_wait +'</div>'; 
			new Ajax.Request(siteurl+'includes/ajax/crop.php',   
			{     
				method:'get',     
				onSuccess: function(transport){       
					var response = transport.responseText || error_string;       
					win.innerHTML = response; 
					$('ajaxContainer').style.top = (getScrollY()+10) + 'px';
					var FO1 = { movie: siteurl + "flash/crop/BitmapDataCrop.swf?siteUrl="+ siteurl + "flash/crop/" , flashvars:"uploadUrl="+ imgurl + "upload/&xmlFile="+ siteurl + "flash/crop/xml/cropmarges.php?template=0", id:"cropToolFlash", width:"958", height:"530", majorversion:"8", build:"0",wmode:"transparent"};
					UFO.create(FO1, "cropTool");
				},    
				onFailure: function(){ 
					win.innerHTML = error_string;   
				}   
			}
		); 
	} else {
		alert(error_string + " 7");
	}
}

function openFolderWindow(chosentype) {
	if (typeof(chosentype) == "undefined"){
		chosentype = "view";
	}
	var win = $('overlay');
	if (win)
	{
		win.innerHTML = "<img src=\""+ siteurl + "admin/img/loader.gif\" alt=\"Inhoud laden...\" />&nbsp;even geduld aub."; 
			new Ajax.Request(siteurl+'includes/ajax/folders.php',   
			{     
				method:'get',     
				parameters: {type: chosentype},
				onSuccess: function(transport){       
					var response = transport.responseText || "Error: #1";       
					win.innerHTML = response;     
					$('ajaxContainer').style.top = (getScrollY()+80) + 'px';
				},    
				onFailure: function(){ 
					win.innerHTML = error_string;
				}   
			}
		); 
	} else {
		alert(error_string + " 8");
	}
}

function uploadSubmit(){
	showWaitScreen();
	$('upForm').submit();
}
function showWaitScreen(){
	$('waitScreen').style.display = '';
	$('waitLoading').style.display = '';
}

function hideWaitScreen(){
	$('waitScreen').style.display = 'none';
	$('waitLoading').style.display = 'none';
}
function showProperties(uin){
	$('func'+uin).style.display = '';
	$('txt'+uin).style.display = '';
}
function swapText(uin){
	$('swap'+uin).style.display = '';
	$('org'+uin).style.display = 'none';
}
function deleteImage(image){
	$('imageList'+image).style.display = 'none';
	new Ajax.Request(siteurl+'includes/ajax/images.php',  {     
			method:'get',     
			parameters: {type: "delete", uin: image},
			onSuccess: function(transport){       
				var response = transport.responseText || "Error"; 
				if (response != "success"){
					alert("Er is een fout opgetreden bij het verwijderen van de afbeelding\r\n\r\n"+response);    
					$('imageList'+image).style.display = '';
				}  
			}
		}
	); 
}
function deleteFolder(folder){
	$('folder'+folder).style.display = 'none';
	new Ajax.Request(siteurl+'includes/ajax/folders.php',  {     
			method:'get',     
			parameters: {type: "delete", uin: folder},
			onSuccess: function(transport){       
				var response = transport.responseText || "Error"; 
				if (response != "success"){
					alert("Er is een fout opgetreden bij het verwijderen van de map\r\n\r\n"+response);    
					$('folder'+folder).style.display = '';
				}  
			}
		}
	); 
}
function saveText(uin){
	$('org'+uin).style.display = '';
	$('swap'+uin).style.display = 'none';
	new Ajax.Request(siteurl+'includes/ajax/images.php',  {     
			method:'get',     
			parameters: {type: "textedit", uin: uin, text: $('imgTitle'+uin).value},
			onSuccess: function(transport){       
				var response = transport.responseText || "Error"; 
				if (response != "success"){
					alert("Er is een fout opgetreden bij het wijzigen van de tekst:\r\n\r\n '"+response+"'");   
					$('imgTitle'+uin).value = $('org'+uin).innerHTML;
				}  else {
					$('org'+uin).innerHTML = $('imgTitle'+uin).value;
				}
			}
		}
	); 
}
function saveFolderText(uin){
	$('org'+uin).style.display = '';
	$('swap'+uin).style.display = 'none';
	new Ajax.Request(siteurl+'includes/ajax/folders.php',  {     
			method:'get',     
			parameters: {type: "textedit", uin: uin, text: $('imgTitle'+uin).value},
			onSuccess: function(transport){       
				var response = transport.responseText || "Error"; 
				if (response != "success"){
					alert("Er is een fout opgetreden bij het wijzigen van de tekst:\r\n\r\n '"+response+"'");   
					$('imgTitle'+uin).value = $('org'+uin).innerHTML;
				}  else {
					$('org'+uin).innerHTML = $('imgTitle'+uin).value;
				}
			}
		}
	); 
}
	function getScrollY() {
	  var scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	  }
	  return  scrOfY ;
	}

function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}


function showExtraImage(max){
	if (visibleImages == max){
		alert('nee');
	} else {
		visibleImages++;
		var newwin = $('imgRow'+visibleImages);
		if (newwin)	{
			newwin.style.display='';
			if (max == visibleImages){
				$('imgRow'+(visibleImages+1)).style.display = 'none';
			}
		} else {
			alert('nee2');
		}
	}
}
function showExtraBlock(max){
	if (visibleImages == max){
		alert('nee');
	} else {
		visibleImages++;
		var newwin = $('blockRow'+visibleImages);
		if (newwin)	{
			newwin.style.display='';
			if (max == visibleImages){
				$('blockRow'+(visibleImages+1)).style.display = 'none';
			}
		} else {
			alert('nee2');
		}
	}
}
function checkProduct(){
	checked = true;
	for (group=1; group<=parseInt(document.getElementById('totalOptions').value); group++) {
		if (document.getElementById('opt_'+group).value == '0') {
			document.getElementById('opt_title_'+group).className = 'optError';
			document.getElementById('optMelding').style.display='';
			checked = false;
		}
	}	
	if (!checked){
		return false;
	}  else {
		document.getElementById('orderform').submit();
		return false;
	}
}
function trim(str) {
    return str.replace(/(^\s+)([^\s]*)(\s+$)/, '$2');
}
function toggleDate () {
	if ($('rowStartdate').style.display != ''){
		$('rowStartdate').style.display = '';
		$('rowEnddate').style.display = '';
		if ($('rowArchive')){
			$('rowArchive').style.display = '';
		}
	} else {
		$('rowStartdate').style.display = 'none';
		$('rowEnddate').style.display = 'none';
		if ($('rowArchive')){
			$('rowArchive').style.display = 'none';
		}
	}
}
function displayDiv(thediv,selection){
	if (selection == 1){
		document.getElementById(thediv).style.display='';
	} else {
		document.getElementById(thediv).style.display='none';
	}
}
function toggleDiv(thediv){
	div = $(thediv);
	if (div.style.display =='none'){
		div.style.display ='';
	} else {
		div.style.display ='none';
	}
}
function toggleAll(num){
	if (!$('alles').checked){
		var value = false;
	} else {
		var value = true;
	}
	for (i=1;i<=num;i++){
		if (!$('acc'+i).disabled) {
			$('acc'+i).checked=value;
		}	
	}
}
/* ----------------------- Document module ------------------------------------ */
function openDocumentWindow(chosentype, active,thefolder){
	itemActive = active;
	if (typeof(thefolder) == "undefined"){
		thefolder =1;
	} 
	var win = $('overlay');
	if (win)
	{
		openBack();
		win.style.display = '';
		win.innerHTML = '<div class="loading"><img src="'+ siteurl + 'img/layout/loader.gif" alt="Inhoud laden..." /><br/>'+ please_wait +'...</div>'; 
		// ajax aanroepen
		new Ajax.Request(siteurl+'includes/ajax/docs.php',   
			{     
				method:'get',     
				parameters: {setActive: active, type: chosentype, folder:thefolder},
				onSuccess: function(transport){       
					var response = transport.responseText || "Error: #1";       
					win.innerHTML = response;     
					$('ajaxContainer').style.top = (getScrollY()+110) + 'px';
				},    
				onFailure: function(){ 
					win.innerHTML = "<p>Er is een fout opgetreden in de documentModule<br/><br/><a href=\"#\" onclick=\"closeAlbumWindow();return false;\">sluit venster</a></p>";
				}   
			}
		); 
	} else {
		alert("het documentVenster is op deze pagina niet aanwezig.");
	}
}
function chooseDocument (docid,docname,docnum){
	div		= $('doc'+docnum);
	edit	= $('editDoc'+docnum);
	del		= $('deleteDoc'+docnum);
	title	= $('docTitle'+docnum);
	descript= $('docdescript'+docnum);
	block	= $('docBlock'+docnum);
	if (div && edit && del && title && block && descript){
		block.style.display='none';
		title.style.display='';
		descript.value= imgurl + 'upload/docs/' + docname; 
		div.value = docid;
		edit.innerHTML = 'Ander document';
		closeAlbumWindow();
	} else {
		alert("het element is op deze pagina niet aanwezig.");
	}
}
function moveDocument(item){
	select	= $('rep'+item);
	folder = select.options[select.selectedIndex].value;
	if (folder != 0){
		$('imageList'+item).style.display = 'none';
		new Ajax.Request(siteurl+'includes/ajax/docs.php',  {     
				method:'get',     
				parameters: {type: "replace", uin: item, folder: folder},
				onSuccess: function(transport){       
					var response = transport.responseText || "Error"; 
					if (response != "success"){
						alert("Er is een fout opgetreden bij het verplaatsen van het document\r\n\r\n"+response);    
						$('imageList'+item).style.display = '';
					} 
				}
			}
		); 
	}
}
function quickRemoveDocument(item){
	itemActive = item;
	div		= $('doc'+itemActive);
	current = $('docBlock'+itemActive);
	title   = $('docTitle'+itemActive);
	edit	= $('editDoc'+itemActive);
	del		= $('deleteDoc'+itemActive);
	if (div && current && edit && del && title)
	{
		current.innerHTML = '<em>-geen geselecteerd-<br/>(u dient alsnog op<br/> opslaan te klikken)</em>';
		div.value = 0;
		current.style.display='';
		title.style.display='none';
		edit.innerHTML = 'kies document';
		del.style.display = 'none';
		itemActive = 0;
	} else {
		alert("het element is op deze pagina niet aanwezig.");
	}
}
function uploadNewDocument() {
	var win = $('overlay');
	if (win)
	{
		openBack();
		win.style.display = '';
		win.innerHTML = '<div class="loading"><img src="'+ siteurl + 'img/layout/loader.gif" alt="Inhoud laden..." /><br/>'+ please_wait +'</div>'; 
		// ajax aanroepen
			new Ajax.Request(siteurl+'includes/ajax/upload_doc.php',   
			{     
				method:'get',     
				onSuccess: function(transport){       
					var response = transport.responseText || "Error: #1";       
					win.innerHTML = response;     
					$('ajaxContainer').style.top = (getScrollY()+80) + 'px';
				},    
				onFailure: function(){ 
					win.innerHTML = "<p>Er is een fout opgetreden in de uploadModule</p>";
				}   
			}
		); 
	} else {
		alert("het albumvenster is op deze pagina niet aanwezig.");
	}
}
function deleteDocument(docid){
	$('imageList'+docid).style.display = 'none';
	new Ajax.Request(siteurl+'includes/ajax/docs.php',  {     
			method:'get',     
			parameters: {type: "delete", uin: docid},
			onSuccess: function(transport){       
				var response = transport.responseText || "Error"; 
				if (response != "success"){
					alert("Er is een fout opgetreden bij het verwijderen van het document\r\n\r\n"+response);    
					$('imageList'+docid).style.display = '';
				}  
			}
		}
	); 
}
function saveDocText(uin){
	$('org'+uin).style.display = '';
	$('swap'+uin).style.display = 'none';
	new Ajax.Request(siteurl+'includes/ajax/docs.php',  {     
			method:'get',     
			parameters: {type: "textedit", uin: uin, text: $('imgTitle'+uin).value},
			onSuccess: function(transport){       
				var response = transport.responseText || "Error"; 
				if (response != "success"){
					alert("Er is een fout opgetreden bij het wijzigen van de tekst:\r\n\r\n '"+response+"'");   
					$('imgTitle'+uin).value = $('org'+uin).innerHTML;
				}  else {
					$('org'+uin).innerHTML = $('imgTitle'+uin).value;
				}
			}
		}
	); 
}
/*----------WINKELMANDJE---------------------------------------------------*/
function sluitVenster(){
	$('#ajaxContainer').fadeOut(500,function() {
        $('#ajaxOverlay').hide();
		$('#ajaxOverlay').html('');
      });
	 closeBack();
}
function addBasket(){
	$.psv({
		url: siteurl + 'includes/ajax/wish2basket.php',
		type: 'POST',
		data: $('input[name="basket[]"]:checked'),
		success: function(data) {
			openBack();
			$('#ajaxOverlay').html(data);
			$('#ajaxContainer').css('top',(getScrollY()+80) + 'px');
			$('#ajaxOverlay').show();
			$('input:checkbox[name="basket[]"]:checked').each(function(index) { 
				$(this).parent().parent().fadeOut(500);
				$(this).attr('checked',false);
			});
			$('#ajaxContainer').fadeIn(500);
		}
	});
}

function addProduct(prodid,ptype){
	if(checkProduct()){
		if (typeof(ptype) == "undefined"){
			ptype= 'cart';
		}
		var opts = '0';
		if($('.options input:checked').length>0){
			$('.options input:checked').each(function(index) { 
				opts += ',' + $(this).val() ;
			});
		} 
		leaseduur = 0;
		if (ptype == 'lease')
		{
			leaseduur = $('#leasemonth').val();
		}
		$.psv({
			url: siteurl + 'includes/ajax/products.php',
			type: 'POST',
			data: {'options': opts,'type': ptype, 'prod_id': prodid, 'leaselength': leaseduur},
			success: function(data) {
				openBack();
				$('#ajaxOverlay').html(data);
				$('#ajaxOverlay').show();
				$('#ajaxContainer').fadeIn(500);
				$('#ajaxContainer').css('top',(getScrollY()+10) + 'px');
			}
		});
	}
}

function openMenu(){
	$(this).addClass('ie_does_hover');
}
function closeMenu(){
	$(this).removeClass('ie_does_hover');
}
function submitLease(){
	$('#leaseCart').submit();
}
function submitCart(){
	$('#shopCart').submit();
}
/*------------------------------------------------------------------------------*/
function checkSites(val){
	var x = document.getElementsByName('sites[]');
	for (a = 0; a < x.length; a++) {
		x[a].checked=val;
	}
}
function checkColors(val){
	var x = document.getElementsByName('colors[]');
	for (a = 0; a < x.length; a++) {
		x[a].checked=val;
	}
}
function checkSingle(val,head,type){
	for (a = 0; a < val.length; a++) {
		document.getElementById('products'+val[a]).checked=type;
	}
	//document.getElementById('head'+head).checked=type;
}
function checkProps(val,head,type){
	for (a = 0; a < val.length; a++) {
		document.getElementById('properties'+val[a]).checked=type;
	}
	//document.getElementById('head'+head).checked=type;
}
function toggleSites(val){
	document.getElementById('website').style.display='none';
	document.getElementById('verwijzing').style.display='none';
	document.getElementById('landingpage').style.display='none';
	document.getElementById(val).style.display='';	
}
function showGroup(num){
	groep = document.getElementById('groep'+num);
	if (groep.style.display == 'none'){
		groep.style.display = '';
	} else { 
		groep.style.display = 'none'
	}
}
function showPropGroup(num){
	groep = document.getElementById('propgroep'+num);
	if (groep.style.display == 'none'){
		groep.style.display = '';
	} else { 
		groep.style.display = 'none'
	}
}


function ismaxlength(obj)
{
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""

	if (obj.getAttribute && obj.value.length>mlength)
	{
		obj.value=obj.value.substring(0,mlength);
	}
}




/*---------------------------------------------------------------------*/
//						Nieuwe Functionaliteiten
/*---------------------------------------------------------------------*/
function getScrollY() {
	  var scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	  }
	  return  scrOfY ;
}
function getPageHeight() {     
	 var yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
	}
	var windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	return pageHeight;
}
function closeWindow(theclass){
	var win = $('overlay');
	if (win) {
		win.removeClassName(theclass);
		win.style.display = 'none';
		closeBack();
	} else {
		alert(error_no_window);
	}
}
function openBack() {
	$('backgroundOverlay').style.height= getPageHeight() +'px';
	$('backgroundOverlay').style.display='';
}
function closeBack() {
	$('backgroundOverlay').style.display='none';
}

function addContentBlock(max){
	var i = $('totalBlocks').value;
	i++;
	var oldCont = $('tplContainer_blank');
	var newCont = oldCont.cloneNode(true);
	newCont = updateID(newCont,i);
	$('allTemplates').insert(newCont,{after: oldCont});
	newCont.style.display='';
	$('totalBlocks').value = i;
	if (i >= max)
	{
		$('addBlock').hide();
	}
	resetOrder();
}

function addImageBlock(max){
	var i = $('totalBlocks').value;
	i++;
	var oldCont = $('tplContainer_blank');
	var newCont = oldCont.cloneNode(true);
	newCont = updateID(newCont,i);
	$('allTemplates').insert(newCont,{after: oldCont});
	newCont.style.display='';
	$('totalBlocks').value = i;
	if (i >= max)
	{
		$('addBlock').hide();
	}
	resetOrder();
	chooseTemplate('0','Images','Y','N','Y',i);
	$('buttons_'+i).hide();
	enableImageFunctions(i);
}
function addSingleImageBlock(max){
	var i = $('totalBlocks').value;
	i++;
	var oldCont = $('tplContainer_blank');
	var newCont = oldCont.cloneNode(true);
	newCont = updateID(newCont,i);
	$('allTemplates').insert(newCont,{after: oldCont});
	newCont.style.display='';
	$('totalBlocks').value = i;
	if (i >= max)
	{
		$('addBlock').hide();
	}
	resetOrder();
	chooseTemplate('0','Images','N','N','Y',i);
	$('removeBlock'+i).hide();
	$('tplFunctions'+i).hide();
	$('buttons_'+i).hide();
	enableImageFunctions(i);
}

function enableImageFunctions(val){
	$('insertAbove'+val).onclick	= function(){insertImage(val,'top');};
	$('insertBelow'+val).onclick	= function(){insertImage(val,'bottom');};
}
function resetOrder(){
	var arr = $('tplContainer_blank').siblings();
	var i=0;
	arr.each(function(elm, num) {
			if (num>=1){
				i++;
				elm.down(0).value = i;
			}
		}
	); 
}
function swapBlock(node, dir){ 
	var thenode = $('tplContainer_'+node); 
	if (thenode){ 
		if (tinyMCE.get('tplText'+node)){
			tinyMCE.execCommand('mceFocus', false, 'tplText'+node);                    
			tinyMCE.execCommand('mceRemoveControl', false, 'tplText'+node);
		}
		var tp = thenode.parentNode;  
		if (dir == "up") {
			var insert = thenode.previous(0);
		} else {
			var insert = thenode.next(1);
		}
		thenode.remove(); 
		tp.insertBefore(thenode, insert); 
		tinyMCE.execCommand('mceAddControl', false, 'tplText'+(node));
		resetOrder();
	}
} 
function copyBlock(block,max) {
	var total = $('totalBlocks').value;
	if (total < max){
		total++; 
		hasMCE = false;
		var oldCont = $('tplContainer_'+block);
		if (tinyMCE.get('tplText'+block)){
			hasMCE = true;
			var curcontent = tinyMCE.get('tplText'+block).getContent();
			tinyMCE.execCommand('mceFocus', false, 'tplText'+block);                    
			tinyMCE.execCommand('mceRemoveControl', false, 'tplText'+block);
		}
		var newCont = oldCont.cloneNode(true);
		newCont = updateID(newCont,total,true,true);
		newCont.style.display='';
		$('allTemplates').insert(newCont,{after: oldCont});
		$('totalBlocks').value = total;
		tinyMCE.execCommand('mceAddControl', false, 'tplText'+total);
		tinyMCE.execCommand('mceAddControl', false, 'tplText'+block);
		if (total >= max) { 
			$('addBlock').hide();
		}
		resetOrder();
	}
}
function insertBlock(block,dir){
	var thenode = $('tplContainer_'+block); 
	var i = $('totalBlocks').value;
	i++;
	var oldCont = $('tplContainer_blank');
	var newCont = oldCont.cloneNode(true);
	newCont = updateID(newCont,i);
	if (thenode){ 
		var tp = thenode.parentNode;  
		if (dir == "top") {
			var insert = thenode;
		} else {
			var insert = thenode.next(0);
		}
		tp.insertBefore(newCont, insert); 
		newCont.style.display='';
		$('totalBlocks').value = i;
			//tinyMCE.execCommand('mceAddControl', false, 'tplText'+(node));
	resetOrder();
	}
}
function insertImage(block,dir){
	var thenode = $('tplContainer_'+block); 
	var i = $('totalBlocks').value;
	i++;
	var oldCont = $('tplContainer_blank');
	var newCont = oldCont.cloneNode(true);
	newCont = updateID(newCont,i);
	if (thenode){ 
		var tp = thenode.parentNode;  
		if (dir == "top") {
			var insert = thenode;
		} else {
			var insert = thenode.next(0);
		}
		tp.insertBefore(newCont, insert); 
		newCont.style.display='';
		$('totalBlocks').value = i;
		resetOrder();
		chooseTemplate('0','Images','Y','N','Y',i);
		enableImageFunctions(i);
	}
}
function updateID(newCont,i,visible,ignore){
	if (typeof(visible) == "undefined"){
		visible =false;
		//visible = true;
	} else {
		visible = true;
	}
	if (typeof(ignore) == "undefined"){
		ignore =false;
		//visible = true;
	} else {
		ignore = true;
	}
	newCont.id = 'tplContainer_'+i;
	newCont.down(0).id = 'volgnr'+i;
	newCont.down(0).name = 'volgnr'+i;
	newCont.down(0).value = i;
	newCont.down(1).id = 'tpl_'+i;
	newCont.down(1).name = 'tpl_'+i;
	newCont.down(2).id	= 'buttons_'+i;
	newCont.down(3).id = 'editBlock'+i;
	newCont.down(3).onclick = function(){openTemplates(i);};
	newCont.down(4).id = 'removeBlock'+i;
	newCont.down(4).onclick = function(){removeTemplate(i);};
	
	if (!visible && !ignore){
		newCont.down(4).style.display='none';
	}
	//tplTitle
	newCont.down(6).id = 'tplTitle'+i;
	newCont.down(6).name = 'tplTitle'+i;
	if (!visible && !ignore){
		newCont.down(6).style.display='none';
	}
	//tplText
	newCont.down(7).id = 'tplText'+i;
	newCont.down(7).name = 'tplText'+i;
	if (!visible && !ignore){
		newCont.down(7).style.display='none';
	}
	//imgs
	newCont.down(8).id = 'picContainer'+i;
	if (!visible && !ignore){
		newCont.down(8).style.display='none';
	}
	//editImage
	newCont.down(10).id = 'editImage'+i;
	newCont.down(10).onclick = function(){openAlbumWindow('normal',+i);};
	//deleteImage
	newCont.down(11).id = 'deleteImage'+i;
	newCont.down(11).onclick = function(){quickRemoveImage(i);};
	//currentIMG
	newCont.down(12).id = 'currentIMG'+i;
	//image hidden field
	newCont.down(14).id = 'image'+i;
	newCont.down(14).name = 'image'+i;
	newCont.down(15).id	= 'tplFunctions'+i;
	newCont.down(16).id = 'insertAbove'+i;
	newCont.down(16).onclick = function(){insertBlock(i,'top');};
	newCont.down(17).id = 'moveUp'+i;
	newCont.down(17).onclick = function(){swapBlock(i,'up');};
	newCont.down(18).id = 'moveDown'+i;
	newCont.down(18).onclick = function(){swapBlock(i,'down');};
	newCont.down(19).id = 'insertBelow'+i;
	newCont.down(19).onclick = function(){insertBlock(i,'bottom');};
	newCont.down(20).id = 'copyBlock'+i;
	newCont.down(20).onclick = function(){copyBlock(i,100);};
	if (!visible && !ignore){
		newCont.down(15).style.display='none';
	}
	return newCont;
}
function openTemplates(volgnr){
	var win = $('overlay');
	if (win)
	{
		openBack();
		win.style.display = '';
		win.innerHTML = '<div class="loading"><img src="'+ siteurl + 'img/layout/loader.gif" alt="Inhoud laden..." /><br/>'+ please_wait +'...</div>'; 
		// ajax aanroepen
		new Ajax.Request(siteurl+'includes/ajax/templates.php',   
			{     
				method:'get',     
				parameters: {loc:volgnr, layout: $('idLayout').value},
				onSuccess: function(transport){       
					var response = transport.responseText || error_string;       
					win.innerHTML = response;     
					$('ajaxContainer').style.top = (getScrollY()+80) + 'px';
				},    
				onFailure: function(){ 
					win.innerHTML = error_string;
				}   
			}
		);
	} else {
		alert(error_no_window + ' 4');
	}
}

function chooseTemplate(thetemplate,thename,hastitle,hastext,hasimage,loc){
	current = $('tplContainer_'+loc);
	edit	= $('editBlock'+loc);
	del		= $('removeBlock'+loc);
	img		= $('picContainer'+loc);
	title	= $('tplTitle'+loc);
	txt		= $('tplText'+loc);
	editimg = $('editImage'+loc);
	div		= $('tpl_'+loc);
	funcs	= $('tplFunctions'+loc);
	if (div && current && edit && img && editimg && del && txt && title && funcs){
		if (hastitle == "Y"){
			title.style.display = '';
		} else {
			title.style.display = 'none';
		}
		if (hastext == "Y"){
			txt.style.display = '';
			if (tinyMCE.get('tplText'+loc)){
				tinyMCE.execCommand('mceFocus', false, 'tplText'+loc);                    
				tinyMCE.execCommand('mceRemoveControl', false, 'tplText'+loc);
			}
			tinyMCE.execCommand('mceAddControl', false, 'tplText'+loc);
		} else {
			if (tinyMCE.get('tplText'+loc)){
				tinyMCE.execCommand('mceFocus', false, 'tplText'+loc);                    
				tinyMCE.execCommand('mceRemoveControl', false, 'tplText'+loc);
			}
			txt.style.display = 'none';
		}
		if (hasimage == "Y")
		{
			img.style.display= '';
			editimg.style.display = '';
		} else {
			img.style.display= 'none';	
		}
		div.value = thetemplate;
		del.style.display= '';
		funcs.style.display='';
		/*if (typeof(theclass) != "undefined"){
			closeWindow(theclass);
			edit.innerHTML = 'Wijzig contentblok';
		} else {
			edit.style.display='none';
			del.innerHTML= 'Wis afbeelding';
		}*/
		closeWindow();
	} else {
		alert("het element is op deze pagina niet aanwezig.");
	}
}
function removeTemplate(item){
	div		= $('tplContainer_'+item);
	volgnr	= $('volgnr'+item).value;
	// afvangen volgnr
	total	= $('totalBlocks').value;
	for (i=1;i<=total;i++)	{
		if ($('volgnr'+i)) {
			if ($('volgnr'+i).value > volgnr) {
				$('volgnr'+i).value = parseFloat($('volgnr'+i).value) - 1;
			}
		}
	}
	if (tinyMCE.get('tplText'+item)){
		tinyMCE.execCommand('mceFocus', false, 'tplText'+item);                    
		tinyMCE.execCommand('mceRemoveControl', false, 'tplText'+item);
	}
	div.parentNode.removeChild(div);
	item++;
	// alles hoger dan removeblock = huidig - 1;
	for (i=item;i<=(total);i++)	{
		// reset alle waarden -1;
		if ($('tplContainer_'+i)){
			sameCont = $('tplContainer_'+i);
			if (tinyMCE.get('tplText'+i)){
				tinyMCE.execCommand('mceFocus', false, 'tplText'+i);                    
				tinyMCE.execCommand('mceRemoveControl', false, 'tplText'+i);
			}
			sameCont = updateID(sameCont,(i-1),true);
			// --- tinyMCE toewijzen ---
			tinyMCE.execCommand('mceAddControl', false, 'tplText'+(i-1));
			// --- einde toewijzen tinyMCE ---
		}
	}
	resetOrder();
	// verwijder element.
	$('totalBlocks').value = (total-1);
}
function openLayout(){
	var win = $('overlay');
	if (win)
	{
		openBack();
		win.style.display = '';
		win.innerHTML = '<div class="loading"><img src="'+ siteurl + 'img/layout/loader.gif" alt="Inhoud laden..." /><br/>'+ please_wait +'...</div>'; 
		// ajax aanroepen
		new Ajax.Request(siteurl+'includes/ajax/layout.php',   
			{     
				method:'get',     
				onSuccess: function(transport){       
					var response = transport.responseText || error_string;       
					win.innerHTML = response;     
					$('ajaxContainer').style.top = (getScrollY()+80) + 'px';
				},    
				onFailure: function(){ 
					win.innerHTML = error_string;
				}   
			}
		);
	} else {
		alert(error_no_window + ' 4');
	}
}

function chooseLayout(thelayout,thename,theimage){
	lay		= $('idLayout');
	txt		= $('chosenLayout');
	all		= $('allTemplates');
	add		= $('addContent');
	if (lay && txt && add && all){
		txt.innerHTML = '<img src="' + siteurl + 'img/layout/'+theimage +'" alt="' + thename +'"/><strong>' + thename + '</strong>';
		lay.value = thelayout;
		all.style.display='';
		add.style.display='';
		closeWindow();
		if ($('totalBlocks').value == 0){
			addContentBlock();
		}
	} else {
		alert("het element is op deze pagina niet aanwezig.");
	}
}
function removeLayout(){
	div		= $('tplContainer_'+item);
	volgnr	= $('volgnr'+item).value;
	// afvangen volgnr
	total	= $('totalBlocks').value;
	for (i=1;i<=total;i++)	{
		if ($('volgnr'+i)) {
			if ($('volgnr'+i).value > volgnr) {
				$('volgnr'+i).value = parseFloat($('volgnr'+i).value) - 1;
			}
		}
	}
	if (tinyMCE.get('tplText'+item)){
		tinyMCE.execCommand('mceFocus', false, 'tplText'+item);                    
		tinyMCE.execCommand('mceRemoveControl', false, 'tplText'+item);
	}
	div.parentNode.removeChild(div);
	item++;
	// alles hoger dan removeblock = huidig - 1;
	for (i=item;i<=(total);i++)	{
		// reset alle waarden -1;
		if ($('tplContainer_'+i)){
			sameCont = $('tplContainer_'+i);
			if (tinyMCE.get('tplText'+i)){
				tinyMCE.execCommand('mceFocus', false, 'tplText'+i);                    
				tinyMCE.execCommand('mceRemoveControl', false, 'tplText'+i);
			}
			sameCont = updateID(sameCont,(i-1),true);
			// --- tinyMCE toewijzen ---
			tinyMCE.execCommand('mceAddControl', false, 'tplText'+(i-1));
			// --- einde toewijzen tinyMCE ---
		}
	}
	resetOrder();
	// verwijder element.
	$('totalBlocks').value = (total-1);
}
function removeImage(item){
	div		= $('tplContainer_'+item);
	volgnr	= $('volgnr'+item).value;
	// afvangen volgnr
	total	= $('totalBlocks').value;
	for (i=1;i<=total;i++)	{
		if ($('volgnr'+i)) {
			if ($('volgnr'+i).value > volgnr) {
				$('volgnr'+i).value = parseFloat($('volgnr'+i).value) - 1;
			}
		}
	}
	div.parentNode.removeChild(div);
	item++;
	// alles hoger dan removeblock = huidig - 1;
	for (i=item;i<=(total);i++)	{
		// reset alle waarden -1;
		if ($('tplContainer_'+i)){
			sameCont = $('tplContainer_'+i);
			sameCont = updateID(sameCont,(i-1),true);
			enableImageFunctions((i-1));
		}
	}
	resetOrder();
	// verwijder element.
	$('totalBlocks').value = (total-1);
}


function closeNotice(){
	$('notice').hide();
}
function showNotice(thenotice,num){
	if (typeof(num) == "undefined"){
		num = "0";
	}
	var win = $('overlay');
	if (win)
	{
		openBack();
		win.style.display = '';
		win.innerHTML = '<div class="loading"><img src="'+ siteurl + 'img/layout/loader.gif" alt="Inhoud laden..." /><br/>'+ please_wait +'</div>'; 
		// ajax aanroepen
		new Ajax.Request(siteurl+'includes/ajax/notice.php',   
			{     
				method:'get',     
				parameters: {notice: thenotice , thedoc: num},
				onSuccess: function(transport){       
					var response = transport.responseText || error_string;       
					win.innerHTML = response;     
					$('ajaxContainer').style.top = (getScrollY()+80) + 'px';
				},    
				onFailure: function(){ 
					win.innerHTML = error_string;
				}   
			}
		);
	} else {
		alert(error_no_window + ' 9');
	}
}
function chooseImage (imgid,imgurl,imgname,picnum){
	var theclass = 'templateWindow';
	div		= $('image'+picnum);
	current = $('currentIMG'+picnum);
	edit	= $('editImage'+picnum);
	del		= $('deleteImage'+picnum);
	if (div && current && edit && del){
		div.value = imgid;
		current.innerHTML= "<img src=\""+ imgurl + "\" alt=\""+ imgname +"\" /><br/>"+ imgname;
		current.style.display = '';
		edit.innerHTML = change_image;
		del.style.display= '';
		closeWindow();
	} else {
		if (div){ alert("div ok");}
		if (current){ alert("current ok");}
		if (edit){ alert("edit ok");}
		if (del){ alert("del ok");}
		alert(error_string + " 5");
	}
}
function toggleAll(num){
	if (!$('alles').checked){
		var value = false;
	} else {
		var value = true;
	}
	for (i=1;i<=num;i++){
		if (!$('acc'+i).disabled) {
			$('acc'+i).checked=value;
		}	
	}
}
function togglePages(type){
	arrElm = document.getElementsByName('pages[]');
	for(i=0;i<=(arrElm.length-1);i++){
		arrElm[i].checked=type;
	}
}
function checkEmail(str){
	var testresults = false;
	//uitleg filter: minimaal 1 letter voor @ ; min 1 max 66 letters na @ ; min 2 max 6 letters na punt.
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)){
		testresults=true;
	}else{
		testresults=false;
	}
	return (testresults);
}	
function aanmeldSubmit(){ // Voor nieuwsbrief aanmeldform naar MuskitoMail
	tel=0;
	if (document.getElementById("last_name").value =='') {				
		tel++;		
		document.getElementById("last_name").className = 'txtInputWrong';
	} else	{ 
		document.getElementById("last_name").className = 'txtInput';
	}
	if (document.getElementById("email").value =='' || !checkEmail(document.getElementById("email").value)) {
		tel++;		
		document.getElementById("email").className = 'txtInputWrong';		
	} else	{ 
		document.getElementById("email").className = 'txtInput';
	}
	if(tel==0){
		return true;
	} else {
		return false;
	}	
}

//-------------SEARCH----------------------------

function startSearch(){
		var link	= $('#group').val() + '/';
		link		+= $('#subgroup').val() + '/';
		if($('input:checkbox[name="sexe[]"]:checked').length>0){
			$('input:checkbox[name="sexe[]"]:checked').each(function(index) { 
				if (index == 0)
				{
				link += $(this).val();
				return true;
				}
				link += ',' + $(this).val() ;
			});
			link += '/';
		} else {
			link += 'm-v/';
		}
		if($('input:checkbox[name="brand[]"]:checked').length>0){
			$('input:checkbox[name="brand[]"]:checked').each(function(index) { 
				if (index == 0)
				{
				link += $(this).val();
				return true;
				}
				link += ',' + $(this).val() ;
			});
			link += '/';
		} else {
			link += 'alle-merken/';
		}
		if($('input:checkbox[name="size[]"]:checked').length>0){
			$('input:checkbox[name="size[]"]:checked').each(function(index) { 
				if (index == 0)
				{
				link += $(this).val();
				return true;
				}
				link += ',' + $(this).val() ;
			});
			link += '/';
		} else {
			link += 'alle-maten/';
		}
		if($('input:checkbox[name="price[]"]:checked').length>0){
			$('input:checkbox[name="price[]"]:checked').each(function(index) { 
				if (index == 0)
				{
				link += $(this).val();
				return true;
				}
				link += ',' + $(this).val() ;
			});
			link += '/';
		} else {
			link += 'alle-prijzen/';
		}	
		document.location.href= siteurl + 'producten/' 
		+ link 
		+ $('#sortorder').val() + '/'
		+ $('#perpage').val() + '/'
		+ $('#curpage').val() + '/';
}

function checkInput(input, was, wordt){
	if(input.value==was){
		input.value=wordt;
	}
}
function checkCallBack(){
	tel=0;
	if (document.getElementById("naam").value =='' || document.getElementById("naam").value == 'Naam') {				
		tel++;		
		document.getElementById("naam").className = 'txtInputWrong';
	} else	{ 
		document.getElementById("naam").className = 'txtInput';
	}
	if (document.getElementById("telefoonnummer").value =='' || document.getElementById("telefoonnummer").value == 'Telefoonnummer') {				
		tel++;		
		document.getElementById("telefoonnummer").className = 'txtInputWrong';
	} else	{ 
		document.getElementById("telefoonnummer").className = 'txtInput';
	}
	if (document.getElementById("opmerkingen").value =='' || document.getElementById("opmerkingen").value =='Vragen of opmerkingen') {				
		tel++;		
		document.getElementById("opmerkingen").className = 'txtAreaWrong';
	} else	{ 
		document.getElementById("opmerkingen").className = 'txtArea';
	}
	if(tel==0){					
		return true;
	} else {
		return false;
	}	
}

function checkContactForm(){
	tel=0;
	if (document.getElementById("naam").value =='') {				
		tel++;		
		document.getElementById("naam").className = 'txtInput wrong';
	} else	{ 
		document.getElementById("naam").className = 'txtInput';
	}
	if (document.getElementById("email").value =='' || !checkEmail(document.getElementById("email").value)) {
		tel++;		
		document.getElementById("email").className = 'txtInput wrong';		
	} else	{ 
		document.getElementById("email").className = 'txtInput';
	}
	if (document.getElementById("onderwerp").value =='') {				
		tel++;		
		document.getElementById("onderwerp").className = 'txtInput wrong';
	} else	{ 
		document.getElementById("onderwerp").className = 'txtInput';
	}
	if (document.getElementById("opmerking").value =='') {				
		tel++;		
		document.getElementById("opmerking").className = 'txtArea wrong';
	} else	{ 
		document.getElementById("opmerking").className = 'txtArea';
	}
	if(tel==0){					
		return true;
	} else {
		document.getElementById("formMelding").innerHTML = '<b>* Vul aub. alle verplichte velden in [' + tel + ']</b>';
		return false;
	}	
}
