/* Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 */
(function($){$.fn.extend({expandable:function(options){options=$.extend({duration:'normal',interval:750,within:1,by:2,init:false},options);return this.filter('textarea').each(function(){var $this=$(this).css({display:'block',overflow:'hidden'}),minHeight=$this.height(),interval,heightDiff=this.offsetHeight-minHeight,rowSize=(parseInt($this.css('lineHeight'),10)||parseInt($this.css('fontSize'),10)),$div=$('<div style="position:absolute;top:-999px;left:-999px;border-color:#000;border-style:solid;overflow-x:hidden;visibility:hidden;z-index:0;" />').appendTo('body');$.each('borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth paddingTop paddingRight paddingBottom paddingLeft fontSize fontFamily fontWeight fontStyle fontStretch fontVariant wordSpacing lineHeight width'.split(' '),function(i,prop){$div.css(prop,$this.css(prop));});$this.bind('keypress',function(event){if(event.keyCode=='13')check();}).bind('focus blur',function(event){if(event.type=='blur')clearInterval(interval);if(event.type=='focus')interval=setInterval(check,options.interval);});function check(){var text=$this.val(),newHeight,height,usedHeight,usedRows,availableRows;$div.html(text.replace(/\n/g,'&nbsp;<br>'));height=$this[0].offsetHeight-heightDiff;usedHeight=$div[0].offsetHeight-heightDiff;usedRows=Math.floor(usedHeight/rowSize);availableRows=Math.floor((height/rowSize)-usedRows);if(availableRows<=options.within){newHeight=rowSize*(usedRows+Math.max(availableRows,0)+options.by);$this.stop().animate({height:newHeight},options.duration);}else if(availableRows>options.by+options.within){newHeight=Math.max(height-(rowSize*(availableRows-(options.by+options.within))),minHeight);$this.stop().animate({height:newHeight},options.duration);}};if(options.init)check();}).end();}});})(jQuery);;(function($){$.fn.defaulttext=function(options){var elText={title:function(input){return $(input).attr('title');},label:function(input){return $('label[for='+input.id+']').text();}},delay=50,loadDelay=100,selector=this.selector,$form=this.parents('form:first');$form.bind('blurText.dt',function(event){var $tgt=$(event.target),prevClass=$tgt.data('dtInfo')&&$tgt.data('dtInfo').prevClass||'';if($.trim($tgt.val())===''){$tgt.prev(prevClass).show();}else{$tgt.prev(prevClass).hide();}}).bind('focusText.dt',function(event,el){var tgt=event.target;$(tgt).prev().hide();if(!$(el).is(':dtinput')){tgt.focus();}}).bind('keyupText.dt',function(event){});this.filter(':dtinput').each(function(){var $input=$(this);var opts=$.extend({},$.fn.defaulttext.defaults,options||{},$.metadata?$input.metadata():$.meta?$input.data():{});if(opts.text.constructor===Function){$input.data('dtInfo',{text:opts.text(this)});}else if(opts.text&&opts.text.constructor===String){$input.data('dtInfo',{text:((/(title|label)/).test(opts.text)?elText[opts.text](this):opts.text)});if(opts.text==='label'){$('label[for= '+this.id+']').css({position:'absolute',left:'-4000em'});}}
if(!$input.data('dtInfo').text){return $input.removeData('dtInfo');}
$input.data('dtinfo',{prevClass:opts.defaultClass?'.'+opts.defaultClass:''});if($input.parent().css('position')=='static'){$input.parent().css({position:'relative'});}
$(opts.tag).html($input.data('dtInfo').text).addClass(opts.defaultClass).css({position:'absolute',width:opts.matchInputWidth?$input.width():'auto',display:'none'}).insertBefore($input);var focused;$input.bind('focus',function(event){$input.trigger('focusText.dt',event.target);focused=setTimeout(function(){$input.trigger('focusText.dt',event.target);},delay);});$input.prev($input.data('dtInfo').prevClass).bind('click',function(event){$input.trigger('focusText.dt',event.target);});$input.bind('blur',function(event){clearTimeout(focused);$form.find(':dtinput').trigger('blurText.dt');}).bind('keyup',function(event){if(event.which!=9){setTimeout(function(){$form.find(':dtinput').filter(function(){return $.data(event.target)!=$.data(this);}).trigger('blurText.dt');},delay);}});$(window).bind('load',function(){setTimeout(function(){$input.trigger('focusText.dt',$input);$input.trigger('blurText.dt');},delay+loadDelay);});});function dtHide(el){el.prev().hide();}
return this;};$.fn.defaulttext.defaults={tag:'<span></span>',defaultClass:'default-text',text:'label',matchInputWidth:false};$.extend($.expr[':'],{dtinput:function(element,index,matches,set){return(/text|password/i).test(element.type)||element.nodeName.toLowerCase()==='textarea';}});})(jQuery);;$.pdl={speed:400};$(document).ready(function(){function filterPath(string){return string.replace(/^\//,'').replace(/(index|default).[a-zA-Z]{3,4}$/,'').replace(/\/$/,'');}
var locationPath=filterPath(location.pathname);$('body').click(function(event){var $link=$(event.target).closest('a');if(!$link.length||$link.parents('.search-box, .pins, .map-links').length){return;}
var link=$link[0];var thisPath=filterPath(link.pathname)||locationPath;if(locationPath==thisPath&&((location.hostname==link.hostname)||!link.hostname)&&link.hash.replace(/#/,'')){event.preventDefault();var $target=$(link.hash),target=link.hash;if($target.length){var targetOffset=$target.offset().top;$('html, body').animate({scrollTop:targetOffset},$.pdl.speed,function(){location.hash=target;});}}});$('textarea').expandable({init:true,duration:100,interval:400,by:1});$('#search-site-input').defaulttext({matchInputWidth:true});$('#search-catalog-input').defaulttext({matchInputWidth:true});$('.search-select a').click(function(event){event.preventDefault();var $searchLink=$(this),$showForm=$(this.hash);$searchLink.addClass('active');$searchLink.parent().siblings().find('a').removeClass('active');$showForm.siblings('form').hide().end().show();});$('#search-catalog').removeClass('alt-hide').hide();$('#quick-links-toggle').click(function(){$('.quick-links').slideToggle();return false;});if(typeof $.fn.columns!=='undefined'){$('.atoz ul').columns({});};if(typeof $.fn.cycle!=='undefined'){$('.booklist-wrapper .slides').after('<a class="prev prevnext replace" href="#">previous</a><a class="next prevnext replace" href="#">next</a>').cycle({timeout:0,next:'.next',prev:'.prev'}).parent().css('overflow','visible');};});$(document).ready(function(){var $zoom=$('.zoom');var $dir='/assets/scripts/fancyzoom/';if(!$zoom.length){return;}
$.getScript($dir+'fancyzoom.min.js',function(){$zoom.fancyZoom({directory:$dir+'images/'});});});$(document).ready(function(){$('a[rel=external]').click(function(){window.open($(this).attr('href'));return false;});});$(window).bind('load',function(event){$('<div id="print-logo" class="print-only"><img src="/assets/styles/images/logo-pdl-bw.png" alt="Portage District Library" /><div>(269) 329-4544</div></div>').insertAfter('.logo-header:first');});$(document).ready(function(){var $contactForm=$('.content form:not([id^=search])');if($contactForm.length){$(':input.required').each(function(){if($(this).parent('.checkbox').length){$(this).next('label').prepend(' <span class="req-mark">*</span>');}else{$(this).prev('label').append(' <span class="req-mark">*</span>');}});$.getScript('/assets/scripts/jquery.tinyvalidate.js',function(){$contactForm.tinyvalidate({inline:{errorElement:null}});});var setFocus;$('.error-summary a').live('click',function(event){var link=this;setFocus=setTimeout(function(){$(link.hash)[0].focus();},$.pdl.speed+50);});}});$('body.ie6 .search-box').css('zoom','1');