(function($,window,document){var ie6=false;if($.browser.msie&&$.browser.version.substr(0,1)<7){ie6=true;}else{document.documentElement.className=document.documentElement.className+' dk_fouc';}
var
methods={},lists=[],keyMap={'left':37,'up':38,'right':39,'down':40,'enter':13},dropdownTemplate=['<div class="dk_container" id="dk_container_{{ id }}" tabindex="{{ tabindex }}">','<a class="dk_toggle">','<span class="dk_label">{{ label }}</span>','</a>','<div class="dk_options">','<ul class="dk_options_inner">','</ul>','</div>','</div>'].join(''),optionTemplate='<li class="{{ current }}"><a data-dk-dropdown-value="{{ value }}">{{ text }}</a></li>',defaults={startSpeed:1000,theme:false,change:false,reverseSync:true},keysBound=false;methods.init=function(settings){settings=$.extend({},defaults,settings);return this.each(function(){var
$select=$(this),$original=$select.find(':selected').first(),$options=$select.find('option'),data=$select.data('dropkick')||{},id=$select.attr('id')||$select.attr('name'),width=settings.width,tabindex=$select.attr('tabindex')?$select.attr('tabindex'):'',$dk=false,theme;if(data.id){return $select;}else{data.settings=settings;data.tabindex=tabindex;data.id=id;data.$original=$original;data.$select=$select;data.value=_notBlank($select.val())||_notBlank($original.attr('value'));data.label=$original.text();data.options=$options;}
$dk=_build(dropdownTemplate,data);$dk.find('.dk_toggle').css({'width':width+'px'});$select.before($dk);$dk=$('#dk_container_'+id).fadeIn(settings.startSpeed);theme=settings.theme?settings.theme:'default';$dk.addClass('dk_theme_'+theme);data.theme=theme;data.$dk=$dk;$select.data('dropkick',data);$dk.data('dropkick',data);lists[lists.length]=$select;$dk.bind('focus.dropkick',function(e){$dk.addClass('dk_focus');}).bind('blur.dropkick',function(e){$dk.removeClass('dk_open dk_focus');});$select.bind('change',function(e){var $dkopt=$(':[data-dk-dropdown-value="'+$select.val()+'"]',$dk);_updateFields($dkopt,$dk,true);});setTimeout(function(){$select.hide();},0);});};methods.theme=function(newTheme){var
$select=$(this),list=$select.data('dropkick'),$dk=list.$dk,oldtheme='dk_theme_'+list.theme;$dk.removeClass(oldtheme).addClass('dk_theme_'+newTheme);list.theme=newTheme;};methods.reset=function(){for(var i=0,l=lists.length;i<l;i++){var
listData=lists[i].data('dropkick'),$dk=listData.$dk,$current=$dk.find('li').first();$dk.find('.dk_label').text(listData.label);$dk.find('.dk_options_inner').animate({scrollTop:0},0);_setCurrent($current,$dk);_updateFields($current,$dk,true);}};$.fn.dropkick=function(method){if(!ie6){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'||!method){return methods.init.apply(this,arguments);}}};function _handleKeyBoardNav(e,$dk){var
code=e.keyCode,data=$dk.data('dropkick'),options=$dk.find('.dk_options'),open=$dk.hasClass('dk_open'),current=$dk.find('.dk_option_current'),first=options.find('li').first(),last=options.find('li').last(),next,prev;switch(code){case keyMap.enter:if(open){_updateFields(current.find('a'),$dk);_closeDropdown($dk);}else{_openDropdown($dk);}
e.preventDefault();break;case keyMap.up:prev=current.prev('li');if(open){if(prev.length){_setCurrent(prev,$dk);}else{_setCurrent(last,$dk);}}else{_openDropdown($dk);}
e.preventDefault();break;case keyMap.down:if(open){next=current.next('li').first();if(next.length){_setCurrent(next,$dk);}else{_setCurrent(first,$dk);}}else{_openDropdown($dk);}
e.preventDefault();break;default:break;}}
function _updateFields(option,$dk,reset){var value,label,data;value=option.attr('data-dk-dropdown-value');label=option.text();data=$dk.data('dropkick');$select=data.$select;$select.val(value);$dk.find('.dk_label').text(label);reset=reset||false;if(data.settings.change&&!reset){data.settings.change.call($select,value,label);}}
function _setCurrent($current,$dk){$dk.find('.dk_option_current').removeClass('dk_option_current');$current.addClass('dk_option_current');_setScrollPos($dk,$current);}
function _setScrollPos($dk,anchor){var height=anchor.prevAll('li').outerHeight()*anchor.prevAll('li').length;$dk.find('.dk_options_inner').animate({scrollTop:height+'px'},0);}
function _closeDropdown($dk){$dk.removeClass('dk_open');}
function _openDropdown($dk){var data=$dk.data('dropkick');$dk.find('.dk_options').css({top:$dk.find('.dk_toggle').outerHeight()-1});$dk.toggleClass('dk_open');}
function _build(tpl,view){var
template=tpl,options=[],$dk;template=template.replace('{{ id }}',view.id);template=template.replace('{{ label }}',view.label);template=template.replace('{{ tabindex }}',view.tabindex);if(view.options&&view.options.length){for(var i=0,l=view.options.length;i<l;i++){var
$option=$(view.options[i]),current='dk_option_current',oTemplate=optionTemplate;oTemplate=oTemplate.replace('{{ value }}',$option.val());oTemplate=oTemplate.replace('{{ current }}',(_notBlank($option.val())===view.value)?current:'');oTemplate=oTemplate.replace('{{ text }}',$option.text());options[options.length]=oTemplate;}}
$dk=$(template);$dk.find('.dk_options_inner').html(options.join(''));return $dk;}
function _notBlank(text){return($.trim(text).length>0)?text:false;}
$(function(){$('.dk_toggle').live('click',function(e){var $dk=$(this).parents('.dk_container').first();_openDropdown($dk);if("ontouchstart"in window){$dk.addClass('dk_touch');$dk.find('.dk_options_inner').addClass('scrollable vertical');}
e.preventDefault();return false;});$('.dk_options a').live(($.browser.msie?'mousedown':'click'),function(e){var
$option=$(this),$dk=$option.parents('.dk_container').first(),data=$dk.data('dropkick');_closeDropdown($dk);_updateFields($option,$dk);_setCurrent($option.parent(),$dk);e.preventDefault();return false;});$(document).bind('keydown.dk_nav',function(e){var
$open=$('.dk_container.dk_open'),$focused=$('.dk_container.dk_focus'),$dk=null;if($open.length){$dk=$open;}else if($focused.length&&!$open.length){$dk=$focused;}
if($dk){_handleKeyBoardNav(e,$dk);}});});})(jQuery,window,document);(function($){$.fn.toTitleCase=function(){$(this).each(function(){var headline=$(this).text();$(this).text(headline.replace(/([\w&`'â€˜â€™"â€œ.@:\/\{\(\[<>_]+-? *)/g,function(match,pl,index,title){if(index>0&&title.charAt(index-2)!==":"&&match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|from|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i)>-1)
return match.toLowerCase();if(title.substring(index-1,index+1).search(/['"_{(\[]/)>-1)
return match.charAt(0)+match.charAt(1).toUpperCase()+match.substr(2);if(match.substr(1).search(/[A-Z]+|&|[\w]+[._][\w]+/)>-1||title.substring(index-1,index+1).search(/[\])}]/)>-1)
return match.charAt(0).toUpperCase()+match.substr(1).toLowerCase();return match.charAt(0).toUpperCase()+match.substr(1);}));});};})(jQuery);


/* extends autosuggest to change labels from text to html */
(function( $ ) {

var proto = $.ui.autocomplete.prototype,
initSource = proto._initSource;

function filter( array, term ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
return $.grep( array, function(value) {
return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
});
}

$.extend( proto, {
_initSource: function() {
if ( this.options.html && $.isArray(this.options.source) ) {
this.source = function( request, response ) {
response( filter( this.options.source, request.term ) );
};
} else {
initSource.call( this );
}
},

_renderItem: function( ul, item) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( $( "<a></a>" )[ this.options.html ? "html" : "text" ]( item.label ) )
.appendTo( ul );
}
});

})( jQuery );

(function($) {
  $.fn.opendiv = function(headeron) {
    return this.each(function() {
    	var $this = $(this);
    	$this.find('.multiTrigger').click(function(){
    			$(this).toggleClass(headeron);
      	      $(this).next('.multiResp').toggleClass('catexpand',500,'easeOutBounce');
      	       $(this).find('.open').toggleClass('close');
      	});
    });
  };
})(jQuery);

/*
 * jSort - jQury sorting plugin
 * http://do-web.com/jsort/overview
 *
 * Copyright 2011, Miriam Zusin
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://do-web.com/jsort/license
 */

(function($){
   $.fn.jSort = function(options){
	   
	var options = $.extend({
		sort_by: 'p',
		item: 'div',
		order: 'asc', //desc
		is_num: false,
		sort_by_attr: false,
		attr_name: ''
	},options);

	return this.each(function() {            
		var hndl = this;
		var titles = [];
		var i = 0;
		
		//init titles
		$(this).find(options.item).each(function(){
		
			var txt;
			var sort_by = $(this).find(options.sort_by);
			
			if(options.sort_by_attr){
				txt = sort_by.attr(options.attr_name).toLowerCase();	
			}
			else{
				txt = sort_by.text().toLowerCase();	
			}
						
			titles.push([txt, i]);
			
			$(this).attr("rel", "sort" + i);			
			i++;
		});
		
		this.sortNum = function(a, b){			
			return eval(a[0] -  b[0]);
		};
		
		this.sortABC = function(a, b){			
			return a[0] > b[0] ? 1 : -1;
		};
		
		if(options.is_num){
			titles.sort(hndl.sortNum);
		}
		else{
			titles.sort(hndl.sortABC);
		}	
		
		if(options.order == "desc"){
			if(options.is_num){
				titles.reverse(hndl.sortNum);
			}
			else{				
				titles.reverse(hndl.sortABC);
			}				
		}
		
		for (var t=0; t < titles.length; t++){
			var el = $(hndl).find(options.item + "[rel='sort" + titles[t][1] + "']");
			$(hndl).append(el);
		}
		
	});    
   };
})(jQuery);


//Set global var to track first click into pu_date : false = not clicked
var puFirstClickStatus = false;
var prevDateDelta = 0;

$(function() {
		var dates = $( "#pu_date, #do_date" ).datepicker({
			changeMonth: false, //true for dd
			numberOfMonths: 3,
			showOtherMonths: true,
			selectOtherMonths: true,
			showOn: "both",
			buttonImage: "/img/ui/form/ic_cal.png",
			buttonImageOnly: true,
			minDate: 0,
			dateFormat: 'M d, yy',
			onSelect: function( selectedDate ) {
				var option = this.id == "pu_date" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
					
					//Change DO_DATE to at least default delta
					var dPu = new Date($('#pu_date').val());
					var dDo = new Date($('#do_date').val());
					var ddelta = Math.floor(( Date.parse(dDo) - Date.parse(dPu) ) / 86400000);
					ddelta < 0 ? ddelta = 0 : ddelta = ddelta;
					
					//If pu_date is greater than do_date, then maintain last delta
					if (dPu > dDo){
						var d = dPu.getDate();
						var m = dPu.getMonth();
						var y = dPu.getFullYear();
						var edate= new Date(y, m, d+prevDateDelta);
						changeDODate(edate);
					}
					prevDateDelta = ddelta;
					
					//Only set MINDATE. Prevent DODATE errors through the date delta
					if (option == "minDate"){
						dates.not( this ).datepicker( "option", option, date );
					}
				//Check for first instance of pu_date clicked only
				if (this.id == "pu_date" && !puFirstClickStatus){
					puFirstClickStatus = true;
					//Check to see if do_date is at least delta out
					var dPu = new Date($('#pu_date').val());
					var dDo = new Date($('#do_date').val());
					var ddelta = Math.floor(( Date.parse(dDo) - Date.parse(dPu) ) / 86400000);
					if (ddelta < 3){
						var d = dPu.getDate();
						var m = dPu.getMonth();
						var y = dPu.getFullYear();
						var edate= new Date(y, m, d+3);
						changeDODate(edate);
					}
					
				}
				
			}
		});
	});

function changeDODate(param){
	$('#do_date').datepicker('setDate', param);	
}



/*
 * 	loopedSlider 0.5.6 - jQuery plugin
 *	written by Nathan Searles	
 *	http://nathansearles.com/loopedslider/
 *
 *	Copyright (c) 2009 Nathan Searles (http://nathansearles.com/)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *	Compatible with jQuery 1.3.2+
 *
 */

/*
 *	markup example for $("#loopedSlider").loopedSlider();
 *
 *	<div id="loopedSlider">	
 *		<div class="container">
 *			<div class="slides">
 *				<div><img src="01.jpg" alt="" /></div>
 *				<div><img src="02.jpg" alt="" /></div>
 *				<div><img src="03.jpg" alt="" /></div>
 *				<div><img src="04.jpg" alt="" /></div>
 *			</div>
 *		</div>
 *		<a href="#" class="previous">previous</a>
 *		<a href="#" class="next">next</a>	
 *	</div>
 *
*/

if(typeof jQuery != 'undefined') {
	jQuery(function($) {
		$.fn.extend({
			loopedSlider: function(options) {
				var settings = $.extend({}, $.fn.loopedSlider.defaults, options);
			
				return this.each(
					function() {
					if($.fn.jquery < '1.3.2') {return;}
					var $t = $(this);
					var o = $.metadata ? $.extend({}, settings, $t.metadata()) : settings;
					
					var distance = 0;
					var times = 1;
					var slides = $(o.slides,$t).children().size();
					var width = $(o.slides,$t).children().outerWidth();
					var position = 0;
					var active = false;
					var number = 0;
					var interval = 0;
					var restart = 0;
					var pagination = $("."+o.pagination+" li a",$t);
					var hoverpause = false;

					if(o.addPagination && !$(pagination).length){
						var buttons = slides;
						$($t).append("<ul class="+o.pagination+">");
						$(o.slides,$t).children().each(function(){
							if (number<buttons) {
								$("."+o.pagination,$t).append("<li><a rel="+(number+1)+" href=\"#\" >"+(number+1)+"</a></li>");
								number = number+1;
							} else {
								number = 0;
								return false;
							}
							$("."+o.pagination+" li a:eq(0)",$t).parent().addClass("active");
						});
						pagination = $("."+o.pagination+" li a",$t);
					} else {
						$(pagination,$t).each(function(){
							number=number+1;
							$(this).attr("rel",number);
							$(pagination.eq(0),$t).parent().addClass("active");
						});
					}

					if (slides===1) {
						$(o.slides,$t).children().css({position:"absolute",left:position,display:"block"});
						return;
					}

					$(o.slides,$t).css({width:(slides*width)});

					$(o.slides,$t).children().each(function(){
						$(this).css({position:"absolute",left:position,display:"block"});
						position=position+width;
					});

					$(o.slides,$t).children(":eq("+(slides-1)+")").css({position:"absolute",left:-width});

					if (slides>3) {
						$(o.slides,$t).children(":eq("+(slides-1)+")").css({position:"absolute",left:-width});
					}

					if(o.autoHeight){autoHeight(times);}

					// B: ADDED THIS SO ANIMATION WILL STOP WHILE MOUSE IS OVER IMAGE AND RESTART ON MOUSEOUT
					if (o.hoverpause) {
						$("a",$t).hover(function(){
							clearInterval(sliderIntervalID);
							clearInterval(interval);
							clearTimeout(restart);
						},function(){
							autoStart();
						});
					}
					
					$(".next",$t).click(function(){
						if(active===false) {
							animate("next",true);
							if(o.autoStart){
								if (o.restart) {autoStart();}
								else {clearInterval(sliderIntervalID);}
							}
						} return false;
					});

					$(".previous",$t).click(function(){
						if(active===false) {	
							animate("prev",true);
							if(o.autoStart){
								if (o.restart) {autoStart();}
								else {clearInterval(sliderIntervalID);}
							}
						} return false;
					});

					if (o.containerClick) {
						$(o.container,$t).click(function(){
							if(active===false) {
								animate("next",true);
								if(o.autoStart){
									if (o.restart) {autoStart();}
									else {clearInterval(sliderIntervalID);}
								}
							} return false;
						});
					}

					$(pagination,$t).click(function(){
						if ($(this).parent().hasClass("active")) {return false;}
						else {
							times = $(this).attr("rel");
							$(pagination,$t).parent().siblings().removeClass("active");
							$(this).parent().addClass("active");
							animate("fade",times);
							if(o.autoStart){
								if (o.restart) {autoStart();}
								else {clearInterval(sliderIntervalID);}
							}
						} return false;
					});

					if (o.autoStart) {
						sliderIntervalID = setInterval(function(){
							if(active===false) {animate("next",true);}
						},o.autoStart);
						function autoStart() {
							if (o.restart) {
							clearInterval(sliderIntervalID);
							clearInterval(interval);
							clearTimeout(restart);
								restart = setTimeout(function() {
									interval = setInterval(	function(){
										animate("next",true);
									},o.autoStart);
								},o.restart);
							} else {
								sliderIntervalID = setInterval(function(){
									if(active===false) {animate("next",true);}
								},o.autoStart);
							}
						};
					}

					function current(times) {
						if(times===slides+1){times = 1;}
						if(times===0){times = slides;}
						$(pagination,$t).parent().siblings().removeClass("active");
						$(pagination+"[rel='" + (times) + "']",$t).parent().addClass("active");
					};

					function autoHeight(times) {
						if(times===slides+1){times=1;}
						if(times===0){times=slides;}	
						var getHeight = $(o.slides,$t).children(":eq("+(times-1)+")",$t).outerHeight();
						$(o.container,$t).animate({height: getHeight},o.autoHeight);					
					};		

					function animate(dir,clicked){	
						active = true;	
						switch(dir){
							case "next":
								times = times+1;
								distance = (-(times*width-width));
								current(times);
								if(o.autoHeight){autoHeight(times);}
								if(slides<3){
									if (times===3){$(o.slides,$t).children(":eq(0)").css({left:(slides*width)});}
									if (times===2){$(o.slides,$t).children(":eq("+(slides-1)+")").css({position:"absolute",left:width});}
								}
								$(o.slides,$t).animate({left: distance}, o.slidespeed,function(){
									if (times===slides+1) {
										times = 1;
										$(o.slides,$t).css({left:0},function(){$(o.slides,$t).animate({left:distance})});							
										$(o.slides,$t).children(":eq(0)").css({left:0});
										$(o.slides,$t).children(":eq("+(slides-1)+")").css({ position:"absolute",left:-width});				
									}
									if (times===slides) $(o.slides,$t).children(":eq(0)").css({left:(slides*width)});
									if (times===slides-1) $(o.slides,$t).children(":eq("+(slides-1)+")").css({left:(slides*width-width)});
									active = false;
								});					
								break; 
							case "prev":
								times = times-1;
								distance = (-(times*width-width));
								current(times);
								if(o.autoHeight){autoHeight(times);}
								if (slides<3){
									if(times===0){$(o.slides,$t).children(":eq("+(slides-1)+")").css({position:"absolute",left:(-width)});}
									if(times===1){$(o.slides,$t).children(":eq(0)").css({position:"absolute",left:0});}
								}
								$(o.slides,$t).animate({left: distance}, o.slidespeed,function(){
									if (times===0) {
										times = slides;
										$(o.slides,$t).children(":eq("+(slides-1)+")").css({position:"absolute",left:(slides*width-width)});
										$(o.slides,$t).css({left: -(slides*width-width)});
										$(o.slides,$t).children(":eq(0)").css({left:(slides*width)});
									}
									if (times===2 ) $(o.slides,$t).children(":eq(0)").css({position:"absolute",left:0});
									if (times===1) $(o.slides,$t).children(":eq("+ (slides-1) +")").css({position:"absolute",left:-width});
									active = false;
								});
								break;
							case "fade":
								times = [times]*1;
								distance = (-(times*width-width));
								current(times);
								if(o.autoHeight){autoHeight(times);}
								$(o.slides,$t).children().fadeOut(o.fadespeed, function(){
									$(o.slides,$t).css({left: distance});
									$(o.slides,$t).children(":eq("+(slides-1)+")").css({left:slides*width-width});
									$(o.slides,$t).children(":eq(0)").css({left:0});
									if(times===slides){$(o.slides,$t).children(":eq(0)").css({left:(slides*width)});}
									if(times===1){$(o.slides,$t).children(":eq("+(slides-1)+")").css({ position:"absolute",left:-width});}
									$(o.slides,$t).children().fadeIn(o.fadespeed);
									active = false;
								});
								break; 
							default:
								break;
							}					
						};
					}
				);
			}
		});
		$.fn.loopedSlider.defaults = {
			container: ".container", //Class/id of main container. You can use "#container" for an id.
			slides: ".slides", //Class/id of slide container. You can use "#slides" for an id.
			pagination: "pagination", //Class name of parent ul for numbered links. Don't add a "." here.
			containerClick: true, //Click slider to goto next slide? true/false
			autoStart: 0, //Set to positive number for true. This number will be the time between transitions.
			restart: 0, //Set to positive number for true. Sets time until autoStart is restarted.
			slidespeed: 600, //Speed of slide animation, 1000 = 1second.
			fadespeed: 200, //Speed of fade animation, 1000 = 1second.
			autoHeight: 0, //Set to positive number for true. This number will be the speed of the animation.
			addPagination: false, //Add pagination links based on content? true/false
			hoverpause: false  //Pause interval if mouse is hovering over the image
		};
	});
}

