ZLTool={};
ZLTool.get=$get=$zlget=function(id)
{
if(typeof(id)=="string")return document.getElementById(id);
return id;
}
ZLTool.show=$show=function(id)
{
var blocks={'DIV':'block','TABLE':'block','P':'block','TD':'block','TR':'block','BODY':'block'};
id=$zlget(id);
id.style.display=blocks[id.tagName]?blocks[id.tagName]:'inline';
}
ZLTool.hide=$hide=function(id)
{
$zlget(id).style.display='none';
}
ZLTool.display=$display=function(id,doShow)
{
if(doShow)$show(id);
else $hide(id);
}
ZLTool.style=$style=function(id)
{
return $get(id).style;
}
ZLTool.isShown=isShown=function(id)
{
return!(!$zlget(id).style.display||$zlget(id).style.display=='none');
}
ZLTool.handle=function(elm,eventName,func)
{
if(eventName instanceof Array)
{
for(var i=0;i<eventName.length;i++)ZLTool.handle(elm,eventName[i],func);
return func;
}
elm=$get(elm);
if(elm.attachEvent)elm.attachEvent('on'+eventName,func);
else elm.addEventListener(eventName,func,false);
return func;
}
Date.prototype.setFullYearOriginal=Date.prototype.setFullYear;
ZLTool.getKey=function(e)
{
if(window.event)
{
return window.event.keyCode;
}
else if(e.which)
{
return e.which;
}else if(e.keyCode)
{
return e.keyCode;
}
return-1;
}
ZLTool.isEnterKeyEntered=function(e)
{
var keynum=ZLTool.getKey(e);
return keynum==13;
}
ZLTool.isNumberEntered=function(e)
{
var keynum=ZLTool.getKey(e);
return(keynum>=48&&keynum<=57)
||(keynum>=96&&keynum<=105);
}
ZLTool.isAlphanumericEntered=function(e)
{
var keynum=ZLTool.getKey(e);
return(keynum>=48&&keynum<=57)
||(keynum>=96&&keynum<=96+26)
||(keynum>=65&&keynum<=65+26);
}
ZLTool.blurOnEnterKeyUp=function(id,e)
{
if(ZLTool.isEnterKeyEntered(e))$get(id).blur();
}
ZLTool.nicifyNumber=function(id)
{
$get(id).value=ZLTool.toNiceNumber(ZLTool.toNumber($get(id).value));
}
ZLTool.toNumber=function(str)
{
str=str.toString();
str=str.replace(/\./g,"");
if(str.indexOf(',')>=0)str=str.substring(0,str.indexOf(','));
return str-0;
}
ZLTool.toNiceNumber=function(n)
{
n=Math.round(n).toString();
var s="";
for(var i=n.length-1,j=0;i>=0;i--,j++)
{
if((j%3)==0&&j>0)s="."+s;
s=n.charAt(i)+s;
}
return s;
}
ZLTool.toPercentage=function(n,totaal,aantalCijfersAchterDeKomma)
{
var perc=100;
if(isNaN(n))return;
if(isNaN(totaal))return;
if(typeof(aantalCijfersAchterDeKomma)!='undefined'&&isNaN(aantalCijfersAchterDeKomma))return;
perc=(n/totaal)*100;
if(typeof(aantalCijfersAchterDeKomma)!='undefined')
{
aantalCijfersAchterDeKomma=ZLTool.toNumber(aantalCijfersAchterDeKomma);
switch(aantalCijfersAchterDeKomma)
{
case 0:
return(Math.round(perc));
break;
case 1:
return(Math.round(perc*10)/10);
break;
case 2:
return(Math.round(perc*100)/100);
break;
case 3:
return(Math.round(perc*1000)/1000);
break;
default:
return(Math.round(perc));
break;
}
}
else
{
return(Math.round(perc));
}
}
ZLTool.padZero=function(n,length)
{
n=n+'';
while(n.length<length)n='0'+n;
return n;
}
ZLTool.selectText=function(id)
{
$zlget(id).select();
$zlget(id).focus();
}
ZLTool.default_blur=function(elm)
{
var defaulText=elm.getAttribute('defaultText');
if(elm.value=='')
{
elm.value=defaulText;
}
}
ZLTool.default_focus=function(elm)
{
var defaultText=elm.getAttribute('defaultText');
if(elm.value==defaultText)
{
elm.value='';
}
}
ZLTool.cancelBubble=function(e)
{
if(!e)e=window.event;
e.cancelBubble=true;
if(e.stopPropagation)e.stopPropagation();
}
ZLTool.isDateValid=function(date,month,year)
{
var d=new Date();
d.setFullYearOriginal(year,month-1,date);
return d.getDate()==date
&&(d.getMonth()+1)==month
&&d.getFullYear()==year;
}
ZLTool.isDateValidByID=function(dateID,monthID,yearID)
{
return ZLTool.isDateValid($get(dateID).value-0,
month=$get(monthID).value-0,
year=$get(yearID).value-0);
}
ZLTool.VAM_isDateValid=function(cond)
{
var inp=cond.IDToEval
var b=false;
ZLTool.toFullYear(inp+'_3')
var dd=$get(inp+'_1').value;
var mm=$get(inp+'_2').value;
var jjjj=$get(inp+'_3').value;
b=ZLTool.isDateValid(dd,mm,jjjj);
ZLTool.toFullDayOrMonth(inp+'_1');
ZLTool.toFullDayOrMonth(inp+'_2');
return b?1:0;
}
ZLTool.VAM_isNewDateValid=function(cond)
{
var inp=cond.IDToEval
var b=false;
ZLTool.toFullYear(inp+'_3')
var dd=$get(inp+'_1').value;
var mm=$get(inp+'_2').value;
var jjjj=$get(inp+'_3').value;
var startDate=new Date();
var currentDate=new Date();
b=ZLTool.isDateValid(dd,mm,jjjj);
ZLTool.toFullDayOrMonth(inp+'_1');
ZLTool.toFullDayOrMonth(inp+'_2');
return b?1:0;
}
ZLTool.VAM_isValidTelefoonNummer=function(cond)
{
var b=false;
if(!$get(cond.IDToEval))return-1;
b=ZLTool.isValidTelefoonNummer($get(cond.IDToEval))
return b?1:0;
}
ZLTool.isValidTelefoonNummer=function(obj)
{
sValue=obj.value.replace(/-/g,"");
sValue=obj.value.replace(/ /g,"");
sName=obj.name;
document.forms[0][sName].value=sValue;
var phoneRE=/^[0]{1}[1-9\-]{1}[0-9\-]{8}$/;
if(sValue.match(phoneRE)){
var phoneRE0=/^[0]{1}[1-9]{1}[0]{8}$/;
var phoneRE1=/^[0]{1}[1]{9}$/;
var phoneRE2=/^[0]{1}[2]{9}$/;
var phoneRE3=/^[0]{1}[3]{9}$/;
var phoneRE4=/^[0]{1}[4]{9}$/;
var phoneRE5=/^[0]{1}[5]{9}$/;
var phoneRE6=/^[0]{1}[6]{9}$/;
var phoneRE7=/^[0]{1}[7]{9}$/;
var phoneRE8=/^[0]{1}[8]{9}$/;
var phoneRE9=/^[0]{1}[9]{9}$/;
for(r=0;r<10;r++){
if(sValue.match(eval("phoneRE"+r))){
return false;
}
}
return true;
}else{
return false;
}
}
ZLTool.VAM_isValidBurgerServiceNummer=function(cond)
{
var b=false;
if(!$get(cond.IDToEval))return-1;
b=ZLTool.isValidBurgerServiceNummer($get(cond.IDToEval))
return b?1:0;
}
ZLTool.isValidBurgerServiceNummer=function(obj)
{
var reSofi=/(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)/;
var bValid=false;var array;var lSom=0;
var val=obj.value;
if(!((val.length==0)||(val==null))){
if(obj.value.length==8){
val="0"+val;
}
bValid=(reSofi.test(val));
}else{
return false;
}
if(bValid){
array=(val.match(reSofi));
for(i=1;i<9;i+=1){
lSom+=(array[i]*(9-(i-1)));
}
bValid=(((lSom-=array[9])%11)==0)
}
return(bValid);
}
ZLTool.selectNextIfComplete=function(fromID,toID,length,e)
{
if(e&&!ZLTool.isAlphanumericEntered(e))return;
if($zlget(fromID).value.length>=length)
{
setTimeout(function(){ZLTool.selectText($zlget(toID));},50);
}
}
ZLTool.toFullYear=function(id,expectFutureDate)
{
var n=ZLTool.getFullYear(id,expectFutureDate);
if(isNaN(n))return;
$get(id).value=n;
}
ZLTool.toFullDayOrMonth=function(id)
{
var n=$get(id).value;
if(isNaN(n))return;
if(n.length==1)n="0"+n;
$get(id).value=n;
}
ZLTool.getFullYear=function(id,expectFutureDate)
{
var v=$zlget(id).value;
if(v==='')return NaN;
var n=v-0;
if(isNaN(n))return NaN;
if(n<100)n+=expectFutureDate?2000:1900;
return n;
}
ZLTool.createDate=function(year,month,day)
{
var d=new Date();
d.setFullYear(year);
d.setMonth(month,day);
return d;
}
ZLTool.copyDate=function(date)
{
return ZLTool.createDate(date.getFullYear(),date.getMonth(),date.getDay());
}
ZLTool.calcAantalMaanden=function(date1,date2)
{
var aantalMaanden=0;
aantalMaanden=12*(date2.getFullYear()-date1.getFullYear());
aantalMaanden-=date1.getMonth()-date2.getMonth();
if(date2.getDate()<date1.getDate())
{
aantalMaanden--;
}
return aantalMaanden;
}
ZLTool.addMaanden=function(date,maanden)
{
var addOneYear=(maanden%12)+date.getMonth()>=12;
date.setFullYear(date.getFullYear()+(maanden/12)+(addOneYear?1:0));
date.setMonth(date.getMonth()+(maanden%12)+(addOneYear?-12:0));
}
ZLTool.isNullDate=function(date)
{
return!date
||(date.getDate()==1
&&date.getMonth()<=1
&&date.getFullYear()<=1901);
}
ZLTool.querystring=function(key,defaultValue)
{
var q=document.location.search;
if(q.charAt(0)=='?')q=q.substring(1);
var ps=q.split('&');
for(var i=0;i<ps.length;i++)
{
var kv=ps[i].split('=');
if(kv.length<2)continue;
if(kv[0]==key)return ps[i].substring(ps[i].indexOf('=')+1);
}
return defaultValue?defaultValue:null;
}
ZLTool.isLocal=function()
{
return document.location.hostname=='nl'||document.location.hostname=='nest'
||document.location.hostname=='nlnew';
}
ZLTool.initRadioQuestion=function(radioGroup,whichForm)
{
if(whichForm!=""&&whichForm!=null)
{
rGroup=document.forms[whichForm][radioGroup];
}
else
{
rGroup=document.forms[0][radioGroup];
}
for(var c=0;c<rGroup.length;c++)
{
rGroup[c].checked=false;
}
}
ZLTool.getSelectedRadioValue=function(radioGroup,whichForm)
{
if(whichForm!=""&&whichForm!=null)
{
radioGroup=document.forms[whichForm][radioGroup];
}
else
{
radioGroup=document.forms[0][radioGroup];
}
for(var c=0;c<radioGroup.length;c++)
{
if(radioGroup[c].checked){
return radioGroup[c].value;
}
}
}
ZLTool.getSelectedRadioIndex=function(radioGroup,whichForm)
{
if(whichForm!=""&&whichForm!=null)
{
radioGroup=document.forms[whichForm][radioGroup];
}
else
{
radioGroup=document.forms[0][radioGroup];
}
for(var c=0;c<radioGroup.length;c++)
{
if(radioGroup[c].checked){
return c;
}
}
return-1;
}
ZLTool.setSelectedRadioIndex=function(radioGroup,selectedIndex,whichForm)
{
if(whichForm!=""&&whichForm!=null)
{
radioGroup=document.forms[whichForm][radioGroup];
}
else
{
radioGroup=document.forms[0][radioGroup];
}
radioGroup[selectedIndex].checked=true;
}
ZLTool.isValidEmail=function(email,isEmptyAllowed)
{
if(isEmptyAllowed&&email==="")return true;
return email.length>=4
&&email.indexOf('@')>0
&&email.indexOf('.',email.indexOf('@'))>0
&&email.indexOf('.')<email.length-1;
}
ZLTool.isValidTelefoon=function(telefoon,isEmptyAllowed)
{
if(isEmptyAllowed&&telefoon==="")return true;
telefoon=telefoon.replace(/[\-\s_]/g,'');
if(telefoon.length!=10)return false;
telefoon=telefoon.replace(/\d/g,'');
return telefoon==="";
}
ZLTool.addNewHtmlObject=function(definitionObject,id,variables,insertBeforeObject,doAppend)
{
var newObject=document.createElement(definitionObject.tagName);
var html=definitionObject.innerHTML;
for(var v in variables)
{
var regexp=new RegExp("\\$"+v+"\\$",["g"]);
html=html.replace(regexp,variables[v]);
}
newObject.innerHTML=html;
newObject.id=id;
newObject.className=definitionObject.className;
if(!insertBeforeObject)insertBeforeObject=definitionObject;
if(doAppend)
{
insertBeforeObject.appendChild(newObject);
}
else
{
insertBeforeObject.parentNode.insertBefore(newObject,insertBeforeObject);
}
return newObject;
}
ZLTool.removeHtmlObject=function(object)
{
object.parentNode.removeChild(object);
}
ZLTool.moveHtmlObject=function(id,newLocationID)
{
var newLocation=$get(newLocationID);
var moveObj=$get(id);
ZLTool.removeHtmlObject(moveObj);
newLocation.parentNode.insertBefore(moveObj,newLocation);
}
ZLTool.addToUrl=function(url,queryToAdd)
{
if(url.indexOf('?')>=0)
{
if(!url.endsWith('&'))url+='&';
}
else url+='?';
return url+queryToAdd;
}
ZLTool.getSelectedOption=function(selectID)
{
var select=$get(selectID);
if(select.selectedIndex<0)return null;
return select.options[select.selectedIndex];
}
ZLTool.setSelectedOption=function(selectID,value)
{
var select=$get(selectID);
for(var i=0;i<select.options.length;i++)
{
var opt=select[i];
if(opt.value==value)
{
select.selectedIndex=i;
return true;
}
}
return false;
}
ZLTool.memberwiseClone=function(object)
{
var newObject={};
for(var e in object)newObject[e]=object[e];
return newObject;
}
ZLTool.absolutePosition=function(id)
{
var x=0,y=0;
var elm=$zlget(id);
while(elm!=null){
x+=elm.offsetLeft;
y+=elm.offsetTop;
elm=elm.offsetParent;
}
return{x:x,y:y};
}
ZLTool.clientWidth=function(){
return ZLTool._filterResults(
window.innerWidth?window.innerWidth:0,
document.documentElement?document.documentElement.clientWidth:0,
document.body?document.body.clientWidth:0
);
}
ZLTool.clientHeight=function(wind){
var doc=wind?wind.document:document;
if(!wind)wind=window;
return ZLTool._filterResults(
wind.innerHeight?wind.innerHeight:0,
doc.documentElement?doc.documentElement.clientHeight:0,
doc.body?doc.body.clientHeight:0
);
}
ZLTool.scrollLeft=function(){
return ZLTool._filterResults(
window.pageXOffset?window.pageXOffset:0,
document.documentElement?document.documentElement.scrollLeft:0,
document.body?document.body.scrollLeft:0
);
}
ZLTool.scrollTop=function(wind){
var doc=wind?wind.document:document;
if(!wind)wind=window;
return ZLTool._filterResults(
wind.pageYOffset?wind.pageYOffset:0,
doc.documentElement?doc.documentElement.scrollTop:0,
doc.body?doc.body.scrollTop:0
);
}
ZLTool._filterResults=function(n_win,n_docel,n_body){
var n_result=n_win?n_win:0;
if(n_docel&&(!n_result||(n_result>n_docel)))
n_result=n_docel;
return n_body&&(!n_result||(n_result>n_body))?n_body:n_result;
}
ZLTool.write=function(text)
{
document.write(text);
}
ZLTool.loadScript=function(src)
{
var script=document.createElement('script');
script.src=src;
script.language='javascript';
document.getElementsByTagName('head')[0].appendChild(script);
}
ZLTool.jsonp=function(url,continueFunction)
{
var cfName='ZLTool_jsonp_'+ZLTool.jsonp.i++;
url=url.replace('{jsonp}',cfName);
window[cfName]=function()
{
window[cfName]=null;
if(continueFunction)continueFunction.apply(null,arguments);
}
ZLTool.loadScript(url);
}
ZLTool.jsonp.i=0;
ZLTool.getCookie=function(c_name)
{
if(document.cookie.length>0)
{
var c_start=document.cookie.indexOf(c_name+"=")
if(c_start!=-1)
{
c_start=c_start+c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if(c_end==-1)c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))
}
}
return""
}
ZLTool.setCookie=function(name,value,expDays,expSeconds,doSecureIfLive)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expDays);
if(expSeconds)exdate.setTime(exdate.getTime()+(expSeconds*1000));
document.cookie=name+"="+value+";expires="+exdate+";path=/"
+(document.location.hostname.indexOf('.zwitserleven.nl')<0?'':';domain=.zwitserleven.nl')
+(doSecureIfLive&&!ZLTool.isLocal()?';secure':'');
}
ZLTool.isSecure=function()
{
return window.location.protocol=='https:'
}
ZLTool.gotoBelForm=function(type,onderwerp,opmerking,
voorletters,tussenvoegsels,achternaam,isMan,telefoon,email,postcode,plaats,geboortedag,geboortemaand,geboortejaar)
{
var exdate=new Date();
exdate.setTime(exdate.getTime()+(45*1000));
document.cookie='zl_belform_opmerking'+"="+escape(opmerking)+";expires="+exdate+";path=/"
+(ZLTool.isSecure()?";secure":"");
var info='';
if(voorletters)info+='&voorletters='+escape(voorletters);
if(tussenvoegsels)info+='&tussenvoegsels='+escape(tussenvoegsels);
if(achternaam)info+='&achternaam='+escape(achternaam);
if(telefoon)info+='&telefoon='+escape(telefoon);
if(email)info+='&email='+escape(email);
if(postcode)info+='&postcode='+escape(postcode);
if(plaats)info+='&plaats='+escape(plaats);
if(geboortedag)info+='&geboortedag='+geboortedag;
if(geboortemaand)info+='&geboortemaand='+geboortemaand;
if(geboortejaar)info+='&geboortejaar='+geboortejaar;
if(typeof(isMan)=='boolean')info+='&isMan='+isMan;
if(info)
{
document.cookie='zl_belform_info'+"="+info.substring(1)+";expires="+exdate+";path=/"
+(ZLTool.isSecure()?";secure":"");
}
if(type=='webshop'||!type)
{
window.top.document.location='/webshop/laat_ons_u_bellen?soort='+escape(onderwerp)+'&zl_hb=1';
}
}
ZLTool.addEvent=function(oTarget,sType,fpDest)
{
var oOldEvent=oTarget[sType];
if(typeof oOldEvent!="function"){
oTarget[sType]=fpDest;
}else{
oTarget[sType]=function(e){
oOldEvent(e);
fpDest(e);
}
}
}
ZLTool.toHTMLSave=function(str)
{
return str?str.replace(/\</gi,"&lt;"):'';
}
ZLTool.setOpacity=function(id,percent)
{
var elm=$zlget(id);
elm.style.filter='alpha(opacity='+percent+')';
elm.style['-moz-opacity']=percent/100;
elm.style.opacity=percent/100;
}
ZLTool.doDarkenBackground=function(elementToShow,maxOpacity,backgroundColor,continueFunction)
{
var elm=ZLTool.doDarkenBackground.element;
elementToShow=$zlget(elementToShow);
ZLTool.doDarkenBackground.elementToShow=elementToShow;
if(!elm)
{
ZLTool.doDarkenBackground.element=elm=document.createElement('div');
elm.style.zIndex=9999;
elm.style.width='100%';
elm.style.height='100%';
elm.style.background=backgroundColor?backgroundColor:'#eee';
elm.style.position='absolute';
elm.style.display='none';
elm.style.top='0px';
elm.style.left='0px';
var body=document.getElementsByTagName('body')[0];
if(!body.childNodes.length)body.appendChild(elm);
else body.insertBefore(elm,body.childNodes[0]);
}
elementToShow.style.zIndex=elm.style.zIndex+1;
var isIE6=/msie|MSIE 6/.test(navigator.userAgent);
if(isIE6)
{
elm.style.height=(ZLTool.scrollTop()+Math.max(screen.height,ZLTool.clientHeight()))+'px';
elm.style.width=(ZLTool.scrollLeft()+Math.min(screen.width,ZLTool.clientWidth()))+'px';
}
elementToShow.style.position='absolute';
elementToShow.style.top=ZLTool.scrollTop()
+Math.round((ZLTool.clientHeight()-elementToShow.offsetHeight)/2)+'px';
elementToShow.style.left=ZLTool.scrollLeft()
+Math.round((ZLTool.clientWidth()-elementToShow.offsetWidth)/2)+'px';
ZLTool.setOpacity(elm,0);
$show(elm);
if(!maxOpacity)maxOpacity=80;
var count=0;
elm.opacity=0;
var interval=setInterval(function()
{
if(count++>100)return;
elm.opacity=Math.min(elm.opacity+15,maxOpacity);
ZLTool.setOpacity(elm,elm.opacity);
if(elm.opacity>=maxOpacity)
{
clearInterval(interval);
if(continueFunction)continueFunction();
}
},20);
}
ZLTool.hideDarkendBackground=function()
{
var elm=ZLTool.doDarkenBackground.element;
if(elm)$hide(elm);
var elementToShow=ZLTool.doDarkenBackground.elementToShow;
if(elementToShow)$hide(elementToShow);
}
ZLTool.setText=function(idOrElm,text)
{
var elm=$zlget(idOrElm);
if(document.all)elm.innerText=text;
else elm.textContent=text;
}