function showHide(id,methode) {
	document.getElementById(id).style.display = methode;
}

function base64_decode(data) {
	// kevin.vanzonneveld.net
	// http://tools.ietf.org/html/rfc4648    
	    
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i=0, enc='';

	    do {  // unpack four hexets into three octets using index points in b64
        h1 = b64.indexOf(data.charAt(i++));
        h2 = b64.indexOf(data.charAt(i++));
        h3 = b64.indexOf(data.charAt(i++));
        h4 = b64.indexOf(data.charAt(i++));
        
        bits = h1<<18 | h2<<12 | h3<<6 | h4;
        
        o1 = bits>>16 & 0xff;
        o2 = bits>>8 & 0xff;
        o3 = bits & 0xff;
        
        if (h3 == 64)      enc += String.fromCharCode(o1);
        else if (h4 == 64) enc += String.fromCharCode(o1, o2);
        else               enc += String.fromCharCode(o1, o2, o3);
    } while (i < data.length);
    
    return enc;
}
	
function base64_encode(data) {
    // kevin.vanzonneveld.net
    // http://tools.ietf.org/html/rfc4648
    
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i=0, enc='';
        
    do {  // pack three octets into four hexets
        o1 = data.charCodeAt(i++);
        o2 = data.charCodeAt(i++);
        o3 = data.charCodeAt(i++);
        
        bits = o1<<16 | o2<<8 | o3;
        
        h1 = bits>>18 & 0x3f;
        h2 = bits>>12 & 0x3f;
        h3 = bits>>6 & 0x3f;
        h4 = bits & 0x3f;
        
        // end of string? index to '=' in b64
        if (isNaN(o3)) h4 = 64;
        if (isNaN(o2)) h3 = 64;
        
        // use hexets to index into b64, and append result to encoded string
        enc += b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
    } while (i < data.length);
    
    return enc;
}
function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	  return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	  return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	   return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
	   return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
	   return false
	}
	
	if (str.indexOf(" ")!=-1){
	   return false
	}

	return true					
}

function SetCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

function verstuurmij() {
		var n = document.getElementById('nb_naam').value;
		var e = document.getElementById('nb_email').value;

	if ((e == null)||(e == "")){
		alert("U moet een e-mailadres opgeven.")
	} else {
		if (echeck(e) == false){
			alert("U moet een geldig e-mailadres opgeven.")
		} else {
			var submitvalue = base64_encode(n+'|'+e);
			SetCookie('SaBra_nieuwsbrief',submitvalue,'365');
			self.location.href = 'index.php?action=nieuwsbrief&id=' + submitvalue;
		}
	}
}

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
  if (document.getElementById){
    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=document.getElementById(args[i]);
      if (val) { nm=args[i+1]; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' moet een geldig e-mailadres zijn.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' moet een getal zijn.\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+' moet een getal zijn tussen '+min+' en '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is verplicht.\n'; }
    } if (errors) alert('De volgende fouten zijn opgetreden:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function newPC() {
		document.getElementById('routeinvoer').style.display = 'block';
		document.getElementById('opnieuw').style.display = 'none';

}
function checkPC() {
	var pc = document.getElementById('fromPC').value;
	if (/ /.test(pc) ) {
		document.getElementById('fromPC').value= pc.replace(/ /, "");
	}
}
