

var j=1;(function(a){a.fn.easyListSplitter=function(g){var h={colNumber:2,direction:'vertical'};this.each(function(){var m=a(this);var b=a.extend(h,g);var k=a(this).children('li').size();var f=Math.ceil(k/b.colNumber);var l=a(this).attr('class');for(i=1;i<=b.colNumber;i++){if(i==1){a(this).addClass('listCol1').wrap('<div class="listContainer'+j+'"></div>')}else if(a(this).is('ul')){a(this).parents('.listContainer'+j).append('<ul class="listCol'+i+'"></ul>')}else{a(this).parents('.listContainer'+j).append('<ol class="listCol'+i+'"></ol>')}a('.listContainer'+j+' > ul,.listContainer'+j+' > ol').addClass(l)}var e=0;var d=1;var c=0;if(b.direction=='vertical'){a(this).children('li').each(function(){e=e+1;if(e>f*(b.colNumber-1)){a(this).parents('.listContainer'+j).find('.listCol'+b.colNumber).append(this)}else{if(e<=(f*d)){a(this).parents('.listContainer'+j).find('.listCol'+d).append(this)}else{a(this).parents('.listContainer'+j).find('.listCol'+(d+1)).append(this);d=d+1}}});a('.listContainer'+j).find('ol,ul').each(function(){if(a(this).children().size()==0){a(this).remove()}})}else{a(this).children('li').each(function(){c=c+1;if(c<=b.colNumber){a(this).parents('.listContainer'+j).find('.listCol'+c).append(this)}else{c=1;a(this).parents('.listContainer'+j).find('.listCol'+c).append(this)}})}a('.listContainer'+j).find('ol:last,ul:last').addClass('last');j=j+1})}})(jQuery);



(function(c,bk){var bd={transition:"elastic",speed:300,width:false,initialWidth:"600",innerWidth:false,maxWidth:false,height:false,initialHeight:"450",innerHeight:false,maxHeight:false,scalePhotos:true,scrolling:true,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:true,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,returnFocus:true,loop:true,slideshow:false,slideshowAuto:true,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false,overlayClose:true,escKey:true,arrowKey:true},u='colorbox',m='cbox',be=m+'_0',R=m+'_1',S=m+'_2',N=m+'_3',bf=m+'_4',O=m+'_5',bg=m+'_6',F=c.browser.msie&&!c.support.opacity,T=F&&c.browser.version<7,P=m+'_7',x,o,C,v,U,V,W,X,l,r,p,H,I,Y,Z,J,K,L,ba,D,E,y,z,q,j,a,w,G,Q=false,g,M=m+'Element';function h(b,f){b=b?' id="'+m+b+'"':'';f=f?' style="'+f+'"':'';return c('<div'+b+f+'/>')}function t(b,f){f=f==='x'?r.width():r.height();return(typeof b==='string')?Math.round((/%/.test(b)?(f/100)*parseInt(b,10):parseInt(b,10))):b}function bb(b){return a.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(b)}function bh(b){for(var f in b){if(c.isFunction(b[f])&&f.substring(0,2)!=='on'){b[f]=b[f].call(q)}}b.rel=b.rel||q.rel||'nofollow';b.href=b.href||c(q).attr('href');b.title=b.title||q.title;return b}function A(b,f){if(f){f.call(q)}c.event.trigger(b)}function bl(){var b,f=m+"Slideshow_",i="click."+m,k,n,d;if(a.slideshow&&l[1]){k=function(){J.text(a.slideshowStop).unbind(i).bind(S,function(){if(j<l.length-1||a.loop){b=setTimeout(g.next,a.slideshowSpeed)}}).bind(R,function(){clearTimeout(b)}).one(i+' '+N,n);o.removeClass(f+"off").addClass(f+"on");b=setTimeout(g.next,a.slideshowSpeed)};n=function(){clearTimeout(b);J.text(a.slideshowStart).unbind([S,R,N,i].join(' ')).one(i,k);o.removeClass(f+"on").addClass(f+"off")};if(a.slideshowAuto){k()}else{n()}}}function bi(f){if(!Q){q=f;a=bh(c.extend({},c.data(q,u)));l=c(q);j=0;if(a.rel!=='nofollow'){l=c('.'+M).filter(function(){var b=c.data(this,u).rel||this.rel;return(b===a.rel)});j=l.index(q);if(j===-1){l=l.add(q);j=l.length-1}}if(!w){w=G=true;o.show();if(a.returnFocus){try{q.blur();c(q).one(bf,function(){try{this.focus()}catch(e){}})}catch(e){}}x.css({"opacity":+a.opacity,"cursor":a.overlayClose?"pointer":"auto"}).show();a.w=t(a.initialWidth,'x');a.h=t(a.initialHeight,'y');g.position(0);if(T){r.bind('resize.'+P+' scroll.'+P,function(){x.css({width:r.width(),height:r.height(),top:r.scrollTop(),left:r.scrollLeft()})}).trigger('scroll.'+P)}A(be,a.onOpen);Z.add(L).add(K).add(J).add(Y).hide();ba.html(a.close).show()}g.load(true)}}g=c.fn[u]=c[u]=function(b,f){var i=this,k;if(!i[0]&&i.selector){return i}b=b||{};if(f){b.onComplete=f}if(!i[0]||i.selector===undefined){i=c('<a/>');b.open=true}i.each(function(){c.data(this,u,c.extend({},c.data(this,u)||bd,b));c(this).addClass(M)});k=b.open;if(c.isFunction(k)){k=k.call(i)}if(k){bi(i[0])}return i};g.init=function(){r=c(bk);o=h().attr({id:u,'class':F?m+'IE':''});x=h("Overlay",T?'position:absolute':'').hide();C=h("Wrapper");v=h("Content").append(p=h("LoadedContent",'width:0;height:0;overflow:hidden'),I=h("LoadingOverlay").add(h("LoadingGraphic")),Y=h("Title"),Z=h("Current"),K=h("Next"),L=h("Previous"),J=h("Slideshow").bind(be,bl),ba=h("Close"));C.append(h().append(h("TopLeft"),U=h("TopCenter"),h("TopRight")),h(false,'clear:left').append(V=h("MiddleLeft"),v,W=h("MiddleRight")),h(false,'clear:left').append(h("BottomLeft"),X=h("BottomCenter"),h("BottomRight"))).children().children().css({'float':'left'});H=h(false,'position:absolute; width:9999px; visibility:hidden; display:none');c('body').prepend(x,o.append(C,H));v.children().hover(function(){c(this).addClass('hover')},function(){c(this).removeClass('hover')}).addClass('hover');D=U.height()+X.height()+v.outerHeight(true)-v.height();E=V.width()+W.width()+v.outerWidth(true)-v.width();y=p.outerHeight(true);z=p.outerWidth(true);o.css({"padding-bottom":D,"padding-right":E}).hide();K.click(g.next);L.click(g.prev);ba.click(g.close);v.children().removeClass('hover');c('.'+M).live('click',function(b){if(!((b.button!==0&&typeof b.button!=='undefined')||b.ctrlKey||b.shiftKey||b.altKey)){b.preventDefault();bi(this)}});x.click(function(){if(a.overlayClose){g.close()}});c(document).bind("keydown",function(b){if(w&&a.escKey&&b.keyCode===27){b.preventDefault();g.close()}if(w&&a.arrowKey&&!G&&l[1]){if(b.keyCode===37&&(j||a.loop)){b.preventDefault();L.click()}else if(b.keyCode===39&&(j<l.length-1||a.loop)){b.preventDefault();K.click()}}})};g.remove=function(){o.add(x).remove();c('.'+M).die('click').removeData(u).removeClass(M)};g.position=function(f,i){var k,n=Math.max(document.documentElement.clientHeight-a.h-y-D,0)/2+r.scrollTop(),d=Math.max(r.width()-a.w-z-E,0)/2+r.scrollLeft();k=(o.width()===a.w+z&&o.height()===a.h+y)?0:f;C[0].style.width=C[0].style.height="9999px";function s(b){U[0].style.width=X[0].style.width=v[0].style.width=b.style.width;I[0].style.height=I[1].style.height=v[0].style.height=V[0].style.height=W[0].style.height=b.style.height}o.dequeue().animate({width:a.w+z,height:a.h+y,top:n,left:d},{duration:k,complete:function(){s(this);G=false;C[0].style.width=(a.w+z+E)+"px";C[0].style.height=(a.h+y+D)+"px";if(i){i()}},step:function(){s(this)}})};g.resize=function(b){if(w){b=b||{};if(b.width){a.w=t(b.width,'x')-z-E}if(b.innerWidth){a.w=t(b.innerWidth,'x')}p.css({width:a.w});if(b.height){a.h=t(b.height,'y')-y-D}if(b.innerHeight){a.h=t(b.innerHeight,'y')}if(!b.innerHeight&&!b.height){var f=p.wrapInner("<div style='overflow:auto'></div>").children();a.h=f.height();f.replaceWith(f.children())}p.css({height:a.h});g.position(a.transition==="none"?0:a.speed)}};g.prep=function(bm){if(!w){return}var bn,bc=a.transition==="none"?0:a.speed;r.unbind('resize.'+m);p.remove();p=h('LoadedContent').html(bm);function bo(){a.w=a.w||p.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}function bp(){a.h=a.h||p.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}p.hide().appendTo(H.show()).css({width:bo(),overflow:a.scrolling?'auto':'hidden'}).css({height:bp()}).prependTo(v);H.hide();c('#'+m+'Photo').css({cssFloat:'none',marginLeft:'auto',marginRight:'auto'});if(T){c('select').not(o.find('select')).filter(function(){return this.style.visibility!=='hidden'}).css({'visibility':'hidden'}).one(N,function(){this.style.visibility='inherit'})}function bj(f){var i,k,n,d,s=l.length,B=a.loop;g.position(f,function(){function b(){if(F){o[0].style.filter=false}}if(!w){return}if(F){if(bn){p.fadeIn(100)}}p.show();A(bg);Y.show().html(a.title);if(s>1){if(typeof a.current==="string"){Z.html(a.current.replace(/\{current\}/,j+1).replace(/\{total\}/,s)).show()}K[(B||j<s-1)?"show":"hide"]().html(a.next);L[(B||j)?"show":"hide"]().html(a.previous);i=j?l[j-1]:l[s-1];n=j<s-1?l[j+1]:l[0];if(a.slideshow){J.show()}if(a.preloading){d=c.data(n,u).href||n.href;k=c.data(i,u).href||i.href;d=c.isFunction(d)?d.call(n):d;k=c.isFunction(k)?k.call(i):k;if(bb(d)){c('<img/>')[0].src=d}if(bb(k)){c('<img/>')[0].src=k}}}I.hide();if(a.transition==='fade'){o.fadeTo(bc,1,function(){b()})}else{b()}r.bind('resize.'+m,function(){g.position(0)});A(S,a.onComplete)})}if(a.transition==='fade'){o.fadeTo(bc,0,function(){bj(0)})}else{bj(bc)}};g.load=function(k){var n,d,s,B=g.prep;G=true;q=l[j];if(!k){a=bh(c.extend({},c.data(q,u)))}A(O);A(R,a.onLoad);a.h=a.height?t(a.height,'y')-y-D:a.innerHeight&&t(a.innerHeight,'y');a.w=a.width?t(a.width,'x')-z-E:a.innerWidth&&t(a.innerWidth,'x');a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=t(a.maxWidth,'x')-z-E;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=t(a.maxHeight,'y')-y-D;a.mh=a.h&&a.h<a.mh?a.h:a.mh}n=a.href;I.show();if(a.inline){h().hide().insertBefore(c(n)[0]).one(O,function(){c(this).replaceWith(p.children())});B(c(n))}else if(a.iframe){o.one(bg,function(){var b=c("<iframe name='"+new Date().getTime()+"' frameborder=0"+(a.scrolling?"":" scrolling='no'")+(F?" allowtransparency='true'":'')+" style='width:100%; height:100%; border:0; display:block;'/>");b[0].src=a.href;b.appendTo(p).one(O,function(){b[0].src='//about:blank'})});B(" ")}else if(a.html){B(a.html)}else if(bb(n)){d=new Image();d.onload=function(){var b;d.onload=null;d.id=m+'Photo';c(d).css({border:'none',display:'block',cssFloat:'left'});if(a.scalePhotos){s=function(){d.height-=d.height*b;d.width-=d.width*b};if(a.mw&&d.width>a.mw){b=(d.width-a.mw)/d.width;s()}if(a.mh&&d.height>a.mh){b=(d.height-a.mh)/d.height;s()}if(!b){if(d.width<a.mw){b=(d.width-a.mw)/d.width;tw=d.width-(d.width*b);th=d.height-(d.height*b);if(tw<=a.mw&&th<=a.mh){s()}}if(d.height<a.mh){b=(d.height-a.mh)/d.height;tw=d.width-(d.width*b);th=d.height-(d.height*b);if(tw<=a.mw&&th<=a.mh){s()}}}}if(a.h){d.style.marginTop=Math.max(a.h-d.height,0)/2+'px'}if(l[1]&&(j<l.length-1||a.loop)){c(d).css({cursor:'pointer'}).click(g.next)}if(F){d.style.msInterpolationMode='bicubic'}setTimeout(function(){B(d)},1)};setTimeout(function(){d.src=n},1)}else if(n){H.load(n,function(b,f,i){B(f==='error'?'Request unsuccessful: '+i.statusText:c(this).children())})}};g.next=function(){if(!G){j=j<l.length-1?j+1:0;g.load()}};g.prev=function(){if(!G){j=j?j-1:l.length-1;g.load()}};g.close=function(){if(w&&!Q){Q=true;w=false;A(N,a.onCleanup);r.unbind('.'+m+' .'+P);x.fadeTo('fast',0);o.stop().fadeTo('fast',0,function(){A(O);p.remove();o.add(x).css({'opacity':1,cursor:'auto'}).hide();setTimeout(function(){Q=false;A(bf,a.onClosed)},1)})}};g.element=function(){return c(q)};g.settings=bd;c(g.init)}(jQuery,this));


(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);


(function($){

	//Finding min and max values in array from http://snippets.dzone.com/posts/show/769
	Array.prototype.min = function(){ return Math.min.apply({},this) };
	Array.prototype.max = function(){ return Math.max.apply({},this) };

	$.fn.masonry = function() {
		this.each(function() {

			var wall = $(this);

			if ( wall.children().length > 0 ) { // check if the element has anything in it

				if( wall.children('.masonryWrap').length == 0 ) {      // checks if the masonryWrap div is already there
					wall.wrapInner('<div class=\"masonryWrap\"></div>');
				}
				var mWrap = wall.children('.masonryWrap');

				var brick = mWrap.children();
				var brickW = brick.outerWidth(true);
				var colCount = Math.floor( mWrap.width() / brickW ) ;

				var colH=new Array();
				for ( i=0; i < colCount; i++) {
					colH[ i ] =  0 ;
				}

				mWrap.css({ position: 'relative' });

				brick.css({
						float: 'none',
						position: 'absolute',
						display: 'block'
					})
					.each(function(){
						for ( i=colCount-1; i > -1; i-- ) {
							if ( colH[ i ] == colH.min() ) {
								var thisCol = i;
							}
						}
						$(this).css({
							top: colH[ thisCol ],
							left: brickW * thisCol
						});
						colH[ thisCol ] += $(this).outerHeight(true);
					});

				mWrap.height( colH.max() );
			}

			return this;
		});
	};
})(jQuery);

// HTML Truncator for jQuery
// by Henrik Nyh <http://henrik.nyh.se> 2008-02-28.
// Free to modify and redistribute with credit.
(function($) {

  var trailing_whitespace = true;

  $.fn.truncate = function(options) {

    var opts = $.extend({}, $.fn.truncate.defaults, options);

    $(this).each(function() {

      var content_length = $.trim(squeeze($(this).text())).length;
      if (content_length <= opts.max_length)
        return;  // bail early if not overlong

      var actual_max_length = opts.max_length - opts.more.length - 3;  // 3 for " ()"
      var truncated_node = recursivelyTruncate(this, actual_max_length);
      var full_node = $(this).hide();

      truncated_node.insertAfter(full_node);

      findNodeForMore(truncated_node).append(' (<a href="#show more content">'+opts.more+'</a>)');
      findNodeForLess(full_node).append(' (<a href="#show less content">'+opts.less+'</a>)');

      truncated_node.find('a:last').click(function() {
        truncated_node.hide(); full_node.show(); return false;
      });
      full_node.find('a:last').click(function() {
        truncated_node.show(); full_node.hide(); return false;
      });

    });
  }
  // Note that the " (more)" bit counts towards the max length ��� so a max
  // length of 10 would truncate "1234567890" to "12 (��?more)".
  $.fn.truncate.defaults = {
    max_length: 100,
    more: 'more',
    less: 'less'
  };
  function recursivelyTruncate(node, max_length) {
    return (node.nodeType == 3) ? truncateText(node, max_length) : truncateNode(node, max_length);
  }
  function truncateNode(node, max_length) {
    var node = $(node);
    var new_node = node.clone().empty();
    var truncatedChild;
    node.contents().each(function() {
      var remaining_length = max_length - new_node.text().length;
      if (remaining_length == 0) return;  // breaks the loop
      truncatedChild = recursivelyTruncate(this, remaining_length);
      if (truncatedChild) new_node.append(truncatedChild);
    });
    return new_node;
  }
  function truncateText(node, max_length) {
    var text = squeeze(node.data);
    if (trailing_whitespace)  // remove initial whitespace if last text
      text = text.replace(/^ /, '');  // node had trailing whitespace.
    trailing_whitespace = !!text.match(/ $/);
    var text = text.slice(0, max_length);
    // Ensure HTML entities are encoded
    // http://debuggable.com/posts/encode-html-entities-with-jquery:480f4dd6-13cc-4ce9-8071-4710cbdd56cb
    text = $('<div/>').text(text).html();
    return text;
  }
  // Collapses a sequence of whitespace into a single space.
  function squeeze(string) {
    return string.replace(/\s+/g, ' ');
  }
  // Finds the last, innermost block-level element
  function findNodeForMore(node) {
    var $node = $(node);
    var last_child = $node.children(":last");
    if (!last_child) return node;
    var display = last_child.css('display');
    if (!display || display=='inline') return $node;
    return findNodeForMore(last_child);
  };
  // Finds the last child if it's a p; otherwise the parent
  function findNodeForLess(node) {
    var $node = $(node);
    var last_child = $node.children(":last");
    if (last_child && last_child.is('p')) return last_child;
    return node;
  };
})(jQuery);


jQuery.fn.rewImgSizer = function(options) {

	var $self = this;

	var defaults = {
		method: 'crop',
		scale: 1,
		align: 'center',
		effect: 'fadeIn',
		noUpScale: false,
		onBeforeShow: function(){},
		onAfterShow: function(){}
	};

	var options = $.extend(defaults, options);

	$self.resize = function ($img) {

	    $self.show();

		

		var pho_vsize = 1;
		var pho_hsize = 1;
		var pho_width = $img.width();
		var pho_heigh = $img.height();

		// Generate both to prevent square images
		pho_vsize = Math.round((pho_width / pho_heigh) * 100) / 100;
		pho_hsize = Math.round((pho_heigh / pho_width) * 100) / 100;

		

		$can = $img.parent();

		var can_vsize = 1;
		var can_hsize = 1;
		var can_width = $can.width();
		var can_heigh = $can.height();

		// Generate both to prevent square images
		can_vsize = Math.round((can_width / can_heigh) * 100) / 100;
		can_hsize = Math.round((can_heigh / can_width) * 100) / 100;


		
		oldmethod = options.method;

		if (options.noUpScale) {
			if(pho_width < can_width && pho_heigh < can_heigh) {
				options.method = 'none';
			}

		}

		
		//$img.attr('title', 'photo height=' + pho_hsize + '; photo width=' + pho_vsize + '; canvas height=' + can_hsize + '; canvas width=' + can_vsize);

		if (options.method == 'crop') {

			if (pho_hsize > can_hsize) {
				$img.width(can_width);
				$img.height($img.width() * pho_hsize);
			} else if (pho_vsize > can_vsize) {
				$img.height(can_heigh);
				$img.width($img.height() * pho_vsize);
			} else {
				// square 1:1
				$img.width(can_width);
				$img.height($img.width() * pho_hsize);
			}

		} else if (options.method == 'fit') {

			$img.height(can_heigh);
			$img.width(can_width);

		} else if (options.method == 'scale') {

			if (pho_hsize > can_hsize) {
				$img.height(can_heigh);
			} else if (pho_vsize > can_vsize) {
				$img.width(can_width);
			} else {
				// square 1:1
				if (can_hsize > can_vsize) {
					$img.width(can_width);
				} else {
					$img.height(can_heigh);
				}
			}

		} else {

			

		}

		
		if (options.scale) {
			sImgH = $img.height() * options.scale;
			sImgW = $img.width() * options.scale;
			$img.width(sImgW);
			$img.height(sImgH);
		}

		$img.css({position:'absolute', left: ''});

		switch (options.align) {

			case 'center':
    			$img.css('top', -($img.height() - can_heigh) / 2 + 'px');
    			$img.css('left', -($img.width() - can_width) / 2 + 'px');
			break;

			case 'top left':
    			$img.css({'top': 0, 'left': 0});
			break;

			case 'top center':
    			$img.css('top', 0);
    			$img.css('left', -($img.width() - can_width) / 2 + 'px');
			break;

			case 'top right':
    			$img.css('top', 0);
    			$img.css('right', 0);
			break;

			case 'center right':
    			$img.css('top', -($img.height() - can_heigh) / 2 + 'px');
    			$img.css('right', 0);
			break;

			case 'center left':
    			$img.css('top', -($img.height() - can_heigh) / 2 + 'px');
    			$img.css('left', 0);
			break;

			case 'bottom right':
    			$img.css('bottom', 0);
    			$img.css('right', 0);
			break;

			case 'bottom center':
    			$img.css('bottom', 0);
    			$img.css('left', -($img.width() - can_width) / 2 + 'px');
			break;

			case 'bottom left':
    			$img.css('bottom', 0);
    			$img.css('left', 0);
			break;

		}

		$img.hide();

		options.onBeforeShow.call(this);
		$img.fadeIn('slow', options.onAfterShow.call(this));

		options.method = oldmethod;

	};

    $self.getDimensions = function (el) {
        el.style.display = 'block';
        var width = el.naturalWidth;
        var height = el.naturalHeight;
        if (!width || !height) {
            // Ooops you are an IE user, let's fix it.
            var img = document.createElement('img');
            img.src = el.src;
            width = img.width;
            height = img.height;
        }
        return { width : width, height: height };
    }
    
    jQuery(this).each(function (i) {
        if (this.nodeType === 1 && this.tagName.toLowerCase() === 'img' && this.src !== '') {
            // Image is already complete (fixes browser issues were cached images isn't triggering the load event)
            var dimens = $self.getDimensions(this);
            if (this.complete || (dimens.width > 0 && dimens.height > 0)) {
                //console.log(dimens.width, 'x', dimens.height);
                $self.resize($(this));
            } else {
                $(this).bind('load', function () {
                    //var dimens = $self.getDimensions(this);
                    //console.log(dimens.width, 'x', dimens.height);
                    $self.resize($(this));
                });
            }
        }
        
        return;
        
    }); 

	// allow jQuery chaining
	return this;

};


(function($) {
    $.fn.splitList = function(options) {
        var defaults = { itemsPerColumn: 10 };
        var opts = $.extend($.fn.splitList.defaults, options);
        this.each(function() {
            var ul = this;
            var li = $(ul).children("li");
            $(ul).empty();
            for (var i = 0; i < opts.itemsPerColumn; i++) $(ul).append(li[i]);
            var curUl = ul;
            $(curUl).css("float", "left");
            for (var i = 1; i < li.length / opts.itemsPerColumn; i++) {
                var newUl = document.createElement("ul");
                for (var j = opts.itemsPerColumn * i; j < (opts.itemsPerColumn * i) + opts.itemsPerColumn; j++) $(newUl).append(li[j]);
                $(newUl).attr('class', $(curUl).attr('class')).css("float", "left");
                $(curUl).after(newUl);
                curUl = newUl;
            }
        });
    };
})(jQuery);


(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.scrollTo&&d.document){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j=
{top:b.of.pageY,left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/
2;if(b.at[1]==="bottom")j.top+=k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+parseInt(c.curCSS(this,"marginRight",true))||0,w=m+q+parseInt(c.curCSS(this,"marginBottom",true))||0,i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]===
"center")i.top-=m/2;i.left=parseInt(i.left);i.top=parseInt(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();
b.left=d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];
b.left+=a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=
c(b),g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery);

(function($) {

    
    $.facebox = function(options) {
        
        
        var $self = this;

        
        $self.defaults = {
            opacity      : 0.3,
            overlay      : true,
            modal        : true,
            noclose      : false,
            //
            div          : false,
            ajax         : false,
            image        : false,
            data         : false,
            iframe       : false,
            //
            title        : '&nbsp;',
            css_top      : 'auto', // auto or number of pixels
            css_left     : 'auto', // auto or number of pixels
            loadingImage : '/img/facebox/loading.gif',
            closeImage   : '/img/facebox/closelabel.gif',
            imageTypes   : [ 'png', 'jpg', 'jpeg', 'gif' ],
            faceboxHtml  : '\
                <div id="facebox" style="display:none;"> \
                    <div class="popup"> \
                        <table> \
                          <tbody> \
                            <tr> \
                              <td class="tl"/><td class="b"/><td class="tr"/> \
                            </tr> \
                            <tr> \
                              <td class="b"/> \
                              <td class="body"> \
                                <div class="titlebar"> \
                                  <span class="title">&nbsp;</span> \
                                  <a href="#" class="close">Close</a> \
                                </div> \
                                <div class="content"> \
                                </div> \
                              </td> \
                              <td class="b"/> \
                            </tr> \
                            <tr> \
                              <td class="bl"/><td class="b"/><td class="br"/> \
                            </tr> \
                          </tbody> \
                        </table> \
                      </div> \
                </div>'
        };

        
        $self.options = $.extend($self.defaults, options);

        
        $self.initilized = false;

        
        $self.makeCompatible = function () {
            $self.options.loadingImage = $self.options.loading_image || $self.options.loadingImage;
            $self.options.closeImage   = $self.options.close_image   || $self.options.closeImage;
            $self.options.imageTypes   = $self.options.image_types   || $self.options.imageTypes;
            $self.options.faceboxHtml  = $self.options.facebox_html  || $self.options.faceboxHtml;
        }

        
        $self.close = function () {
            $(document).unbind('close.facebox');
            $(document).unbind('keydown.facebox');
            $('#facebox').fadeOut(function() {
                $('#facebox .content').removeClass().addClass('content');
                $self.hideOverlay();
                $('#facebox .loading').remove();
            }).remove();
            return false;
        }

        
        $self.skipOverlay = function () {
            return $self.options.overlay == false || $self.options.opacity === null;
        }

        
        $self.showOverlay = function () {
            if ($self.skipOverlay()) return;
            if ($('#facebox_overlay').length == 0) {
                $("body").append('<div id="facebox_overlay" class="facebox_hide"></div>');
            }
            $('#facebox_overlay').hide().addClass("facebox_overlayBG").css('opacity', $self.options.opacity).click(function() {
                if ($self.options.modal != true) {
                    $self.close();
                }
            }).fadeIn(200);
            return false;
        }

        
        $self.hideOverlay = function () {
            if ($self.skipOverlay()) return;
            $('#facebox_overlay').fadeOut(200, function() {
                $("#facebox_overlay").removeClass("facebox_overlayBG");
                $("#facebox_overlay").addClass("facebox_hide");
                $("#facebox_overlay").remove();
            });
            return false;
        }

        
        $self.fillFaceboxFromHref = function (href) {

            // div
            if (href.match(/#/)) {
                var url    = window.location.href.split('#')[0];
                var target = href.replace(url, '');
                if (target == '#') return;
                $self.reveal($(target).html());

            // image
            } else if (href.match($self.options.imageTypesRegexp)) {
                $self.fillFaceboxFromImage(href);

            // ajax
            } else {
                $self.fillFaceboxFromAjax(href);

            }

        }

        
        $self.fillFaceboxFromImage = function (href) {
            var image = new Image();
            image.onload = function () {
                $self.reveal('<div class="image"><img src="' + image.src + '" /></div>');
            }
            image.src = href;
        }

        
        $self.fillFaceboxFromAjax = function (href) {
            $.get(href, function(data) {
                $self.reveal(data);
            });
        }

        
        $self.fillFaceboxFromIFrame = function (href) {
            
            
            var href = (href.indexOf('?') != -1) ? href + '&facebox_Frame=true' : href + '?facebox_Frame=false';

            
            $('#facebox-iframe').remove();
            
            
            href = href.replace(/\"/g, "'");
            var iframe = $('<iframe id="facebox-iframe" src="' + href + '" width="100%" height="100" frameborder="0" scrolling="no" style="overflow-x: hidden;" />');
            
            
            
            $self.reveal(iframe);

        }

        
        $self.reveal = function (data) {
            $('#facebox .content').append(data);
            $('#facebox .loading').remove();
            $('#facebox .body').children().fadeIn('normal');
            if ($self.options.noclose == true) {
                $('#facebox .titlebar a.close').hide();
            } else {
                $('#facebox .titlebar a.close').show();
            }
            $('#facebox').css('left', $(window).width() / 2 - ($('#facebox table').width() / 2));
        }

        
        $self.getPageScroll = function () {
            var xScroll, yScroll;
            if (self.pageYOffset) {
                yScroll = self.pageYOffset;
                xScroll = self.pageXOffset;
            } else if (document.documentElement && document.documentElement.scrollTop) {     // Explorer 6 Strict
                yScroll = document.documentElement.scrollTop;
                xScroll = document.documentElement.scrollLeft;
            } else if (document.body) {// all other Explorers
                yScroll = document.body.scrollTop;
                xScroll = document.body.scrollLeft;
            }
            return new Array(xScroll, yScroll);
        }

        
        $self.getPageHeight = function () {
            var windowHeight;
            if (self.innerHeight) { // all except Explorer
                windowHeight = self.innerHeight;
            } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowHeight = document.documentElement.clientHeight;
            } else if (document.body) { // other Explorers
                windowHeight = document.body.clientHeight;
            }
            return windowHeight;
        }

        
        $self.init = function () {

            
            if ($self.initilized) {
                return true;
            } else {
                $self.initilized = true;
            }

            
            $self.makeCompatible();

            var imageTypes = $self.options.imageTypes.join('|');
            $self.options.imageTypesRegexp = new RegExp('\.(' + imageTypes + ')$', 'i');

            
            $('body').append($self.options.faceboxHtml);

            
            var preload = [ new Image(), new Image() ];
            preload[0].src = $self.options.closeImage;
            preload[1].src = $self.options.loadingImage;

            
            $('#facebox').find('.b:first, .bl').each(function() {
                preload.push(new Image());
                preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1');
            });

            
            $('#facebox .close').click($self.close);
            $('#facebox .close_image').attr('src', $self.options.closeImage);

        }

        
        $self.loading = function() {

            $self.init();

            if ($('#facebox .loading').length == 1) return true;

            $self.showOverlay();

            $('#facebox .content').empty();
            $('#facebox .body').children().hide().end().
            append('<div class="loading"><img src="' + $self.options.loadingImage + '"/></div>')

            $('#facebox').css({
                top:    $self.options.css_top  != 'auto' ? $self.options.css_top  : $self.getPageScroll()[1] + ($self.getPageHeight() / 10),
                left:   $self.options.css_left != 'auto' ? $self.options.css_left : $(window).width() / 2 - 205
            }).show()

            if (typeof($self.options.title) != 'undefined') {
                $('#facebox .titlebar span.title').html($self.options.title);
            }

            if (typeof($self.options.width) != 'undefined') {
                $('#facebox .body').width($self.options.width);
            }

            if (typeof($self.options.height) != 'undefined') {
                $('#facebox .body').height($self.options.height);
            }

            $(document).bind('keydown.facebox', function(e) {
                if ($self.options.modal != true) {
                    if (e.keyCode == 27) {
                        $self.close();
                    }
                }
                return true;
            });
            
            $(document).bind('close.facebox', function(e) {
                $self.close();
            });

        }

        
        $self.init();

        
        $self.loading();

        
        if ($self.options.ajax) {
            $self.fillFaceboxFromAjax($self.options.ajax);

        
        } else if ($self.options.iframe) {
            $self.fillFaceboxFromIFrame($self.options.iframe);

        
        } else if ($self.options.image) {
            $self.fillFaceboxFromImage($self.options.image);

        
        } else if ($self.options.div) {
            $self.fillFaceboxFromHref($self.options.div);

        
        } else {
            $self.reveal($self.options.data);

        }

        
        return $self;

    };

})(jQuery);

(function(){function f(a,b){if(b)for(var c in b)if(b.hasOwnProperty(c))a[c]=b[c];return a}function l(a,b){var c=[];for(var d in a)if(a.hasOwnProperty(d))c[d]=b(a[d]);return c}function m(a,b,c){if(e.isSupported(b.version))a.innerHTML=e.getHTML(b,c);else if(b.expressInstall&&e.isSupported([6,65]))a.innerHTML=e.getHTML(f(b,{src:b.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title});else{if(!a.innerHTML.replace(/\s/g,"")){a.innerHTML="<h2>Flash version "+b.version+
" or greater is required</h2><h3>"+(g[0]>0?"Your version is "+g:"You have no flash plugin installed")+"</h3>"+(a.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+k+"'>here</a></p>");if(a.tagName=="A")a.onclick=function(){location.href=k}}if(b.onFail){var d=b.onFail.call(this);if(typeof d=="string")a.innerHTML=d}}if(i)window[b.id]=document.getElementById(b.id);f(this,{getRoot:function(){return a},getOptions:function(){return b},getConf:function(){return c},
getApi:function(){return a.firstChild}})}var i=document.all,k="http://www.adobe.com/go/getflashplayer",n=typeof jQuery=="function",o=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,j={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};window.attachEvent&&window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}});
window.flashembed=function(a,b,c){if(typeof a=="string")a=document.getElementById(a.replace("#",""));if(a){if(typeof b=="string")b={src:b};return new m(a,f(f({},j),b),c)}};var e=f(window.flashembed,{conf:j,getVersion:function(){var a,b;try{b=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(c){try{b=(a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"))&&a.GetVariable("$version")}catch(d){try{b=(a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"))&&a.GetVariable("$version")}catch(h){}}}return(b=
o.exec(b))?[b[1],b[3]]:[0,0]},asString:function(a){if(a===null||a===undefined)return null;var b=typeof a;if(b=="object"&&a.push)b="array";switch(b){case "string":a=a.replace(new RegExp('(["\\\\])',"g"),"\\$1");a=a.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+a+'"';case "array":return"["+l(a,function(d){return e.asString(d)}).join(",")+"]";case "function":return'"function()"';case "object":b=[];for(var c in a)a.hasOwnProperty(c)&&b.push('"'+c+'":'+e.asString(a[c]));return"{"+b.join(",")+"}"}return String(a).replace(/\s/g,
" ").replace(/\'/g,'"')},getHTML:function(a,b){a=f({},a);var c='<object width="'+a.width+'" height="'+a.height+'" id="'+a.id+'" name="'+a.id+'"';if(a.cachebusting)a.src+=(a.src.indexOf("?")!=-1?"&":"?")+Math.random();c+=a.w3c||!i?' data="'+a.src+'" type="application/x-shockwave-flash"':' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';c+=">";if(a.w3c||i)c+='<param name="movie" value="'+a.src+'" />';a.width=a.height=a.id=a.w3c=a.src=null;a.onFail=a.version=a.expressInstall=null;for(var d in a)if(a[d])c+=
'<param name="'+d+'" value="'+a[d]+'" />';a="";if(b){for(var h in b)if(b[h]){d=b[h];a+=h+"="+(/function|object/.test(typeof d)?e.asString(d):d)+"&"}a=a.slice(0,-1);c+='<param name="flashvars" value=\''+a+"' />"}c+="</object>";return c},isSupported:function(a){return g[0]>a[0]||g[0]==a[0]&&g[1]>=a[1]}}),g=e.getVersion();if(n){jQuery.tools=jQuery.tools||{version:"1.2.5"};jQuery.tools.flashembed={conf:j};jQuery.fn.flashembed=function(a,b){return this.each(function(){$(this).data("flashembed",flashembed(this,
a,b))})}}})();
(function(b){function h(c){if(c){var a=d.contentWindow.document;a.open().close();a.location.hash=c}}var g,d,f,i;b.tools=b.tools||{version:"1.2.5"};b.tools.history={init:function(c){if(!i){if(b.browser.msie&&b.browser.version<"8"){if(!d){d=b("<iframe/>").attr("src","javascript:false;").hide().get(0);b("body").append(d);setInterval(function(){var a=d.contentWindow.document;a=a.location.hash;g!==a&&b.event.trigger("hash",a)},100);h(location.hash||"#")}}else setInterval(function(){var a=location.hash;
a!==g&&b.event.trigger("hash",a)},100);f=!f?c:f.add(c);c.click(function(a){var e=b(this).attr("href");d&&h(e);if(e.slice(0,1)!="#"){location.href="#"+e;return a.preventDefault()}});i=true}}};b(window).bind("hash",function(c,a){a?f.filter(function(){var e=b(this).attr("href");return e==a||e==a.replace("#","")}).trigger("history",[a]):f.eq(0).trigger("history",[a]);g=a});b.fn.history=function(c){b.tools.history.init(this);return this.bind("history",c)}})(jQuery);
(function(b){function k(){if(b.browser.msie){var a=b(document).height(),d=b(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,a-d<20?d:a]}return[b(document).width(),b(document).height()]}function h(a){if(a)return a.call(b.mask)}b.tools=b.tools||{version:"1.2.5"};var l;l=b.tools.expose={conf:{maskId:"exposeMask",loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,startOpacity:0,color:"#fff",onLoad:null,
onClose:null}};var c,i,e,g,j;b.mask={load:function(a,d){if(e)return this;if(typeof a=="string")a={color:a};a=a||g;g=a=b.extend(b.extend({},l.conf),a);c=b("#"+a.maskId);if(!c.length){c=b("<div/>").attr("id",a.maskId);b("body").append(c)}var m=k();c.css({position:"absolute",top:0,left:0,width:m[0],height:m[1],display:"none",opacity:a.startOpacity,zIndex:a.zIndex});a.color&&c.css("backgroundColor",a.color);if(h(a.onBeforeLoad)===false)return this;a.closeOnEsc&&b(document).bind("keydown.mask",function(f){f.keyCode==
27&&b.mask.close(f)});a.closeOnClick&&c.bind("click.mask",function(f){b.mask.close(f)});b(window).bind("resize.mask",function(){b.mask.fit()});if(d&&d.length){j=d.eq(0).css("zIndex");b.each(d,function(){var f=b(this);/relative|absolute|fixed/i.test(f.css("position"))||f.css("position","relative")});i=d.css({zIndex:Math.max(a.zIndex+1,j=="auto"?0:j)})}c.css({display:"block"}).fadeTo(a.loadSpeed,a.opacity,function(){b.mask.fit();h(a.onLoad);e="full"});e=true;return this},close:function(){if(e){if(h(g.onBeforeClose)===
false)return this;c.fadeOut(g.closeSpeed,function(){h(g.onClose);i&&i.css({zIndex:j});e=false});b(document).unbind("keydown.mask");c.unbind("click.mask");b(window).unbind("resize.mask")}return this},fit:function(){if(e){var a=k();c.css({width:a[0],height:a[1]})}},getMask:function(){return c},isLoaded:function(a){return a?e=="full":e},getConf:function(){return g},getExposed:function(){return i}};b.fn.mask=function(a){b.mask.load(a);return this};b.fn.expose=function(a){b.mask.load(a,this);return this}})(jQuery);
(function(b){function c(a){switch(a.type){case "mousemove":return b.extend(a.data,{clientX:a.clientX,clientY:a.clientY,pageX:a.pageX,pageY:a.pageY});case "DOMMouseScroll":b.extend(a,a.data);a.delta=-a.detail/3;break;case "mousewheel":a.delta=a.wheelDelta/120;break}a.type="wheel";return b.event.handle.call(this,a,a.delta)}b.fn.mousewheel=function(a){return this[a?"bind":"trigger"]("wheel",a)};b.event.special.wheel={setup:function(){b.event.add(this,d,c,{})},teardown:function(){b.event.remove(this,
d,c)}};var d=!b.browser.mozilla?"mousewheel":"DOMMouseScroll"+(b.browser.version<"1.9"?" mousemove":"")})(jQuery);
(function(c){function p(d,b,a){var e=this,l=d.add(this),h=d.find(a.tabs),i=b.jquery?b:d.children(b),j;h.length||(h=d.children());i.length||(i=d.parent().find(b));i.length||(i=c(b));c.extend(this,{click:function(f,g){var k=h.eq(f);if(typeof f=="string"&&f.replace("#","")){k=h.filter("[href*="+f.replace("#","")+"]");f=Math.max(h.index(k),0)}if(a.rotate){var n=h.length-1;if(f<0)return e.click(n,g);if(f>n)return e.click(0,g)}if(!k.length){if(j>=0)return e;f=a.initialIndex;k=h.eq(f)}if(f===j)return e;
g=g||c.Event();g.type="onBeforeClick";l.trigger(g,[f]);if(!g.isDefaultPrevented()){o[a.effect].call(e,f,function(){g.type="onClick";l.trigger(g,[f])});j=f;h.removeClass(a.current);k.addClass(a.current);return e}},getConf:function(){return a},getTabs:function(){return h},getPanes:function(){return i},getCurrentPane:function(){return i.eq(j)},getCurrentTab:function(){return h.eq(j)},getIndex:function(){return j},next:function(){return e.click(j+1)},prev:function(){return e.click(j-1)},destroy:function(){h.unbind(a.event).removeClass(a.current);
i.find("a[href^=#]").unbind("click.T");return e}});c.each("onBeforeClick,onClick".split(","),function(f,g){c.isFunction(a[g])&&c(e).bind(g,a[g]);e[g]=function(k){k&&c(e).bind(g,k);return e}});if(a.history&&c.fn.history){c.tools.history.init(h);a.event="history"}h.each(function(f){c(this).bind(a.event,function(g){e.click(f,g);return g.preventDefault()})});i.find("a[href^=#]").bind("click.T",function(f){e.click(c(this).attr("href"),f)});if(location.hash&&a.tabs=="a"&&d.find("[href="+location.hash+"]").length)e.click(location.hash);
else if(a.initialIndex===0||a.initialIndex>0)e.click(a.initialIndex)}c.tools=c.tools||{version:"1.2.5"};c.tools.tabs={conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",rotate:false,history:false},addEffect:function(d,b){o[d]=b}};var o={"default":function(d,b){this.getPanes().hide().eq(d).show();b.call()},fade:function(d,b){var a=this.getConf(),e=a.fadeOutSpeed,l=this.getPanes();e?l.fadeOut(e):l.hide();l.eq(d).fadeIn(a.fadeInSpeed,b)},slide:function(d,
b){this.getPanes().slideUp(200);this.getPanes().eq(d).slideDown(400,b)},ajax:function(d,b){this.getPanes().eq(0).load(this.getTabs().eq(d).attr("href"),b)}},m;c.tools.tabs.addEffect("horizontal",function(d,b){m||(m=this.getPanes().eq(0).width());this.getCurrentPane().animate({width:0},function(){c(this).hide()});this.getPanes().eq(d).animate({width:m},function(){c(this).show();b.call()})});c.fn.tabs=function(d,b){var a=this.data("tabs");if(a){a.destroy();this.removeData("tabs")}if(c.isFunction(b))b=
{onBeforeClick:b};b=c.extend({},c.tools.tabs.conf,b);this.each(function(){a=new p(c(this),d,b);c(this).data("tabs",a)});return b.api?a:this}})(jQuery);
(function(c){function p(g,a){function m(f){var e=c(f);return e.length<2?e:g.parent().find(f)}var b=this,i=g.add(this),d=g.data("tabs"),h,j=true,n=m(a.next).click(function(){d.next()}),k=m(a.prev).click(function(){d.prev()});c.extend(b,{getTabs:function(){return d},getConf:function(){return a},play:function(){if(h)return b;var f=c.Event("onBeforePlay");i.trigger(f);if(f.isDefaultPrevented())return b;h=setInterval(d.next,a.interval);j=false;i.trigger("onPlay");return b},pause:function(){if(!h)return b;
var f=c.Event("onBeforePause");i.trigger(f);if(f.isDefaultPrevented())return b;h=clearInterval(h);i.trigger("onPause");return b},stop:function(){b.pause();j=true}});c.each("onBeforePlay,onPlay,onBeforePause,onPause".split(","),function(f,e){c.isFunction(a[e])&&c(b).bind(e,a[e]);b[e]=function(q){return c(b).bind(e,q)}});a.autopause&&d.getTabs().add(n).add(k).add(d.getPanes()).hover(b.pause,function(){j||b.play()});a.autoplay&&b.play();a.clickable&&d.getPanes().click(function(){d.next()});if(!d.getConf().rotate){var l=
a.disabledClass;d.getIndex()||k.addClass(l);d.onBeforeClick(function(f,e){k.toggleClass(l,!e);n.toggleClass(l,e==d.getTabs().length-1)})}}var o;o=c.tools.tabs.slideshow={conf:{next:".forward",prev:".backward",disabledClass:"disabled",autoplay:false,autopause:true,interval:3E3,clickable:true,api:false}};c.fn.slideshow=function(g){var a=this.data("slideshow");if(a)return a;g=c.extend({},o.conf,g);this.each(function(){a=new p(c(this),g);c(this).data("slideshow",a)});return g.api?a:this}})(jQuery);
(function(f){function p(a,b,c){var h=c.relative?a.position().top:a.offset().top,d=c.relative?a.position().left:a.offset().left,i=c.position[0];h-=b.outerHeight()-c.offset[0];d+=a.outerWidth()+c.offset[1];if(/iPad/i.test(navigator.userAgent))h-=f(window).scrollTop();var j=b.outerHeight()+a.outerHeight();if(i=="center")h+=j/2;if(i=="bottom")h+=j;i=c.position[1];a=b.outerWidth()+a.outerWidth();if(i=="center")d-=a/2;if(i=="left")d-=a;return{top:h,left:d}}function u(a,b){var c=this,h=a.add(c),d,i=0,j=
0,m=a.attr("title"),q=a.attr("data-tooltip"),r=o[b.effect],l,s=a.is(":input"),v=s&&a.is(":checkbox, :radio, select, :button, :submit"),t=a.attr("type"),k=b.events[t]||b.events[s?v?"widget":"input":"def"];if(!r)throw'Nonexistent effect "'+b.effect+'"';k=k.split(/,\s*/);if(k.length!=2)throw"Tooltip: bad events configuration for "+t;a.bind(k[0],function(e){clearTimeout(i);if(b.predelay)j=setTimeout(function(){c.show(e)},b.predelay);else c.show(e)}).bind(k[1],function(e){clearTimeout(j);if(b.delay)i=
setTimeout(function(){c.hide(e)},b.delay);else c.hide(e)});if(m&&b.cancelDefault){a.removeAttr("title");a.data("title",m)}f.extend(c,{show:function(e){if(!d){if(q)d=f(q);else if(b.tip)d=f(b.tip).eq(0);else if(m)d=f(b.layout).addClass(b.tipClass).appendTo(document.body).hide().append(m);else{d=a.next();d.length||(d=a.parent().next())}if(!d.length)throw"Cannot find tooltip for "+a;}if(c.isShown())return c;d.stop(true,true);var g=p(a,d,b);b.tip&&d.html(a.data("title"));e=e||f.Event();e.type="onBeforeShow";
h.trigger(e,[g]);if(e.isDefaultPrevented())return c;g=p(a,d,b);d.css({position:"absolute",top:g.top,left:g.left});l=true;r[0].call(c,function(){e.type="onShow";l="full";h.trigger(e)});g=b.events.tooltip.split(/,\s*/);if(!d.data("__set")){d.bind(g[0],function(){clearTimeout(i);clearTimeout(j)});g[1]&&!a.is("input:not(:checkbox, :radio), textarea")&&d.bind(g[1],function(n){n.relatedTarget!=a[0]&&a.trigger(k[1].split(" ")[0])});d.data("__set",true)}return c},hide:function(e){if(!d||!c.isShown())return c;
e=e||f.Event();e.type="onBeforeHide";h.trigger(e);if(!e.isDefaultPrevented()){l=false;o[b.effect][1].call(c,function(){e.type="onHide";h.trigger(e)});return c}},isShown:function(e){return e?l=="full":l},getConf:function(){return b},getTip:function(){return d},getTrigger:function(){return a}});f.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(e,g){f.isFunction(b[g])&&f(c).bind(g,b[g]);c[g]=function(n){n&&f(c).bind(g,n);return c}})}f.tools=f.tools||{version:"1.2.5"};f.tools.tooltip=
{conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,position:["top","center"],offset:[0,0],relative:false,cancelDefault:true,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,b,c){o[a]=[b,c]}};var o={toggle:[function(a){var b=this.getConf(),c=this.getTip();b=b.opacity;b<1&&c.css({opacity:b});c.show();a.call()},function(a){this.getTip().hide();
a.call()}],fade:[function(a){var b=this.getConf();this.getTip().fadeTo(b.fadeInSpeed,b.opacity,a)},function(a){this.getTip().fadeOut(this.getConf().fadeOutSpeed,a)}]};f.fn.tooltip=function(a){var b=this.data("tooltip");if(b)return b;a=f.extend(true,{},f.tools.tooltip.conf,a);if(typeof a.position=="string")a.position=a.position.split(/,?\s/);this.each(function(){b=new u(f(this),a);f(this).data("tooltip",b)});return a.api?b:this}})(jQuery);
(function(d){var i=d.tools.tooltip;d.extend(i.conf,{direction:"up",bounce:false,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!d.browser.msie});var e={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};i.addEffect("slide",function(g){var a=this.getConf(),f=this.getTip(),b=a.slideFade?{opacity:a.opacity}:{},c=e[a.direction]||e.up;b[c[1]]=c[0]+"="+a.slideOffset;a.slideFade&&f.css({opacity:0});f.show().animate(b,a.slideInSpeed,g)},function(g){var a=this.getConf(),f=a.slideOffset,
b=a.slideFade?{opacity:0}:{},c=e[a.direction]||e.up,h=""+c[0];if(a.bounce)h=h=="+"?"-":"+";b[c[1]]=h+"="+f;this.getTip().animate(b,a.slideOutSpeed,function(){d(this).hide();g.call()})})})(jQuery);
(function(g){function j(a){var c=g(window),d=c.width()+c.scrollLeft(),h=c.height()+c.scrollTop();return[a.offset().top<=c.scrollTop(),d<=a.offset().left+a.width(),h<=a.offset().top+a.height(),c.scrollLeft()>=a.offset().left]}function k(a){for(var c=a.length;c--;)if(a[c])return false;return true}var i=g.tools.tooltip;i.dynamic={conf:{classNames:"top right bottom left"}};g.fn.dynamic=function(a){if(typeof a=="number")a={speed:a};a=g.extend({},i.dynamic.conf,a);var c=a.classNames.split(/\s/),d;this.each(function(){var h=
g(this).tooltip().onBeforeShow(function(e,f){e=this.getTip();var b=this.getConf();d||(d=[b.position[0],b.position[1],b.offset[0],b.offset[1],g.extend({},b)]);g.extend(b,d[4]);b.position=[d[0],d[1]];b.offset=[d[2],d[3]];e.css({visibility:"hidden",position:"absolute",top:f.top,left:f.left}).show();f=j(e);if(!k(f)){if(f[2]){g.extend(b,a.top);b.position[0]="top";e.addClass(c[0])}if(f[3]){g.extend(b,a.right);b.position[1]="right";e.addClass(c[1])}if(f[0]){g.extend(b,a.bottom);b.position[0]="bottom";e.addClass(c[2])}if(f[1]){g.extend(b,
a.left);b.position[1]="left";e.addClass(c[3])}if(f[0]||f[2])b.offset[0]*=-1;if(f[1]||f[3])b.offset[1]*=-1}e.css({visibility:"visible"}).hide()});h.onBeforeShow(function(){var e=this.getConf();this.getTip();setTimeout(function(){e.position=[d[0],d[1]];e.offset=[d[2],d[3]]},0)});h.onHide(function(){var e=this.getTip();e.removeClass(a.classNames)});ret=h});return a.api?ret:this}})(jQuery);
(function(e){function p(f,c){var b=e(c);return b.length<2?b:f.parent().find(c)}function u(f,c){var b=this,n=f.add(b),g=f.children(),l=0,j=c.vertical;k||(k=b);if(g.length>1)g=e(c.items,f);e.extend(b,{getConf:function(){return c},getIndex:function(){return l},getSize:function(){return b.getItems().size()},getNaviButtons:function(){return o.add(q)},getRoot:function(){return f},getItemWrap:function(){return g},getItems:function(){return g.children(c.item).not("."+c.clonedClass)},move:function(a,d){return b.seekTo(l+
a,d)},next:function(a){return b.move(1,a)},prev:function(a){return b.move(-1,a)},begin:function(a){return b.seekTo(0,a)},end:function(a){return b.seekTo(b.getSize()-1,a)},focus:function(){return k=b},addItem:function(a){a=e(a);if(c.circular){g.children("."+c.clonedClass+":last").before(a);g.children("."+c.clonedClass+":first").replaceWith(a.clone().addClass(c.clonedClass))}else g.append(a);n.trigger("onAddItem",[a]);return b},seekTo:function(a,d,h){a.jquery||(a*=1);if(c.circular&&a===0&&l==-1&&d!==
0)return b;if(!c.circular&&a<0||a>b.getSize()||a<-1)return b;var i=a;if(a.jquery)a=b.getItems().index(a);else i=b.getItems().eq(a);var r=e.Event("onBeforeSeek");if(!h){n.trigger(r,[a,d]);if(r.isDefaultPrevented()||!i.length)return b}i=j?{top:-i.position().top}:{left:-i.position().left};l=a;k=b;if(d===undefined)d=c.speed;g.animate(i,d,c.easing,h||function(){n.trigger("onSeek",[a])});return b}});e.each(["onBeforeSeek","onSeek","onAddItem"],function(a,d){e.isFunction(c[d])&&e(b).bind(d,c[d]);b[d]=function(h){h&&
e(b).bind(d,h);return b}});if(c.circular){var s=b.getItems().slice(-1).clone().prependTo(g),t=b.getItems().eq(1).clone().appendTo(g);s.add(t).addClass(c.clonedClass);b.onBeforeSeek(function(a,d,h){if(!a.isDefaultPrevented())if(d==-1){b.seekTo(s,h,function(){b.end(0)});return a.preventDefault()}else d==b.getSize()&&b.seekTo(t,h,function(){b.begin(0)})});b.seekTo(0,0,function(){})}var o=p(f,c.prev).click(function(){b.prev()}),q=p(f,c.next).click(function(){b.next()});if(!c.circular&&b.getSize()>1){b.onBeforeSeek(function(a,
d){setTimeout(function(){if(!a.isDefaultPrevented()){o.toggleClass(c.disabledClass,d<=0);q.toggleClass(c.disabledClass,d>=b.getSize()-1)}},1)});c.initialIndex||o.addClass(c.disabledClass)}c.mousewheel&&e.fn.mousewheel&&f.mousewheel(function(a,d){if(c.mousewheel){b.move(d<0?1:-1,c.wheelSpeed||50);return false}});if(c.touch){var m={};g[0].ontouchstart=function(a){a=a.touches[0];m.x=a.clientX;m.y=a.clientY};g[0].ontouchmove=function(a){if(a.touches.length==1&&!g.is(":animated")){var d=a.touches[0],h=
m.x-d.clientX;d=m.y-d.clientY;b[j&&d>0||!j&&h>0?"next":"prev"]();a.preventDefault()}}}c.keyboard&&e(document).bind("keydown.scrollable",function(a){if(!(!c.keyboard||a.altKey||a.ctrlKey||e(a.target).is(":input")))if(!(c.keyboard!="static"&&k!=b)){var d=a.keyCode;if(j&&(d==38||d==40)){b.move(d==38?-1:1);return a.preventDefault()}if(!j&&(d==37||d==39)){b.move(d==37?-1:1);return a.preventDefault()}}});c.initialIndex&&b.seekTo(c.initialIndex,0,function(){})}e.tools=e.tools||{version:"1.2.5"};e.tools.scrollable=
{conf:{activeClass:"active",circular:false,clonedClass:"cloned",disabledClass:"disabled",easing:"swing",initialIndex:0,item:null,items:".items",keyboard:true,mousewheel:false,next:".next",prev:".prev",speed:400,vertical:false,touch:true,wheelSpeed:0}};var k;e.fn.scrollable=function(f){var c=this.data("scrollable");if(c)return c;f=e.extend({},e.tools.scrollable.conf,f);this.each(function(){c=new u(e(this),f);e(this).data("scrollable",c)});return f.api?c:this}})(jQuery);
(function(b){var f=b.tools.scrollable;f.autoscroll={conf:{autoplay:true,interval:3E3,autopause:true}};b.fn.autoscroll=function(c){if(typeof c=="number")c={interval:c};var d=b.extend({},f.autoscroll.conf,c),g;this.each(function(){var a=b(this).data("scrollable");if(a)g=a;var e,h=true;a.play=function(){if(!e){h=false;e=setInterval(function(){a.next()},d.interval)}};a.pause=function(){e=clearInterval(e)};a.stop=function(){a.pause();h=true};d.autopause&&a.getRoot().add(a.getNaviButtons()).hover(a.pause,
a.play);d.autoplay&&a.play()});return d.api?g:this}})(jQuery);
(function(d){function p(b,g){var h=d(g);return h.length<2?h:b.parent().find(g)}var m=d.tools.scrollable;m.navigator={conf:{navi:".navi",naviItem:null,activeClass:"active",indexed:false,idPrefix:null,history:false}};d.fn.navigator=function(b){if(typeof b=="string")b={navi:b};b=d.extend({},m.navigator.conf,b);var g;this.each(function(){function h(a,c,i){e.seekTo(c);if(j){if(location.hash)location.hash=a.attr("href").replace("#","")}else return i.preventDefault()}function f(){return k.find(b.naviItem||
"> *")}function n(a){var c=d("<"+(b.naviItem||"a")+"/>").click(function(i){h(d(this),a,i)}).attr("href","#"+a);a===0&&c.addClass(l);b.indexed&&c.text(a+1);b.idPrefix&&c.attr("id",b.idPrefix+a);return c.appendTo(k)}function o(a,c){a=f().eq(c.replace("#",""));a.length||(a=f().filter("[href="+c+"]"));a.click()}var e=d(this).data("scrollable"),k=b.navi.jquery?b.navi:p(e.getRoot(),b.navi),q=e.getNaviButtons(),l=b.activeClass,j=b.history&&d.fn.history;if(e)g=e;e.getNaviButtons=function(){return q.add(k)};
f().length?f().each(function(a){d(this).click(function(c){h(d(this),a,c)})}):d.each(e.getItems(),function(a){n(a)});e.onBeforeSeek(function(a,c){setTimeout(function(){if(!a.isDefaultPrevented()){var i=f().eq(c);!a.isDefaultPrevented()&&i.length&&f().removeClass(l).eq(c).addClass(l)}},1)});e.onAddItem(function(a,c){c=n(e.getItems().index(c));j&&c.history(o)});j&&f().history(o)});return b.api?g:this}})(jQuery);
(function(a){function t(d,b){var c=this,j=d.add(c),o=a(window),k,f,m,g=a.tools.expose&&(b.mask||b.expose),n=Math.random().toString().slice(10);if(g){if(typeof g=="string")g={color:g};g.closeOnClick=g.closeOnEsc=false}var p=b.target||d.attr("rel");f=p?a(p):d;if(!f.length)throw"Could not find Overlay: "+p;d&&d.index(f)==-1&&d.click(function(e){c.load(e);return e.preventDefault()});a.extend(c,{load:function(e){if(c.isOpened())return c;var h=q[b.effect];if(!h)throw'Overlay: cannot find effect : "'+b.effect+
'"';b.oneInstance&&a.each(s,function(){this.close(e)});e=e||a.Event();e.type="onBeforeLoad";j.trigger(e);if(e.isDefaultPrevented())return c;m=true;g&&a(f).expose(g);var i=b.top,r=b.left,u=f.outerWidth({margin:true}),v=f.outerHeight({margin:true});if(typeof i=="string")i=i=="center"?Math.max((o.height()-v)/2,0):parseInt(i,10)/100*o.height();if(r=="center")r=Math.max((o.width()-u)/2,0);h[0].call(c,{top:i,left:r},function(){if(m){e.type="onLoad";j.trigger(e)}});g&&b.closeOnClick&&a.mask.getMask().one("click",
c.close);b.closeOnClick&&a(document).bind("click."+n,function(l){a(l.target).parents(f).length||c.close(l)});b.closeOnEsc&&a(document).bind("keydown."+n,function(l){l.keyCode==27&&c.close(l)});return c},close:function(e){if(!c.isOpened())return c;e=e||a.Event();e.type="onBeforeClose";j.trigger(e);if(!e.isDefaultPrevented()){m=false;q[b.effect][1].call(c,function(){e.type="onClose";j.trigger(e)});a(document).unbind("click."+n).unbind("keydown."+n);g&&a.mask.close();return c}},getOverlay:function(){return f},
getTrigger:function(){return d},getClosers:function(){return k},isOpened:function(){return m},getConf:function(){return b}});a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(e,h){a.isFunction(b[h])&&a(c).bind(h,b[h]);c[h]=function(i){i&&a(c).bind(h,i);return c}});k=f.find(b.close||".close");if(!k.length&&!b.close){k=a('<a class="close"></a>');f.prepend(k)}k.click(function(e){c.close(e)});b.load&&c.load()}a.tools=a.tools||{version:"1.2.5"};a.tools.overlay={addEffect:function(d,
b,c){q[d]=[b,c]},conf:{close:null,closeOnClick:true,closeOnEsc:true,closeSpeed:"fast",effect:"default",fixed:!a.browser.msie||a.browser.version>6,left:"center",load:false,mask:null,oneInstance:true,speed:"normal",target:null,top:"10%"}};var s=[],q={};a.tools.overlay.addEffect("default",function(d,b){var c=this.getConf(),j=a(window);if(!c.fixed){d.top+=j.scrollTop();d.left+=j.scrollLeft()}d.position=c.fixed?"fixed":"absolute";this.getOverlay().css(d).fadeIn(c.speed,b)},function(d){this.getOverlay().fadeOut(this.getConf().closeSpeed,
d)});a.fn.overlay=function(d){var b=this.data("overlay");if(b)return b;if(a.isFunction(d))d={onBeforeLoad:d};d=a.extend(true,{},a.tools.overlay.conf,d);this.each(function(){b=new t(a(this),d);s.push(b);a(this).data("overlay",b)});return d.api?b:this}})(jQuery);
(function(h){function k(d){var e=d.offset();return{top:e.top+d.height()/2,left:e.left+d.width()/2}}var l=h.tools.overlay,f=h(window);h.extend(l.conf,{start:{top:null,left:null},fadeInSpeed:"fast",zIndex:9999});function o(d,e){var a=this.getOverlay(),c=this.getConf(),g=this.getTrigger(),p=this,m=a.outerWidth({margin:true}),b=a.data("img"),n=c.fixed?"fixed":"absolute";if(!b){b=a.css("backgroundImage");if(!b)throw"background-image CSS property not set for overlay";b=b.slice(b.indexOf("(")+1,b.indexOf(")")).replace(/\"/g,
"");a.css("backgroundImage","none");b=h('<img src="'+b+'"/>');b.css({border:0,display:"none"}).width(m);h("body").append(b);a.data("img",b)}var i=c.start.top||Math.round(f.height()/2),j=c.start.left||Math.round(f.width()/2);if(g){g=k(g);i=g.top;j=g.left}if(c.fixed){i-=f.scrollTop();j-=f.scrollLeft()}else{d.top+=f.scrollTop();d.left+=f.scrollLeft()}b.css({position:"absolute",top:i,left:j,width:0,zIndex:c.zIndex}).show();d.position=n;a.css(d);b.animate({top:a.css("top"),left:a.css("left"),width:m},
c.speed,function(){a.css("zIndex",c.zIndex+1).fadeIn(c.fadeInSpeed,function(){p.isOpened()&&!h(this).index(a)?e.call():a.hide()})}).css("position",n)}function q(d){var e=this.getOverlay().hide(),a=this.getConf(),c=this.getTrigger();e=e.data("img");var g={top:a.start.top,left:a.start.left,width:0};c&&h.extend(g,k(c));a.fixed&&e.css({position:"absolute"}).animate({top:"+="+f.scrollTop(),left:"+="+f.scrollLeft()},0);e.animate(g,a.closeSpeed,d)}l.addEffect("apple",o,q)})(jQuery);
(function(d){function R(a,c){return 32-(new Date(a,c,32)).getDate()}function S(a,c){a=""+a;for(c=c||2;a.length<c;)a="0"+a;return a}function T(a,c,j){var q=a.getDate(),h=a.getDay(),r=a.getMonth();a=a.getFullYear();var f={d:q,dd:S(q),ddd:B[j].shortDays[h],dddd:B[j].days[h],m:r+1,mm:S(r+1),mmm:B[j].shortMonths[r],mmmm:B[j].months[r],yy:String(a).slice(2),yyyy:a};c=c.replace(X,function(s){return s in f?f[s]:s.slice(1,s.length-1)});return Y.html(c).html()}function v(a){return parseInt(a,10)}function U(a,
c){return a.getFullYear()===c.getFullYear()&&a.getMonth()==c.getMonth()&&a.getDate()==c.getDate()}function C(a){if(a){if(a.constructor==Date)return a;if(typeof a=="string"){var c=a.split("-");if(c.length==3)return new Date(v(c[0]),v(c[1])-1,v(c[2]));if(!/^-?\d+$/.test(a))return;a=v(a)}c=new Date;c.setDate(c.getDate()+a);return c}}function Z(a,c){function j(b,e,g){n=b;D=b.getFullYear();E=b.getMonth();G=b.getDate();g=g||d.Event("api");g.type="change";H.trigger(g,[b]);if(!g.isDefaultPrevented()){a.val(T(b,
e.format,e.lang));a.data("date",b);h.hide(g)}}function q(b){b.type="onShow";H.trigger(b);d(document).bind("keydown.d",function(e){if(e.ctrlKey)return true;var g=e.keyCode;if(g==8){a.val("");return h.hide(e)}if(g==27)return h.hide(e);if(d(V).index(g)>=0){if(!w){h.show(e);return e.preventDefault()}var i=d("#"+f.weeks+" a"),t=d("."+f.focus),o=i.index(t);t.removeClass(f.focus);if(g==74||g==40)o+=7;else if(g==75||g==38)o-=7;else if(g==76||g==39)o+=1;else if(g==72||g==37)o-=1;if(o>41){h.addMonth();t=d("#"+
f.weeks+" a:eq("+(o-42)+")")}else if(o<0){h.addMonth(-1);t=d("#"+f.weeks+" a:eq("+(o+42)+")")}else t=i.eq(o);t.addClass(f.focus);return e.preventDefault()}if(g==34)return h.addMonth();if(g==33)return h.addMonth(-1);if(g==36)return h.today();if(g==13)d(e.target).is("select")||d("."+f.focus).click();return d([16,17,18,9]).index(g)>=0});d(document).bind("click.d",function(e){var g=e.target;if(!d(g).parents("#"+f.root).length&&g!=a[0]&&(!L||g!=L[0]))h.hide(e)})}var h=this,r=new Date,f=c.css,s=B[c.lang],
k=d("#"+f.root),M=k.find("#"+f.title),L,I,J,D,E,G,n=a.attr("data-value")||c.value||a.val(),m=a.attr("min")||c.min,p=a.attr("max")||c.max,w;if(m===0)m="0";n=C(n)||r;m=C(m||c.yearRange[0]*365);p=C(p||c.yearRange[1]*365);if(!s)throw"Dateinput: invalid language: "+c.lang;if(a.attr("type")=="date"){var N=d("<input/>");d.each("class,disabled,id,maxlength,name,readonly,required,size,style,tabindex,title,value".split(","),function(b,e){N.attr(e,a.attr(e))});a.replaceWith(N);a=N}a.addClass(f.input);var H=
a.add(h);if(!k.length){k=d("<div><div><a/><div/><a/></div><div><div/><div/></div></div>").hide().css({position:"absolute"}).attr("id",f.root);k.children().eq(0).attr("id",f.head).end().eq(1).attr("id",f.body).children().eq(0).attr("id",f.days).end().eq(1).attr("id",f.weeks).end().end().end().find("a").eq(0).attr("id",f.prev).end().eq(1).attr("id",f.next);M=k.find("#"+f.head).find("div").attr("id",f.title);if(c.selectors){var z=d("<select/>").attr("id",f.month),A=d("<select/>").attr("id",f.year);M.html(z.add(A))}for(var $=
k.find("#"+f.days),O=0;O<7;O++)$.append(d("<span/>").text(s.shortDays[(O+c.firstDay)%7]));d("body").append(k)}if(c.trigger)L=d("<a/>").attr("href","#").addClass(f.trigger).click(function(b){h.show();return b.preventDefault()}).insertAfter(a);var K=k.find("#"+f.weeks);A=k.find("#"+f.year);z=k.find("#"+f.month);d.extend(h,{show:function(b){if(!(a.attr("readonly")||a.attr("disabled")||w)){b=b||d.Event();b.type="onBeforeShow";H.trigger(b);if(!b.isDefaultPrevented()){d.each(W,function(){this.hide()});
w=true;z.unbind("change").change(function(){h.setValue(A.val(),d(this).val())});A.unbind("change").change(function(){h.setValue(d(this).val(),z.val())});I=k.find("#"+f.prev).unbind("click").click(function(){I.hasClass(f.disabled)||h.addMonth(-1);return false});J=k.find("#"+f.next).unbind("click").click(function(){J.hasClass(f.disabled)||h.addMonth();return false});h.setValue(n);var e=a.offset();if(/iPad/i.test(navigator.userAgent))e.top-=d(window).scrollTop();k.css({top:e.top+a.outerHeight({margins:true})+
c.offset[0],left:e.left+c.offset[1]});if(c.speed)k.show(c.speed,function(){q(b)});else{k.show();q(b)}return h}}},setValue:function(b,e,g){var i=v(e)>=-1?new Date(v(b),v(e),v(g||1)):b||n;if(i<m)i=m;else if(i>p)i=p;b=i.getFullYear();e=i.getMonth();g=i.getDate();if(e==-1){e=11;b--}else if(e==12){e=0;b++}if(!w){j(i,c);return h}E=e;D=b;g=new Date(b,e,1-c.firstDay);g=g.getDay();var t=R(b,e),o=R(b,e-1),P;if(c.selectors){z.empty();d.each(s.months,function(x,F){m<new Date(b,x+1,-1)&&p>new Date(b,x,0)&&z.append(d("<option/>").html(F).attr("value",
x))});A.empty();i=r.getFullYear();for(var l=i+c.yearRange[0];l<i+c.yearRange[1];l++)m<=new Date(l+1,-1,1)&&p>new Date(l,0,0)&&A.append(d("<option/>").text(l));z.val(e);A.val(b)}else M.html(s.months[e]+" "+b);K.empty();I.add(J).removeClass(f.disabled);l=!g?-7:0;for(var u,y;l<(!g?35:42);l++){u=d("<a/>");if(l%7===0){P=d("<div/>").addClass(f.week);K.append(P)}if(l<g){u.addClass(f.off);y=o-g+l+1;i=new Date(b,e-1,y)}else if(l>=g+t){u.addClass(f.off);y=l-t-g+1;i=new Date(b,e+1,y)}else{y=l-g+1;i=new Date(b,
e,y);if(U(n,i))u.attr("id",f.current).addClass(f.focus);else U(r,i)&&u.attr("id",f.today)}m&&i<m&&u.add(I).addClass(f.disabled);p&&i>p&&u.add(J).addClass(f.disabled);u.attr("href","#"+y).text(y).data("date",i);P.append(u)}K.find("a").click(function(x){var F=d(this);if(!F.hasClass(f.disabled)){d("#"+f.current).removeAttr("id");F.attr("id",f.current);j(F.data("date"),c,x)}return false});f.sunday&&K.find(f.week).each(function(){var x=c.firstDay?7-c.firstDay:0;d(this).children().slice(x,x+1).addClass(f.sunday)});
return h},setMin:function(b,e){m=C(b);e&&n<m&&h.setValue(m);return h},setMax:function(b,e){p=C(b);e&&n>p&&h.setValue(p);return h},today:function(){return h.setValue(r)},addDay:function(b){return this.setValue(D,E,G+(b||1))},addMonth:function(b){return this.setValue(D,E+(b||1),G)},addYear:function(b){return this.setValue(D+(b||1),E,G)},hide:function(b){if(w){b=d.Event();b.type="onHide";H.trigger(b);d(document).unbind("click.d").unbind("keydown.d");if(b.isDefaultPrevented())return;k.hide();w=false}return h},
getConf:function(){return c},getInput:function(){return a},getCalendar:function(){return k},getValue:function(b){return b?T(n,b,c.lang):n},isOpen:function(){return w}});d.each(["onBeforeShow","onShow","change","onHide"],function(b,e){d.isFunction(c[e])&&d(h).bind(e,c[e]);h[e]=function(g){g&&d(h).bind(e,g);return h}});a.bind("focus click",h.show).keydown(function(b){var e=b.keyCode;if(!w&&d(V).index(e)>=0){h.show(b);return b.preventDefault()}return b.shiftKey||b.ctrlKey||b.altKey||e==9?true:b.preventDefault()});
C(a.val())&&j(n,c)}d.tools=d.tools||{version:"1.2.5"};var W=[],Q,V=[75,76,38,39,74,72,40,37],B={};Q=d.tools.dateinput={conf:{format:"mm/dd/yy",selectors:false,yearRange:[-5,5],lang:"en",offset:[0,0],speed:0,firstDay:0,min:undefined,max:undefined,trigger:false,css:{prefix:"cal",input:"date",root:0,head:0,title:0,prev:0,next:0,month:0,year:0,days:0,body:0,weeks:0,today:0,current:0,week:0,off:0,sunday:0,focus:0,disabled:0,trigger:0}},localize:function(a,c){d.each(c,function(j,q){c[j]=q.split(",")});
B[a]=c}};Q.localize("en",{months:"January,February,March,April,May,June,July,August,September,October,November,December",shortMonths:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",days:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",shortDays:"Sun,Mon,Tue,Wed,Thu,Fri,Sat"});var X=/d{1,4}|m{1,4}|yy(?:yy)?|"[^"]*"|'[^']*'/g,Y=d("<a/>");d.expr[":"].date=function(a){var c=a.getAttribute("type");return c&&c=="date"||!!d(a).data("dateinput")};d.fn.dateinput=function(a){if(this.data("dateinput"))return this;
a=d.extend(true,{},Q.conf,a);d.each(a.css,function(j,q){if(!q&&j!="prefix")a.css[j]=(a.css.prefix||"")+(q||j)});var c;this.each(function(){var j=new Z(d(this),a);W.push(j);j=j.getInput().data("dateinput",j);c=c?c.add(j):j});return c?c:this}})(jQuery);
(function(e){function F(d,a){a=Math.pow(10,a);return Math.round(d*a)/a}function q(d,a){if(a=parseInt(d.css(a),10))return a;return(d=d[0].currentStyle)&&d.width&&parseInt(d.width,10)}function C(d){return(d=d.data("events"))&&d.onSlide}function G(d,a){function h(c,b,f,j){if(f===undefined)f=b/k*z;else if(j)f-=a.min;if(s)f=Math.round(f/s)*s;if(b===undefined||s)b=f*k/z;if(isNaN(f))return g;b=Math.max(0,Math.min(b,k));f=b/k*z;if(j||!n)f+=a.min;if(n)if(j)b=k-b;else f=a.max-f;f=F(f,t);var r=c.type=="click";
if(D&&l!==undefined&&!r){c.type="onSlide";A.trigger(c,[f,b]);if(c.isDefaultPrevented())return g}j=r?a.speed:0;r=r?function(){c.type="change";A.trigger(c,[f])}:null;if(n){m.animate({top:b},j,r);a.progress&&B.animate({height:k-b+m.width()/2},j)}else{m.animate({left:b},j,r);a.progress&&B.animate({width:b+m.width()/2},j)}l=f;H=b;d.val(f);return g}function o(){if(n=a.vertical||q(i,"height")>q(i,"width")){k=q(i,"height")-q(m,"height");u=i.offset().top+k}else{k=q(i,"width")-q(m,"width");u=i.offset().left}}
function v(){o();g.setValue(a.value!==undefined?a.value:a.min)}var g=this,p=a.css,i=e("<div><div/><a href='#'/></div>").data("rangeinput",g),n,l,u,k,H;d.before(i);var m=i.addClass(p.slider).find("a").addClass(p.handle),B=i.find("div").addClass(p.progress);e.each("min,max,step,value".split(","),function(c,b){c=d.attr(b);if(parseFloat(c))a[b]=parseFloat(c,10)});var z=a.max-a.min,s=a.step=="any"?0:a.step,t=a.precision;if(t===undefined)try{t=s.toString().split(".")[1].length}catch(I){t=0}if(d.attr("type")==
"range"){var w=e("<input/>");e.each("class,disabled,id,maxlength,name,readonly,required,size,style,tabindex,title,value".split(","),function(c,b){w.attr(b,d.attr(b))});w.val(a.value);d.replaceWith(w);d=w}d.addClass(p.input);var A=e(g).add(d),D=true;e.extend(g,{getValue:function(){return l},setValue:function(c,b){o();return h(b||e.Event("api"),undefined,c,true)},getConf:function(){return a},getProgress:function(){return B},getHandle:function(){return m},getInput:function(){return d},step:function(c,
b){b=b||e.Event();var f=a.step=="any"?1:a.step;g.setValue(l+f*(c||1),b)},stepUp:function(c){return g.step(c||1)},stepDown:function(c){return g.step(-c||-1)}});e.each("onSlide,change".split(","),function(c,b){e.isFunction(a[b])&&e(g).bind(b,a[b]);g[b]=function(f){f&&e(g).bind(b,f);return g}});m.drag({drag:false}).bind("dragStart",function(){o();D=C(e(g))||C(d)}).bind("drag",function(c,b,f){if(d.is(":disabled"))return false;h(c,n?b:f)}).bind("dragEnd",function(c){if(!c.isDefaultPrevented()){c.type=
"change";A.trigger(c,[l])}}).click(function(c){return c.preventDefault()});i.click(function(c){if(d.is(":disabled")||c.target==m[0])return c.preventDefault();o();var b=m.width()/2;h(c,n?k-u-b+c.pageY:c.pageX-u-b)});a.keyboard&&d.keydown(function(c){if(!d.attr("readonly")){var b=c.keyCode,f=e([75,76,38,33,39]).index(b)!=-1,j=e([74,72,40,34,37]).index(b)!=-1;if((f||j)&&!(c.shiftKey||c.altKey||c.ctrlKey)){if(f)g.step(b==33?10:1,c);else if(j)g.step(b==34?-10:-1,c);return c.preventDefault()}}});d.blur(function(c){var b=
e(this).val();b!==l&&g.setValue(b,c)});e.extend(d[0],{stepUp:g.stepUp,stepDown:g.stepDown});v();k||e(window).load(v)}e.tools=e.tools||{version:"1.2.5"};var E;E=e.tools.rangeinput={conf:{min:0,max:100,step:"any",steps:0,value:0,precision:undefined,vertical:0,keyboard:true,progress:false,speed:100,css:{input:"range",slider:"slider",progress:"progress",handle:"handle"}}};var x,y;e.fn.drag=function(d){document.ondragstart=function(){return false};d=e.extend({x:true,y:true,drag:true},d);x=x||e(document).bind("mousedown mouseup",
function(a){var h=e(a.target);if(a.type=="mousedown"&&h.data("drag")){var o=h.position(),v=a.pageX-o.left,g=a.pageY-o.top,p=true;x.bind("mousemove.drag",function(i){var n=i.pageX-v;i=i.pageY-g;var l={};if(d.x)l.left=n;if(d.y)l.top=i;if(p){h.trigger("dragStart");p=false}d.drag&&h.css(l);h.trigger("drag",[i,n]);y=h});a.preventDefault()}else try{y&&y.trigger("dragEnd")}finally{x.unbind("mousemove.drag");y=null}});return this.data("drag",true)};e.expr[":"].range=function(d){var a=d.getAttribute("type");
return a&&a=="range"||!!e(d).filter("input").data("rangeinput")};e.fn.rangeinput=function(d){if(this.data("rangeinput"))return this;d=e.extend(true,{},E.conf,d);var a;this.each(function(){var h=new G(e(this),e.extend(true,{},d));h=h.getInput().data("rangeinput",h);a=a?a.add(h):h});return a?a:this}})(jQuery);
(function(e){function t(a,b,c){var k=a.offset().top,f=a.offset().left,l=c.position.split(/,?\s+/),p=l[0];l=l[1];k-=b.outerHeight()-c.offset[0];f+=a.outerWidth()+c.offset[1];if(/iPad/i.test(navigator.userAgent))k-=e(window).scrollTop();c=b.outerHeight()+a.outerHeight();if(p=="center")k+=c/2;if(p=="bottom")k+=c;a=a.outerWidth();if(l=="center")f-=(a+b.outerWidth())/2;if(l=="left")f-=a;return{top:k,left:f}}function y(a){function b(){return this.getAttribute("type")==a}b.key="[type="+a+"]";return b}function u(a,
b,c){function k(g,d,i){if(!(!c.grouped&&g.length)){var j;if(i===false||e.isArray(i)){j=h.messages[d.key||d]||h.messages["*"];j=j[c.lang]||h.messages["*"].en;(d=j.match(/\$\d/g))&&e.isArray(i)&&e.each(d,function(m){j=j.replace(this,i[m])})}else j=i[c.lang]||i;g.push(j)}}var f=this,l=b.add(f);a=a.not(":button, :image, :reset, :submit");e.extend(f,{getConf:function(){return c},getForm:function(){return b},getInputs:function(){return a},reflow:function(){a.each(function(){var g=e(this),d=g.data("msg.el");
if(d){g=t(g,d,c);d.css({top:g.top,left:g.left})}});return f},invalidate:function(g,d){if(!d){var i=[];e.each(g,function(j,m){j=a.filter("[name='"+j+"']");if(j.length){j.trigger("OI",[m]);i.push({input:j,messages:[m]})}});g=i;d=e.Event()}d.type="onFail";l.trigger(d,[g]);d.isDefaultPrevented()||q[c.effect][0].call(f,g,d);return f},reset:function(g){g=g||a;g.removeClass(c.errorClass).each(function(){var d=e(this).data("msg.el");if(d){d.remove();e(this).data("msg.el",null)}}).unbind(c.errorInputEvent||
"");return f},destroy:function(){b.unbind(c.formEvent+".V").unbind("reset.V");a.unbind(c.inputEvent+".V").unbind("change.V");return f.reset()},checkValidity:function(g,d){g=g||a;g=g.not(":disabled");if(!g.length)return true;d=d||e.Event();d.type="onBeforeValidate";l.trigger(d,[g]);if(d.isDefaultPrevented())return d.result;var i=[];g.not(":radio:not(:checked)").each(function(){var m=[],n=e(this).data("messages",m),v=r&&n.is(":date")?"onHide.v":c.errorInputEvent+".v";n.unbind(v);e.each(w,function(){var o=
this,s=o[0];if(n.filter(s).length){o=o[1].call(f,n,n.val());if(o!==true){d.type="onBeforeFail";l.trigger(d,[n,s]);if(d.isDefaultPrevented())return false;var x=n.attr(c.messageAttr);if(x){m=[x];return false}else k(m,s,o)}}});if(m.length){i.push({input:n,messages:m});n.trigger("OI",[m]);c.errorInputEvent&&n.bind(v,function(o){f.checkValidity(n,o)})}if(c.singleError&&i.length)return false});var j=q[c.effect];if(!j)throw'Validator: cannot find effect "'+c.effect+'"';if(i.length){f.invalidate(i,d);return false}else{j[1].call(f,
g,d);d.type="onSuccess";l.trigger(d,[g]);g.unbind(c.errorInputEvent+".v")}return true}});e.each("onBeforeValidate,onBeforeFail,onFail,onSuccess".split(","),function(g,d){e.isFunction(c[d])&&e(f).bind(d,c[d]);f[d]=function(i){i&&e(f).bind(d,i);return f}});c.formEvent&&b.bind(c.formEvent+".V",function(g){if(!f.checkValidity(null,g))return g.preventDefault()});b.bind("reset.V",function(){f.reset()});a[0]&&a[0].validity&&a.each(function(){this.oninvalid=function(){return false}});if(b[0])b[0].checkValidity=
f.checkValidity;c.inputEvent&&a.bind(c.inputEvent+".V",function(g){f.checkValidity(e(this),g)});a.filter(":checkbox, select").filter("[required]").bind("change.V",function(g){var d=e(this);if(this.checked||d.is("select")&&e(this).val())q[c.effect][1].call(f,d,g)});var p=a.filter(":radio").change(function(g){f.checkValidity(p,g)});e(window).resize(function(){f.reflow()})}e.tools=e.tools||{version:"1.2.5"};var z=/\[type=([a-z]+)\]/,A=/^-?[0-9]*(\.[0-9]+)?$/,r=e.tools.dateinput,B=/^([a-z0-9_\.\-\+]+)@([\da-z\.\-]+)\.([a-z\.]{2,6})$/i,
C=/^(https?:\/\/)?[\da-z\.\-]+\.[a-z\.]{2,6}[#&+_\?\/\w \.\-=]*$/i,h;h=e.tools.validator={conf:{grouped:false,effect:"default",errorClass:"invalid",inputEvent:null,errorInputEvent:"keyup",formEvent:"submit",lang:"en",message:"<div/>",messageAttr:"data-message",messageClass:"error",offset:[0,0],position:"center right",singleError:false,speed:"normal"},messages:{"*":{en:"Please correct this value"}},localize:function(a,b){e.each(b,function(c,k){h.messages[c]=h.messages[c]||{};h.messages[c][a]=k})},
localizeFn:function(a,b){h.messages[a]=h.messages[a]||{};e.extend(h.messages[a],b)},fn:function(a,b,c){if(e.isFunction(b))c=b;else{if(typeof b=="string")b={en:b};this.messages[a.key||a]=b}if(b=z.exec(a))a=y(b[1]);w.push([a,c])},addEffect:function(a,b,c){q[a]=[b,c]}};var w=[],q={"default":[function(a){var b=this.getConf();e.each(a,function(c,k){c=k.input;c.addClass(b.errorClass);var f=c.data("msg.el");if(!f){f=e(b.message).addClass(b.messageClass).appendTo(document.body);c.data("msg.el",f)}f.css({visibility:"hidden"}).find("p").remove();
e.each(k.messages,function(l,p){e("<p/>").html(p).appendTo(f)});f.outerWidth()==f.parent().width()&&f.add(f.find("p")).css({display:"inline"});k=t(c,f,b);f.css({visibility:"visible",position:"absolute",top:k.top,left:k.left}).fadeIn(b.speed)})},function(a){var b=this.getConf();a.removeClass(b.errorClass).each(function(){var c=e(this).data("msg.el");c&&c.css({visibility:"hidden"})})}]};e.each("email,url,number".split(","),function(a,b){e.expr[":"][b]=function(c){return c.getAttribute("type")===b}});
e.fn.oninvalid=function(a){return this[a?"bind":"trigger"]("OI",a)};h.fn(":email","Please enter a valid email address",function(a,b){return!b||B.test(b)});h.fn(":url","Please enter a valid URL",function(a,b){return!b||C.test(b)});h.fn(":number","Please enter a numeric value.",function(a,b){return A.test(b)});h.fn("[max]","Please enter a value smaller than $1",function(a,b){if(b===""||r&&a.is(":date"))return true;a=a.attr("max");return parseFloat(b)<=parseFloat(a)?true:[a]});h.fn("[min]","Please enter a value larger than $1",
function(a,b){if(b===""||r&&a.is(":date"))return true;a=a.attr("min");return parseFloat(b)>=parseFloat(a)?true:[a]});h.fn("[required]","Please complete this mandatory field.",function(a,b){if(a.is(":checkbox"))return a.is(":checked");return!!b});h.fn("[pattern]",function(a){var b=new RegExp("^"+a.attr("pattern")+"$");return b.test(a.val())});e.fn.validator=function(a){var b=this.data("validator");if(b){b.destroy();this.removeData("validator")}a=e.extend(true,{},h.conf,a);if(this.is("form"))return this.each(function(){var c=
e(this);b=new u(c.find(":input"),c,a);c.data("validator",b)});else{b=new u(this,this.eq(0).closest("form"),a);return this.data("validator",b)}}})(jQuery);

var rewForm = function (rewform) {
    var l = rewform.length;
    for (var i = 0; i < l; i++) {
        var $form = $(rewform[i]);
        // these three lines cause a strange flash in top left corner (ON search.html ONLY)
        $form.wrapInner('<div class="form-wrap"></div>');
        $form.find('.field').wrapInner('<span class="field-iwrap"></span>');
        $form.find('.field select').wrap('<span class="select-wrap"></span>');
        //
        $form.find('.field input:text,.field input:password').wrap('<span class="input-wrap"></span>');
        $form.find('.field textarea').not('.richtext').wrap('<span class="textarea-wrap"></span>');
        $form.find('.token').wrapInner('<span class="token-iwrap"></span>');
        $form.find('legend').each(function() {
            var content = $(this).html();
            $(this).after('<h4 class="legend">'+ content +'</h4>').hide();
            $(this).remove();
         });
    }
};

$(document).ready(function() {

    
    $('#directory-categories').splitList({'itemsPerColumn':3});
	$('#content .directory-categories:nth-child(4n)').addClass('last');
	
	$('#blog-entries .blog-entry:last-child').addClass('last');
    
    
    $('body').append('<div class="tooltip"></div>');

    
    $('#content .tabset li').bind('click', function(event) {
        var target = $(event.target);
        if (target.is('li')) {
            target.find('a').trigger('click');
            return false;
        } else if (target.is('a')) {
        	if (target.attr('target') != '_blank') {
        	    window.location.href = target.attr('href');
        	}
        }
    });

    
    var colNumber = $('body').hasClass('lec3') ? 2: 3;
    $('.communities-nav ul').easyListSplitter({'colNumber': colNumber});
    $('.communities-nav ul').each(function() {
        $(this).find('li:odd').addClass('odd');
	});

    
    $('.agent .photos img, .office .photos img').rewImgSizer({method:'crop'});

    
    $('#refine-form dl.panel, #quick-search dl.panel').each(function(i){
        $(this).find('dt').append('<span class="ico-panel-trigger"></span>');
        $(this).find('dt').bind('click', function(){
                $(this).parent('dl').toggleClass('open');
            $(this).next('dd').slideToggle();
            });
        });

    $("#content div.item").wrap('<div class="dialog">'+'<div class="bd">'+'<div class="c">'+'<div class="s">'+'</div>'+'</div>'+'</div>'+'</div>');

    $('div.dialog').prepend('<div class="hd">'+'<div class="c"></div>'+'</div>').append('<div class="ft">'+'<div class="c"></div>'+'</div>');


    $('#nav .nav.primary li div').css({'left':'-1px'}).hide();

    $('#nav .nav.primary li').hoverIntent(function() {
        $(this).find('div').show();
    }, function() {
        $(this).find('div').hide();
    });

    $('#content hr').wrap('<div class="hr"></div>');

    $('#content legend').each( function() {
        val = $(this).html();
        $(this).after('<h5 class="legend"><span>' + val + '</span></h5>');
        $(this).html('');
    });

    
    if (!$('body').hasClass('enablesuckerfish')) {
        $('#nav ul ul, #nav ul div').remove();
    }

    
    $('form[autocomplete!=on]').attr('autocomplete', 'off');

    
    rewForm($('form.rewfw'));

    
    $('#content .actions a.button').each(function(){
        $button = $(this);
        $label = $(this).html();
        $classes = $(this).attr('class').replace('button','');
        $(this).wrap('<div class="button link ' + $classes + '"></div>').after('<span class="label">' + $label + '</span>');
        $(this).find('.button').live('click', function() {
            document.location = $(this).find('a').attr('href');
        });
    });

    
    $('.rewbtn').bind({
        'mousedown'  : function() { $(this).addClass('active'); },
        'mouseleave' : function() { $(this).removeClass('active'); }
    });

    
    $('input.autocomplete').each(function () {
        var $this = $(this), multiple = $this.hasClass('single') ? false : true;
        $this.autocomplete({
            source: function (request, response) {
        		if (multiple) {
        			request.term = request.term.split(/,\s*/).pop();
        		}
                $.getJSON('/idx/inc/php/ajax/json.php?limit=10&search=' + $this.attr('name'), {
                    q : request.term,
                    search_city : function () {
                	    var search_city = $this.closest('form').find('select[name="search_city"]');
                	    if (search_city.length == 1) {
                	    	return search_city.val();
                	    } else {
                	    	return '';
                	    }
                    }
                }, function (data) {
                    var parsed = [];
                    var rows   = data.options ? data.options : [];
                    for (var i=0; i < rows.length; i++) {
                        var row = $.trim(rows[i].title);
                        if (row) {
                            row = row.split('|');
                            parsed.push({
                                value: row[0],
                                label: row[0]
                            });
                        }
                    }
                    response(parsed);
                });
            },
            focus: function () {
                return false;
            },
            select: function (event, ui) {
            	if (multiple) {
	                var terms = this.value.split(/,\s*/);
	                terms.pop();
	                terms.push(ui.item.value);
	                terms.push('');
	                this.value = terms.join(', ');
	                return false;
            	}
            }
        });
    });

    
    $('#nav-supplementary li a').mouseover(function() { $('.menu').hide(); });
    $('.menu').hover(function() {}, function() { $('.menu').hide(); });

    
    var $compact = $('.compact .listing');
    $compact.live('mouseover', function() { $(this).addClass('hover'); });
    $compact.live('mouseout', function() { $(this).removeClass('hover'); });
    $compact.live('click', function() {
        document.location = $(this).find('a:first').attr('href');
    });

    
    $('.set .photos img').rewImgSizer({ method: 'crop', scale: 1 });

});

var rew_setCookie = function (name, value, expires) {
    if (typeof(expires) == 'undefined') {
        var exp = new Date(); //set new date object
        exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 30)); //set it 30 days ahead
    }
    document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? "" : "; expires=" + expires.toGMTString());
};


var rew_getCookie = function (c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
};


var openPage = function openPage (href) {
    closeFacebox();
    $.facebox({'iframe' : href});
};


var closeFacebox = function () {
    $(document).trigger('close.facebox');
};


var reloadUserTools = function () {
    $.ajax({
        'url' : '?',
        'success' : function (data) {
            var data = $('#login', data).html();
            if (typeof(data) != 'undefined') {
                $('#login', window.parent.document.body).html(data);
                if (typeof(Cufon) != 'undefined') Cufon.refresh();
            }
        }
    });
};


var bookmarkListing = function (mls_number, container) {

    
    $.ajax({
        'url'      : '/idx/inc/php/ajax/json.php?bookmarkListing',
        'type'     : 'POST',
        'dataType' : 'json',
        'data'     : {
            'mls_number' : mls_number
        },
        'error'    : function (XMLHttpRequest, textStatus, errorThrown) {
            alert('An error has occurred. Listing could not be saved.');
            return;
        },
        'success'  : function (json, textStatus) {

            
            if (json.returnCode == 200) {

                
                if (json.added) $(container).addClass('saved');

                
                if (json.removed) $(container).removeClass('saved');

                
                $('#favs-menu').load('/idx/inc/php/ajax/favourites.php', function () {
                    $(this).addClass('loaded');
                });

            } else {

                
                if (json.register) {

                    
                    openPage(json.register);

                } else {

                    
                    alert('An error has occurred. Listing could not be saved.');

                }
            }
            return;
        }
    });

};


var saveSearch = function (search) {

    
    search = search ? search : {};

    
    var content  = $('<div />', {
        'id'  : 'save-search'
    });

    
    var message  = $('<div />', {
        'class'  : 'response'
    });

    
    var form  = $('<form />', {
        'class'  : 'rewfw',
        'autocomplete' : 'off'
    });
    
    
    var search_title = search.search_title ? search.search_title : search.save_prompt;

    
    var input_text = $('<input />', {
        type  : 'text',
        name  : 'search_title',
        value : (search_title != '') ? search_title : 'My Saved Search'
    });
    
    
    var frequency = [], freq = search.frequency ? search.frequency : 'weekly';
    frequency.push('<select name="frequency">');
	frequency.push('<option value="daily"' + (freq == 'daily' ? ' selected' : '') + '>Daily</option>');
	frequency.push('<option value="weekly"' + (freq == 'weekly' ? ' selected' : '') + '>Weekly</option>');
	frequency.push('<option value="monthly"' + (freq == 'monthly' ? ' selected' : '') + '>Monthly</option>');
    frequency.push('</select>');
    frequency = $(frequency.join("\n"));

    
    form.wrapInner('<div class="form-wrap"><fieldset><ul></ul></fieldset><div class="buttonset"><button type="submit" name="search" value="Save Search" class="rewbtn primary"><b><i>Save Search</i></b></button></div></div>');

    
    form.find('ul').append(input_text);
    
    
    form.find('ul').append(frequency);

    
    input_text.wrap('<span class="input-wrap" />').wrap('<li><div class="field rpd-gridcolx6"><span class="field-iwrap"><label>Search Title</label></span></div></li>');
    
    
    frequency.wrap('<span class="input-wrap" />').wrap('<li><div class="field rpd-gridcolx2"><span class="field-iwrap"><label>Frequency</label></span></div></li>');

    
    content.append(message).append(form);

    
    form.bind('submit', function () {

        
        message.html('');

        
        var search_title = $(this).find('input[name="search_title"]').val();

        
        search.search_title = search_title;
        
        
        search.frequency = $(this).find('select[name="frequency"]').val();

        
        search.save_search = true;

        
        $.ajax({
            'url'      : '/idx/inc/php/ajax/json.php?saveSearch',
            'type'     : 'POST',
            'dataType' : 'json',
            'data'     : search,
            'error'    : function (XMLHttpRequest, textStatus, errorThrown) {
                //alert('AJAX Error');
            },
            'success'  : function (json, textStatus) {
                if (typeof(json) == 'undefined' || !json) return;
                if (json.success) {
                    if (search.create_search && search.lead_id) {
                        window.location = '/backend/leads/lead/searches/?id=' + search.lead_id;
                    } else {
                        $(document).trigger('close.facebox');
                        if (json.search) {
                            $('#results-message').html('<p>You are viewing your <strong>"' + search.search_title + '"</strong> saved search. <a href="?edit_search=true&saved_search_id=' + json.search + '">Edit this Search</a></p>');
                        }
                    }
                } else {
                    if (json.error) message.html('<div class="msg errors"><h5 class="title">Oops, There was an Error with your Form Submission!</h5><ul><li>' + json.error + '</li></ul></div>');
                    if (json.redirect) {
                        openPage(json.redirect);
                    }
                }
            }
        });

        
        return false;

    });

    
    if (search.trigger) {
        form.trigger('submit');
    }

    
    $.facebox({
        title : 'Save this Search',
        data : content
    });

    
    return;

};


var editSearch = function (search) {

    
    search = search ? search : {};

    
    $.ajax({
        'url'      : '/idx/inc/php/ajax/json.php?editSearch',
        'type'     : 'POST',
        'dataType' : 'json',
        'data'     : search,
        'success'  : function (json, textStatus) {
            if (typeof(json) == 'undefined' || !json) return;
            if (json.success) {
                if (search.edit_search && search.lead_id) {
                    window.location = '/backend/leads/lead/searches/?id=' + search.lead_id;
                } else if (search.saved_search_id && search.search_by == 'map') {
                    window.location = '/idx/map/' + search.saved_search_id + '/';
                } else if (search.saved_search_id) {
                    window.location = '/idx/search/' + search.saved_search_id + '/';
                }
            } else if (json.error) {
                alert(json.error);
            }
        }
    });

    
    return;

};
