var CampaignWebsite=new Class({Implements:[Options,Events],options:{site:{positioning:{horizontal:'center',vertical:'center',offset:{x:0,y:0}},size:{x:900,y:580}},popup:{positioning:{offset:{x:0,y:0}},size:{x:500,y:400}},error_popup:{positioning:{offset:{x:0,y:0}},size:{x:300,y:210}},loading:{positioning:{offset:{x:0,y:0}},size:{x:400,y:300}},links:{dynamic:true,target:'content'},forms:{dynamic:true,target:'content'},pngFix:{bgElements:''}},bodySize:[],initialize:function(options,framework){this.setOptions(options);this.positionSite();window.addEvent('resize',function(){this.positionSite();this.positionPopup()}.bind(this));if(this.options.site.backgroundImage)this.setSiteBackground();if(this.options.links.dynamic)this.dynamicLinks();if(this.options.forms.dynamic)this.dynamicForms();if(this.options.site.contentEl)this.setContentScroll();this.createPopup();this.popupLinks();this.supBrowser=(Browser.Engine.trident&&!Browser.Engine.trident5&&document.body.filters)?true:false;if(this.supBrowser){new Asset.javascript('javascript/pngfix.js');this.pngFix=new pngFix({cssBgElements:[this.options.pngFix.bgElements]})}},setBodySize:function(){this.bodySize.x=document.body.clientWidth;this.bodySize.y=document.body.clientHeight},positionSite:function(){this.setBodySize();$('site').setStyle('position','relative');$('site').setStyle('width',this.options.site.size.x);$('site').setStyle('height',this.options.site.size.y);if(this.options.site.positioning.vertical=='center')$('site').setStyle('top',(this.bodySize.y-this.options.site.size.y)/2+this.options.site.positioning.offset.y);else if(this.options.site.positioning.vertical=='top')$('site').setStyle('top',0+this.options.site.positioning.offset.y);else if(this.options.site.positioning.vertical=='bottom')$('site').setStyle('top',this.bodySize.y-this.options.site.size.y-this.options.site.positioning.offset.y);if(this.options.site.positioning.horizontal=='center')$('site').setStyle('left',(this.bodySize.x-this.options.site.size.x)/2+this.options.site.positioning.offset.x);else if(this.options.site.positioning.horizontal=='left')$('site').setStyle('left',0+this.options.site.positioning.offset.x);else if(this.options.site.positioning.vertical=='right')$('site').setStyle('left',this.bodySize.x-this.options.site.size.x-this.options.site.positioning.offset.x)},setSiteBackground:function(){},setContentScroll:function(){if($(this.options.site.contentEl)){}},createPopup:function(){new Element('div',{id:'popup',style:'z-index: 20000; background: url('+this.options.popup.backgroundImage+')'}).injectTop('body');new Element('div',{id:'inner_popup',style:'position: absolute; z-index: 30000;'}).injectBottom('popup');new Element('div',{id:'close_popup',style:'position: absolute; z-index: 40000; top: 0px; right: 0px;'}).injectBottom('popup');$('close_popup').addEvent('click',function(){this.hidePopup()}.bind(this));new Element('div',{id:'mask',style:'z-index: 1500; display: none'}).injectTop('body');$('mask').addEvent('click',function(){this.hidePopup()}.bind(this));this.positionPopup();this.hidePopup()},setPopupBackground:function(){},positionPopup:function(){this.setBodySize();$('popup').setStyle('position','absolute');$('popup').setStyle('width',this.options.popup.size.x);$('popup').setStyle('height',this.options.popup.size.y);$('popup').setStyle('top',(this.bodySize.y-this.options.popup.size.y)/2+this.options.popup.positioning.offset.y);$('popup').setStyle('left',(this.bodySize.x-this.options.popup.size.x)/2+this.options.popup.positioning.offset.x);$('mask').setStyle('position','absolute');$('mask').setStyle('width',this.bodySize.x);$('mask').setStyle('height',this.bodySize.x);$('mask').setStyle('top',0);$('mask').setStyle('left',0)},showPopup:function(){$('mask').setStyle('display','block');$('popup').setStyle('display','block')},hidePopup:function(){$('mask').setStyle('display','none');$('popup').setStyle('display','none')},dynamicLinks:function(){if(this.options.links.dynamic){$$('a').each(function(link){if(link.get('target')!='_blank'&&link.get('rel')!='popup'&&link.get('rel')!='normal'){var target=this.options.links.target;var req=new Request.HTML({evalScripts:false,evalResponse:false,url:link.get('href'),onComplete:function(responseTree,responseElements,responseHTML,responseJavaScript){$(this.options.links.target).set('html',responseHTML);$exec(responseJavaScript);this.dynamicLinks();this.dynamicForms();this.popupLinks();if(this.supBrowser)this.pngFix.initialize({cssBgElements:[this.options.pngFix.bgElements]})}.bind(this)});link.removeEvents('click');link.addEvent('click',function(e){e.stop();req.send()})}}.bind(this))}},popupLinks:function(){$$('a[rel=popup]').each(function(link){var req=new Request.HTML({evalScripts:false,evalResponse:false,url:link.get('href'),onComplete:function(responseTree,responseElements,responseHTML,responseJavaScript){$('inner_popup').set('html',responseHTML);this.showPopup();this.dynamicLinks();this.popupLinks();this.dynamicForms();if(this.supBrowser)this.pngFix.initialize({cssBgElements:[this.options.pngFix.bgElements]});$exec(responseJavaScript)}.bind(this)});link.removeEvents('click');link.addEvent('click',function(e){e.stop();req.send()})}.bind(this));$$('a[rel=popup2]').each(function(link){var req=new Request.HTML({evalScripts:false,evalResponse:false,url:link.get('href'),onComplete:function(responseTree,responseElements,responseHTML,responseJavaScript){$('inner_popup2').set('html',responseHTML);this.showPopup2();this.dynamicLinks();this.popupLinks();this.dynamicForms();if(this.supBrowser)this.pngFix.initialize({cssBgElements:[this.options.pngFix.bgElements]});$exec(responseJavaScript)}.bind(this)});link.removeEvents('click');link.addEvent('click',function(e){e.stop();req.send()})}.bind(this))},dynamicForms:function(){if(this.options.links.dynamic){$$('form').each(function(form){var target=this.options.forms.target;var req=new Request.HTML({evalScripts:false,evalResponse:false,url:'?',onComplete:function(responseTree,responseElements,responseHTML,responseJavaScript){$exec(responseJavaScript);$(this.options.forms.target).set('html',responseHTML);this.dynamicLinks();this.dynamicForms();this.popupLinks();if(afterSubmit=form.get('aftersubmit')){eval(afterSubmit+'()')}}.bind(this)});form.removeEvents('submit');form.addEvent('submit',function(e){e.stop();if(beforeSubmit=form.get('beforesubmit')){if(eval(beforeSubmit+'()')){req.post(form)}}else req.post(form)})}.bind(this))}},positionLoading:function(){this.setBodySize();$('loading').setStyle('position','absolute');$('loading').setStyle('width',this.options.loading.size.x);$('loading').setStyle('height',this.options.loading.size.y);$('loading').setStyle('top',(this.bodySize.y-this.options.loading.size.y)/2+this.options.loading.positioning.offset.y);$('loading').setStyle('left',(this.bodySize.x-this.options.loading.size.x)/2+this.options.loading.positioning.offset.x);$('loading_mask').setStyle('position','absolute');$('loading_mask').setStyle('width',this.bodySize.x);$('loading_mask').setStyle('height',this.bodySize.x);$('loading_mask').setStyle('top',0);$('loading_mask').setStyle('left',0);$('loading_mask').setStyle('z-index',30000);$('loading').setStyle('z-index',30001)},showLoading:function(){$('loading_mask').setStyle('display','block');$('loading').setStyle('display','block')},hideLoading:function(){$('loading_mask').setStyle('display','none');$('loading').setStyle('display','none')},formErrors:function(errors){var errorMsg='Niet alle velden zijn juist ingevuld:'+"\r\n\r\n";errors.each(function(error){errorMsg+='- '+error+"\r\n"});alert(errorMsg)},checkEmail:function(email){var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;if(filter.test(email))return true;else return false},checkPostcode:function(postcode){postcode=postcode.toUpperCase().split(' ').join('');var filter=/^[1-9]{1}[0-9]{3}[A-Z]{2}$/;if(filter.test(postcode))return true;else return false},checkNumeric:function(value){if(isNaN(value))return false;else return true}});window.addEvent('domready',function(){website=new CampaignWebsite({site:{positioning:{horizontal:'center',vertical:'center',offset:{x:0,y:20}},size:{x:1025,y:567},backgroundImage:'graphics/site_bg2.png',contentEl:'content'},popup:{size:{x:600,y:400},backgroundImage:'graphics/popup.png'},links:{dynamic:true,target:'content'},forms:{dynamic:true,target:'content'}})});function check(){var errors=new Array();if(!$('firstname').value.trim())errors.include('Vul je voornaam in');if(!$('lastname').value.trim())errors.include('Vul je achternaam in');if(!$('street').value.trim())errors.include('Vul je straat in');if(!$('number').value.trim()||!website.checkNumeric($('number').value.trim()))errors.include('Vul je huisnummer in (zonder toevoeging)');if(!website.checkPostcode($('zipcode').value.trim()))errors.include('Vul je postcode in (1234AA)');if(!$('city').value.trim())errors.include('Vul je woonplaats in');if($('email').value.trim()){if(!website.checkEmail($('email').value.trim()))errors.include('Vul een geldig e-mail adres in')}if(!$('hazelnut').checked&&!$('caramel').checked)errors.include('Kies tenminste 1 smaak');if(errors.length>0){website.formErrors(errors);return false}else{return true}}
