jQuery(function(b){b("#modal").dialog({autoOpen:false,draggable:false,modal:true,resizeable:false,width:510,height:172,bgiframe:true});var a=b("#page.terminal").length===0?14:34,c=function(){b(".scroll").not(".message .text.privacy .scroll").not("#page.story-detail .gallery .scroll").not("#page.animal.terminal .godfathers .scroll").jScrollPane({scrollbarMargin:10,scrollbarWidth:a,reinitialiseOnImageLoad:true});b("#page.animal.terminal .godfathers .scroll").jScrollPane({scrollbarMargin:10,reinitialiseOnImageLoad:true,
scrollbarWidth:69,showArrows:true})};b.browser.opera?window.setTimeout(c,300):c();b("div.birth input").dpSetOffset(0,-79);b("input[type=text][alt],textarea[title]").each(function(){var a=b(this),c=a.css("color"),f=a.is("input")?"alt":"title";a.val()===""&&a.val(a.attr(f)).css("color","#826F4A");a.focus(function(){a.val()===a.attr(f)&&a.val("").css("color",c)}).blur(function(){a.val()===""&&a.val(a.attr(f)).css("color","#826F4A")})});b(".box, label",".checkbox").click(function(){var a=b(".box",b(this).parent()),
c=b("input[type=checkbox]",a);c.attr("checked")?(c.attr("checked",false),a.removeClass("checked")):(c.attr("checked",true),a.addClass("checked"))});typeof addthis_sendto!=="undefined"&&b("li .facebook, li .twitter").click(addthis_sendto);b("a.faqQuestion").click(function(){var a=b(".answers .scroll"),c=b(this).attr("rel");a[0].scrollTo(c);return false});typeof modalClassName=="string"&&modalClassName=="error"&&showModal("error");b("a.modal").click(function(){showModal("privacy",false,500);b(".message .text.privacy .scroll").jScrollPane({scrollbarMargin:10,
scrollbarWidth:14});return false})});busy=error=false;function showSuccessModal(b,a){a.errors==0&&showModal("success",true)}function showFileErrorModal(){showModal("fileError")}
function showModal(b,a,c){c=c||172;$("#modal").each(function(){var e=$(this);e.dialog("option",{height:c});e.dialog("open");b&&e.addClass(b);$(".close",this).click(function(){a&&window.redirectUrl&&redirectUrl?window.location.href=redirectUrl:(e.removeClass(b),e.dialog("close"),$("body").trigger("dialogClosed"));return false})})}function addErrorClassIfNot(b,a){return!b?(a.addClass("error"),a.next().addClass("error"),true):false}
function isRequiredField(b){var a=b.is("textarea")?"title":"alt";return b.attr(a).indexOf("*")>-1}
function getFormData(){var b={};$("input[type=text][alt],textarea[title],input[type=checkbox],select").each(function(){var a=$(this),c=a.val(),e=a.attr("name"),d=a.parent();d.removeClass("error");d.next().removeClass("error");if(!$("#aspresent").attr("checked")&&a.is("[name^=donee]"))return true;if(a.is("input[type=text]"))if(c!==a.attr("alt")?b[e]=c:error|=addErrorClassIfNot(!isRequiredField(a),d),a.is("#headline"))error|=addErrorClassIfNot(c.length<=23,d);else if(a.is("[name*=email]")){var f=c.match(/^([^@\s]+)@((?:[\-a-z0-9]+\.)+[a-z]{2,})$/i);
error|=addErrorClassIfNot(f,d)}else a.is("[name*=zip]")?(f=c.match(/[0-9]{5}/),error|=addErrorClassIfNot(f,d)):a.is("[name*=birth]")&&c!=a.attr("alt")&&(error|=addErrorClassIfNot(Date.validate(c),d));a.is("#website")&&(f=c.match(/[^\"\s]+\.[^\"\s]{2,}/)||c==a.attr("alt"),error|=addErrorClassIfNot(f,d));a.is("textarea")?c!=a.attr("title")?b[e]=c:isRequiredField(a)&&(error|=addErrorClassIfNot(false,d)):a.is("input[type=checkbox]")?a.attr("checked")?b[e]=c:isRequiredField(a)&&(d.addClass("error"),error=
true):a.is("select")&&(a=$("option:selected",a).val(),a!=""?(d.css("background-image","url(assets/images/background_input_dropdown.png)"),b[e]=a):(d.css("background-image","url(assets/images/background_input_dropdown_error.png)"),error=true))});return b}var first=true,randomTimeout=null;
function getRandomContent(b,a){a||(a=-1);var c=$("#random"),e=startInterval,d={exclude:a},f=b==="stories"?"story.php":"animal.php";$.ajaxSetup({cache:false});$.get(f,d,function(a){if(typeof a.success!="undefined"&&a.success==true){if(first){var d=$("<img />").attr("src","").attr("alt","").attr("title","").addClass("media"),f=$('<p class="text"></p>');c.find("h2").after(f).after(d);c.find(".media").wrap('<div class="imgBox"></div>')}else e=autoplayInterval;d="c338w__238h__";b=="adoptions"&&(d="c338w__c238h__");
c.find(".more").attr("href",a.link).end().find(".media").attr("src",a.image?"imageresize/"+d+a.image:"").attr("alt",a.title).css("display",a.image?"block":"none").end().find(".imageOverlay").css("display",a.image?"block":"none").end().find(".text").html(a.text).end().find(".becomepate").attr("href",a.formlink+"?animal="+a.id);c.siblings("a.becomepate").attr("href",a.formlink+"?animal="+a.id);first=false;window.clearTimeout(randomTimeout);randomTimeout=window.setTimeout(function(){getRandomContent(b,
a.id)},e);c.unbind("mouseenter");c.mouseenter(function(){window.clearTimeout(randomTimeout)});c.unbind("mouseleave");c.mouseleave(function(){randomTimeout=window.setTimeout(function(){getRandomContent(b,a.id)},e)})}},"json")}function resetForm(){$("input[type=text][alt],textarea[title]").each(function(){var b=$(this),a=b.is("input")?"alt":"title";b.val(b.attr(a)).css("color","#826F4A")})};
(function(b){var a=function(h){var d=h.childNodes[1],i=h,k="",m=null,j=0,g=0,f=null,l=document.createElement("a");if(d.className=="liam"){m=h.firstChild.nodeValue;i=d}g=i.childNodes.length;for(;j<g;++j){f=i.childNodes[j];if(f.nodeType==3){k+=f.nodeValue.replace(/ ?(|&#173;|&shy;|&#x00AD;) ?/g,"")}}if(m===null){m=k}l.href="mailto:"+k;l.innerHTML=m;h.parentNode.replaceChild(l,h)},c=function(){b("span.mapson").unbind("mouseover");b("span.mapson").mouseover(function(){a(this)})};b(c)})(jQuery);
Date.dayNames=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];Date.abbrDayNames=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];Date.monthNames=['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'];Date.abbrMonthNames=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];Date.firstDayOfWeek=1;Date.format='dd.mm.yyyy';Date.fullYearStart='20';(function(){function add(name,method){if(!Date.prototype[name]){Date.prototype[name]=method;}};add("isLeapYear",function(){var y=this.getFullYear();return(y%4==0&&y%100!=0)||y%400==0;});add("isWeekend",function(){return this.getDay()==0||this.getDay()==6;});add("isWeekDay",function(){return!this.isWeekend();});add("getDaysInMonth",function(){return[31,(this.isLeapYear()?29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()];});add("getDayName",function(abbreviated){return abbreviated?Date.abbrDayNames[this.getDay()]:Date.dayNames[this.getDay()];});add("getMonthName",function(abbreviated){return abbreviated?Date.abbrMonthNames[this.getMonth()]:Date.monthNames[this.getMonth()];});add("getDayOfYear",function(){var tmpdtm=new Date("1/1/"+this.getFullYear());return Math.floor((this.getTime()-tmpdtm.getTime())/86400000);});add("getWeekOfYear",function(){return Math.ceil(this.getDayOfYear()/7);});add("setDayOfYear",function(day){this.setMonth(0);this.setDate(day);return this;});add("addYears",function(num){this.setFullYear(this.getFullYear()+num);return this;});add("addMonths",function(num){var tmpdtm=this.getDate();this.setMonth(this.getMonth()+num);if(tmpdtm>this.getDate())
this.addDays(-this.getDate());return this;});add("addDays",function(num){this.setTime(this.getTime()+(num*86400000));return this;});add("addHours",function(num){this.setHours(this.getHours()+num);return this;});add("addMinutes",function(num){this.setMinutes(this.getMinutes()+num);return this;});add("addSeconds",function(num){this.setSeconds(this.getSeconds()+num);return this;});add("zeroTime",function(){this.setMilliseconds(0);this.setSeconds(0);this.setMinutes(0);this.setHours(0);return this;});add("asString",function(format){var r=format||Date.format;return r.split('yyyy').join(this.getFullYear()).split('yy').join((this.getFullYear()+'').substring(2)).split('mmmm').join(this.getMonthName(false)).split('mmm').join(this.getMonthName(true)).split('mm').join(_zeroPad(this.getMonth()+1)).split('dd').join(_zeroPad(this.getDate())).split('hh').join(_zeroPad(this.getHours())).split('min').join(_zeroPad(this.getMinutes())).split('ss').join(_zeroPad(this.getSeconds()));});Date.validate=function(s,format){var f=format||Date.format;var daysPerMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);var now=new Date();var dates=s.match(/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/);if(!dates)return false;var year=Number(dates[3]);var month=Number(dates[2]);var day=Number(dates[1]);if((year%4==0&&year%100!=0)||year%400==0)daysPerMonth[1]=29;if(month<1||month>12)return false;if(day<1||day>daysPerMonth[(month-1)])return false;return true;}
Date.fromString=function(s,format)
{var f=format||Date.format;var d=new Date('01/01/1977');var mLength=0;var iM=f.indexOf('mmmm');if(iM>-1){for(var i=0;i<Date.monthNames.length;i++){var mStr=s.substr(iM,Date.monthNames[i].length);if(Date.monthNames[i]==mStr){mLength=Date.monthNames[i].length-4;break;}}
d.setMonth(i);}else{iM=f.indexOf('mmm');if(iM>-1){var mStr=s.substr(iM,3);for(var i=0;i<Date.abbrMonthNames.length;i++){if(Date.abbrMonthNames[i]==mStr)break;}
d.setMonth(i);}else{d.setMonth(Number(s.substr(f.indexOf('mm'),2))-1);}}
var iY=f.indexOf('yyyy');if(iY>-1){if(iM<iY)
{iY+=mLength;}
d.setFullYear(Number(s.substr(iY,4)));}else{if(iM<iY)
{iY+=mLength;}
d.setFullYear(Number(Date.fullYearStart+s.substr(f.indexOf('yy'),2)));}
var iD=f.indexOf('dd');if(iM<iD)
{iD+=mLength;}
d.setDate(Number(s.substr(iD,2)));if(isNaN(d.getTime())){return false;}
return d;};var _zeroPad=function(num){var s='0'+num;return s.substring(s.length-2)};})();
var maxFileSize=2097152;
jQuery(function(a){a(".story-overview .search-container form").submit(function(){var b=a("input[type=text]",this),c=b.val();return a.trim(c)===""||c==b.attr("alt")?(showModal("empty"),false):true});a("#upload").length>0&&a("#upload").uploadify({uploader:"assets/js/jquery/uploadify.swf",script:window.location.href,cancelImg:"assets/images/icon_collapse.png",queueID:"fileQueue",auto:false,multi:true,buttonImg:"assets/images/background_button_upload.png",width:"169",height:"26",wmode:"transparent",onSelect:checkFile,
onSelectOnce:prepareImageList,onComplete:prepareImageList,onCancel:prepareImageList,onAllComplete:uploadifyFinish,sizeLimit:maxFileSize,onError:showFileErrorModal,fileDesc:"*.jpg, *.jpeg, *.png",fileExt:"*.jpg;*.jpeg;*.png"});a("a.send").click(function(){if(!busy){busy=true;var b=getFormData();if(error)showModal("error");else{if(a("#tell-story").length>0){editKey="";for(var c=0;c<20;c++)editKey+=parseInt(Math.random()*10)}else if(a("#edit-story").length>0)b.oldFileOrder=createOldList();b.editKey=
editKey;b.fileOrder=createImageList();b.imageListLength=a(".uploadifyQueueItem:not(.old)").length;b.imageListLength>0?(a("body").addClass("waiter"),a("#upload").uploadifySettings("scriptData",b),a("#upload").uploadifyUpload()):(a("body").addClass("waiter"),a.post(window.location.href,b,function(b){a("body").removeClass("waiter");b==1?showModal("success",true):showModal("error")}))}error=busy=false}return false});a(".galImg",this).each(function(){a(this).click(function(){current=a(this).prevAll().length;
clearTimeout(timeout);a("#detail .images").mouseleave(function(){timeout=window.setTimeout("changeImage()",interval);a("#detail .images").unbind("mouseleave")});a(".bigImg div img").hide();a(".bigImg div img:eq("+a(this).prevAll().length+")").fadeIn("slow")})});var d=a(".gallery .scroll").height()-10;a(".pfeil.hoch").click(function(){var b=a(".gallery .scroll"),c=b.css("margin-top");parseInt(c)<0&&b.css("margin-top",parseInt(c)+65)});a(".pfeil.runter").click(function(){var b=a(".gallery .scroll"),
c=b.css("margin-top");d+parseInt(c)>128&&b.css("margin-top",parseInt(c)-65)});a("#edit-story .uploadifyQueueItem.old").each(function(){var b=a(this);a(".cancel",b).click(function(){b.fadeOut(250,function(){a(this).remove();prepareImageList()})})})});function checkFile(a,d,b){return b.size>maxFileSize?(showFileErrorModal(),false):true}function uploadifyFinish(a,d){$("body").removeClass("waiter");showSuccessModal(a,d)}
function prepareImageList(){$(".scroll").jScrollPane({scrollbarMargin:0,scrollbarWidth:14});setFirstLastElement();$(".uploadifyQueueItem").each(function(){var a=$(this);a.click(function(){a.siblings().removeClass("active");$(this).addClass("active");$(".input.left.file #fileName").val($(".fileName",a).text())});$(".arrow.up",a).click(function(){a.prev().before(a);setFirstLastElement()});$(".arrow.down",a).click(function(){a.next().after(a);setFirstLastElement()})})}
function setFirstLastElement(){$(".uploadifyQueueItem").removeClass("first").removeClass("last");$(".uploadifyQueueItem:first-child").addClass("first");$(".uploadifyQueueItem:last-child").addClass("last")}function createList(a,d){var b=[];$(a).each(function(){b.push($(d,this).text().replace(/ /g,"_"))});return b.join(",")}function createImageList(){return createList(".uploadifyQueueItem",".fileName")}function createOldList(){return createList(".uploadifyQueueItem.old",".rexFileName")}
function changeImage(){current++;current>=countImages&&(current=0);$(".bigImg div img").hide();$(".bigImg div img:eq("+current+")").fadeIn("slow");timeout=window.setTimeout(changeImage,interval)};

