var FitState=new Class({Implements:[Events,Options],options:{element:'background',center:true,minWidth:1024,minHeight:768,primary:'auto',sizeElement:window,time:8000,transPeriod:3000,transition:'linear',load:function(){},change:function(){},complete:function(){}},initialize:function(images,options){options=options||{};options.primary=options.primary&&['width','height','auto'].contains(options.primary)?options.primary:'auto';this.setOptions(options);this.resize=this.resize.bind(this);this.animate=this.animate.bind(this);if($(this.options.element)){if(images.length>0){var object=this;this.slides=[];this.current=0;var loader=new Asset.images(images,{properties:{styles:{opacity:0,position:'absolute',width:'100%',zIndex:1}},onComplete:function(e){var src=$(object.options.element).getElements('img')[0].get('src');$(object.options.element).empty();loader.each(function(obj,i){if(src==obj.get('src')){object.current=i;}
object.slides.push({element:obj.inject(object.options.element).erase('height'),fx:new Fx.Tween(obj,{duration:object.options.transPeriod,transition:object.options.transition,property:'opacity',onComplete:function(e,a){object.animating=false;object.options.complete(obj);}})});});object.slides[object.current].element.setStyles({opacity:1,zIndex:2});if(loader.length>1){object.starttimer=object.animate.delay(object.options.time);}
object.options.load();}});}}
this.attach();},attach:function(){window.addEvents({'load':this.resize,'resize':this.resize});},detach:function(){window.removeEvents({'load':this.resize,'resize':this.resize});},resize:function(){$(this.options.element).setStyle('visibility','visible');if(this.options.sizeElement==window){var size=document.id(this.options.sizeElement).getSize(),rate=size.x/size.y,styles={};if(!this.size){if($(this.options.element)){this.size={};this.size.x=$(this.options.element).get('data-width');this.size.y=$(this.options.element).get('data-height');this.rate=this.size.x/this.size.y;}else{return this;}}
if(this.options.primary=='width'||(this.options.primary=='auto'&&this.rate<rate)){styles.width=size.x;styles.height=null;}else if(this.options.primary=='height'||(this.options.primary=='auto'&&this.rate>rate)){styles.width=null;styles.height=size.y;}else{styles.width=size.x;styles.height=size.y;}
if(styles.width!==null&&this.options.minWidth>styles.width)styles.width=this.options.minWidth;if(styles.height!==null&&this.options.minHeight>styles.height)styles.height=this.options.minHeight;if(styles.width===null)styles.width=Math.round(styles.height*this.size.x/this.size.y);if(styles.height===null)styles.height=Math.round(styles.width*this.size.y/this.size.x);if(this.options.center){if(styles.width>size.x)styles.left=0-Math.round((styles.width-size.x)/2);else if(styles.width<size.x)styles.left=Math.round((size.x-styles.width)/2);else styles.left=0;if(styles.height>size.y)styles.top=0-Math.round((styles.height-size.y)/2);else if(styles.height<size.y)styles.top=Math.round((size.y-styles.height)/2);else styles.top=0;}
$(this.options.element).setStyles(styles);return this;}else{var img=$(this.options.sizeElement).getElements('img')[0];if(img){var size=$(img).getSize();$(this.options.sizeElement).setStyle('height',size.y);}}},animate:function(override){this.animating=true;this.slides[this.current].element.setStyle('zIndex',2);this.slides[this.current].fx.start(0);if(override!=undefined){override=parseInt(override);this.current=(this.slides[override]?override:0);}else{++this.current;this.current=(this.slides[this.current]?this.current:0);}
this.slides[this.current].element.setStyle('zIndex',1);this.slides[this.current].fx.start(1);this.options.change(this.current);if(!this.timer){this.timer=this.animate.periodical(this.options.time+this.options.transPeriod);}}});window.addEvent('domready',function(){if(Browser.Platform.ios){$('background').set('data-height',920);$('wrapper').addClass('ios');}
if(Browser.Platform.android){$('wrapper').addClass('android');}
if(Browser.Platform.win){$('wrapper').addClass('win');}
myScroll=new Fx.SmoothScroll({duration:400},window);$$('a[rel="external"], a.external').set('target','_blank');$$('a.email').each(function(el){el.set('href','mailto:'+el.get('data-email').replace('|','@').replace('/',''));});new FitState('images/bg.jpg',{primary:((Browser.Platform.ios)||(Browser.Platform.android))?'height':'auto',minWidth:0,minHeight:1080});var test=new Element('input');if(!("placeholder"in test)){$$('input[placeholder], textarea[placeholder]').each(function(el){new OverText(el,{textOverride:el.get('placeholder')});});}
if($('cform')){var form=new Form.Validator.Inline($('cform'),{serial:false,useTitles:true,onFormValidate:function(passed,form,event){if($('resetvalue').get('value')==0){if(!passed){if($('agree')){if($('agree').hasClass('validation-failed')){$$('label[for="agree"]').addClass('validation-failed');}}}}}});$('reset').addEvent('click',function(e){$('cform').getElements('input, select, textarea').set('data-validators','');$('resetvalue').set('value',1);$('cform').set('action',$('cform').get('data-action')+'#verification');});if($('agree')){$('agree').addEvent('click',function(e){if($(this).get('checked')){$$('label[for="agree"]').removeClass('validation-failed');}else{$$('label[for="agree"]').addClass('validation-failed');}});}}
siteInit();});window.addEvent('load',siteInit);window.addEvent('resize',siteInit);function siteInit(){if($('internal-wrapper')){$('wrapper').setStyle('min-height','100%');$('internal-wrapper').setStyle('height','auto');var wrapHeight=$('wrapper').getComputedSize().totalHeight;var internalHeight=($('internal-wrapper').getComputedSize().totalHeight)+40;if(internalHeight>wrapHeight){$('wrapper').setStyle('min-height',internalHeight+35);$('internal-wrapper').setStyle('height',internalHeight-60);}else{$('internal-wrapper').setStyle('height',wrapHeight-95);}}}