function setPointer(theRow, thePointerColor) {
  //  alert(theRow.style);
  if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
    return false;
  }
  
  if (typeof(document.getElementsByTagName) != 'undefined') {
    var theCells = theRow.getElementsByTagName('td');
    //        alert("ok");
    
  }
  else if (typeof(theRow.cells) != 'undefined') {
    var theCells = theRow.cells;
  }
  else {
    return false;
  }
  
  var rowCellsCnt  = theCells.length;
  
  //enkel laatste cel  
  if ( theCells[rowCellsCnt-1].className != 'tdmainnav1active' ) {
    theCells[rowCellsCnt-1].style.backgroundColor = thePointerColor;
  }
  
  return true;
} // end of the 'setPointer()' function



function setPointerCell(theCell, image, actclass) {

  /*
  if (thePointerColor == '' || typeof(theCell.style) == 'undefined') {
    return false;
  }
  */
  var imgsrc;


  if( theCell.className != actclass ){
	  if ( image!="")
	      theCell.style.backgroundImage='url(content/themes/img/subnav_bg_selection_over.gif)';	
	  else	
	      theCell.style.backgroundImage='';	
	
  }
  
  return true;
} // end of the 'setPointer()' function

function postform(formname){

	if ( formname=='frm_mailfriend' ){
		var mailfrom=document.frm_mailfriend.uwemail.value;
		var mailto=document.frm_mailfriend.vriendemail.value;

		MM_validateForm('uwemail','','RisEmail','vriendemail','','RisEmail');

		if ( document.MM_returnValue ) {	
			window.location.href = window.location.href+"&pagefrom="+mailfrom+"&pageto="+mailto;	
		}else{ 
			document.MM_returnValue = false;
		}
	}
	else if ( formname=='frm_login' ){
  
  		var errors = ""
	        errors += validateEmail ( document.frm_login.useremail );
    
	    if ( errors != '' ) {
	      alert ( errors );
	    }
	    else{	
		document.frm_login.submit();
	    }

	
       }
	
	if( formname=='frm_pw' ){ //frm_pw
  
	    	var errors = ""
	
	if ( document.frm_pw.pwnew1.value != document.frm_pw.pwnew2.value ){
		errors+="Gekozen paswoord moet 2 maal hetzelfde zijn";
	}
    
	    if ( errors != '' ) {
	      alert ( errors )
	    }
	    else{	
		document.frm_pw.submit();
	    }
       }
	
}

function removeValue ( el, initVal ) {
  if ( el.value == initVal) {
    el.value = "";
    el.style.color = "black";
  }

}

function setValue ( el, initVal ) {
  if ( el.value == "" ) {
    el.value = initVal ;
    el.style.color = "gray";
  }

}


// MM functions
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } 
      else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function validateEmail(field) {
  
  var errors = "";
  email = field.value;
  
  
  
  var a = email.lastIndexOf('@');
  var b = email.lastIndexOf('.');
  var c = email.indexOf(':');
  var d = email.indexOf('/');
  var e = email.substring(0,a);
  var f = e.indexOf('@');
  var g = email.substring(a+1,email.length);
  var h = g.indexOf('[');
  var  i = g.indexOf(']');
  var j = g.indexOf('&lt;');
  var k = g.indexOf('&gt;');
  var l = email.substring(a+1,b);
  var m = email.substring(b+1,email.length);
  var n = email.substring(0,a);
  var o = 0;
  
  if (a > b) {o++};
  if (c != -1) {o++};
  if (d != -1) {o++};
  if (f != -1) {o++};
  if (h != -1) {o++};
  if (i != -1) {o++};
  if (j != -1) {o++};
  if (k != -1) {o++};
  if (l.length < 3) {o++};
  if (m.length < 2) {o++};
  if (n.length < 1) {o++};
  
  if (o == 0) {
      
  }
  else  {
    errors+='- '+field.name+' must contain an e-mail address.\n';
  }
  

    return errors;



}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function toggle_comp(){
	
	var bool_unempl;
	var bg_col;
	var stat_checked;

	for (var i=0;i < document.forms['mtiform'].billing_address.length;i++){
        	if ( document.forms['mtiform'].billing_address[i].checked ){
			stat_checked=document.forms['mtiform'].billing_address[i].value;
		}
	}

	if(stat_checked=="company" ){ // werd net aangecheckt
	 bool_iscomp=true;	
	 bool_ispriv=false;	
	bg_col="#CCCCCC";
	bg_col_priv="white";
	}
	else{
	 bool_iscomp=false;			
	 bool_ispriv=true;			
	bg_col="white"	;
	bg_col_priv="#CCCCCC";	
	}	

	arr_priv = new Array("street_nr", "zip", "city", "tel", "fax","country","testje");
	arr_comp = new Array("company", "division", "street_nr2", "zip2", "city2", "tel2", "fax2", "url2","country2","BTW-number");

	for (var i=0; i<arr_priv.length; i++){

	   if ( typeof document.forms['mtiform'][arr_priv[i]] != 'undefined'){
		document.forms['mtiform'][arr_priv[i]].disabled = bool_iscomp;	
		document.forms['mtiform'][arr_priv[i]].style.backgroundColor = bg_col;	
	   }
	}

	for (var i=0; i<arr_comp.length; i++){
	   if ( typeof document.forms['mtiform'][arr_comp[i]] != 'undefined'){
		document.forms['mtiform'][arr_comp[i]].disabled = bool_ispriv;	
		document.forms['mtiform'][arr_comp[i]].style.backgroundColor = bg_col_priv;	
        }
	}


}

	var prev;
	var max_width ;

	function set_preview_width (){
	
		
		
			if ( prev.width > max_width ) {
				
				prev.width = max_width	
				
			}	
	}

	function set_preview (el){
		
		 prev = window.document.frmMain.preview;
		 max_width = window.document.frmMain.max_width.value;
		
		 prev.src = el.value;
		
		 setTimeout ("set_preview_width()",1000)	
		
//		alert(window.document.frmMain.preview.height);
		
		
		
	}
	
	function modify_checkboxes (el) {
		checkboxes = window.document.frmMain["groups[]"];
		
		for (i=0;i<checkboxes.length;i++) {
			checkboxes[i].checked = false;
		}
		
		if (el.checked) {
		}
	}
	
	function modify_first_checkbox (el) {
		
			
		checkboxes = window.document.frmMain["groups[]"];
		
		checkboxes[0].checked = true;
	
	}
	
	function enable_radio (el) {
		checkboxes = window.document.frmMain["groups[]"];
		
		if (el.checked)	 {
			window.document.frmMain.toegankelijk[1].checked = true;
		}
		
		var all_unchecked = true;
		for (i=0;i<checkboxes.length;i++) {
			
			if (checkboxes[i].checked == true) {
					all_unchecked = false;
			}
			
		}
		
		if (all_unchecked) {
			window.document.frmMain.toegankelijk[0].checked = true;
		}
		
	}
	