	/**
 * Download counter
 */

var radioPlayerWindow="undefined";
var videoPlayerWindow="undefined";

function dc(sender) {
  if (sender.href) {
    var img=new Image;
    img.src="/plugins/modules/xstats/downloadcounter.php?doc="+sender.href+"&rnd="+Math.random();
  }
}

function videoPlayer(url,title) {
  videoPlayerWindow=window.open("/videoplayer.php?fragment="+url+"&title="+title,'popup_videoplayer','width=600,height=480,scrollbars=no,status=no,menubar=no,location=no,resizable=yes,titlebar=no');
  videoPlayerWindow.focus();
}	

function audioPlayer(url,title) {
	radioPlayerWindow=window.open("/audioplayer.php?fragment="+url+"&title="+title,'popup_audioplayer','width=280,height=70,scrollbars=no,status=no,menubar=no,location=no,resizable=no,titlebar=no');
  radioPlayerWindow.focus();
}

/**
 * Printerdeprint...
 */
function printContent() {
  var w=window.open('/print.html','printer_window','width=640,height=500,toolbar=0,resizable=1,scrollbars=1');
  w.focus();
}

function getPrinterContent()
{
  // get all 'printblok' divs and concatenate them into a large, serialized string
  divs = document.getElementsByTagName("div");
  var s = "";
  for ( i=0; i<divs.length; i++ ) {
	if(divs[i].getAttribute("id") == "printblok") {
		s += divs[i].innerHTML + "<br/><br/>";
	}
  }
  return s;
}

/**
 * Doorsturen 
 */
function stuurDoor(p) {
	var v="";
	var w=window.open("/stuur_door"+v+"?p="+p,'stuurdoor_window','width=564, height=525, scrollbars=auto');
	w.focus();
}

function submitForm(formname) {
  var f=document.forms[formname];
 	if (validateForm(f)) {
    f.submit();
  }  
}

/* FAQ - VRAAG & ANTWOORD */

function groupShow(groep) {
	hideOtherGroups("groep"+groep);
	currgroep=groep;

	//toggle clicked div
	var div_vragen=document.getElementById("groep"+groep);
	div_vragen.style.display=(div_vragen.style.display=='none')?div_vragen.style.display='block':div_vragen.style.display='none';
}

function hideOtherGroups(groep) {
	divs=document.getElementsByTagName("div");
	for (var i=0; i<divs.length; i++) {
	  if (divs[i].id!=groep && divs[i].id.substr(0, 5)=="groep" && divs[i].style.display!="none") {
	  	divs[i].style.display="none";
		}
	}
}

/* TOGGLE - Divs aan een uitzetten*/
function toggleDiv(divid) {
	if (document.getElementById(divid).style.display=='block') {
		hideDiv(divid);
	}
	else {
		showDiv(divid);
	}
}

function showDiv(divid) {
	if (document.layers) document.layers[divid].display='block';
	else document.getElementById(divid).style.display='block';
}

function hideDiv(divid) {
	if (document.layers) document.layers[divid].display='none';
	else document.getElementById(divid).style.display='none';
}


/** 
 * Shop
 */
function checkAantal(frm) {
	
	var f=document.forms[frm];	
	var val=parseInt(f.aantal.value);
  var max=f.maxaantal.value;  
  
  /* max=0 betekent géén limiet */
  
  if(parseInt(max)==0) { 
  	f.submit();
  	return false;
  }
  
  if (f.maximum && parseInt(f.maximum.value)>0) {
  	max=parseInt(f.maximum.value);
  }
  
  var re=new RegExp("^[0-9]+$");
  if (re.test(val)) {
  	if (val==0) {
  		return false;
  	} else if (val>max) {
  		f.aantal.value=max;
  		alert("Let op: U kunt van dit product maximaal "+max+" items bestellen.");
  		return false;
  	} else {
  		 f.submit();
  	}
  }
	return false;
}

function removeItem(productCode) {
	var f=document.forms.mainform;
	f.cmd.value="remove_from_cart";
	f.params.value=productCode;
	f.submit();
}

function emptyCart() {
	if (confirm("Weet u zeker dat u alle producten uit uw winkelmandje wilt verwijderen?")) {
		var f=document.forms.mainform;
		f.cmd.value="empty_cart";
		f.submit();
	}
}

function recalcCart() {
	var f=document.forms.mainform;
	f.cmd.value="recalc_cart";
	f.submit();
}

function checkMaximumAantal(boxje) {
	var maxaantal=parseInt(boxje.getAttribute('maxaantal'));
	var aantal=parseInt(boxje.value);
	if (maxaantal>0 && aantal>maxaantal) {
		boxje.value=maxaantal;
		alert("Let op: u kunt van dit product maximaal "+maxaantal+" stuks bestellen.");
	}
}

function bestellen() {
	var f=document.forms.mainform;
	if (f.nproducten.value > 0) {
		f.cmd.value="goto_yourdata";
		f.submit();
	} else {
		alert("U heeft geen producten in uw winkelmand.");
	}
}

function plaatsBestelling() {
	var f=document.forms.mainform;
	if (f.nproducten.value > 0) {
		f.cmd.value="place_order";
		f.submit();
	} else {
		alert("U heeft geen producten in uw winkelmand.");
	}
}

function naarWinkelmand(){
	document.forms.add2chart.submit();
}

