// Print functie (haalt bepaalde TD uit de maintable en gooit deze in een popup)
	function printPage(aantal,tdeen,tdtwee,tddrie) {
	
		//niet printen in admindeel
		if (/\/admin\//.test(document.location)) {
			alert('Printen is niet mogelijk binnen de PageProcessor admin omgeving');
			return false;
		}
		
		if (document.getElementById(tdeen))
			var print1 = document.getElementById(tdeen).innerHTML;
		if (document.getElementById(tdtwee))
			var print2 = document.getElementById(tdtwee).innerHTML;
		if (document.getElementById(tddrie))
			var print3 = document.getElementById(tddrie).innerHTML;
		
		if (aantal ==  1)
			window.printgedeelte = '<table><tr><td>'+print1+'</td></tr></table>';
		else if (aantal == 2)  
			window.printgedeelte = '<table><tr><td>'+print1+'</td><td>'+print2+'</td></tr></table>';
		else
			window.printgedeelte = '<table><tr><td>'+print1+'</td><td>'+print2+'</td><td>'+print3+'</td></tr></table>';

		//disable de links om bladeren via printversie te voorkomen
		window.printgedeelte = window.printgedeelte.replace(/href/gi,"hrefdisabled");
		window.printgedeelte = window.printgedeelte.replace(/onclick/gi,"onclickdisabled");

	 
		//open popup en vul deze 
		var w = window.open('/print.html');
	}


//functies voor productzoeken
function toon_geenafbeelding(img) {
	if (img.src)
		img.src = '/images/dot_clear.gif';
}

function search(actie) {
	if (actie !== 'getSubrubrieken' && actie !== 'getZoektermen') {
		if (document.zoekproduct.keyword.value == '- Zoekterm -' || document.zoekproduct.keyword.value == '- Keyword -')
			actie = 'zoekenGroep';
		else
			actie = 'zoekenOnderwerp';
	} 
	document.zoekproduct.actie.value = actie;
	if (validateZoekForm() == true)
		document.zoekproduct.submit();
	else
		return false;
}
function validateZoekForm() {
	if (document.zoekproduct.actie.value !== 'getSubrubrieken' && document.zoekproduct.actie.value !== 'getZoektermen') {
		var groep = document.zoekproduct.groep_fk.value;
		var onderwerp = document.zoekproduct.onderwerp.value;
		var keyword = document.zoekproduct.keyword.value;
		
		if (onderwerp !== 'all' && (keyword == '' || keyword == '- Zoekterm -' || keyword == '- Keyword -')) {
			alert('Vul een geldige zoekterm in a.u.b.');
			return false;
		} else if (keyword == '') { 
			alert('Vul een geldige zoekterm in a.u.b.');
			return false;
		} else if (onderwerp == 'all' && keyword !== '' && keyword !== '- Zoekterm -' && keyword !== '- Keyword -') {
			alert('Kies een onderwerp a.u.b.');
			return false;
		} else if (onderwerp == 'all' && groep == 'all') {
			alert('Kies een productgroep a.u.b.');
			return false;
		} else
			return true;
	} else
		return true;
}
function changeTR(e) {
	e = e || window.event;
	var el = e.srcElement?e.srcElement:e.target;
	var actie = e.type;
	var tr = el.parentNode;
	var tds = tr.getElementsByTagName("td");
	for (var i = 0; i < tds.length; i++) {
		var mytd = tds[i];
		if (actie == 'mouseover') {
			changeTR.oldcolor = mytd.style.backgroundColor;
			mytd.style.background = '#A7D8F6';
		} else {
			if (mytd.style.background)
				mytd.style.background = changeTR.oldcolor;
		}
	}
}
function zdisplayDetails(id,e) {
	//als op infoknopje is geklikt, verder niets doen
	var e = e || window.event; 
	var sourceobj = e.target || e.srcElement; 
	if (sourceobj && sourceobj.className == 'info')
		return false;

	document.zoekproductdetails.productid.value = id;
	document.zoekproductdetails.submit();
}
function chooseSchets(soort,groepid) {
	if (soort == 'groep') {
		document.zoekproduct.groep_fk.onchange = '';
		document.zoekproduct.groep_fk.value = groepid;
		document.zoekproduct.actie.value = 'zoekenGroep';
	} else {
		document.zoekproduct.subgroep_fk.onchange = '';
		document.zoekproduct.subgroep_fk.value = groepid;
		document.zoekproduct.actie.value = 'zoekenGroep';
	}
	document.zoekproduct.submit();
}

//popup voor modules binnen admin
top.window.popupProductmodule = function () {
	popupModules('producten');
}
top.window.popupDownloads = function () {
	popupModules('downloads');
}

function popupModules(modulenaam) {
	var filename="/admin/modules/"+modulenaam+"/index.php";
	var fileid="Producten";
	var width="650";
	var height="580";
	var scrollbars="no";
	var resizable="no";
	var menubar="no";
	var toolbar="no";
	var status="no";
	var location="no";
	var popupscherm=0;
	var args = "height=" + height + ", width=" + width + ", scrollbars=" + scrollbars + ", resizable=" + resizable +  ", menubar=" + menubar + ", toolbar=" +toolbar + ", status=" + status + " ,location=" + location;
	popupscherm = top.window.open(filename, fileid, args);
}
function toon_afbeelding_leeg(afbeelding){
	afbeelding.onerror = '';
	afbeelding.src='/images/dot_clear.gif'
}

//Functies voor online shop
function popup(url) {
	var filename="/"+url;
	var fileid="1";
	var width="500";
	var height="480";
	var scrollbars="no";
	var resizable="no";
	var menubar="no";
	var toolbar="no";
	var status="no";
	var location="no";
	var popupscherm=0;
	var args = "height=" + height + ", width=" + width + ", scrollbars=" + scrollbars + ", resizable=" + resizable +  ", menubar=" + menubar + ", toolbar=" +toolbar + ", status=" + status + " ,location=" + location;
	popupscherm = top.window.open(filename, fileid, args);
}

//streep de rijen van een tabel
 function hasClass(obj) {
    var result = false;
    if (obj.getAttributeNode("class") != null) {
        result = obj.getAttributeNode("class").value;
    }
    return result;
 }   

function stripe(id) {
  // the flag we'll use to keep track of 
  // whether the current row is odd or even
  var even = false;

  // if arguments are provided to specify the colours
  // of the even & odd rows, then use the them;
  // otherwise use the following defaults:
  var evenColor = arguments[1] ? arguments[1] : "#fff";
  var oddColor = arguments[2] ? arguments[2] : "#E0F1FB";

  // obtain a reference to the desired table
  // if no such table exists, abort
  var table = document.getElementById(id);
  if (! table) { return; }
  

  // by definition, tables can have more than one tbody
  // element, so we'll have to get the list of child
  // &lt;tbody&gt;s 
  var tbodies = table.getElementsByTagName("tbody");

  // and iterate through them...
  for (var h = 0; h < tbodies.length; h++) {
  
   // find all the &lt;tr&gt; elements... 
    var trs = tbodies[h].getElementsByTagName("tr");
    
    // ... and iterate through them
    for (var i = 0; i < trs.length; i++) {

      // avoid rows that have a class attribute
      // or backgroundColor style
      if (! hasClass(trs[i]) &&
          ! trs[i].style.backgroundColor) {
		  
		  	if (table.allowclick !== 'true') {
				trs[i].style.cursor = 'pointer';
				trs[i].onmouseover = changeTR;
				trs[i].onmouseout = changeTR;
			}
	  
        // get all the cells in this row...
        var tds = trs[i].getElementsByTagName("td");
      
        // and iterate through them...
        for (var j = 0; j < tds.length; j++) {
      
          var mytd = tds[j];

          // avoid cells that have a class attribute
          // or backgroundColor style
          if (! hasClass(mytd) &&
              ! mytd.style.backgroundColor) {
      
            mytd.style.backgroundColor =
              even ? evenColor : oddColor;
          
          }
        }
      }
      // flip from odd to even, or vice-versa
      even =  ! even;
    }
  }
}
