(function($){$.fn.inflatesViewport=function(){var inflateAmount=$(window).height()-$("body").height(),$this=$(this),$inflateElement;if(inflateAmount>0){$this=$(this);$inflateElement=($this.length>1)?$this.first():$this;$inflateElement.height($inflateElement.height()+inflateAmount);}return $this;};$.fn.disableSelection=function(){return this.each(function(){$(this).attr("unselectable","on").css({"-moz-user-select":"none","-webkit-user-select":"none","user-select":"none"}).each(function(){this.onselectstart=function(){return false;};});});};})(jQuery);function isValidEmail(email,allowEmpty,checkHost){var emailReg=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,allowEmpty=allowEmpty||false,checkHost=(typeof checkHost=="undefined")?true:checkHost,hostActive;if(email==""&&allowEmpty){return 1;}else{if(email==""){return 0;}}if(!emailReg.test(email)){return 0;}else{$.ajax({async:false,url:yii.path.checkEmail,type:"GET",data:{email:email},cache:false,timeout:10000,error:function(){return -1;},success:function(msg){var msg=(isNaN(+msg))?false:+msg;hostActive=(msg)?true:false;}});return hostActive;}}function initContactForm(){function showResponse(title,msg,icon){$.ajax({url:yii.path.getServerResponseHtml,type:"GET",data:{title:title,icon:icon,body:msg},cache:false,timeout:20000,error:function(){$.fn.colorbox({html:"<div class='serverError'>"+serverTimeout+"</div>",open:true,onLoad:function(){$("#cboxClose").show();}});},success:function(msg){$.fn.colorbox({html:msg,open:true,onLoad:function(){$("#cboxClose").hide();$("input").keypress(function(e){if(e.keyCode==13){$.colorbox.close();return false;}});},onComplete:function(){$("#ok_btn").click(function(){$.colorbox.close();});},onClosed:function(){$("input").unbind("keypress");}});}});}function onSubmitForm(formData,jqForm){var form=jqForm[0],errors=false,errorMsg="";$.fn.colorbox({html:"<div class='colorboxLoading'>&nbsp;</div>",initialWidth:175,initialHeight:75,scolling:false,open:true,onLoad:function(){$("#cboxLoadingGraphic").show();$("#cboxClose").hide();}});if(form.msg.value==""){errorMsg+="&bull; "+yii.i18n.response.enterMessage+"<br />";errors=true;}if(form.fromEmail.value&&!isValidEmail(form.fromEmail.value)){errorMsg+="&bull; "+yii.i18n.response.badEmail+"<br />";errors=true;}if(errors){showResponse(yii.i18n.response.errorTitle,errorMsg,yii.icons.error);}return(errors)?false:true;}function onServerResponse(response){var response=$.parseJSON(response);if(response.success){$("#contactForm").resetForm();}showResponse(response.title,response.msg,response.icon);}$("#contactForm").ajaxForm({beforeSubmit:onSubmitForm,success:onServerResponse});}function initColorboxContact(){var transitionSpeed=250,serverTimeout=20000,formId="colorboxContact",formPageId="colorboxContactWrapper",responsePageId="colorboxResponse";formPageWrapperId="formPagesWrapper";var initialized=false,formPages={form:false,response:false},formPagesWrapper=$("<div/>",{id:formPageWrapperId,"class":"hide"}).appendTo("body"),colorboxContactWrapper,colorboxContactResponseTemplate;function showResponse(title,msg,icon,returnToForm){var icon=(typeof icon=="undefined")?"email.png":icon,returnToForm=(typeof returnToForm=="undefined")?true:returnToForm,responseText=colorboxContactResponseTemplate,response=$("#"+responsePageId);responseText=responseText.replace("{title}",title);responseText=responseText.replace("{body}",msg);responseText=responseText.replace("{icon}",icon);if(!response.length){response=$("<div/>",{id:responsePageId}).appendTo(formPagesWrapper);}response.html(responseText);$.colorbox({open:true,href:("#"+responsePageId),inline:true,onLoad:function(){$("#cboxClose").hide();$("input").keypress(function(e){if(e.keyCode==13){$.colorbox.close();return false;}});},onComplete:function(){$("#cboxLoadingGraphic").hide();$("#ok_btn").click(function(){if(returnToForm){$("#cboxClose").show();$.fn.colorbox({open:true,href:("#"+formPageId),inline:true});}else{$.colorbox.close();}});},onCleanup:function(){$("input").unbind("keypress");$("#ok_btn").unbind("click");}});}function onSubmitForm(formData,jqForm){var form=jqForm[0],errors=false,errorMsg="";$("#cboxLoadingGraphic").show();if(form.msg.value==""){errorMsg+="&bull; "+yii.i18n.response.enterMessage+"<br />";errors=true;}if(form.fromEmail.value&&!isValidEmail(form.fromEmail.value)){errorMsg+="&bull; "+yii.i18n.response.badEmail+"<br />";errors=true;}if(errors){showResponse(yii.i18n.response.errorTitle,errorMsg,yii.icons.error);}return(errors)?false:true;}function onServerResponse(response){var response=$.parseJSON(response);if(response.success){showResponse(response.title,response.msg,yii.icons.emailSent,false);$("#"+formId).resetForm();}else{showResponse(yii.i18n.response.errorTitle,response.msg,yii.icons.error);}}function initForm(){$("a.contact").colorbox({speed:transitionSpeed,href:"#"+formPageId,inline:true});$("#"+formId).ajaxForm({beforeSubmit:onSubmitForm,success:onServerResponse});}function onPageReceived(page){switch(page){case"form":formPages.form=true;break;case"response":formPages.response=true;break;}if(formPages.form&&formPages.response){initForm();}}function getPage(page,cb){$.ajax({url:page,type:"GET",cache:false,timeout:serverTimeout,success:cb});}getPage(yii.path.getContactForm,function(html){colorboxContactWrapper=$("<div/>",{id:formPageId}).appendTo(formPagesWrapper).html(html);onPageReceived("form");});getPage(yii.path.getServerResponseHtml,function(html){colorboxContactResponseTemplate=html;onPageReceived("response");});}$(function(){var d=document,s=d.getElementsByTagName("script")[0];$("a.popup").click(function(){var $this=$(this),href=($this.attr("data-href"))?$this.attr("data-href"):$this.attr("href");$this.colorbox($.extend({},colorbox.settings,{href:href,rel:"nofollow",open:true,scrolling:false}));return false;});$(".openGallery").click(function(e){var btn=$(this),img=btn.attr("data-image")||0,galRel=btn.attr("data-gallery"),$gal=$('a[rel="'+galRel+'"]').colorbox(colorbox.settings);e.preventDefault();$gal.eq(img).click();});initColorboxContact();$('[title][data-tipsy!="disabled"]').tipsy();$('a[href^="http://"]').attr("target","_blank");window.___gcfg={lang:"de"};var po=document.createElement("script");po.type="text/javascript";po.async=true;po.src="https://apis.google.com/js/plusone.js";s.parentNode.insertBefore(po,s);var fbId="facebook-jssdk",fbJs;if(d.getElementById(fbId)){return;}fbJs=d.createElement("script");fbJs.id=fbId;fbJs.src="//connect.facebook.net/en_US/all.js#xfbml=1";s.parentNode.insertBefore(fbJs,s);$(".likeConfirm").click(function(){var confirmBtn=$(this),confirmMsg=$("#"+confirmBtn.attr("data-msgId")),resetConfirm=function(){confirmMsg.fadeOut();confirmBtn.show();},maxR=$(window).width()-10,pos,rPos;confirmBtn.hide();pos=confirmMsg.fadeIn().offset();rPos=pos.left+confirmMsg.outerWidth(true);if(rPos>maxR){confirmMsg.css("left",(parseFloat(confirmMsg.css("left"),10)-(rPos-maxR))+"px");}($("#top")).mouseleave(resetConfirm);$(window).focus(resetConfirm);return false;});$(".bdy").inflatesViewport();$("#topnav").disableSelection();});
