/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
 * Build: http://www.modernizr.com/download/#-fontface-opacity-rgba-cssanimations-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-canvas-iepp-cssclasses-addtest-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
 */
;window.Modernizr=function(a,b,c){function D(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1),d=(a+" "+o.join(c+" ")+c).split(" ");return C(d,b)}function C(a,b){for(var d in a)if(k[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function B(a,b){return!!~(""+a).indexOf(b)}function A(a,b){return typeof a===b}function z(a,b){return y(n.join(a+";")+(b||""))}function y(a){k.cssText=a}var d="2.0.6",e={},f=!0,g=b.documentElement,h=b.head||b.getElementsByTagName("head")[0],i="modernizr",j=b.createElement(i),k=j.style,l,m=Object.prototype.toString,n=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),o="Webkit Moz O ms Khtml".split(" "),p={},q={},r={},s=[],t=function(a,c,d,e){var f,h,j,k=b.createElement("div");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:i+(d+1),k.appendChild(j);f=["&shy;","<style>",a,"</style>"].join(""),k.id=i,k.innerHTML+=f,g.appendChild(k),h=c(k,a),k.parentNode.removeChild(k);return!!h},u=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=A(e[d],"function"),A(e[d],c)||(e[d]=c),e.removeAttribute(d))),e=null;return f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),v,w={}.hasOwnProperty,x;!A(w,c)&&!A(w.call,c)?x=function(a,b){return w.call(a,b)}:x=function(a,b){return b in a&&A(a.constructor.prototype[b],c)};var E=function(a,c){var d=a.join(""),f=c.length;t(d,function(a,c){var d=b.styleSheets[b.styleSheets.length-1],g=d.cssRules&&d.cssRules[0]?d.cssRules[0].cssText:d.cssText||"",h=a.childNodes,i={};while(f--)i[h[f].id]=h[f];e.csstransforms3d=i.csstransforms3d.offsetLeft===9,e.fontface=/src/i.test(g)&&g.indexOf(c.split(" ")[0])===0},f,c)}(['@font-face {font-family:"font";src:url("https://")}',["@media (",n.join("transform-3d),("),i,")","{#csstransforms3d{left:9px;position:absolute}}"].join("")],["fontface","csstransforms3d"]);p.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},p.rgba=function(){y("background-color:rgba(150,255,150,.5)");return B(k.backgroundColor,"rgba")},p.opacity=function(){z("opacity:.55");return/^0.55$/.test(k.opacity)},p.cssanimations=function(){return D("animationName")},p.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";y((a+n.join(b+a)+n.join(c+a)).slice(0,-a.length));return B(k.backgroundImage,"gradient")},p.cssreflections=function(){return D("boxReflect")},p.csstransforms=function(){return!!C(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])},p.csstransforms3d=function(){var a=!!C(["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"]);a&&"webkitPerspective"in g.style&&(a=e.csstransforms3d);return a},p.csstransitions=function(){return D("transitionProperty")},p.fontface=function(){return e.fontface};for(var F in p)x(p,F)&&(v=F.toLowerCase(),e[v]=p[F](),s.push((e[v]?"":"no-")+v));e.addTest=function(a,b){if(typeof a=="object")for(var d in a)x(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return;b=typeof b=="boolean"?b:!!b(),g.className+=" "+(b?"":"no-")+a,e[a]=b}return e},y(""),j=l=null,a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function s(a){var b=-1;while(++b<g)a.createElement(f[b])}a.iepp=a.iepp||{};var d=a.iepp,e=d.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",f=e.split("|"),g=f.length,h=new RegExp("(^|\\s)("+e+")","gi"),i=new RegExp("<(/*)("+e+")","gi"),j=/^\s*[\{\}]\s*$/,k=new RegExp("(^|[^\\n]*?\\s)("+e+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),l=b.createDocumentFragment(),m=b.documentElement,n=m.firstChild,o=b.createElement("body"),p=b.createElement("style"),q=/print|all/,r;d.getCSS=function(a,b){if(a+""===c)return"";var e=-1,f=a.length,g,h=[];while(++e<f){g=a[e];if(g.disabled)continue;b=g.media||b,q.test(b)&&h.push(d.getCSS(g.imports,b),g.cssText),b="all"}return h.join("")},d.parseCSS=function(a){var b=[],c;while((c=k.exec(a))!=null)b.push(((j.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(h,"$1.iepp_$2")+c[4]);return b.join("\n")},d.writeHTML=function(){var a=-1;r=r||b.body;while(++a<g){var c=b.getElementsByTagName(f[a]),d=c.length,e=-1;while(++e<d)c[e].className.indexOf("iepp_")<0&&(c[e].className+=" iepp_"+f[a])}l.appendChild(r),m.appendChild(o),o.className=r.className,o.id=r.id,o.innerHTML=r.innerHTML.replace(i,"<$1font")},d._beforePrint=function(){p.styleSheet.cssText=d.parseCSS(d.getCSS(b.styleSheets,"all")),d.writeHTML()},d.restoreHTML=function(){o.innerHTML="",m.removeChild(o),m.appendChild(r)},d._afterPrint=function(){d.restoreHTML(),p.styleSheet.cssText=""},s(b),s(l);d.disablePP||(n.insertBefore(p,n.firstChild),p.media="print",p.className="iepp-printshim",a.attachEvent("onbeforeprint",d._beforePrint),a.attachEvent("onafterprint",d._afterPrint))}(a,b),e._version=d,e._prefixes=n,e._domPrefixes=o,e.hasEvent=u,e.testProp=function(a){return C([a])},e.testAllProps=D,e.testStyles=t,g.className=g.className.replace(/\bno-js\b/,"")+(f?" js "+s.join(" "):"");return e}(this,this.document),function(a,b,c){function k(a){return!a||a=="loaded"||a=="complete"}function j(){var a=1,b=-1;while(p.length- ++b)if(p[b].s&&!(a=p[b].r))break;a&&g()}function i(a){var c=b.createElement("script"),d;c.src=a.s,c.onreadystatechange=c.onload=function(){!d&&k(c.readyState)&&(d=1,j(),c.onload=c.onreadystatechange=null)},m(function(){d||(d=1,j())},H.errorTimeout),a.e?c.onload():n.parentNode.insertBefore(c,n)}function h(a){var c=b.createElement("link"),d;c.href=a.s,c.rel="stylesheet",c.type="text/css";if(!a.e&&(w||r)){var e=function(a){m(function(){if(!d)try{a.sheet.cssRules.length?(d=1,j()):e(a)}catch(b){b.code==1e3||b.message=="security"||b.message=="denied"?(d=1,m(function(){j()},0)):e(a)}},0)};e(c)}else c.onload=function(){d||(d=1,m(function(){j()},0))},a.e&&c.onload();m(function(){d||(d=1,j())},H.errorTimeout),!a.e&&n.parentNode.insertBefore(c,n)}function g(){var a=p.shift();q=1,a?a.t?m(function(){a.t=="c"?h(a):i(a)},0):(a(),j()):q=0}function f(a,c,d,e,f,h){function i(){!o&&k(l.readyState)&&(r.r=o=1,!q&&j(),l.onload=l.onreadystatechange=null,m(function(){u.removeChild(l)},0))}var l=b.createElement(a),o=0,r={t:d,s:c,e:h};l.src=l.data=c,!s&&(l.style.display="none"),l.width=l.height="0",a!="object"&&(l.type=d),l.onload=l.onreadystatechange=i,a=="img"?l.onerror=i:a=="script"&&(l.onerror=function(){r.e=r.r=1,g()}),p.splice(e,0,r),u.insertBefore(l,s?null:n),m(function(){o||(u.removeChild(l),r.r=r.e=o=1,j())},H.errorTimeout)}function e(a,b,c){var d=b=="c"?z:y;q=0,b=b||"j",C(a)?f(d,a,b,this.i++,l,c):(p.splice(this.i++,0,a),p.length==1&&g());return this}function d(){var a=H;a.loader={load:e,i:0};return a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=r&&!s,u=s?l:n.parentNode,v=a.opera&&o.call(a.opera)=="[object Opera]",w="webkitAppearance"in l.style,x=w&&"async"in b.createElement("script"),y=r?"object":v||x?"img":"script",z=w?"img":y,A=Array.isArray||function(a){return o.call(a)=="[object Array]"},B=function(a){return Object(a)===a},C=function(a){return typeof a=="string"},D=function(a){return o.call(a)=="[object Function]"},E=[],F={},G,H;H=function(a){function f(a){var b=a.split("!"),c=E.length,d=b.pop(),e=b.length,f={url:d,origUrl:d,prefixes:b},g,h;for(h=0;h<e;h++)g=F[b[h]],g&&(f=g(f));for(h=0;h<c;h++)f=E[h](f);return f}function e(a,b,e,g,h){var i=f(a),j=i.autoCallback;if(!i.bypass){b&&(b=D(b)?b:b[a]||b[g]||b[a.split("/").pop().split("?")[0]]);if(i.instead)return i.instead(a,b,e,g,h);e.load(i.url,i.forceCSS||!i.forceJS&&/css$/.test(i.url)?"c":c,i.noexec),(D(b)||D(j))&&e.load(function(){d(),b&&b(i.origUrl,h,g),j&&j(i.origUrl,h,g)})}}function b(a,b){function c(a){if(C(a))e(a,h,b,0,d);else if(B(a))for(i in a)a.hasOwnProperty(i)&&e(a[i],h,b,i,d)}var d=!!a.test,f=d?a.yep:a.nope,g=a.load||a.both,h=a.callback,i;c(f),c(g),a.complete&&b.load(a.complete)}var g,h,i=this.yepnope.loader;if(C(a))e(a,0,i,0);else if(A(a))for(g=0;g<a.length;g++)h=a[g],C(h)?e(h,0,i,0):A(h)?H(h):B(h)&&b(h,i);else B(a)&&b(a,i)},H.addPrefix=function(a,b){F[a]=b},H.addFilter=function(a){E.push(a)},H.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",G=function(){b.removeEventListener("DOMContentLoaded",G,0),b.readyState="complete"},0)),a.yepnope=d()}(this,this.document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};;
// credit to https://gist.github.com/1221602

(function(Modernizr, window) {
    Modernizr.addTest('positionfixed', function () {
        var test = document.createElement('div'),
            control = test.cloneNode(false),
                fake = false,
                root = document.body || (function () {
                fake = true;
                return document.documentElement.appendChild(document.createElement('body'));
            }());

        var oldCssText = root.style.cssText;
        root.style.cssText = 'padding:0;margin:0';
        test.style.cssText = 'position:fixed;top:42px';
        root.appendChild(test);
        root.appendChild(control);
   
        var ret = test.offsetTop !== control.offsetTop;
   
        root.removeChild(test);
        root.removeChild(control);
        root.style.cssText = oldCssText;
   
        if (fake) {
            document.documentElement.removeChild(root);
        }
   
        return ret;
    });
    
    Modernizr.addTest('iospositionfixed', function () {
        var test = document.createElement('div'),
            ret,
            fake = false,
            root = document.body || (function () {
                fake = true;
                return document.documentElement.appendChild(document.createElement('body'));
            }());
        
        if (typeof document.body.scrollIntoViewIfNeeded === 'function') {
        
            var oldCssText = root.style.cssText,
                testScrollTop = 20,
                originalScrollTop = window.pageYOffset;

            root.appendChild(test);

            test.style.cssText = 'position:fixed;top:0px;height:10px;';

            root.style.height="3000px";
            
            /* avoided hoisting for clarity */
            var testScroll = function() {
                if (ret === undefined) {
                    test.scrollIntoViewIfNeeded();
                    if (window.pageYOffset === testScrollTop) {
                        ret = true;
                    } else {
                        ret = false;
                    }
                }
                window.removeEventListener('scroll', testScroll, false);
            }

            window.addEventListener('scroll', testScrollTop, false);
            window.setTimeout(testScroll, 20); // ios 4 does'nt publish the scroll event on scrollto
            window.scrollTo(0, testScrollTop);
            testScroll();

            root.removeChild(test);
            root.style.cssText = oldCssText;
            window.scrollTo(0, originalScrollTop);

        } else {
            ret = Modernizr.positionfixed; // firefox and IE doesnt have document.body.scrollIntoViewIfNeeded, so we test with the original modernizr test
        }
            
        if (fake) {
            document.documentElement.removeChild(root);
        }

        return ret;
    });
})(Modernizr, window);;
/**
 * @author Alexander Farkas
 * v. 1.22
 */


(function($) {
	if(!document.defaultView || !document.defaultView.getComputedStyle){ // IE6-IE8
		var oldCurCSS = $.curCSS;
		$.curCSS = function(elem, name, force){
			if(name === 'background-position'){
				name = 'backgroundPosition';
			}
			if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
				return oldCurCSS.apply(this, arguments);
			}
			var style = elem.style;
			if ( !force && style && style[ name ] ){
				return style[ name ];
			}
			return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
		};
	}
	
	var oldAnim = $.fn.animate;
	$.fn.animate = function(prop){
		if('background-position' in prop){
			prop.backgroundPosition = prop['background-position'];
			delete prop['background-position'];
		}
		if('backgroundPosition' in prop){
			prop.backgroundPosition = '('+ prop.backgroundPosition;
		}
		return oldAnim.apply(this, arguments);
	};
	
	function toArray(strg){
		strg = strg.replace(/left|top/g,'0px');
		strg = strg.replace(/right|bottom/g,'100%');
		strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	}
	
	$.fx.step. backgroundPosition = function(fx) {
		if (!fx.bgPosReady) {
			var start = $.curCSS(fx.elem,'backgroundPosition');
			if(!start){//FF2 no inline-style fallback
				start = '0px 0px';
			}
			
			start = toArray(start);
			fx.start = [start[0],start[2]];
			var end = toArray(fx.end);
			fx.end = [end[0],end[2]];
			
			fx.unit = [end[1],end[3]];
			fx.bgPosReady = true;
		}
		//return;
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	};
})(jQuery);;
/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */;
(function( $ ){ 
	$(document).ready(function() {
	$("html").removeClass("non-js");
	$.data(document.body,'eF', "easeOutExpo");
  // Animations
	// jQuery-only Animations
	var intent = '';
	var tbDelay = '';
	// Blog Archive Tree Accordions
	$("#archive-tree a").toggle(function(e) { 
		var parent = $(this).parent('li');
		if (parent.hasClass("title")) {
			window.location.href = $(this).attr("href");
			return false;
		}
		e.preventDefault();
		if (parent.hasClass("empty")) { return false; }
		else if ((parent.hasClass("year")) || (parent.hasClass("month"))) { 
			$(this).addClass("opened"); 
			parent.addClass("opened"); 
			$(this).next().show("fast");  
		}
	},
	function(e) {
		var parent = $(this).parent('li');
		if (parent.hasClass("title")) {
			window.location.href = $(this).attr("href");
			return false;
		}
		e.preventDefault();
		if (parent.hasClass("empty")) { return false; }
		else if ((parent.hasClass("year")) || (parent.hasClass("month"))) { 
			$(this).removeClass("opened"); 
			parent.removeClass("opened"); 
			$(this).next().hide("fast"); 
		}
	});
});
})( jQuery );;
/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * Version: 3.0.2
 * 
 * Requires: 1.2.2+
 */
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);;
/*!
 * jQuery Form Plugin
 * version: 2.86 (08-OCT-2011)
 * @requires jQuery v1.3.2 or later
 *
 * Examples and documentation at: http://malsup.com/jquery/form/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
;(function($) {

/*
	Usage Note:
	-----------
	Do not use both ajaxSubmit and ajaxForm on the same form.  These
	functions are intended to be exclusive.  Use ajaxSubmit if you want
	to bind your own submit handler to the form.  For example,

	$(document).ready(function() {
		$('#myForm').bind('submit', function(e) {
			e.preventDefault(); // <-- important
			$(this).ajaxSubmit({
				target: '#output'
			});
		});
	});

	Use ajaxForm when you want the plugin to manage all the event binding
	for you.  For example,

	$(document).ready(function() {
		$('#myForm').ajaxForm({
			target: '#output'
		});
	});

	When using ajaxForm, the ajaxSubmit function will be invoked for you
	at the appropriate time.
*/

/**
 * ajaxSubmit() provides a mechanism for immediately submitting
 * an HTML form using AJAX.
 */
$.fn.ajaxSubmit = function(options) {
	// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
	if (!this.length) {
		log('ajaxSubmit: skipping submit process - no element selected');
		return this;
	}
	
	var method, action, url, $form = this;

	if (typeof options == 'function') {
		options = { success: options };
	}

	method = this.attr('method');
	action = this.attr('action');
	url = (typeof action === 'string') ? $.trim(action) : '';
	url = url || window.location.href || '';
	if (url) {
		// clean url (don't include hash vaue)
		url = (url.match(/^([^#]+)/)||[])[1];
	}

	options = $.extend(true, {
		url:  url,
		success: $.ajaxSettings.success,
		type: method || 'GET',
		iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
	}, options);

	// hook for manipulating the form data before it is extracted;
	// convenient for use with rich editors like tinyMCE or FCKEditor
	var veto = {};
	this.trigger('form-pre-serialize', [this, options, veto]);
	if (veto.veto) {
		log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
		return this;
	}

	// provide opportunity to alter form data before it is serialized
	if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
		log('ajaxSubmit: submit aborted via beforeSerialize callback');
		return this;
	}

   var traditional = options.traditional;
   if ( traditional === undefined ) {
      traditional = $.ajaxSettings.traditional;
   }
   
	var qx,n,v,a = this.formToArray(options.semantic);
	if (options.data) {
		options.extraData = options.data;
      qx = $.param(options.data, traditional);
	}

	// give pre-submit callback an opportunity to abort the submit
	if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
		log('ajaxSubmit: submit aborted via beforeSubmit callback');
		return this;
	}

	// fire vetoable 'validate' event
	this.trigger('form-submit-validate', [a, this, options, veto]);
	if (veto.veto) {
		log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
		return this;
	}

	var q = $.param(a, traditional);
   if (qx)
      q = ( q ? (q + '&' + qx) : qx );

	if (options.type.toUpperCase() == 'GET') {
		options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
		options.data = null;  // data is null for 'get'
	}
	else {
		options.data = q; // data is the query string for 'post'
	}

	var callbacks = [];
	if (options.resetForm) {
		callbacks.push(function() { $form.resetForm(); });
	}
	if (options.clearForm) {
		callbacks.push(function() { $form.clearForm(); });
	}

	// perform a load on the target only if dataType is not provided
	if (!options.dataType && options.target) {
		var oldSuccess = options.success || function(){};
		callbacks.push(function(data) {
			var fn = options.replaceTarget ? 'replaceWith' : 'html';
			$(options.target)[fn](data).each(oldSuccess, arguments);
		});
	}
	else if (options.success) {
		callbacks.push(options.success);
	}

	options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
		var context = options.context || options;   // jQuery 1.4+ supports scope context 
		for (var i=0, max=callbacks.length; i < max; i++) {
			callbacks[i].apply(context, [data, status, xhr || $form, $form]);
		}
	};

	// are there files to upload?
	var fileInputs = $('input:file', this).length > 0;
	var mp = 'multipart/form-data';
	var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);

	// options.iframe allows user to force iframe mode
	// 06-NOV-09: now defaulting to iframe mode if file input is detected
   if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
	   // hack to fix Safari hang (thanks to Tim Molendijk for this)
	   // see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
	   if (options.closeKeepAlive) {
		   $.get(options.closeKeepAlive, function() { fileUpload(a); });
		}
	   else {
		   fileUpload(a);
		}
   }
   else {
		// IE7 massage (see issue 57)
		if ($.browser.msie && method == 'get' && typeof options.type === "undefined") {
			var ieMeth = $form[0].getAttribute('method');
			if (typeof ieMeth === 'string')
				options.type = ieMeth;
		}
		$.ajax(options);
   }

	// fire 'notify' event
	this.trigger('form-submit-notify', [this, options]);
	return this;


	// private function for handling file uploads (hat tip to YAHOO!)
	function fileUpload(a) {
		var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
        var useProp = !!$.fn.prop;

        if (a) {
            if ( useProp ) {
            	// ensure that every serialized input is still enabled
              	for (i=0; i < a.length; i++) {
                    el = $(form[a[i].name]);
                    el.prop('disabled', false);
              	}
            } else {
              	for (i=0; i < a.length; i++) {
                    el = $(form[a[i].name]);
                    el.removeAttr('disabled');
              	}
            };
        }

		if ($(':input[name=submit],:input[id=submit]', form).length) {
			// if there is an input with a name or id of 'submit' then we won't be
			// able to invoke the submit fn on the form (at least not x-browser)
			alert('Error: Form elements must not have name or id of "submit".');
			return;
		}
		
		s = $.extend(true, {}, $.ajaxSettings, options);
		s.context = s.context || s;
		id = 'jqFormIO' + (new Date().getTime());
		if (s.iframeTarget) {
			$io = $(s.iframeTarget);
			n = $io.attr('name');
			if (n == null)
			 	$io.attr('name', id);
			else
				id = n;
		}
		else {
			$io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
			$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
		}
		io = $io[0];


		xhr = { // mock object
			aborted: 0,
			responseText: null,
			responseXML: null,
			status: 0,
			statusText: 'n/a',
			getAllResponseHeaders: function() {},
			getResponseHeader: function() {},
			setRequestHeader: function() {},
			abort: function(status) {
				var e = (status === 'timeout' ? 'timeout' : 'aborted');
				log('aborting upload... ' + e);
				this.aborted = 1;
				$io.attr('src', s.iframeSrc); // abort op in progress
				xhr.error = e;
				s.error && s.error.call(s.context, xhr, e, status);
				g && $.event.trigger("ajaxError", [xhr, s, e]);
				s.complete && s.complete.call(s.context, xhr, e);
			}
		};

		g = s.global;
		// trigger ajax global events so that activity/block indicators work like normal
		if (g && ! $.active++) {
			$.event.trigger("ajaxStart");
		}
		if (g) {
			$.event.trigger("ajaxSend", [xhr, s]);
		}

		if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
			if (s.global) {
				$.active--;
			}
			return;
		}
		if (xhr.aborted) {
			return;
		}

		// add submitting element to data if we know it
		sub = form.clk;
		if (sub) {
			n = sub.name;
			if (n && !sub.disabled) {
				s.extraData = s.extraData || {};
				s.extraData[n] = sub.value;
				if (sub.type == "image") {
					s.extraData[n+'.x'] = form.clk_x;
					s.extraData[n+'.y'] = form.clk_y;
				}
			}
		}
		
		var CLIENT_TIMEOUT_ABORT = 1;
		var SERVER_ABORT = 2;

		function getDoc(frame) {
			var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document;
			return doc;
		}
		
		// take a breath so that pending repaints get some cpu time before the upload starts
		function doSubmit() {
			// make sure form attrs are set
			var t = $form.attr('target'), a = $form.attr('action');

			// update form attrs in IE friendly way
			form.setAttribute('target',id);
			if (!method) {
				form.setAttribute('method', 'POST');
			}
			if (a != s.url) {
				form.setAttribute('action', s.url);
			}

			// ie borks in some cases when setting encoding
			if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
				$form.attr({
					encoding: 'multipart/form-data',
					enctype:  'multipart/form-data'
				});
			}

			// support timout
			if (s.timeout) {
				timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
			}
			
			// look for server aborts
			function checkState() {
				try {
					var state = getDoc(io).readyState;
					log('state = ' + state);
					if (state.toLowerCase() == 'uninitialized')
						setTimeout(checkState,50);
				}
				catch(e) {
					log('Server abort: ' , e, ' (', e.name, ')');
					cb(SERVER_ABORT);
					timeoutHandle && clearTimeout(timeoutHandle);
					timeoutHandle = undefined;
				}
			}

			// add "extra" data to form if provided in options
			var extraInputs = [];
			try {
				if (s.extraData) {
					for (var n in s.extraData) {
						extraInputs.push(
							$('<input type="hidden" name="'+n+'" />').attr('value',s.extraData[n])
								.appendTo(form)[0]);
					}
				}

				if (!s.iframeTarget) {
					// add iframe to doc and submit the form
					$io.appendTo('body');
	                io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
				}
				setTimeout(checkState,15);
				form.submit();
			}
			finally {
				// reset attrs and remove "extra" input elements
				form.setAttribute('action',a);
				if(t) {
					form.setAttribute('target', t);
				} else {
					$form.removeAttr('target');
				}
				$(extraInputs).remove();
			}
		}

		if (s.forceSync) {
			doSubmit();
		}
		else {
			setTimeout(doSubmit, 10); // this lets dom updates render
		}

		var data, doc, domCheckCount = 50, callbackProcessed;

		function cb(e) {
			if (xhr.aborted || callbackProcessed) {
				return;
			}
			try {
				doc = getDoc(io);
			}
			catch(ex) {
				log('cannot access response document: ', ex);
				e = SERVER_ABORT;
			}
			if (e === CLIENT_TIMEOUT_ABORT && xhr) {
				xhr.abort('timeout');
				return;
			}
			else if (e == SERVER_ABORT && xhr) {
				xhr.abort('server abort');
				return;
			}

			if (!doc || doc.location.href == s.iframeSrc) {
				// response not received yet
				if (!timedOut)
					return;
			}
            io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);

			var status = 'success', errMsg;
			try {
				if (timedOut) {
					throw 'timeout';
				}

				var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
				log('isXml='+isXml);
				if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
					if (--domCheckCount) {
						// in some browsers (Opera) the iframe DOM is not always traversable when
						// the onload callback fires, so we loop a bit to accommodate
						log('requeing onLoad callback, DOM not available');
						setTimeout(cb, 250);
						return;
					}
					// let this fall through because server response could be an empty document
					//log('Could not access iframe DOM after mutiple tries.');
					//throw 'DOMException: not available';
				}

				//log('response detected');
                var docRoot = doc.body ? doc.body : doc.documentElement;
                xhr.responseText = docRoot ? docRoot.innerHTML : null;
				xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
				if (isXml)
					s.dataType = 'xml';
				xhr.getResponseHeader = function(header){
					var headers = {'content-type': s.dataType};
					return headers[header];
				};
                // support for XHR 'status' & 'statusText' emulation :
                if (docRoot) {
                    xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status;
                    xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
                }

				var dt = (s.dataType || '').toLowerCase();
				var scr = /(json|script|text)/.test(dt);
				if (scr || s.textarea) {
					// see if user embedded response in textarea
					var ta = doc.getElementsByTagName('textarea')[0];
					if (ta) {
						xhr.responseText = ta.value;
                        // support for XHR 'status' & 'statusText' emulation :
                        xhr.status = Number( ta.getAttribute('status') ) || xhr.status;
                        xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
					}
					else if (scr) {
						// account for browsers injecting pre around json response
						var pre = doc.getElementsByTagName('pre')[0];
						var b = doc.getElementsByTagName('body')[0];
						if (pre) {
							xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;
						}
						else if (b) {
							xhr.responseText = b.textContent ? b.textContent : b.innerText;
						}
					}
				}
				else if (dt == 'xml' && !xhr.responseXML && xhr.responseText != null) {
					xhr.responseXML = toXml(xhr.responseText);
				}

                try {
                    data = httpData(xhr, dt, s);
                }
                catch (e) {
                    status = 'parsererror';
                    xhr.error = errMsg = (e || status);
                }
			}
			catch (e) {
				log('error caught: ',e);
				status = 'error';
                xhr.error = errMsg = (e || status);
			}

			if (xhr.aborted) {
				log('upload aborted');
				status = null;
			}

            if (xhr.status) { // we've set xhr.status
                status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error';
            }

			// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
			if (status === 'success') {
				s.success && s.success.call(s.context, data, 'success', xhr);
				g && $.event.trigger("ajaxSuccess", [xhr, s]);
			}
            else if (status) {
				if (errMsg == undefined)
					errMsg = xhr.statusText;
				s.error && s.error.call(s.context, xhr, status, errMsg);
				g && $.event.trigger("ajaxError", [xhr, s, errMsg]);
            }

			g && $.event.trigger("ajaxComplete", [xhr, s]);

			if (g && ! --$.active) {
				$.event.trigger("ajaxStop");
			}

			s.complete && s.complete.call(s.context, xhr, status);

			callbackProcessed = true;
			if (s.timeout)
				clearTimeout(timeoutHandle);

			// clean up
			setTimeout(function() {
				if (!s.iframeTarget)
					$io.remove();
				xhr.responseXML = null;
			}, 100);
		}

		var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
			if (window.ActiveXObject) {
				doc = new ActiveXObject('Microsoft.XMLDOM');
				doc.async = 'false';
				doc.loadXML(s);
			}
			else {
				doc = (new DOMParser()).parseFromString(s, 'text/xml');
			}
			return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
		};
		var parseJSON = $.parseJSON || function(s) {
			return window['eval']('(' + s + ')');
		};

		var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4

			var ct = xhr.getResponseHeader('content-type') || '',
				xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
				data = xml ? xhr.responseXML : xhr.responseText;

			if (xml && data.documentElement.nodeName === 'parsererror') {
				$.error && $.error('parsererror');
			}
			if (s && s.dataFilter) {
				data = s.dataFilter(data, type);
			}
			if (typeof data === 'string') {
				if (type === 'json' || !type && ct.indexOf('json') >= 0) {
					data = parseJSON(data);
				} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
					$.globalEval(data);
				}
			}
			return data;
		};
	}
};

/**
 * ajaxForm() provides a mechanism for fully automating form submission.
 *
 * The advantages of using this method instead of ajaxSubmit() are:
 *
 * 1: This method will include coordinates for <input type="image" /> elements (if the element
 *	is used to submit the form).
 * 2. This method will include the submit element's name/value data (for the element that was
 *	used to submit the form).
 * 3. This method binds the submit() method to the form for you.
 *
 * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely
 * passes the options argument along after properly binding events for submit elements and
 * the form itself.
 */
$.fn.ajaxForm = function(options) {
	// in jQuery 1.3+ we can fix mistakes with the ready state
	if (this.length === 0) {
		var o = { s: this.selector, c: this.context };
		if (!$.isReady && o.s) {
			log('DOM not ready, queuing ajaxForm');
			$(function() {
				$(o.s,o.c).ajaxForm(options);
			});
			return this;
		}
		// is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
		log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
		return this;
	}

	return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
		if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
			e.preventDefault();
			$(this).ajaxSubmit(options);
		}
	}).bind('click.form-plugin', function(e) {
		var target = e.target;
		var $el = $(target);
		if (!($el.is(":submit,input:image"))) {
			// is this a child element of the submit el?  (ex: a span within a button)
			var t = $el.closest(':submit');
			if (t.length == 0) {
				return;
			}
			target = t[0];
		}
		var form = this;
		form.clk = target;
		if (target.type == 'image') {
			if (e.offsetX != undefined) {
				form.clk_x = e.offsetX;
				form.clk_y = e.offsetY;
			} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
				var offset = $el.offset();
				form.clk_x = e.pageX - offset.left;
				form.clk_y = e.pageY - offset.top;
			} else {
				form.clk_x = e.pageX - target.offsetLeft;
				form.clk_y = e.pageY - target.offsetTop;
			}
		}
		// clear form vars
		setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
	});
};

// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
	return this.unbind('submit.form-plugin click.form-plugin');
};

/**
 * formToArray() gathers form element data into an array of objects that can
 * be passed to any of the following ajax functions: $.get, $.post, or load.
 * Each object in the array has both a 'name' and 'value' property.  An example of
 * an array for a simple login form might be:
 *
 * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
 *
 * It is this array that is passed to pre-submit callback functions provided to the
 * ajaxSubmit() and ajaxForm() methods.
 */
$.fn.formToArray = function(semantic) {
	var a = [];
	if (this.length === 0) {
		return a;
	}

	var form = this[0];
	var els = semantic ? form.getElementsByTagName('*') : form.elements;
	if (!els) {
		return a;
	}

	var i,j,n,v,el,max,jmax;
	for(i=0, max=els.length; i < max; i++) {
		el = els[i];
		n = el.name;
		if (!n) {
			continue;
		}

		if (semantic && form.clk && el.type == "image") {
			// handle image inputs on the fly when semantic == true
			if(!el.disabled && form.clk == el) {
				a.push({name: n, value: $(el).val()});
				a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
			}
			continue;
		}

		v = $.fieldValue(el, true);
		if (v && v.constructor == Array) {
			for(j=0, jmax=v.length; j < jmax; j++) {
				a.push({name: n, value: v[j]});
			}
		}
		else if (v !== null && typeof v != 'undefined') {
			a.push({name: n, value: v});
		}
	}

	if (!semantic && form.clk) {
		// input type=='image' are not found in elements array! handle it here
		var $input = $(form.clk), input = $input[0];
		n = input.name;
		if (n && !input.disabled && input.type == 'image') {
			a.push({name: n, value: $input.val()});
			a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
		}
	}
	return a;
};

/**
 * Serializes form data into a 'submittable' string. This method will return a string
 * in the format: name1=value1&amp;name2=value2
 */
$.fn.formSerialize = function(semantic) {
	//hand off to jQuery.param for proper encoding
	return $.param(this.formToArray(semantic));
};

/**
 * Serializes all field elements in the jQuery object into a query string.
 * This method will return a string in the format: name1=value1&amp;name2=value2
 */
$.fn.fieldSerialize = function(successful) {
	var a = [];
	this.each(function() {
		var n = this.name;
		if (!n) {
			return;
		}
		var v = $.fieldValue(this, successful);
		if (v && v.constructor == Array) {
			for (var i=0,max=v.length; i < max; i++) {
				a.push({name: n, value: v[i]});
			}
		}
		else if (v !== null && typeof v != 'undefined') {
			a.push({name: this.name, value: v});
		}
	});
	//hand off to jQuery.param for proper encoding
	return $.param(a);
};

/**
 * Returns the value(s) of the element in the matched set.  For example, consider the following form:
 *
 *  <form><fieldset>
 *	  <input name="A" type="text" />
 *	  <input name="A" type="text" />
 *	  <input name="B" type="checkbox" value="B1" />
 *	  <input name="B" type="checkbox" value="B2"/>
 *	  <input name="C" type="radio" value="C1" />
 *	  <input name="C" type="radio" value="C2" />
 *  </fieldset></form>
 *
 *  var v = $(':text').fieldValue();
 *  // if no values are entered into the text inputs
 *  v == ['','']
 *  // if values entered into the text inputs are 'foo' and 'bar'
 *  v == ['foo','bar']
 *
 *  var v = $(':checkbox').fieldValue();
 *  // if neither checkbox is checked
 *  v === undefined
 *  // if both checkboxes are checked
 *  v == ['B1', 'B2']
 *
 *  var v = $(':radio').fieldValue();
 *  // if neither radio is checked
 *  v === undefined
 *  // if first radio is checked
 *  v == ['C1']
 *
 * The successful argument controls whether or not the field element must be 'successful'
 * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
 * The default value of the successful argument is true.  If this value is false the value(s)
 * for each element is returned.
 *
 * Note: This method *always* returns an array.  If no valid value can be determined the
 *	   array will be empty, otherwise it will contain one or more values.
 */
$.fn.fieldValue = function(successful) {
	for (var val=[], i=0, max=this.length; i < max; i++) {
		var el = this[i];
		var v = $.fieldValue(el, successful);
		if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
			continue;
		}
		v.constructor == Array ? $.merge(val, v) : val.push(v);
	}
	return val;
};

/**
 * Returns the value of the field element.
 */
$.fieldValue = function(el, successful) {
	var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
	if (successful === undefined) {
		successful = true;
	}

	if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
		(t == 'checkbox' || t == 'radio') && !el.checked ||
		(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
		tag == 'select' && el.selectedIndex == -1)) {
			return null;
	}

	if (tag == 'select') {
		var index = el.selectedIndex;
		if (index < 0) {
			return null;
		}
		var a = [], ops = el.options;
		var one = (t == 'select-one');
		var max = (one ? index+1 : ops.length);
		for(var i=(one ? index : 0); i < max; i++) {
			var op = ops[i];
			if (op.selected) {
				var v = op.value;
				if (!v) { // extra pain for IE...
					v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
				}
				if (one) {
					return v;
				}
				a.push(v);
			}
		}
		return a;
	}
	return $(el).val();
};

/**
 * Clears the form data.  Takes the following actions on the form's input fields:
 *  - input text fields will have their 'value' property set to the empty string
 *  - select elements will have their 'selectedIndex' property set to -1
 *  - checkbox and radio inputs will have their 'checked' property set to false
 *  - inputs of type submit, button, reset, and hidden will *not* be effected
 *  - button elements will *not* be effected
 */
$.fn.clearForm = function() {
	return this.each(function() {
		$('input,select,textarea', this).clearFields();
	});
};

/**
 * Clears the selected form elements.
 */
$.fn.clearFields = $.fn.clearInputs = function() {
	var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
	return this.each(function() {
		var t = this.type, tag = this.tagName.toLowerCase();
		if (re.test(t) || tag == 'textarea') {
			this.value = '';
		}
		else if (t == 'checkbox' || t == 'radio') {
			this.checked = false;
		}
		else if (tag == 'select') {
			this.selectedIndex = -1;
		}
	});
};

/**
 * Resets the form data.  Causes all form elements to be reset to their original value.
 */
$.fn.resetForm = function() {
	return this.each(function() {
		// guard against an input with the name of 'reset'
		// note that IE reports the reset function as an 'object'
		if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
			this.reset();
		}
	});
};

/**
 * Enables or disables any matching elements.
 */
$.fn.enable = function(b) {
	if (b === undefined) {
		b = true;
	}
	return this.each(function() {
		this.disabled = !b;
	});
};

/**
 * Checks/unchecks any matching checkboxes or radio buttons and
 * selects/deselects and matching option elements.
 */
$.fn.selected = function(select) {
	if (select === undefined) {
		select = true;
	}
	return this.each(function() {
		var t = this.type;
		if (t == 'checkbox' || t == 'radio') {
			this.checked = select;
		}
		else if (this.tagName.toLowerCase() == 'option') {
			var $sel = $(this).parent('select');
			if (select && $sel[0] && $sel[0].type == 'select-one') {
				// deselect all other options
				$sel.find('option').selected(false);
			}
			this.selected = select;
		}
	});
};

// expose debug var
$.fn.ajaxSubmit.debug = false;

// helper fn for console logging
function log() {
	if (!$.fn.ajaxSubmit.debug) 
		return;
	var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
	if (window.console && window.console.log) {
		window.console.log(msg);
	}
	else if (window.opera && window.opera.postError) {
		window.opera.postError(msg);
	}
};

})(jQuery);
;
/*
	
	jQuery selectBox (version 1.0.6)
	
		A cosmetic, styleable replacement for SELECT elements.
	
		Homepage:   http://abeautifulsite.net/blog/2011/01/jquery-selectbox-plugin/
		Demo page:  http://labs.abeautifulsite.net/projects/js/jquery/selectBox/
		
		Copyright 2011 Cory LaViska for A Beautiful Site, LLC.
		
	Features:

		- Supports OPTGROUPS
		- Supports standard dropdown controls
		- Supports multi-select controls (i.e. multiple="multiple")
		- Supports inline controls (i.e. size="5")
		- Fully accessible via keyboard
		- Shift + click (or shift + enter) to select a range of options in multi-select controls
		- Type to search when the control has focus
		- Auto-height based on the size attribute (to use, omit the height property in your CSS!)
		- Tested in IE7-IE9, Firefox 3-4, recent webkit browsers, and Opera
	
	
	License:
		
		Licensed under both the MIT license and the GNU GPLv2 (same as jQuery: http://jquery.org/license)
	
	
	Usage:
		
		Link to the JS file:
			
			<script src="jquery.selectbox.min.js" type="text/javascript"></script>
		
		Add the CSS file (or append contents to your own stylesheet):
		
			<link href="jquery.selectbox.min.css" rel="stylesheet" type="text/css" />
		
		To create:
			
			$("SELECT").selectBox([settings]);
	
	
	Settings:
		
		To specify settings, use this syntax: $("SELECT").selectBox('settings', { settingName: value, ... });
			
			menuTransition: ['default', 'slide', 'fade'] - the show/hide transition for dropdown menus
			menuSpeed: [integer, 'slow', 'normal', 'fast'] - the show/hide transition speed
	
	
	Methods:
		
		To call a method use this syntax: $("SELECT").selectBox('methodName', [options]);
		
			create - Creates the control (default method)
			destroy - Destroys the selectBox control and reverts back to the original form control
			disable - Disables the control (i.e. disabled="disabled")
			enable - Enables the control
			value - if passed with a value, sets the control to that value; otherwise returns the current value
			options - pass in either a string of HTML or a JSON object to replace the existing options
			control - returns the selectBox control element (an anchor tag) for working with directly
	
	
	Events:
		
		Events are fired on the original select element. You can bind events like this:
			
			$("SELECT").selectBox().change( function() { alert( $(this).val() ); } );
			
			focus - Fired when the control gains focus
			blur - Fired when the control loses focus
			change - Fired when the value of a control changes
	
	
	Change Log:
		
		v1.0.0 (2011-04-03) - Complete rewrite with added support for inline and multi-select controls
		v1.0.1 (2011-04-04) - Fixed options method so it doesn't destroy/recreate the control when called.
		                    - Added a check for iOS devices (their native controls are much better for 
		                      touch-based devices; you can still use selectBox API methods for theme)
		                    - Fixed issue where IE window would lose focus on XP
		                    - Fixed premature selection issue in Webkit browsers
		v1.0.2 (2011-04-13) - Fixed auto-height for inline controls when control is invisible on load
		                    - Removed auto-width for dropdown and inline controls; now relies 100% on CSS
		                      for setting the width
		                   	- Added 'control' method for working directly with the selectBox control
		v1.0.3 (2011-04-22) - Fixed bug in value method that errored if the control didn't exist
		v1.0.4 (2011-04-22) - Fixed bug where controls without any options would render with incorrect heights
		v1.0.5 (2011-04-22) - Removed 'tick' image in lieu of background colors to indicate selection
		                    - Clicking no longer toggles selected/unselected in multi-selects; use CTRL/CMD and 
		                      SHIFT like in normal browser controls
		                    - Fixed bug where inline controls would not receive focus unless tabbed into
		v1.0.6 (2011-04-29) - Fixed bug where inline controls could be "dragged" when selecting an empty area
		
		                      
	Known Issues:
	
		- The blur and focus callbacks are not very reliable in IE7. The change callback works fine.
	
*/
if(jQuery) (function($) {
	
	$.extend($.fn, {
		
		selectBox: function(method, data) {
			
			var typeTimer, typeSearch = '';
			var longest = 0;			
			
			//
			// Private methods
			//
			
			
			var init = function(select, data) {
				
				// Disable for iOS devices (their native controls are more suitable for a touch device)
				if( navigator.userAgent.match(/iPad|iPhone/i) ) return false;
				
				// Element must be a select control
				if( select.tagName.toLowerCase() !== 'select' ) return false;
				
				select = $(select);
				var css_id = 'selectBox-'+select.attr('id');
				if( select.data('selectBox-control') ) return false;
				
				var control = $('<a class="selectBox" />'),
					inline = select.attr('multiple') || parseInt(select.attr('size')) > 1;
				
				var settings = data || {};
				
				// Inherit class names, style, and title attributes
				control
					.addClass(select.attr('class'))
					.attr('style', select.attr('style') || '')
					.attr('title', select.attr('title') || '')
					.attr('tabindex', parseInt(select.attr('tabindex')))
					.css('display', 'inline-block')
					.bind('focus.selectBox', function() {
						if( this !== document.activeElement ) $(document.activeElement).blur();
						if( control.hasClass('selectBox-active') ) return;
						control.addClass('selectBox-active');
						select.trigger('focus');
					})
					.bind('blur.selectBox', function() {
						if( !control.hasClass('selectBox-active') ) return;
						control.removeClass('selectBox-active');
						select.trigger('blur');
					});
				
				if( select.attr('disabled') ) control.addClass('selectBox-disabled');
				
				// Generate control
				if( inline ) {
					
					//
					// Inline controls
					//
					var options = getOptions(select, 'inline');
					
					control
						.append(options)
						.data('selectBox-options', options)
						.addClass('selectBox-inline')
						.addClass('selectBox-menuShowing')
						.bind('keydown.selectBox', function(event) {
							handleKeyDown(select, event);
						})
						.bind('keypress.selectBox', function(event) {
							handleKeyPress(select, event);
						})
						.bind('mousedown.selectBox', function(event) {
							if( $(event.target).is('A.selectBox-inline') ) event.preventDefault();
							if( !control.hasClass('selectBox-focus') ) control.focus();
						})
						.insertAfter(select);
					
					// Auto-height based on size attribute
					if( !select[0].style.height ) {
						
						var size = select.attr('size') ? parseInt(select.attr('size')) : 5;
						
						// Draw a dummy control off-screen, measure, and remove it
						var tmp = control
							.clone()
							.removeAttr('id')
							.css({
								position: 'absolute',
								top: '-9999em'
							})
							.show()
							.appendTo('body');
						tmp.find('.selectBox-options').html('<li><a>\u00A0</a></li>');
						optionHeight = parseInt(tmp.find('.selectBox-options A:first').html('&nbsp;').outerHeight());
						tmp.remove();
						
						control.height(optionHeight * size);
						
					}
					
					disableSelection(control);
					
				} else {
					
					//
					// Dropdown controls
					//
					
					var label = $('<span class="selectBox-label" />'),
						arrow = $('<span class="selectBox-arrow" />');
					
					label.text( $(select).find('OPTION:selected').text() || '\u00A0' );
					
					var options = getOptions(select, 'dropdown');
					options.appendTo('BODY');
					options.attr('id',css_id);
					control
						.data('selectBox-options', options)
						.addClass('selectBox-dropdown')
						.append(label)
						.append(arrow)
						.bind('mousedown.selectBox', function(event) {
							if( control.hasClass('selectBox-menuShowing') ) {
								hideMenus();
							} else {
								event.stopPropagation();
								// Webkit fix to prevent premature selection of options
								options.data('selectBox-down-at-x', event.screenX).data('selectBox-down-at-y', event.screenY);
								showMenu(select);
							}
						})
						.bind('keydown.selectBox', function(event) {
							handleKeyDown(select, event);
						})
						.bind('keypress.selectBox', function(event) {
							handleKeyPress(select, event);
						})
						.insertAfter(select);
					
					disableSelection(control);
						
				}
				
				// Store data for later use and show the control
				select
					.addClass('selectBox')
					.data('selectBox-control', control)
					.data('selectBox-settings', settings)
					.hide();
				
			};
			
			
			var getOptions = function(select, type) {
				
				var options;
				switch( type ) {
					
					case 'inline':
						

						options = $('<ul class="selectBox-options" />');
						
						if( select.find('OPTGROUP').length ) {
							select.find('OPTGROUP').each( function() {
								
								var optgroup = $('<li class="selectBox-optgroup" />');
								optgroup.text($(this).attr('label'));
								options.append(optgroup);
								
								$(this).find('OPTION').each( function() {
									var li = $('<li />'),
										a = $('<a />');
									li.addClass( $(this).attr('class') );
									a.attr('rel', $(this).val()).text( $(this).text() );
									li.append(a);
									if( $(this).attr('disabled') ) li.addClass('selectBox-disabled');
									if( $(this).attr('selected') ) li.addClass('selectBox-selected');
									options.append(li);
								});
								
							});
						
						} else {
						
							select.find('OPTION').each( function() {
								var li = $('<li />'),
									a = $('<a />');
								li.addClass( $(this).attr('class') );
								a.attr('rel', $(this).val()).text( $(this).text() );
								li.append(a);
								if( $(this).attr('disabled') ) li.addClass('selectBox-disabled');
								if( $(this).attr('selected') ) li.addClass('selectBox-selected');
								options.append(li);
							});
							
						}
						
						options
							.find('A')
								.bind('mouseover.selectBox', function(event) {
									addHover(select, $(this).parent());
								})
								.bind('mouseout.selectBox', function(event) {
									removeHover(select, $(this).parent());
								})
								.bind('mousedown.selectBox', function(event) {
									event.preventDefault(); // Prevent options from being "dragged"
									if( !select.selectBox('control').hasClass('selectBox-active') ) select.selectBox('control').focus();
								})
								.bind('mouseup.selectBox', function(event) {
									hideMenus();
									selectOption(select, $(this).parent(), event);
								});
						
						disableSelection(options);
						
						return options;
					
					case 'dropdown':
						
						options = $('<ul class="selectBox-dropdown-menu selectBox-options" />');
						
						if( select.find('OPTGROUP').length ) {
							var groups = 0;
							options = $('<div class="selectBox-dropdown-menu selectBox-options" />');
							options.addClass("dynamic");
							select.find('OPTGROUP').each( function() {
								var optgroup = $('<ul class="selectBox-optgroup" />');
								//optgroup.text($(this).attr('label'));							
								options.append(optgroup);
								$(this).find('OPTION').each( function() {
									var li = $('<li />'),
										a = $('<a />');
									li.addClass( $(this).attr('class') );
									a.attr('rel', $(this).val()).text( $(this).text() );
									li.append(a);
									if( $(this).attr('disabled') ) li.addClass('selectBox-disabled');
									if( $(this).attr('selected') ) li.addClass('selectBox-selected');
									optgroup.append(li);
									if ($(this).text().length > longest) { longest = $(this).text().length; }
								});
								groups++;	
							});
						} else {
							
							if( select.find('OPTION').length > 0 ) {
								select.find('OPTION').each( function() {
									var li = $('<li />'),
										a = $('<a />');
									li.addClass( $(this).attr('class') );
									a.attr('rel', $(this).val()).text( $(this).text() );
									li.append(a);
									if( $(this).attr('disabled') ) li.addClass('selectBox-disabled');
									if( $(this).attr('selected') ) li.addClass('selectBox-selected');
									options.append(li);
								});
							} else {
								options.append('<li>\u00A0</li>');
							}
							
						}
						
						options
							.data('selectBox-select', select)
							.css('display', 'none')
							.appendTo('BODY')
							.find('A')
								.bind('mousedown.selectBox', function(event) {
									event.preventDefault(); // Prevent options from being "dragged"
									if( event.screenX === options.data('selectBox-down-at-x') && event.screenY === options.data('selectBox-down-at-y') ) {
										options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');
										hideMenus();
									}
								})
								.bind('mouseup.selectBox', function(event) {
									if( event.screenX === options.data('selectBox-down-at-x') && event.screenY === options.data('selectBox-down-at-y') ) {
										return;
									} else {
										options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');
									}
									selectOption(select, $(this).parent());
									hideMenus();
								}).bind('mouseover.selectBox', function(event) {
									addHover(select, $(this).parent());
								})
								.bind('mouseout.selectBox', function(event) {
									removeHover(select, $(this).parent());
								});
						
						disableSelection(options);
						
						return options;
					
				}
				
			};
			
			
			var destroy = function(select) {
				
				select = $(select);
				
				var control = select.data('selectBox-control');
				if( !control ) return;
				var options = control.data('selectBox-options');
				
				options.remove();
				control.remove();
				select
					.removeClass('selectBox')
					.removeData('selectBox-control')
					.removeData('selectBox-settings')
					.show();
				
			};
			
			
			var showMenu = function(select) {
				
				select = $(select);
				var control = select.data('selectBox-control'),
					settings = select.data('selectBox-settings'),
					options = control.data('selectBox-options');
				if( control.hasClass('selectBox-disabled') ) return false;
				
				hideMenus();
				
				// Show menu
				var bbWidth = parseInt(control.css('borderBottomWidth'));
				if (!bbWidth) { bbWidth = 0; }
				options.css({
					//width: 10+control.outerWidth() - (parseInt(control.css('borderLeftWidth')) + parseInt(control.css('borderLeftWidth'))),
					top: 5+control.offset().top + control.outerHeight() - bbWidth,
					left: control.offset().left
				});
				
				switch( settings.menuTransition ) {
					
					case 'fade':
						options.fadeIn(settings.menuSpeed);
						break;
					
					case 'slide':
						options.slideDown(settings.menuSpeed);
						break;
					
					default:
						options.show(settings.menuSpeed);
						break;
					
				}
				
				// Center on selected option
				var li = options.find('.selectBox-selected:first');
				keepOptionInView(select, li, true);
				addHover(select, li);
				
				control.addClass('selectBox-menuShowing');
				
				$(document).bind('mousedown.selectBox', function(event) {
					if( $(event.target).parents().andSelf().hasClass('selectBox-options') ) return;
					hideMenus();
				});
				
			};
			
			
			var hideMenus = function() {
				
				if( $(".selectBox-dropdown-menu").length === 0 ) return;
				$(document).unbind('mousedown.selectBox');
				
				$(".selectBox-dropdown-menu").each( function() {
					
					var options = $(this),
						select = options.data('selectBox-select'),
						control = select.data('selectBox-control'),
						settings = select.data('selectBox-settings');
					
					switch( settings.menuTransition ) {
						
						case 'fade':
							options.fadeOut(settings.menuSpeed);
							break;
						
						case 'slide':
							options.slideUp(settings.menuSpeed);
							break;
							
						default:
							options.hide(settings.menuSpeed);
							break;
						
					}
					
					control.removeClass('selectBox-menuShowing');
					
				});
				
			};
			
			
			var selectOption = function(select, li, event) {
				
				select = $(select);
				li = $(li);
				var control = select.data('selectBox-control'),
					settings = select.data('selectBox-settings');
				if( control.hasClass('selectBox-disabled') ) return false;
				if( li.length === 0 || li.hasClass('selectBox-disabled') ) return false;
				
				if( select.attr('multiple') ) {
					
					// If event.shiftKey is true, this will select all options between li and the last li selected
					if( event.shiftKey && control.data('selectBox-last-selected') ) {
						
						li.toggleClass('selectBox-selected');
						
						var affectedOptions;
						if( li.index() > control.data('selectBox-last-selected').index() ) {
							affectedOptions = li.siblings().slice(control.data('selectBox-last-selected').index(), li.index());
						} else {
							affectedOptions = li.siblings().slice(li.index(), control.data('selectBox-last-selected').index());
						}
						
						affectedOptions = affectedOptions.not('.selectBox-optgroup, .selectBox-disabled');
						
						if( li.hasClass('selectBox-selected') ) {
							affectedOptions.addClass('selectBox-selected');
						} else {
							affectedOptions.removeClass('selectBox-selected');
						}
						
					} else if( event.metaKey ) {
						li.toggleClass('selectBox-selected');
					} else {
						li.siblings().removeClass('selectBox-selected');
						li.addClass('selectBox-selected');
					}
					
				} else {
					li.siblings().removeClass('selectBox-selected');
					li.addClass('selectBox-selected');
				}
				
				if( control.hasClass('selectBox-dropdown') ) {
					control.find('.selectBox-label').text(li.text());
				}
				// Update original control's value
				var i = 0, selection = [];
				if( select.attr('multiple') ) {
					control.find('.selectBox-selected A').each( function() {
						selection[i++] = $(this).attr('rel');
					});
				} else {
					selection = li.find('A').attr('rel');
				}
				
				// Remember most recently selected item
				control.data('selectBox-last-selected', li);
				
				// Change callback
				if( select.val() !== selection ) {
					select.val(selection);
					select.trigger('change');
				}
				
				return true;
				
			};
			
			
			var addHover = function(select, li) {
				select = $(select);
				li = $(li);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options');
				
				options.find('.selectBox-hover').removeClass('selectBox-hover');
				li.addClass('selectBox-hover');
			};
			
			
			var removeHover = function(select, li) {
				select = $(select);
				li = $(li);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options');
				options.find('.selectBox-hover').removeClass('selectBox-hover');
			};
			
			
			var keepOptionInView = function(select, li, center) {
				
				if( !li || li.length === 0 ) return;
				
				select = $(select);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options'),
					scrollBox = control.hasClass('selectBox-dropdown') ? options : options.parent(),
					top = parseInt(li.offset().top - scrollBox.position().top),
					bottom = parseInt(top + li.outerHeight());
				
				if( center ) {
					scrollBox.scrollTop( li.offset().top - scrollBox.offset().top + scrollBox.scrollTop() - (scrollBox.height() / 2) );
				} else {
					if( top < 0 ) {
						scrollBox.scrollTop( li.offset().top - scrollBox.offset().top + scrollBox.scrollTop() );
					}
					if( bottom > scrollBox.height() ) {
						scrollBox.scrollTop( (li.offset().top + li.outerHeight()) - scrollBox.offset().top + scrollBox.scrollTop() - scrollBox.height() );
					}
				}
				
			};
			
			
			var handleKeyDown = function(select, event) {
				
				//
				// Handles open/close and arrow key functionality
				//
				
				select = $(select);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options'),
					totalOptions = 0,
					i = 0;
				
				if( control.hasClass('selectBox-disabled') ) return;
				
				switch( event.keyCode ) {
					
					case 8: // backspace
						event.preventDefault();
						typeSearch = '';
						break;
					
					case 9: // tab
					case 27: // esc
						hideMenus();
						removeHover(select);
						break;
					
					case 13: // enter
						if( control.hasClass('selectBox-menuShowing') ) {
							selectOption(select, options.find('LI.selectBox-hover:first'), event);
							if( control.hasClass('selectBox-dropdown') ) hideMenus();
						} else {
							showMenu(select);
						}
						break;
						
					case 38: // up
					case 37: // left
						
						event.preventDefault();
						
						if( control.hasClass('selectBox-menuShowing') ) {
							
							var prev = options.find('.selectBox-hover').prev('LI');
							totalOptions = options.find('LI:not(.selectBox-optgroup)').length;
							i = 0;
							
							while( prev.length === 0 || prev.hasClass('selectBox-disabled') || prev.hasClass('selectBox-optgroup') ) {
								prev = prev.prev('LI');
								if( prev.length === 0 ) prev = options.find('LI:last');
								if( ++i >= totalOptions ) break;
							}
							
							addHover(select, prev);
							keepOptionInView(select, prev);
							
						} else {
							showMenu(select);
						}
						
						break;
						
					case 40: // down
					case 39: // right
					
						event.preventDefault();
						
						if( control.hasClass('selectBox-menuShowing') ) {
							
							var next = options.find('.selectBox-hover').next('LI');
							totalOptions = options.find('LI:not(.selectBox-optgroup)').length;
							i = 0;
							
							while( next.length === 0 || next.hasClass('selectBox-disabled') || next.hasClass('selectBox-optgroup') ) {
								next = next.next('LI');
								if( next.length === 0 ) next = options.find('LI:first');
								if( ++i >= totalOptions ) break;
							}
							
							addHover(select, next);
							keepOptionInView(select, next);
							
						} else {
							showMenu(select);
						}
						
						break;
						
				}
				
			};
			
			
			var handleKeyPress = function(select, event) {
				
				//
				// Handles type-to-find functionality
				//
				
				select = $(select);
				var control = select.data('selectBox-control'),
					options = control.data('selectBox-options');
				
				if( control.hasClass('selectBox-disabled') ) return;
				
				switch( event.keyCode ) {
					
					case 9: // tab
					case 27: // esc
					case 13: // enter
					case 38: // up
					case 37: // left
					case 40: // down
					case 39: // right
						// Don't interfere with the keydown event!
						break;
					
					default: // Type to find
						
						if( !control.hasClass('selectBox-menuShowing') ) showMenu(select);
						
						event.preventDefault();
						
						clearTimeout(typeTimer);
						typeSearch += String.fromCharCode(event.charCode || event.keyCode);
						
						options.find('A').each( function() {
							if( $(this).text().substr(0, typeSearch.length).toLowerCase() === typeSearch.toLowerCase() ) {
								addHover(select, $(this).parent());
								keepOptionInView(select, $(this).parent());
								return false;
							}
						});
						
						// Clear after a brief pause
						typeTimer = setTimeout( function() { typeSearch = ''; }, 1000);
						
						break;
						
				}
				
			};
			
			
			var enable = function(select) {
				select = $(select);
				select.attr('disabled', false);
				var control = select.data('selectBox-control');
				if( !control ) return;
				control.removeClass('selectBox-disabled');
			};
			
			
			var disable = function(select) {
				select = $(select);
				select.attr('disabled', true);
				var control = select.data('selectBox-control');
				if( !control ) return;
				control.addClass('selectBox-disabled');
			};
			
			
			var setValue = function(select, value) {
				select = $(select);
				select.val(value);
				value = select.val();
				var control = select.data('selectBox-control');
				if( !control ) return;
				var settings = select.data('selectBox-settings'),
					options = control.data('selectBox-options');
				
				// Update label
				control.find('.selectBox-label').text( $(select).find('OPTION:selected').text() || '\u00A0' );
				
				// Update control values
				options.find('.selectBox-selected').removeClass('selectBox-selected');
				options.find('A').each( function() {
					if( typeof(value) === 'object' ) {
						for( var i = 0; i < value.length; i++ ) {
							if( $(this).attr('rel') == value[i] ) {
								$(this).parent().addClass('selectBox-selected');
							}
						}
					} else {
						if( $(this).attr('rel') == value ) {
							$(this).parent().addClass('selectBox-selected');
						}
					}
				});
				
				if( settings.change ) settings.change.call(select);
				
			};
			
			
			var setOptions = function(select, options) {
				
				select = $(select);
				var control = select.data('selectBox-control'),
					settings = select.data('selectBox-settings');
				
				switch( typeof(data) ) {
					
					case 'string':
						select.html(data);
						break;
						
					case 'object':
						select.html('');
						for( var i in data ) {
							if( data[i] === null ) continue;
							if( typeof(data[i]) === 'object' ) {
								var optgroup = $('<optgroup label="' + i + '" />');
								for( var j in data[i] ) {
									optgroup.append('<option value="' + j + '">' + data[i][j] + '</option>');
								}
								select.append(optgroup);
							} else {
								var option = $('<option value="' + i + '">' + data[i] + '</option>');
								select.append(option);
							}
						}
						break;
					
				}
				
				if( !control ) return;
				
				// Remove old options
				control.data('selectBox-options').remove();
				
				// Generate new options
				var type = control.hasClass('selectBox-dropdown') ? 'dropdown' : 'inline',
					options = getOptions(select, type);
				control.data('selectBox-options', options);
				
				switch( type ) {
					case 'inline':
						control.append(options);
						break;
					case 'dropdown':
						control.find('.selectBox-label').text( $(select).find('OPTION:selected').text() || '\u00A0' );
						$("BODY").append(options);
						break;
				}
				
			};
			
			
			var disableSelection = function(selector) {
				$(selector)
					.css('MozUserSelect', 'none')
					.bind('selectstart', function(event) {
						event.preventDefault();
					});
			};
			
			
			//
			// Public methods
			//
			
			
			switch( method ) {
				
				case 'control':
					return $(this).data('selectBox-control');
					break;
				
				case 'settings':
					if( !data ) return $(this).data('selectBox-settings');
					$(this).each( function() {
						$(this).data('selectBox-settings', $.extend(true, $(this).data('selectBox-settings'), data));
					});
					break;
				
				case 'options':
					$(this).each( function() {
						setOptions(this, data);
					});
					break;
				
				case 'value':
					if( !data ) return $(this).val();
					$(this).each( function() {
						setValue(this, data);
					});
					break;
				
				case 'enable':
					$(this).each( function() {
						enable(this);
					});
					break;
				
				case 'disable':
					$(this).each( function() {
						disable(this);
					});
					break;
				
				case 'destroy':
					$(this).each( function() {
						destroy(this);
					});
					break;
				
				default:
					$(this).each( function() {
						init(this, method);
					});
					break;
				
			}
			
			return $(this);
			
		}
		
	});
	
})(jQuery);;
/**
 * jQuery Validation Plugin 1.9.0
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2011 Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function(c){c.extend(c.fn,{validate:function(a){if(this.length){var b=c.data(this[0],"validator");if(b)return b;this.attr("novalidate","novalidate");b=new c.validator(a,this[0]);c.data(this[0],"validator",b);if(b.settings.onsubmit){a=this.find("input, button");a.filter(".cancel").click(function(){b.cancelSubmit=true});b.settings.submitHandler&&a.filter(":submit").click(function(){b.submitButton=this});this.submit(function(d){function e(){if(b.settings.submitHandler){if(b.submitButton)var f=c("<input type='hidden'/>").attr("name",
b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);b.settings.submitHandler.call(b,b.currentForm);b.submitButton&&f.remove();return false}return true}b.settings.debug&&d.preventDefault();if(b.cancelSubmit){b.cancelSubmit=false;return e()}if(b.form()){if(b.pendingRequest){b.formSubmitted=true;return false}return e()}else{b.focusInvalid();return false}})}return b}else a&&a.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing")},valid:function(){if(c(this[0]).is("form"))return this.validate().form();
else{var a=true,b=c(this[0].form).validate();this.each(function(){a&=b.element(this)});return a}},removeAttrs:function(a){var b={},d=this;c.each(a.split(/\s/),function(e,f){b[f]=d.attr(f);d.removeAttr(f)});return b},rules:function(a,b){var d=this[0];if(a){var e=c.data(d.form,"validator").settings,f=e.rules,g=c.validator.staticRules(d);switch(a){case "add":c.extend(g,c.validator.normalizeRule(b));f[d.name]=g;if(b.messages)e.messages[d.name]=c.extend(e.messages[d.name],b.messages);break;case "remove":if(!b){delete f[d.name];
return g}var h={};c.each(b.split(/\s/),function(j,i){h[i]=g[i];delete g[i]});return h}}d=c.validator.normalizeRules(c.extend({},c.validator.metadataRules(d),c.validator.classRules(d),c.validator.attributeRules(d),c.validator.staticRules(d)),d);if(d.required){e=d.required;delete d.required;d=c.extend({required:e},d)}return d}});c.extend(c.expr[":"],{blank:function(a){return!c.trim(""+a.value)},filled:function(a){return!!c.trim(""+a.value)},unchecked:function(a){return!a.checked}});c.validator=function(a,
b){this.settings=c.extend(true,{},c.validator.defaults,a);this.currentForm=b;this.init()};c.validator.format=function(a,b){if(arguments.length==1)return function(){var d=c.makeArray(arguments);d.unshift(a);return c.validator.format.apply(this,d)};if(arguments.length>2&&b.constructor!=Array)b=c.makeArray(arguments).slice(1);if(b.constructor!=Array)b=[b];c.each(b,function(d,e){a=a.replace(RegExp("\\{"+d+"\\}","g"),e)});return a};c.extend(c.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",
validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:c([]),errorLabelContainer:c([]),onsubmit:true,ignore:":hidden",ignoreTitle:false,onfocusin:function(a){this.lastActive=a;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass);this.addWrapper(this.errorsFor(a)).hide()}},onfocusout:function(a){if(!this.checkable(a)&&(a.name in this.submitted||!this.optional(a)))this.element(a)},
onkeyup:function(a){if(a.name in this.submitted||a==this.lastElement)this.element(a)},onclick:function(a){if(a.name in this.submitted)this.element(a);else a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).addClass(b).removeClass(d):c(a).addClass(b).removeClass(d)},unhighlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).removeClass(b).addClass(d):c(a).removeClass(b).addClass(d)}},setDefaults:function(a){c.extend(c.validator.defaults,
a)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:c.validator.format("Please enter no more than {0} characters."),
minlength:c.validator.format("Please enter at least {0} characters."),rangelength:c.validator.format("Please enter a value between {0} and {1} characters long."),range:c.validator.format("Please enter a value between {0} and {1}."),max:c.validator.format("Please enter a value less than or equal to {0}."),min:c.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){function a(e){var f=c.data(this[0].form,"validator"),g="on"+e.type.replace(/^validate/,
"");f.settings[g]&&f.settings[g].call(f,this[0],e)}this.labelContainer=c(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||c(this.currentForm);this.containers=c(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var b=this.groups={};c.each(this.settings.groups,function(e,f){c.each(f.split(/\s/),function(g,h){b[h]=e})});var d=
this.settings.rules;c.each(d,function(e,f){d[e]=c.validator.normalizeRule(f)});c(this.currentForm).validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",a).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",
a);this.settings.invalidHandler&&c(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){this.checkForm();c.extend(this.submitted,this.errorMap);this.invalid=c.extend({},this.errorMap);this.valid()||c(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(a){this.lastElement=
a=this.validationTargetFor(this.clean(a));this.prepareElement(a);this.currentElements=c(a);var b=this.check(a);if(b)delete this.invalid[a.name];else this.invalid[a.name]=true;if(!this.numberOfInvalids())this.toHide=this.toHide.add(this.containers);this.showErrors();return b},showErrors:function(a){if(a){c.extend(this.errorMap,a);this.errorList=[];for(var b in a)this.errorList.push({message:a[b],element:this.findByName(b)[0]});this.successList=c.grep(this.successList,function(d){return!(d.name in a)})}this.settings.showErrors?
this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){c.fn.resetForm&&c(this.currentForm).resetForm();this.submitted={};this.lastElement=null;this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b=0,d;for(d in a)b++;return b},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return this.size()==
0},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{c(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(a){}},findLastActive:function(){var a=this.lastActive;return a&&c.grep(this.errorList,function(b){return b.element.name==a.name}).length==1&&a},elements:function(){var a=this,b={};return c(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&
a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in b||!a.objectLength(c(this).rules()))return false;return b[this.name]=true})},clean:function(a){return c(a)[0]},errors:function(){return c(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext)},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=c([]);this.toHide=c([]);this.currentElements=c([])},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers)},
prepareElement:function(a){this.reset();this.toHide=this.errorsFor(a)},check:function(a){a=this.validationTargetFor(this.clean(a));var b=c(a).rules(),d=false,e;for(e in b){var f={method:e,parameters:b[e]};try{var g=c.validator.methods[e].call(this,a.value.replace(/\r/g,""),a,f.parameters);if(g=="dependency-mismatch")d=true;else{d=false;if(g=="pending"){this.toHide=this.toHide.not(this.errorsFor(a));return}if(!g){this.formatAndAdd(a,f);return false}}}catch(h){this.settings.debug&&window.console&&console.log("exception occured when checking element "+
a.id+", check the '"+f.method+"' method",h);throw h;}}if(!d){this.objectLength(b)&&this.successList.push(a);return true}},customMetaMessage:function(a,b){if(c.metadata){var d=this.settings.meta?c(a).metadata()[this.settings.meta]:c(a).metadata();return d&&d.messages&&d.messages[b]}},customMessage:function(a,b){var d=this.settings.messages[a];return d&&(d.constructor==String?d:d[b])},findDefined:function(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==undefined)return arguments[a]},defaultMessage:function(a,
b){return this.findDefined(this.customMessage(a.name,b),this.customMetaMessage(a,b),!this.settings.ignoreTitle&&a.title||undefined,c.validator.messages[b],"<strong>Warning: No message defined for "+a.name+"</strong>")},formatAndAdd:function(a,b){var d=this.defaultMessage(a,b.method),e=/\$?\{(\d+)\}/g;if(typeof d=="function")d=d.call(this,b.parameters,a);else if(e.test(d))d=jQuery.format(d.replace(e,"{$1}"),b.parameters);this.errorList.push({message:d,element:a});this.errorMap[a.name]=d;this.submitted[a.name]=
d},addWrapper:function(a){if(this.settings.wrapper)a=a.add(a.parent(this.settings.wrapper));return a},defaultShowErrors:function(){for(var a=0;this.errorList[a];a++){var b=this.errorList[a];this.settings.highlight&&this.settings.highlight.call(this,b.element,this.settings.errorClass,this.settings.validClass);this.showLabel(b.element,b.message)}if(this.errorList.length)this.toShow=this.toShow.add(this.containers);if(this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);
if(this.settings.unhighlight){a=0;for(b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass)}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return c(this.errorList).map(function(){return this.element})},showLabel:function(a,b){var d=this.errorsFor(a);if(d.length){d.removeClass(this.settings.validClass).addClass(this.settings.errorClass);
d.attr("generated")&&d.html(b)}else{d=c("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(a),generated:true}).addClass(this.settings.errorClass).html(b||"");if(this.settings.wrapper)d=d.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();this.labelContainer.append(d).length||(this.settings.errorPlacement?this.settings.errorPlacement(d,c(a)):d.insertAfter(a))}if(!b&&this.settings.success){d.text("");typeof this.settings.success=="string"?d.addClass(this.settings.success):this.settings.success(d)}this.toShow=
this.toShow.add(d)},errorsFor:function(a){var b=this.idOrName(a);return this.errors().filter(function(){return c(this).attr("for")==b})},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(a){if(this.checkable(a))a=this.findByName(a.name).not(this.settings.ignore)[0];return a},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(a){var b=this.currentForm;return c(document.getElementsByName(a)).map(function(d,
e){return e.form==b&&e.name==a&&e||null})},getLength:function(a,b){switch(b.nodeName.toLowerCase()){case "select":return c("option:selected",b).length;case "input":if(this.checkable(b))return this.findByName(b.name).filter(":checked").length}return a.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):true},dependTypes:{"boolean":function(a){return a},string:function(a,b){return!!c(a,b.form).length},"function":function(a,b){return a(b)}},optional:function(a){return!c.validator.methods.required.call(this,
c.trim(a.value),a)&&"dependency-mismatch"},startRequest:function(a){if(!this.pending[a.name]){this.pendingRequest++;this.pending[a.name]=true}},stopRequest:function(a,b){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[a.name];if(b&&this.pendingRequest==0&&this.formSubmitted&&this.form()){c(this.currentForm).submit();this.formSubmitted=false}else if(!b&&this.pendingRequest==0&&this.formSubmitted){c(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=
false}},previousValue:function(a){return c.data(a,"previousValue")||c.data(a,"previousValue",{old:null,valid:true,message:this.defaultMessage(a,"remote")})}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(a,b){a.constructor==String?this.classRuleSettings[a]=b:c.extend(this.classRuleSettings,
a)},classRules:function(a){var b={};(a=c(a).attr("class"))&&c.each(a.split(" "),function(){this in c.validator.classRuleSettings&&c.extend(b,c.validator.classRuleSettings[this])});return b},attributeRules:function(a){var b={};a=c(a);for(var d in c.validator.methods){var e;if(e=d==="required"&&typeof c.fn.prop==="function"?a.prop(d):a.attr(d))b[d]=e;else if(a[0].getAttribute("type")===d)b[d]=true}b.maxlength&&/-1|2147483647|524288/.test(b.maxlength)&&delete b.maxlength;return b},metadataRules:function(a){if(!c.metadata)return{};
var b=c.data(a.form,"validator").settings.meta;return b?c(a).metadata()[b]:c(a).metadata()},staticRules:function(a){var b={},d=c.data(a.form,"validator");if(d.settings.rules)b=c.validator.normalizeRule(d.settings.rules[a.name])||{};return b},normalizeRules:function(a,b){c.each(a,function(d,e){if(e===false)delete a[d];else if(e.param||e.depends){var f=true;switch(typeof e.depends){case "string":f=!!c(e.depends,b.form).length;break;case "function":f=e.depends.call(b,b)}if(f)a[d]=e.param!==undefined?
e.param:true;else delete a[d]}});c.each(a,function(d,e){a[d]=c.isFunction(e)?e(b):e});c.each(["minlength","maxlength","min","max"],function(){if(a[this])a[this]=Number(a[this])});c.each(["rangelength","range"],function(){if(a[this])a[this]=[Number(a[this][0]),Number(a[this][1])]});if(c.validator.autoCreateRanges){if(a.min&&a.max){a.range=[a.min,a.max];delete a.min;delete a.max}if(a.minlength&&a.maxlength){a.rangelength=[a.minlength,a.maxlength];delete a.minlength;delete a.maxlength}}a.messages&&delete a.messages;
return a},normalizeRule:function(a){if(typeof a=="string"){var b={};c.each(a.split(/\s/),function(){b[this]=true});a=b}return a},addMethod:function(a,b,d){c.validator.methods[a]=b;c.validator.messages[a]=d!=undefined?d:c.validator.messages[a];b.length<3&&c.validator.addClassRules(a,c.validator.normalizeRule(a))},methods:{required:function(a,b,d){if(!this.depend(d,b))return"dependency-mismatch";switch(b.nodeName.toLowerCase()){case "select":return(a=c(b).val())&&a.length>0;case "input":if(this.checkable(b))return this.getLength(a,
b)>0;default:return c.trim(a).length>0}},remote:function(a,b,d){if(this.optional(b))return"dependency-mismatch";var e=this.previousValue(b);this.settings.messages[b.name]||(this.settings.messages[b.name]={});e.originalMessage=this.settings.messages[b.name].remote;this.settings.messages[b.name].remote=e.message;d=typeof d=="string"&&{url:d}||d;if(this.pending[b.name])return"pending";if(e.old===a)return e.valid;e.old=a;var f=this;this.startRequest(b);var g={};g[b.name]=a;c.ajax(c.extend(true,{url:d,
mode:"abort",port:"validate"+b.name,dataType:"json",data:g,success:function(h){f.settings.messages[b.name].remote=e.originalMessage;var j=h===true;if(j){var i=f.formSubmitted;f.prepareElement(b);f.formSubmitted=i;f.successList.push(b);f.showErrors()}else{i={};h=h||f.defaultMessage(b,"remote");i[b.name]=e.message=c.isFunction(h)?h(a):h;f.showErrors(i)}e.valid=j;f.stopRequest(b,j)}},d));return"pending"},minlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)>=d},maxlength:function(a,
b,d){return this.optional(b)||this.getLength(c.trim(a),b)<=d},rangelength:function(a,b,d){a=this.getLength(c.trim(a),b);return this.optional(b)||a>=d[0]&&a<=d[1]},min:function(a,b,d){return this.optional(b)||a>=d},max:function(a,b,d){return this.optional(b)||a<=d},range:function(a,b,d){return this.optional(b)||a>=d[0]&&a<=d[1]},email:function(a,b){return this.optional(b)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(a)},
url:function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},
date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a))},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9 -]+/.test(a))return false;var d=0,e=0,f=false;a=a.replace(/\D/g,"");for(var g=a.length-1;g>=
0;g--){e=a.charAt(g);e=parseInt(e,10);if(f)if((e*=2)>9)e-=9;d+=e;f=!f}return d%10==0},accept:function(a,b,d){d=typeof d=="string"?d.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(b)||a.match(RegExp(".("+d+")$","i"))},equalTo:function(a,b,d){d=c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){c(b).valid()});return a==d.val()}}});c.format=c.validator.format})(jQuery);
(function(c){var a={};if(c.ajaxPrefilter)c.ajaxPrefilter(function(d,e,f){e=d.port;if(d.mode=="abort"){a[e]&&a[e].abort();a[e]=f}});else{var b=c.ajax;c.ajax=function(d){var e=("port"in d?d:c.ajaxSettings).port;if(("mode"in d?d:c.ajaxSettings).mode=="abort"){a[e]&&a[e].abort();return a[e]=b.apply(this,arguments)}return b.apply(this,arguments)}}})(jQuery);
(function(c){!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.handle.call(this,e)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)},handler:function(e){arguments[0]=c.event.fix(e);arguments[0].type=b;return c.event.handle.apply(this,arguments)}}});c.extend(c.fn,{validateDelegate:function(a,
b,d){return this.bind(b,function(e){var f=c(e.target);if(f.is(a))return d.apply(f,arguments)})}})})(jQuery);
;
/*
 * JP Enterprises jQuery Slider
 * http://www.jp-enterprises.com
 *
 * Copyright 2011, Chris Viccaro & JP Enterprises
 * 
 * September 30 2011 9:45PM EST
 * JPE-Slider v1.2.6 - Branch 
 * Log: 
 * 1.1.1 - Conversion to be more MVC.  First commit.  Not working.
 * 1.1.2 - Second commit of 1.1.1's conversion, fully working
 * 1.1.3 - Fixed changeTo bug
 * 1.1.4 - Added 2 settings, centerOnResize & animateOnResize  (default: true, true)
 * 		   (Note: animateOnResize requires jquery.backgroundPosition.js)
 * 1.1.5 - Added setting for the easing function used. (default: linear)
 * 1.1.6 - Added setting for the animation speed and standardized all animation speeds. (default: 750 [ms])
 * 1.1.7 - Added setting to define canvasWidth (default: 100%)
 * 1.1.8 - Added setting to turn on or off the slide-control hover-state.  Off by default.
 * 1.1.9 - Added logic: if centerOnResize is off, the slider-panes (jpe-slider-img class) width is set to settings.imageWidth.  Otherwise, the true width of the image is used.
 * 1.2.x (Branch) - Added setting to change & specify transition effect (default: slide)
 * 					Added Fade effect.  added layout changes set up for and based upon effect
 * 1.2.1			Added Scale effect.  (like fade, but scales the image 200% as it fades)
 * 1.2.2			Added Blind effect (requires jQuery UI)
 * 1.2.3 - Bug Fixes (slideHover placement problem)
 * 1.2.4 - Bug fix: if pauseTime was higher than the animation speed, things would get wonky because the timer was only getting cleared on a button click, not on an automatic move to the next slide.
 * 1.2.5 - Added manualAdvance setting, bug fix in previous function with effect fade
 * 1.2.6 - added css crossfades
 */
 
(function( $ ){
  
  var JPESlider = function(element,options) {
	// defaults are at bottom of code
	var settings = $.extend({}, $.fn.jpeSlider.defaults, options),
		bW = $(window).width(),
	    vars = {currentSlide: 0,totalSlides: 0,totalWidth:0};
	// create canvas that will stretch browser-width and hold the slides
	var canvas = document.createElement('DIV');
	canvas.id = "slider-images";
	canvas.className = "slider-images";
	// create controls
	var controls = document.createElement('DIV');
	controls.id = "slider-controls";
	controls.className = "jpe-controls slider-controls";
	// define horizontal shift for slide image & caption to center slide image and align caption with right-side of 960 container
	var shiftSlide = 0;
	if (settings.centerOnResize == true) { 
		//init this setting
		if ($(window).width() < settings.imageWidth) { shiftSlide = -((settings.imageWidth - bW) / 2); }
	}
	// get the slider element
	var slider = $(element);
	// add classes
	slider.addClass('jpe-slider');
	if (settings.effect == "fade") { slider.addClass('csstransitions'); }
	slider.data('jpe:vars',vars);
	var i = 0;
	slider.children().each(function() {
		var child = $(this);
		if (child.is('img')) {
			vars.totalSlides++;
			var imgWidth = child.width();
			if (imgWidth == 0) { imgWidth = child.attr('width'); }
			//override imgWidth if centeronresize is false
			if (settings.centerOnResize == false) { imgWidth = settings.imageWidth; }
			vars.totalWidth += imgWidth;
			var imgHeight = child.height();
			if (imgHeight == 0) { imgHeight = child.attr('height'); }
			var imgCaption = child.attr('title');
			var imgSrc = child.attr('src');
			if (imgCaption.substr(0,1) == "#") {
				var caption = $(imgCaption).html();
				$(imgCaption).hide();
			}
			else { var caption = imgCaption; }
			// get slide's link
			var link = document.getElementById("jpe-link-container-"+i);
			var dummy = document.createElement('DIV');
			dummy.appendChild(link);
			var linkHTML = dummy.innerHTML;
			// set initial offset
			var absOffset = i * settings.imageWidth;
			// layout differs per effect
			if (settings.effect == "slide") {
				$(canvas).append('<div class="jpe-slider-img '+settings.effect+'" style="position:absolute; top:0px; left:'+absOffset+'px; background-image:url(\''+imgSrc+'\')"><div class="jpe-caption" style="left:'+shiftSlide+'px">'+caption+'<div class="jpe-link">'+linkHTML+'</div></div></div>');
			}
			else if ((settings.effect == "fade") || (settings.effect == "scale") || (settings.effect == "blind")) {
				if (Modernizr.csstransitions) {
					if (i > 0) { 
						$(canvas).append('<div class="jpe-slider-img '+settings.effect+'" style="opacity:0;position:absolute; top:0px; left:0px; z-index:'+(900-i)+';background-image:url(\''+imgSrc+'\')"><div class="jpe-caption" style="left:'+shiftSlide+'px">'+caption+'<div class="jpe-link">'+linkHTML+'</div></div></div>');
					}
					else { $(canvas).append('<div class="jpe-slider-img '+settings.effect+'" style="position:absolute; top:0px; left:0px; z-index:'+(900-i)+';background-image:url(\''+imgSrc+'\')"><div class="jpe-caption" style="left:'+shiftSlide+'px">'+caption+'<div class="jpe-link">'+linkHTML+'</div></div></div>'); }
				} else {
					if (i > 0) { 
						$(canvas).append('<div class="jpe-slider-img '+settings.effect+'" style="display:none;position:absolute; top:0px; left:0px; z-index:'+(900-i)+';background-image:url(\''+imgSrc+'\')"><div class="jpe-caption" style="left:'+shiftSlide+'px">'+caption+'<div class="jpe-link">'+linkHTML+'</div></div></div>');
					}
					else { $(canvas).append('<div class="jpe-slider-img '+settings.effect+'" style="position:absolute; top:0px; left:0px; z-index:'+(900-i)+';background-image:url(\''+imgSrc+'\')"><div class="jpe-caption" style="left:'+shiftSlide+'px">'+caption+'<div class="jpe-link">'+linkHTML+'</div></div></div>'); }
				}
			}
			//append controls
			if (i == 0) { var classes = "active"; }
			else { var classes = ""; }
			$(controls).append('<a class="jpe-slider-control '+classes+'" rel="'+i+'">'+i+'</a>');
			$(controls).append('<div class="slidehover" ><span class="toparrow">&nbsp;</span>Preview of content goes here.</div>');
			i++;	
		}
	});
	//update vars
	slider.data('jpe:vars',vars);
	
	//prepend and append directional controls
	if (settings.directionalControls == true) {
		$(controls).prepend('<a class="jpe-directional-control prev">&nbsp;</a>');
		$(controls).append('<a class="jpe-directional-control next">&nbsp;</a>');
	}
	
	//clear slider and append canvas & controls
	$(canvas).width(settings.canvasWidth);
	slider.empty();
	slider.append(canvas);
	slider.append(controls);
	// set & start the timer
	if (settings.manualAdvance == false) { var timer = setInterval(function() { jpeRun(slider, settings,'next'); },settings.pauseTime); }
	
	//event listeners for prev/next buttons
	$("a.jpe-directional-control.prev").click(function() { 
		if ($(this).parents('.jpe-controls').hasClass("locked")) { return false; }
		else {
			// kill timer
			if (typeof timer !== "undefined") { 
				clearInterval(timer);
				timer = '';
			}
			jpeRun(slider,settings,'prev');
		}
	});
	$("a.jpe-directional-control.next").click(function() { 
		if ($(this).parents('.jpe-controls').hasClass("locked")) { return false; }
		else {
			// kill timer
			if (typeof timer !== "undefined") { 
				clearInterval(timer);
				timer = '';
			}
			jpeRun(slider,settings,'next');
		}
	});
	//event listeners for each slide control
	var n = 0;
	$("a.jpe-slider-control").each(function() {
		var intent = [];
		var element = $(this);
		var shiftHover = n*22;
		var oldShift = parseInt(element.next('div.slidehover').css('right'));
		if (oldShift == 0) { oldShift = 29; }  // FF3.x fails to read the 'right' css property on a element with display:none.  This is a bandaid until I clear it up.
		var newShift = oldShift - shiftHover;
		// on click
		$(this).click(function() { 
			if ($(this).parents('.jpe-controls').hasClass("locked")) { return false; }
			else { 
				// kill timer
				if (typeof timer !== "undefined") { 
					clearInterval(timer);
					timer = '';
				}
				jpeRun(slider,settings,'changeTo',$(this).attr('rel'));
			 }
		});
		if (settings.controlHovers == true) { 
			// on hover
			$(this).hover(function() { 
				var hover = element.next('div.slidehover');
				hover.css('right',newShift);
				intent = setTimeout(function() { 
					hover.show("fast");
				},500);
			},function() {
				clearTimeout(intent);
				var hover = element.next('div.slidehover');
				if (hover.is(":visible")) { hover.hide("fast"); } 
			}); 
		}
		n++;
	});
	// browser resize function to center slide-image & caption
	if (settings.centerOnResize == true) {
		$(window).resize(function() {
			// if ($(window).width() < settings.imageWidth) { 
				if (settings.animateOnResize == true) {
					if (Modernizr.csstransitions) {
						$(".jpe-caption").each(function() { $(this).css('left',-((settings.imageWidth - $(window).width()) / 2)); }); 
						$(".jpe-slider-img").each(function() { 
							$(this).css('background-position',-((settings.imageWidth - $(window).width()) / 2)+'px 0px');
						});						
					} else {
						$(".jpe-caption").each(function() { $(this).animate({left:-((settings.imageWidth - $(window).width()) / 2)},500,settings.easingFunc); }); 
						$(".jpe-slider-img").each(function() { 
							$(this).animate({backgroundPosition:-((settings.imageWidth - $(window).width()) / 2)+'px 0px'},500,settings.easingFunc);
						});
					}
				}
				else {
					$(".jpe-caption").each(function() { $(this).css('left',-((settings.imageWidth - $(window).width()) / 2)); }); 
					$(".jpe-slider-img").each(function() { 
						$(this).css('background-position',-((settings.imageWidth - $(window).width()) / 2)+'px 0px');
					});
				}
			//}
		});
	}
	this.options = function(optMap) {
		$.each(optMap,function(k,v) { 
			if (k == "pauseTime") { 
				settings.pauseTime = v; 
				if (settings.manualAdvance == false) {
					clearInterval(timer);
					timer = '';
					timer = setInterval(function() { jpeRun(slider, settings,'next'); },v);
				}
			}
			if (k == "infinite") { settings.infinite = v; }
			if (k == "imageWidth") { settings.imageWidth = v; }
			if (k == "centerOnResize") { settings.centerOnResize = v; }
			if (k == "animateOnResize") { settings.animateOnResize = v; }
			if (k == "easingFunc") { settings.easingFunc = v; }
			if (k == "animSpeed") { settings.animSpeed = v; }
		});
	}
	//Post-animation standard call-back
	var wrapItUp = function(toRemove) {
		$(".jpe-controls").removeClass("locked");
		var x = 0;
		if (settings.effect == "fade") {
			$(".jpe-slider-img").each(function() {
				if (x != vars.currentSlide) { $(this).hide(); }
				x++;
			});
		}
		if (typeof toRemove !== "undefined") { $(".jpe-slider-img").eq(toRemove).remove(); }
		//start timer again
		if ((settings.manualAdvance == false) && (timer == '')) { timer = setInterval(function() { jpeRun(slider, settings,'next'); },settings.pauseTime); }
	}
	//Slide transition function
	var jpeRun = function(slider,settings,direction,target) {
		var vars = slider.data('jpe:vars'),
			currentSlide = vars.currentSlide,
			totalSlides = vars.totalSlides,
			len = $("#slider-images").children().length;
		if ((settings.manualAdvance == false) && (timer !== '')) { clearInterval(timer); timer = ''; }
		if (direction == 'next') {
		  //Slide Transition
		  if (settings.effect == "slide") {
			if (settings.infinite == true) { 
				if (currentSlide < (totalSlides-1)) { 
					if (len > totalSlides) { 
						console.log("guess you need to use this code block after all.  find if (len > totalSlides) inside the if(currentSlide < totalSlides-1) in the NEXT function");
						}
					else {
						var copy = $(".jpe-slider-img").eq(0).clone();
						copy.hide();
						var initOffset = totalSlides * settings.imageWidth;
						$("#slider-images").append(copy.css('left',initOffset).show());
						var i = 0;
						$(".jpe-controls").addClass("locked");
						$(".jpe-slider-img").each(function() {
							var theShift = (i-1)*settings.imageWidth;
							if (i == (totalSlides-1)) { $(this).animate({left: theShift},settings.animSpeed,settings.easingFunc,function() { wrapItUp(0); }); }
							else { $(this).animate({left: theShift},settings.animSpeed,settings.easingFunc); }
							i++;
							});
						}
				currentSlide++;
				}
				else {
					var copy = $(".jpe-slider-img").eq(0).clone();
					copy.hide();
					var initOffset = totalSlides * settings.imageWidth;
					$("#slider-images").append(copy.css('left',initOffset).show());
					var i = 0;
					$(".jpe-controls").addClass("locked");
					$(".jpe-slider-img").each(function() {
						var theShift = (i-1) * settings.imageWidth;
						if (i == (totalSlides-1)) { $(this).animate({left: theShift},settings.animSpeed,settings.easingFunc,function() { wrapItUp(0); }); }
						else { $(this).animate({left: theShift},settings.animSpeed,settings.easingFunc); }
						i++;
					});
					currentSlide = 0;
				}
			}
			else {
				if (currentSlide < (totalSlides - 1)) { 
					currentSlide++;
					var shiftSlide = -(settings.imageWidth) *currentSlide;
					$(".jpe-slider div.jpe-slider-img").each(function() {
						$(this).animate({left: '-='+settings.imageWidth}, settings.animSpeed, settings.easingFunc);
					});
					}
				else {
					var i =0;
					$(".jpe-slider div.jpe-slider-img").each(function() {
						$(this).animate({left: (i*settings.imageWidth)}, settings.animSpeed, settings.easingFunc);
						i++;
					});
					currentSlide = 0;
				}
			}
		  }
		  else if (settings.effect == "fade") {
			//$(".jpe-controls").addClass("locked");
			if (currentSlide < (totalSlides - 1)) { 
			  var slides = new Array($(".jpe-slider-img").eq(currentSlide),$(".jpe-slider-img").eq(currentSlide+1));	
				if (Modernizr.csstransitions) {
					var z = slides[0].css('z-index');
					if (z < 100) { slides[0].css('z-index',900); z = 900; }
					slides[1].css('z-index',z-1).show();
					slides[0].css('opacity',0);
					slides[1].css('opacity',1);
					currentSlide++;
					setTimeout(function(){ wrapItUp();},settings.animSpeed);
				} else {	
					slides[0].fadeOut(settings.animSpeed,settings.easingFunc);
					currentSlide++;
					slides[1].fadeIn(settings.animSpeed,settings.easingFunc, function() { wrapItUp(); });
				}
			}
			else {
   			  var slides = new Array($(".jpe-slider-img").eq(currentSlide),$(".jpe-slider-img").eq(0));
				if (Modernizr.csstransitions) {
					var z = slides[0].css('z-index');
					if (z < 100) { slides[0].css('z-index',900); z = 900; }
					slides[1].css('z-index',z-1).show();
					slides[0].css('opacity',0);
					slides[1].css('opacity',1);
					currentSlide = 0;
					setTimeout(function(){ wrapItUp();},settings.animSpeed);
				} else {
					slides[0].fadeOut(settings.animSpeed,settings.easingFunc);
					slides[1].fadeIn(settings.animSpeed,settings.easingFunc,function() { wrapItUp(); });
					currentSlide = 0;
				}
			}	
		  }
		  else if (settings.effect == "scale") {
			//$(".jpe-controls").addClass("locked");
			if (currentSlide < (totalSlides - 1)) { 
					$(".jpe-slider-img").eq(currentSlide).animate({height:'200%',width:settings.imageWidth,opacity:"hide"},settings.animSpeed,settings.easingFunc);
					$(".jpe-slider-img").eq(currentSlide).fadeOut(settings.animSpeed,settings.easingFunc, function() { $(this).css({height: '100%',width:settings.imageWidth}); });
					currentSlide++;
					$(".jpe-slider-img").eq(currentSlide).fadeIn(settings.animSpeed,settings.easingFunc, function() { wrapItUp(); });
					}
				else {
					$(".jpe-slider-img").eq(currentSlide).animate({height:'200%',width:settings.imageWidth,opacity:"hide"},settings.animSpeed,settings.easingFunc);
					$(".jpe-slider-img").eq(currentSlide).fadeOut(settings.animSpeed,settings.easingFunc,function() { $(this).css({height: '100%',width:settings.imageWidth}); });
					$(".jpe-slider-img").eq(0).fadeIn(settings.animSpeed,settings.easingFunc,function() { wrapItUp(); });
					currentSlide = 0;
				}	
		  }
		  else if (settings.effect == "blind") {
			//$(".jpe-controls").addClass("locked");
			if (currentSlide < (totalSlides - 1)) { 
					$(".jpe-slider-img").eq(currentSlide+1).show(0,function() { 
						$(".jpe-slider-img").eq(currentSlide).hide('blind',{easing:settings.easingFunc},settings.animSpeed, function() { 
							wrapItUp();
						});
					});
					currentSlide++;
				}
			else {
					var tmp = currentSlide;
					$(".jpe-slider-img").eq(0).show('blind',{easing:settings.easingFunc},settings.animSpeed,function() { 
						$(".jpe-slider-img").eq(tmp).hide(0, function() { 
							wrapItUp();
						});
					});
					currentSlide = 0;
			}	
		  }
		}
		else if (direction == 'prev') {
		  //Slide Transition
		  if (settings.effect == "slide") {
			if (settings.infinite == true) { 
				if (currentSlide > 0) { 
					if (len > totalSlides) { 
						console.log("guess you need to use this code block after all.  find if (len > totalSlides) inside the if(currentSlide < totalSlides-1) in the PREV function");
						$(".jpe-slider-img").eq(len-1).remove();
						var i = 0;
						$(".jpe-slider-img").each(function() {
							var theShift = (i)*settings.imageWidth;
							$(this).css('left',theShift);
							i++;
						});
						}
					else {
						var i = totalSlides-1;
						var copy = $(".jpe-slider-img").eq(totalSlides-1);
						copy.hide();
						var theShift = -(settings.imageWidth);
						$("#slider-images").prepend(copy.css('left',theShift).show());
						var sliders = $(".jpe-slider-img").get().reverse();
						//iterate animations over slider images, disable controls while animating.
						$(".jpe-controls").addClass("locked");
						$.each(sliders,function() {
							var theShift = (i)*settings.imageWidth;
							if (i == 0) { $(this).animate({left: theShift},settings.animSpeed,settings.easingFunc,function() { wrapItUp(); }); }
							else { $(this).animate({left: theShift},settings.animSpeed,settings.easingFunc); }
							i--;
							});
						}
				currentSlide--;
				}
				else {
					var copy = $(".jpe-slider-img").eq(len-1).clone();
					copy.hide();
					var theShift = -(settings.imageWidth);
					$("#slider-images").prepend(copy.css('left',theShift).show());
					var sliders = $(".jpe-slider-img").get().reverse();
					var i = totalSlides-1;
					$(".jpe-controls").addClass("locked");
					$.each(sliders,function() {
						var theShift = (i+1) * settings.imageWidth;
						if (i == (totalSlides-1)) { $(this).animate({left: theShift},settings.animSpeed,settings.easingFunc,function() { wrapItUp(len); }); }
						else { $(this).animate({left: theShift},settings.animSpeed,settings.easingFunc); }
						i--;
					});
					currentSlide = totalSlides-1;
				}
			}
			else {
				if ((currentSlide - 1) >= 0) { 
						var i = 0;
						$(".jpe-controls").addClass("locked");
						$(".jpe-slider div.jpe-slider-img").each(function() {
							if (i == (totalSlides-1)) { 
								$(this).animate({left: '+='+settings.imageWidth}, settings.animSpeed, settings.easingFunc,function() { wrapItUp(); });
							}
							else { 
								$(this).animate({left: '+='+settings.imageWidth}, settings.animSpeed, settings.easingFunc);
							}
							i++;
						});
						currentSlide--;
					}
				else {
					var i = totalSlides-1;
					$(".jpe-controls").addClass("locked");
					$(".jpe-slider div.jpe-slider-img").each(function() {
						var theShift = (-i)*settings.imageWidth;
						if (i == 0) { $(this).animate({left: theShift}, settings.animSpeed, settings.easingFunc,function() { wrapItUp(); }); }
						else { $(this).animate({left: theShift}, settings.animSpeed, settings.easingFunc); }
						i--;
					});
					currentSlide = totalSlides-1;
				}
			}
		  }
		  else if (settings.effect == "fade") {
			//$(".jpe-controls").addClass("locked");
			if (currentSlide > 0) { 
			  var slides = new Array($(".jpe-slider-img").eq(currentSlide),$(".jpe-slider-img").eq(currentSlide-1));	
				if (Modernizr.csstransitions) {
						var z = slides[0].css('z-index');
						if (z < 100) { slides[0].css('z-index',900); z = 900; }
						slides[1].css('z-index',z-1).show();
						slides[0].css('opacity',0);
						slides[1].css('opacity',1);
						currentSlide--;
						setTimeout(function() { wrapItUp(); },settings.animSpeed);
					}
					else {
						slides[0].fadeOut(settings.animSpeed,settings.easingFunc);
						currentSlide--;
						slides[1].fadeIn(settings.animSpeed,settings.easingFunc,function() { wrapItUp(); });
					}
			} else {
				var slides = new Array($(".jpe-slider-img").eq(currentSlide),$(".jpe-slider-img").eq(len-1));		
				if (Modernizr.csstransitions) {
					var z = slides[0].css('z-index');
					if (z < 100) { slides[0].css('z-index',900); z = 900; }
					slides[1].css('z-index',z-1).show();
					slides[0].css('opacity',0);
					slides[1].css('opacity',1);
					currentSlide = len-1;
					setTimeout(function() { wrapItUp(); },settings.animSpeed);
				} else {
					slides[0].fadeOut(settings.animSpeed,settings.easingFunc);
					slides[1].fadeIn(settings.animSpeed,settings.easingFunc,function() { wrapItUp(); });
					currentSlide = len-1;
				}
			}	
		  }
		  else if (settings.effect == "scale") {
			//$(".jpe-controls").addClass("locked");
			if (currentSlide > 0) { 
					$(".jpe-slider-img").eq(currentSlide).animate({height:'200%',width:settings.imageWidth,opacity:"hide"},settings.animSpeed,settings.easingFunc);
					$(".jpe-slider-img").eq(currentSlide).fadeOut(settings.animSpeed,settings.easingFunc, function() { $(this).css({height: '100%',width:settings.imageWidth},settings.animSpeed,settings.easingFunc); });
					currentSlide--;
					$(".jpe-slider-img").eq(currentSlide).fadeIn(settings.animSpeed,settings.easingFunc, function() { wrapItUp(); });
					}
				else {
					$(".jpe-slider-img").eq(currentSlide).animate({height:'200%',width:settings.imageWidth,opacity:"hide"},settings.animSpeed,settings.easingFunc);
					$(".jpe-slider-img").eq(currentSlide).fadeOut(settings.animSpeed,settings.easingFunc,function() { $(this).css({height: '100%',width:settings.imageWidth},settings.animSpeed,settings.easingFunc); });
					$(".jpe-slider-img").eq(len-1).fadeIn(settings.animSpeed,settings.easingFunc,function() { wrapItUp(); });
					currentSlide = len-1;
				}	
		  }
		  else if (settings.effect == "blind") {
			//$(".jpe-controls").addClass("locked");
			if (currentSlide > 0) { 
					var tmp = currentSlide;
					$(".jpe-slider-img").eq(tmp-1).show('blind',{easing:settings.easingFunc},settings.animSpeed,function() { 
						$(".jpe-slider-img").eq(tmp).hide(0, function() { 
							wrapItUp();
						});
					});
					currentSlide--;
				}
			else {
					var tmp = currentSlide;
					$(".jpe-slider-img").eq(len-1).show(0);
					$(".jpe-slider-img").eq(tmp).hide('blind',{easing:settings.easingFunc},settings.animSpeed, function() { 
							wrapItUp();
					});
					currentSlide = len-1;
				}
			}
		}
		else if (direction == 'changeTo') {
			//check for valid target
			if (typeof target == "undefined") { 
				console.log('jpeslider error: no target specified for changeTo function'); 
				return; 
			}
			// may as well leverage the next and prev funcs if the target is within a slide of the current slide
			if ( ((target - currentSlide) == 1) || ((currentSlide == (totalSlides-1)) && (target == 0)) ) {
				jpeRun(slider,settings,'next');
				return;
			}
			else if ( ((currentSlide - target) == 1) || ((currentSlide == 0) && (target == (totalSlides-1))) ) {
				jpeRun(slider,settings,'prev');
				return;
			}
	// target is farther away than 1, commence changeTo func
	  //Slide Transition
	  if (settings.effect == "slide") { 
	  	$(".jpe-controls").addClass("locked");
		if (settings.infinite == true) { 
			if (target > currentSlide) {
				// slides slide to the left (a la next function), re-ordering as we go
				var theShift = (target - currentSlide) * settings.imageWidth;
				var initOffset = settings.imageWidth;
				var holder = new Array();
				var copies = new Array();
				var i = 0;
				$(".jpe-slider-img").each(function() { 
					if (i == (target - currentSlide)) { 
						var x = 0;
						$(".jpe-slider-img").each(function() { 
							$(this).animate({left: "-="+theShift},settings.animSpeed,settings.easingFunc,function() { 
								$(".jpe-controls").removeClass("locked");
								$.each(holder,function() { $(this).remove(); });
								$.each(copies,function() {
									$("#slider-images").append($(this));
								});
								wrapItUp();
							});
							x++;
						});
					}
					else if (i < (target - currentSlide)) { 
						holder.push($(this));
						var copy = $(this).clone();
						var thisOffset = initOffset * (i+1);
						copy.css('left',thisOffset+"px");
						copies.push(copy);
					}
					i++;
				});
			}
			else if (target < currentSlide) {
				// slides slide to the right (a la prev function), re-ordering as we go
				var theShift = (target - currentSlide) * settings.imageWidth;
				var initOffset = -(settings.imageWidth);
				var holder = new Array();
				var slides = $(".jpe-slider-img").get().reverse();
				var i = 0;
				$.each(slides,function() { 
					if (i == (currentSlide - target)) { 
						$(".jpe-slider-img").each(function() { 
							$(this).animate({left: '-='+theShift},settings.animSpeed,settings.easingFunc,function() { 
								wrapItUp();
							});
						});
					}
					else if (i < (currentSlide - target)) { 
						var copy = $(this).clone();
						copy.css('left',initOffset*(i+1)).hide();
						$("#slider-images").prepend(copy.show());
						$(this).remove();
					}
					i++;
				});
			}
			currentSlide = target;

		}
		else {
			//target should be rel from a tag
			var shiftSlide = -(target - currentSlide) * settings.imageWidth;
			if (shiftSlide > 0) { shiftSlide = "+="+Math.abs(shiftSlide); }
			else { shiftSlide = "-="+Math.abs(shiftSlide); }
			$(".jpe-slider div.jpe-slider-img").each(function() {
					$(this).animate({left: shiftSlide}, settings.animSpeed, settings.easingFunc,function() { wrapItUp(); });
				});
			currentSlide = target;
		}
	  }
	  else if (settings.effect == "fade") {
	  	//$(".jpe-controls").addClass("locked");
	  	var slides = new Array($(".jpe-slider-img").eq(currentSlide),$(".jpe-slider-img").eq(target));
		if (Modernizr.csstransitions) {
			var z = slides[0].css('z-index');
			if (z < 100) { slides[0].css('z-index',900); z = 900; }
			slides[1].css('z-index',z-1).show();
			slides[0].css('opacity',0);
			slides[1].css('opacity',1);
			currentSlide = target;
			setTimeout(function() { wrapItUp(); },settings.animSpeed);
		}
		else {	
			slides[0].fadeOut(settings.animSpeed,settings.easingFunc);
			currentSlide = target;
			slides[1].fadeIn(settings.animSpeed, settings.easingFunc,function() { wrapItUp(); });
		}
	  }
	  else if (settings.effect == "scale") {
	  	//$(".jpe-controls").addClass("locked");
		$(".jpe-slider-img").eq(currentSlide).animate({height:'200%',width:settings.imageWidth,opacity:"hide"},settings.animSpeed,settings.easingFunc);
		$(".jpe-slider-img").eq(currentSlide).fadeOut(settings.animSpeed,settings.easingFunc, function() { $(this).css({height: '100%',width:settings.imageWidth},settings.animSpeed,settings.easingFunc); });
		currentSlide = target;
		$(".jpe-slider-img").eq(currentSlide).fadeIn(settings.animSpeed,settings.easingFunc, function() { wrapItUp(); });
	  }
	  else if (settings.effect == "blind") { 
	  	//$(".jpe-controls").addClass("locked");
		$(".jpe-slider-img").eq(currentSlide).hide('blind',{easing:settings.easingFunc},settings.animSpeed);
		$(".jpe-slider-img").eq(target).show('blind',{easing:settings.easingFunc},(settings.animSpeed / 2),function() { wrapItUp(); });
		currentSlide = target;
	  }
		}
		// change active control
		$(".jpe-slider .slider-controls a").each(function() { $(this).removeClass("active"); });
		$('.jpe-slider .slider-controls a[rel="'+currentSlide+'"]').addClass("active");
		//update currentSlide variable
		vars.currentSlide = currentSlide;
		slider.data('jpe:vars',vars);
	}
	return this;
  };
  $.fn.jpeSlider = function(options) {
	return this.each(function(key,value) {
		var element = $(this);
		if (element.data('jpeslider')) return element.data('jpeslider');
        // Pass options to plugin constructor
        var jpeslider = new JPESlider(this, options);
        // Store plugin object in this element's data
        element.data('jpeslider', jpeslider);
	});
  };
  
  $.fn.jpeSlider.defaults = {
	canvasWidth: "100%",
	animSpeed: 750,
	pauseTime: 5000,
	imageWidth: 1900,
	effect: "slide",
	infinite: false,
	manualAdvance: false,
	easingFunc: "linear",
	centerOnResize: true,
	animateOnResize: true,
	controlHovers: false,
	directionalControls: true
  };
})( jQuery );;
/*========================================*/
/*    Overrides jpe main theme's main.js  */
/*========================================*/
(function( $ ){ 
	var intent = '',
		animation = 0,
		dTimer = '',
		contactForm = '';
	eF = "easeOutExpo";
	$(document).ready(function() {
	//jQuery plugin calls
		$("#slider").jpeSlider({
			centerOnResize: false,
			animateOnResize: false,
			imageWidth:1900,
			animSpeed: 800,
			pauseTime: 6000,
			easingFunc: "easeOutCubic",
			controlHovers: false,
			infinite:true,
			manualAdvance: false,
			directionalControls: false,
			effect: "fade"
		});	
		//$("#webform-component-best-datetime-to-contact-me input").datepicker();
		// Footer Flyout contact us Form
		contactForm = $("#footer-flyout form.contact-us-form").validate({
			messages: {
				'submitted[fname]': {required: ""},
				'submitted[lname]': {required: ""},
				'submitted[phone]': {required: ""},				
				'submitted[e_mail_address]': {required: ""},
				'submitted[comments]': {required: ""}
			}
		});
		$('#content_bottom .contact-us-form').validate({
			rules: {
				'submitted[contact_via]':{required:true},
				'submitted[interested_in]':{required:true}
			},
			messages: {
				'submitted[fname]': {required: "We need your first name"},
				'submitted[lname]': {required: "We need your last name"},
				'submitted[e_mail_address]': {required: "We need your email address to contact you"},
				'submitted[subject]': {required: "Subject is required"},
				'submitted[phone]': {required: 'We need at least your office contact number'},
				'submitted[contact_via]': {required: 'Please choose one'},
				'submitted[interested_in]': {required: 'Please choose one'}
			}
		});
		$("#user-login").validate({
			messages: {
				name: {required: "Enter your username to log in"},
				pass: {required: "Enter your password to log in"}
			}
		});
		$("#user-login-form").validate({
			messages: {
				name: {required: "Enter your username to log in"},
				pass: {required: "Enter your password to log in"}
			}
		});
		$("#user-register-form").validate({
			messages: {
				name: {required: "Enter your desired username"},
				mail: {required: "Your e-mail address is required"},
				captcha_response: {required: "Type in the characters you see above"}
			}
		});
		$("#search-form").validate({
			rules: { keys: {required: true,minlength: 3} },
			messages: { keys: {required: "Enter some keywords before you search",minlength: "Enter at least 3 characters"} }
		});
		$("#user-pass").validate({
			messages: { name: {required: "Enter either your username or e-mail address to receive a new, temporary password"} }
		});
   
		// Select Box prettification
		$("body.page-forum #main select").selectBox({menuTransition:"slide",menuSpeed:150});
		$(".view-node-grid .views-exposed-widgets select").selectBox({menuTransition:"slide",menuSpeed:150});

		//work subcategories
		$(".work-filter select").selectBox({menuTransition:"slide",menuSpeed:150});		
		// fix for the project title line-break from 1 to 2 causing the clear-less float-layout to fail.
		if ($('.filter-children-of-parent').length) {
			var highest = 0;		
			$('.node-grid-container').each(function() {
				if ($(this).height() > highest) { highest = $(this).height(); }
			});
		}
		$('.work-filter select').focus(function(e) {
			var sbId = '#selectBox-'+$(this).attr('id');
			if (sbId == '#selectBox-filter-clients-select') { var t = 'Show All Clients'; }
			else if (sbId == '#selectBox-filter-types-select') {var t = 'Show All Types'; }
			$(sbId).children('li').eq(0).children('a').text(t);
		});
		$('.filter-children-of-parent').change(function(){
			var subcat = $(this).val(),
				i = 0;
			if (subcat == 'all') { 
				$(this).next().find('.selectBox-label').text('Subcategories');
			}
			$('.node-grid-container').each(function() {
				if (!$(this).hasClass('filtered-client')) {
					if (($.trim($(this).find('.subcategory h5').html()) == subcat) || (subcat == 'all')) {
						$(this).css('display','').removeClass('filtered-subcat slideOut s0 s1 s2').css('height',highest).addClass('slideIn s'+i);
						if (i < 2) { i++; } else { i = 0; }					
					} else {
						var ng = $(this);				
						ng.addClass('filtered-subcat slideOut').css('height','').removeClass('slideIn s0 s1 s2'); 
						setTimeout(function() { ng.css('display','none') },261);					
					}
				}
			});
		});
		$('.filter-clients-of-term').change(function(){
			var client = $(this).val().replace('&','&amp;');
				i = 0;
			if (client == 'all') { 
				$(this).next().find('.selectBox-label').text('Client');
			}
			$('.node-grid-container').each(function() {
				if (!$(this).hasClass('filtered-subcat')) {
					if (($.trim($(this).find('.node-client h5').html()) == client) || (client == 'all')) {
						$(this).css('display','').removeClass('filtered-client slideOut s0 s1 s2').addClass('slideIn s'+i).css('height',highest);
						if (i < 2) { i++; } else { i = 0; }					
					} else {
						var ng = $(this);				
						ng.addClass('filtered-client slideOut').css('height','').removeClass('slideIn s0 s1 s2'); 
						setTimeout(function() { ng.css('display','none') },261);					
					}
				}
			});
		});

		//forum
		//$(".filter-container select").selectBox({menuTransition:"slide",menuSpeed: 150});
		/*$(".selectBox-dropdown-menu.dynamic").each(function() {
			var controls = '<div class="select-nav"><span class="prev"><a href="#"><</a></span><span class="next"><a href="#">></a></span></div>',
				total = $(this).children('ul').length;
			$(this).append(controls);
			$(this).data({current: 0, max: total});
			$(this).find('.select-nav').each(function(){
				$(this).find('.prev a').click(function(e) {
					e.preventDefault();
					var settings = $(this).parents('.selectBox-dropdown-menu').data();
					if (settings.current !== 0) {
						var groups = $(this).parents('.select-nav').siblings();	
						groups.animate({left: '+=160'},333);
						settings.current--;
					} else {
						return false;
					}
				});
				$(this).find('.next a').click(function(e) {
					e.preventDefault();
					var settings = $(this).parents('.selectBox-dropdown-menu').data();
					if (settings.current < settings.max-1) {
						var groups = $(this).parents('.select-nav').siblings();	
						groups.animate({left: '-=160'},333);
						settings.current++;
					} else {
						return false;
					}
				});
			});
		});*/
	//		Event Listeners
		// Back To Top
		var bt = $('#backtotop');
		bt.hover(
			function(){
				intent = setTimeout(function() { 
					bt.find('.expanded').show().animate({top:3},{duration:160,easing:eF,queue:false});
					bt.find('.icon').animate({top:-35},{duration:160,easing:eF,queue:false}); 
				},150);
			},
			function() {
				clearTimeout(intent);
				if (bt.find('.expanded').is(':visible')) {
					bt.find('.expanded').animate({top:38},{duration:160,easing:eF,queue:false});
					bt.find('.icon').animate({top:0},{duration:160,easing:eF,queue:false},function() { 
						bt.find('.expanded').hide()
					}); 
				}
			}
		);
		var hf = $("#header-flyout"),
			ff = $("#footer-flyout"),
			bar = {top:$("#header-bar"),bottom:$("#footer-bar")};
			
		//Header & Footer Menu - Flyout Triggers
		bar.top.find('ul li a').click(function(e) {
			e.preventDefault();
			bar.top.find('ul li').removeClass("clicked");
			$(this).parent('li').addClass('clicked');
			var idx = $("#header-bar ul.menu li a").index(this);
			var pid = hf.find('.block').eq(idx).attr('id');
			if (!hf.data('visible')) { 
				showBar(hf,idx,pid); 
			}
			else { 
				var tohide = hf.data('section');
				if (tohide !== pid) { showBar(hf,idx,tohide); }
				else { hideBar(hf,bar.top); }
			}
		});
		bar.bottom.find('ul li a').click(function(e) {
			e.preventDefault();
			bar.bottom.find('ul li').removeClass("clicked"); 
			$(this).parent('li').addClass('clicked');
			var idx = $("#footer-bar ul.menu li a").index(this);
			var pid = ff.find('.block').eq(idx).attr('id');
			if (!ff.data('visible')) { 
				showBar(ff,idx); 
			}
			else { 
				var tohide = ff.data('section');
				if (tohide !== pid) { showBar(ff,idx,tohide); }
				else { hideBar(ff,bar.bottom); }
			}
		});
		 hf.find(".close-x").click(function() { 
		 	$(this).parents('li').removeClass("clicked"); 
		 	hideBar(hf,bar.top);
		 });
		 ff.find(".close-x").click(function() { 
		 //	$(this).parents('li').removeClass("clicked");
		 	hideBar(ff,bar.bottom);
		 });
		// Hilight Node Pager
		$(".block-pager .control-item a").click(blockPagerClick);
		//Hilight Node Action-link Overlay 
		$("#node-view-work .node-action-overlay-innerbox a").click(goFullScreen);
		$(".hilight-node-action-overlay").hover(function(e){
			//var ths = $(this).parents('.hilight-wrapper').children('.hilight-node-action-overlay');
			var ths = $(this);
			var h = ths.height();
			if (Modernizr.csstransitions) { 
				ths.addClass("hover");
			} else {
				ths.fadeTo(333,1,eF);
				ths.children('.bg').fadeTo(333,.5,eF);
				ths.children('.node-action-overlay-innerboxes').css('top',h).animate({top:(h/2)-14,opacity:1},250,eF);
			}
		},function() {
			//var ths = $(this).parents('.hilight-wrapper').children('.hilight-node-action-overlay');
			var ths = $(this);
			if (Modernizr.csstransitions) { 
				ths.addClass("hoveroff");
				setTimeout(function() { ths.removeClass("hover hoveroff"); },170);
			} else { 
				ths.fadeTo(333,0.01,eF);
				ths.children('.bg').fadeTo(333,0,eF);
				ths.children('.node-action-overlay-innerboxes').animate({top:-30,opacity:0},250,eF);
			}
		});
		// Hilight Node Rotate-On-Click
		$(document).delegate(".hilight-wrapper.rotate-on-click .hilight-node-action-overlay",{
			click: function(e) {
				if (!$("#page-overlay").is(":visible")) {
					var currentControl = $(this).parents('.hilight-wrapper').find(".block-pager .control-item.active"); 
					if (currentControl.hasClass("last")) { 
						$(this).parents('.hilight-wrapper').find(".block-pager .control-item").eq(0).children('a').click();
					} else {
						currentControl.next().children('a').click();
					}
				}
			}
		});
		//Smooth Scroll To Top 
		//thanks Joe "Mayer"s
		$("#backtotop a").click(function(e) { 
			e.preventDefault(); 
			e.stopPropagation(); 
			$('body, html').animate({scrollTop: 0}, 800,eF);
		});
		// Small Icon (Footer Images) Hover
		$(".sm-icon").hover(function() {
				if (Modernizr.csstransitions) {
					$(this).children('.front.face').css('opacity',0);
				} else {
					$(this).children('.front.face').fadeTo(333,0.01);
				}
			}, function() {
				if (Modernizr.csstransitions) {
					$(this).children('.front.face').css('opacity',1);
				} else {
					$(this).children('.front.face').fadeTo(333,1);
				}
			});
		/* vanilla hover animations for non-css3 browsers */
		if (!Modernizr.csstransitions) { 
			
			$(".node-grid-container").hover(function() { 
				//,.grid-item-subtitle h5,.grid-item-subtitle h5 a
				$(this).find('.node-title a').animate({color:'#0090c7'},{queue:false,duration:500,easing:eF});
				$(this).find(".grid-item-image").fadeTo(500,0.01,eF);
			},function() {
				$(this).find('.node-title a').animate({color:'#777'},{queue:false,duration:500,easing:eF});
				//$(this).find('.grid-item-subtitle h5,.grid-item-subtitle h5 a').animate({color:'#2b2e30'},{queue:false,duration:500,easing:eF});	
				$(this).find(".grid-item-image").fadeTo(500,1,eF);
			});
			
			$("#region-content-left .block .views-row").hover(function() {
				$(this).css('cursor','pointer');
				$(this).find('.block-post-date-month').animate({backgroundColor:'#0090c7'},{queue:false,duration:500,easing:eF});		
				$(this).find('.readmore a').animate({color:'#0090c7'},{queue:false,duration:500,easing:eF});
			},function() {
				$(this).css('cursor','default');
				$(this).find('.readmore a').animate({color:'#2b2e30'},{queue:false,duration:500,easing:eF});
				$(this).find('.block-post-date-month').animate({backgroundColor:'#2b2e30'},{queue:false,duration:500,easing:eF});
			});
			var logotimer = '';
			$(".term-logo").hover(function() {
				var logo = $(this),
					hover = $(this).next();
				if (logo.hasClass('nolink')) { e.preventDefault();e.stopPropagation();return false; }
				logotimer = setTimeout(function() { 
					hover.fadeTo(500,1,eF);
					logo.fadeTo(500,0,eF);
				},150);
			},function() {		
				if (logotimer) {
					clearTimeout(logotimer);
					$(this).next().fadeTo(500,0,eF);
					$(this).fadeTo(500,1,eF);
				}
			});
			
		}	
	$('.term-logo.nolink').click(function(e){e.preventDefault();e.stopPropagation();});
	}); // end document ready

	$(window).ready(function() {
		// Emulate position: fixed on footer
		if ($("html").hasClass("no-positionfixed") && $("html").hasClass("no-iospositionfixed")) {
			$("#footer").addClass("noposfixed");
			$("#footer").css({position: "absolute",top:window.innerHeight-30});
			$(window).scroll(function(e) {
				var posY = window.pageYOffset + window.innerHeight-38;
				$("#footer").css('top',posY);
			});
		}
	});
	$(window).load(function() { 
		//if (typeof G_vmlCanvasManager !== "undefined") { $('html').addClass('excanvas'); }
		if (($("canvas.va_button").length) && ((Modernizr.canvas) || (typeof G_vmlCanvasManager !== "undefined"))) {
			initCanvas(); 
		}
	});	
	function initCanvas() {
		var duration = 250,
			rate = 10,
			arrow = $(".html5canvas").eq(0).find('img')[0];
		$("canvas.va_button").each(function() { 
			//if (typeof G_vmlCanvasManager !== "undefined") { 
			//	var el = G_vmlCanvasManager.initElement(this);
//
			//} else { var el = this; }
			var el = this;
			var context = el.getContext("2d");
			drawButton(el,arrow,"#00a4e2",27.5,24.5,"#0090c7");
		});
		$(document).delegate('canvas.va_button',{
			'mouseenter': function() {
				var canvas = this;
				clearInterval(dTimer);
				dTimer = setInterval(function() { 
					if (animation < duration) {
						var t = animation / duration,
							cubic = cubicEase(t,24.5,24,22,21.5),
							insideFrom = {r:0,g:144,b:199},
							insideTo = {r:0,g:132,b:184},
							steps = duration / rate,
							drgb = {r:(insideTo.r - insideFrom.r) / steps,g:(insideTo.g - insideFrom.g) / steps,b:(insideTo.b - insideFrom.b) / steps},
	           				dcolor = 'rgb(' + Math.round(insideFrom.r + drgb.r * cubicEase(t,0,25,125,150)/rate) + ','
                                   + Math.round(insideFrom.g + drgb.g * cubicEase(t,0,25,125,150)/rate) + ','
                                   + Math.round(insideFrom.b + drgb.b * cubicEase(t,0,25,125,150)/rate) + ')';
						drawButton(canvas,arrow,"#00a4e2",27.5,cubic,dcolor);
						animation = animation+rate;
					}
					else {
						clearInterval(dTimer);
						animation = 0;
						return;
					}
				},rate);
			},
			'mouseleave':function() {
				var canvas = this;
				clearInterval(dTimer);
				dTimer = setInterval(function() { 
					if (animation < duration) {
						var t = animation / duration,
							cubic = cubicEase(t,21.5,22,24,24.5),
							insideFrom = {r:0,g:132,b:184},
							insideTo = {r:0,g:144,b:199},
							steps = duration / rate,
							drgb = {r:(insideTo.r - insideFrom.r) / steps,g:(insideTo.g - insideFrom.g) / steps,b:(insideTo.b - insideFrom.b) / steps},
	           				dcolor = 'rgb(' + Math.round(insideFrom.r + drgb.r * cubicEase(t,0,25,125,150)/rate) + ','
                                   + Math.round(insideFrom.g + drgb.g * cubicEase(t,0,25,125,150)/rate) + ','
                                   + Math.round(insideFrom.b + drgb.b * cubicEase(t,0,25,125,150)/rate) + ')';
						drawButton(canvas,arrow,"#00a4e2",27.5,cubic,dcolor);
						animation = animation+rate;
					}
					else {
						clearInterval(dTimer);
						animation = 0;
						return;
					}
				},rate);
			}
		});
	}
	function drawButton(canvas,arrow,outsideColor,outsideRadius,insideRadius,insideColor) {
		//reset canvas
		canvas.width = canvas.width;
		var context = canvas.getContext("2d"),
			farRadius = outsideRadius*1.2;
		if (Modernizr.rgba) {
			context.shadowOffsetX = 0;
			context.shadowOffsetY = 2;
			context.shadowBlur = 5;
			context.shadowColor = "rgba(0,0,0,0.75)";
		} else {
			context.shadowOffsetX = 1;
			context.shadowOffsetY = 2;
			context.shadowBlur = 3;
			context.shadowColor = "#212121";
		}
		context.beginPath();
		context.arc(farRadius,farRadius,outsideRadius,0,Math.PI * 2, false);
		context.closePath();
		context.strokeStyle = outsideColor;
		context.stroke();
		context.fillStyle = outsideColor;
		context.fill();
		context.shadowOffsetX = 0;
		context.shadowOffsetY = 0;
		context.shadowBlur = 6;
		context.shadowColor = "#00a4e2";
		context.beginPath();
		context.arc(farRadius,farRadius,insideRadius,0,Math.PI * 2, false);
		context.closePath();
		context.fillStyle = insideColor;
		context.fill();
		context.drawImage(arrow,outsideRadius+1,outsideRadius-4);
	}
	function cubicEase(t,p0,p1,p2,p3) {
		//(1-t)^3P0 + 3(1-t)^2*t*P1 + 3(1-t)t^2P2 + t^3*p3
		return Math.pow(1-t,3)*p0 + 3*(Math.pow(1-t,2))*t*p1 + 3*(1-t)*Math.pow(t,2)*p2 + Math.pow(t,3)*p3;
	}
	
	function goFullScreen(e) {
		e.preventDefault();
		e.stopPropagation();
		var toGrow = $(this).parents('.view').find('.hilight-node-container').addClass("grow");
		//ajax loader
		$('body').append('<div id="ajaxloader"><div class="ajaxloader">&nbsp;</div></div>');
		Spinners.create('.ajaxloader', {
			radii: [6,20],
			color: '#eee',
			dashes: 12,
			dashWidth: 3,
			opacity:1
		}).play();
		var fullScreen = $('#page-overlay'),
			closebutton = '<a href="#" class="close-button-link">close</a>',
			prevbutton = '<a href="#" class="prev-button">&nbsp;</a>',
			nextbutton = '<a href="#" class="next-button">&nbsp;</a>',
			fullscreenControls = '<div class="fullscreen-controls"><div class="fs-button fs-prev-button inactive">'+prevbutton+'</div><div class="fs-button fs-close-button">'+closebutton+'</div><div class="fs-button fs-next-button inactive">'+nextbutton+'</div></div>',
			metaData = {'project':$('#project-name h1').text(),'client':$('#client-name .field-item').text(),'url':''},
			idx = $(this).index('.node-action-overlay-innerbox a'),
			fullView = ($.trim($('#ptype').find('.field').text()) == "Web") ? true : false; 
		//init fullScreen obj
		var x = $('#content_bottom .node-action-overlay-innerbox a'),
			max = x.length;
		fullScreen.empty();
		fullScreen.data({'objects':new Array(),'idx':idx});
		fullScreen.hrefs = new Array();
		for (var i = 0;i<max;i++) {
			fullScreen.hrefs[i] = x[i];
		}
//		$('.node-action-overlay-innerbox a').each(function() { fullScreen.data('hrefs').push($(this).attr('href')) });
		if ($('#project-url a').length) { metaData.url = $('#project-url a'); }
		var scrollBar = $('<div id="scrollBar" class="scrollBar" />'),
			tracker = $('<div class="tracker" />');
		scrollBar.height($(window).height()*.5-54).css('top',($(window).height()-scrollBar.height())/2).append(tracker);
		tracker.bind({
			'mousedown':function(e) {
				e.preventDefault();
				e.stopPropagation();
				tracker.inControl = true;
				tracker.initY = e.pageY;
				tracker.initPos = $(this).position().top;
			},
			'mousemove':function(e) { moveTracker(e,tracker) },
			'mouseup':function(e) {
				tracker.inControl = false;
			}
		});
		//append controls and scrollBar
		$('body').append(fullscreenControls,scrollBar);
		//cache buttons to call later
		var fsPrev = $('.fs-prev-button'),
			fsNext = $('.fs-next-button'),
			fsClose = $('.fs-close-button');
		//fade out everything else
		$("#header-flyout,#footer,#container,#region-mini-footer").fadeOut(250,function() {
			toGrow.removeClass("grow");
		});
		fullScreen.fadeIn(250,function() { 
			$(".fullscreen-controls").fadeIn(250);
			var poc = $('<div class="page-overlay-canvas fadeout" />'),
				img = new Image();
			fullScreen.data('objects')[idx] = poc;
			fullScreen.append(poc);
			img.src = fullScreen.hrefs[idx];
			$(window).resize(function(e) {
				if (!scrollBar.is(':animated') && fullView) {
					scrollBar.height($(window).height()*.5-54);
					var h = img.height*($(window).width()/img.width);				
					if ((img.height > $(window).height()) && (!scrollBar.is(':visible'))) {
						scrollBar.fadeIn(333);
					 } else if ((img.height < $(window).height()) && (scrollBar.is(':visible'))) {
					 	scrollBar.fadeOut(333);
					 }
				}
			});
			var dragger = {'dragging': false,'wheeling': false,'initial': 0,'dragRespect': 0,'wheelRespect':0,'ratio':$(window).width() / img.width};
			fullScreen.delegate('.draggable',{
				'mousedown':function(e){
					e.preventDefault();
					e.stopPropagation();
					dragger.dragging = true;
					dragger.initial = e.pageY;		
					dragger.dragRespect = $(this).find('img').position($(this)).top;
				},
				'mouseup':function(e){
					e.preventDefault();
					e.stopPropagation();
					if (dragger.dragging) {
						dragger.dragging = false;
						dragger.dragRespect = $(this).find('img').position($(this)).top;
					} else if (tracker.inControl) { tracker.inControl = false; }
				},
				'mousemove':function(e){
					e.preventDefault();
					e.stopPropagation();
					if (dragger.dragging) {
						var img = $(this).find('img');
						var amt = dragger.dragRespect - (dragger.initial - e.pageY);
						if ((-amt >= 0) && (-amt <= img.height()-$(window).height())) { $(this).find('img').css('top',amt) }
						var pct = -amt / (img.height()-$(window).height()-54);
						if (pct > 1) { pct = 1; }
						else if (pct < 0) { pct = 0; }
						tracker.css('top',(scrollBar.height()-tracker.height())*pct);
					} else if (tracker.inControl) { moveTracker(e,tracker); }
				},
				'mousewheel':function(e,delta){
					e.preventDefault();
					e.stopPropagation();
					if (dragger.wheeling) {
						dragger.wheelRespect = $(this).find('img').position($(this)).top;
						var amt = dragger.wheelRespect - -delta*20,
							img = $(this).find('img');
						if ((-amt >= 0) && (-amt <= img.height()-$(window).height())) { $(this).find('img').css('top',amt) }
						var pct = -amt / (img.height()-$(window).height()-54);
						if (pct > 1) { pct = 1; }
						else if (pct < 0) { pct = 0; }
						tracker.css('top',(scrollBar.height()-tracker.height())*pct);
					} else {
						dragger.wheeling = true;
						dragger.initial = e.pageY;
						dragger.wheelRespect = dragger.dragRespect;
					}
				},
				'mouseleave':function() {
					dragger.dragging = false;
					tracker.inControl = false;
				}
			});
			img.onload = function() {
				img.style.maxWidth = img.width+"px";
				//fade in scrollBar if needed
				if ((img.height*(($(window).width()/img.width)) > $(window).height()) && (fullView)) { scrollBar.fadeIn(250); }
			setTimeout(function() {	pocAdjust(poc,img,fullView); },100);
				//build floating control panel
				var fcp = $('<div id="fcp" class="ui-floating-box" />'),
					infoTitle = '<div class="infoTitle">You are currently viewing...</div>',
					infoBody = $('<div class="infoBody" />'),
					fcpClose = $('<a href="#" class="closebox" id="close-fcp" />'),
					fcpOpen = $('<a href="#" class="openbox" id="grow-fcp" />'),
					controlBar = $('<div class="control-bar" />'),
					controlFitToScreen = $('<div class="cb-button fit-to-screen"><span class="icon fit-to-screen">&nbsp;</span><span>Fit to Screen</span></div>'),
					controlActualSize = $('<div class="cb-button actual-size"><span class="icon actual-size">&nbsp;</span><span>Actual Size</span></div>'),
					keyboardHelp = new Array(
						'<div id="help-bar" class="help-bar">',
						// '<a href="#" id="close-help" class="closebox">&nbsp;</a><a href="#" id="open-help" class="openbox">&nbsp;</a>',
						'<div class="group one-col">',
						'<div class="keymap scrollUp"><span class="icon up-arrow">&nbsp;</span><span class="name">Scroll Up</span></div>',
						'<div class="keymap scrollDown"><span class="icon down-arrow">&nbsp;</span><span class="name">Scroll Down</span></div>',
						'</div><div class="group two-col">',				
						'<div class="keymap previousKey"><span class="icon left-arrow">&nbsp;</span><span class="name">Previous</span></div>',
						'<div class="keymap nextKey"><span class="icon right-arrow">&nbsp;</span><span class="name">Next</span></div>',
						'<div class="keymap escapeKey"><span class="icon escape">&nbsp;</span><span class="name">Exit</span></div>',		
						'</div></div>'
						);
				controlBar.append(controlFitToScreen,controlActualSize);
				infoBody.append('<div id="fcp-idx-container" class="row"><span id="fcpIdx"></span> of '+max+'</div>',
								'<div id="info-project-name" class="row"><div class="label">Project</div><div class="body">'+metaData.project+'</div></div>',
								'<div id="info-client-name" class="row"><div class="label">Client</div><div class="body">'+metaData.client+'</div></div>');
				if (metaData.url !== '') { 
					infoBody.append('<div id="info-client-url" class="row"><div class="label">URL</div><div class="body">'+$("<div>").append($(metaData.url).clone()).html()+'</div></div>');
				}
				fcp.append(fcpClose,fcpOpen,infoTitle,infoBody,controlBar,keyboardHelp.join("\r\n"));
				//add floating control panel to body
				$('body').append(fcp);
				//run updateOverlayInfo first time
				updateOverlayInfo(fullView,idx,poc,img);
				//fade in control panel, apply jqueryui draggable
				$('.ui-floating-box').addClass('jfade').fadeIn(250,function(){$(this).removeClass('jfade').draggable({containment:'window'})});
				//bind events
				var ostate = new Array();
				$('.ui-floating-box .closebox').click(function(e){
					e.preventDefault();
					var thebox = $(this).parents('.ui-floating-box'),
						bid = thebox.attr('id');
					ostate[bid] = thebox.position();
					if (bid == 'help-bar') { 
						thebox.addClass('closed').animate({left:-5,top:74},100).draggable('disable');
						thebox.find('.keymap,.closebox').hide();
						thebox.find('.openbox').fadeIn(250);
					} else if (bid == 'fcp') {
						thebox.addClass('closed').animate({left:-5,top:74},100).draggable('disable');					
						thebox.find('.infoTitle,.infoBody,.control-bar,.closebox,.help-bar').hide();
						thebox.find('.openbox').fadeIn(250);
					}
				});
				$('.ui-floating-box .openbox').click(function(e) {
					e.preventDefault();
					var thebox = $(this).parents('.ui-floating-box'),
						bid = thebox.attr('id');
					thebox.removeClass('closed').animate({left:ostate[bid].left,top:ostate[bid].top},100).draggable('enable');
					thebox.find('.openbox').hide();
					if (bid == 'fcp') { thebox.find('.infoBody,.control-bar.control-bar,.closebox,.help-bar').fadeIn(250); }
					else if (bid == 'help-bar') { thebox.find('.keymap,.closebox').fadeIn(250); }
				});
				controlActualSize.click(function(e) {
					var cState = fcp.data();
					if (!cState.control.hasClass('actual-size')) { 
						cState.control.addClass('actual-size');
						pocAdjust(cState.control,cState.img,true);
						fullView = true;
						updateOverlayInfo(fullView);
					}
				});
				controlFitToScreen.click(function(e) {
					var cState = fcp.data();
					if (cState.control.hasClass('actual-size')) { 
						cState.control.removeClass('actual-size');
						fullView = false;
						updateOverlayInfo(fullView);
						pocAdjust(cState.control,cState.img,false);
					}
				});
				// build help overlay (lets call it helpBox)
				//var helpBox = $('<div id="helpBox" class="ui-floating-box closed" />'),
				//	helpToggle = $('<a id="helpToggle" class="icon toggle" />');
				//helpBox.append(helpToggle).addClass('jfade');
				//$('body').append(helpBox.fadeIn(333,function(){$(this).removeClass('jfade').draggable('create').draggable('disable')}));
				// set up controls
				// set up previous & next controls if needed
				if (max > 1) { 
					fullScreen.multiple = true;
					if (idx < max-1) { fsNext.removeClass("inactive"); }
					if (idx > 0) { fsPrev.removeClass("inactive"); }
					$(".fs-next-button,.fs-prev-button").hover(function() { 
							if (!$(this).hasClass("inactive")) { 
								$(this).addClass("hover");
							}
						},function() { 
							$(this).removeClass("hover");
					});
					fsPrev.click(function(e) {
						e.preventDefault();
						e.stopPropagation();
						var a = $(this).find('a'),
							mdata = fullScreen.data();
						if (($(this).hasClass("inactive")) && (!a.data('allow'))) { return false; }
						else if (a.data('allow')) { a.data('allow',false); }
						var idx = mdata.idx,
							href = fullScreen.hrefs[idx-1],
							apoc = mdata.objects[idx];
						dragger.dragRespect = 0;
						dragger.wheeling = false;
						dragger.dragging = false;
						//if poc HAS BEEN created & cached
						if (typeof mdata.objects[idx-1] !== "undefined") {
							var poc = mdata.objects[idx-1],
								img = poc.find('img').get(0);				
							apoc.addClass("fadeout");	
							$(img).css('top',0);
							setTimeout(function() { pocAdjust(poc,img,fullView); },100);
						} 
						else { 
							//if poc HAS NOT BEEN created & cached
							$("#ajaxloader").fadeIn(250);
							Spinners.get('.ajaxloader').play();
							var poc = $('<div class="page-overlay-canvas" />'),
								img = new Image();
							mdata.objects[idx-1] = poc; 
							img.src = href;
							img.onload = function() { 	
								img.style.maxWidth = img.width+"px";					
								fullScreen.append(poc.addClass("fadeout").css('z-index',499));
								apoc.addClass("fadeout");
								Spinners.get('.ajaxloader').stop(); 
								$("#ajaxloader").fadeOut(250);
							setTimeout(function() { pocAdjust(poc,img,fullView); },100);
							}	
						}
						tracker.animate({top:0},500);
						//update data
						mdata.idx--;
						fullScreen.data(mdata);
						if (mdata.idx > 0) { $(this).removeClass("inactive"); }
						else { $(this).addClass("inactive"); }
						fsNext.removeClass("inactive");
						updateOverlayInfo(fullView,mdata.idx,poc,img);
					});
					fsNext.click(function(e) {
						e.preventDefault();
						e.stopPropagation();
						var a = $(this).find('a'),
							mdata = fullScreen.data();
						if (($(this).hasClass("inactive")) && (!a.data('allow'))) { return false; }
						else if (a.data('allow')) { a.data('allow',false); }
						var idx = mdata.idx,
							href = fullScreen.hrefs[idx+1],
							apoc = mdata.objects[idx];				
						dragger.dragRespect = 0;
						dragger.wheeling = false;
						dragger.dragging = false;
						//if poc HAS BEEN created & cached
						if (typeof mdata.objects[idx+1] !== "undefined") {
							var poc = mdata.objects[idx+1];
								img = poc.find('img').get(0);
							apoc.addClass("fadeout");	
							$(img).css('top',0);
							setTimeout(function() { pocAdjust(poc,img,fullView); },100);							
						} 
						else {
						//if poc HAS NOT BEEN created & cached
							$("#ajaxloader").fadeIn(250);
							Spinners.get('.ajaxloader').play();
							var poc = $('<div class="page-overlay-canvas" />'),
								img = new Image();
							mdata.objects[idx+1] = poc; 
							img.src = href;
							img.onload = function() { 
								img.style.maxWidth = img.width+"px";						
								fullScreen.append(poc.addClass("fadeout").css('z-index',499));
								Spinners.get('.ajaxloader').stop(); 
								$("#ajaxloader").fadeOut(250);
								apoc.addClass("fadeout");	
								setTimeout(function() { pocAdjust(poc,img,fullView); },100);
							}
						}
						tracker.animate({top:0},500);
						//update data
						mdata.idx++;
						fullScreen.data(mdata);
						if (mdata.idx < max-1) { $(this).removeClass("inactive"); }
						else { $(this).addClass("inactive"); }
						fsPrev.removeClass("inactive");					
						updateOverlayInfo(fullView,mdata.idx,poc,img);
					});
				} // end control setup
				//close overlay function
				fsClose.click(function(e) {
					$(document).unbind('keydown');
					fullScreen.undelegate('.draggable');
					Spinners.get('.ajaxloader').remove();
					$('.ui-floating-box').addClass('jfade'); 
					$("#ajaxloader,.fullscreen-controls,#scrollBar,.ui-floating-box").fadeOut(250,function() { $(this).remove(); });
					$("#container,#region-mini-footer,#footer").show();
					fullScreen.fadeOut(250);
				});				
				$(document).keydown(function(e){ 
						switch(e.keyCode) {
							case 27: //esc 
								fsClose.click();
								break;
							case 37: // left arrow
								if (fullScreen.multiple) { 
									if (fullScreen.data('idx') > 0) {
										var key = $('.keymap.previousKey span.name');
										key.addClass('blue');
										key.animate({color:'#0090c7'},25,function() { setTimeout(function() { key.animate({color:'#fff'},25) },100)});
										fsPrev.find('a').data('allow',true).click();										
									}
								}
								break;
							case 39: // right arrow
								if (fullScreen.multiple) {
									if (fullScreen.data('idx') < max-1) {
										var key = $('.keymap.nextKey span.name');
										key.animate({color:'#0090c7'},25,function() { setTimeout(function() { key.animate({color:'#fff'},25) },100)});									
										fsNext.find('a').data('allow',true).click(); 
									}	
								}
								break;
							case 38: // up arrow
								var apoc = fullScreen.data('objects')[fullScreen.data('idx')];
								if (apoc.hasClass('draggable')) { 
									var apocImg = apoc.find('img'),
										scrollPos = tracker.position(tracker.parent()).top,
										ratio = tracker.parent().height() / (apocImg.height() - $(window).height());  
									if (-apocImg.position(apoc).top > 0) { 
										var key = $('.keymap.scrollUp span.name');
										key.animate({color:'#0090c7'},25,function() { setTimeout(function() { key.animate({color:'#fff'},25) },100)});									
										if (scrollPos-20*ratio <= 0) { var scrollAmt = 0; }
										else { var scrollAmt = scrollPos-20*ratio; }
										apocImg.css('top',apocImg.position(apoc).top+20);
										tracker.css('top',scrollAmt);
									 } 
								}
								break;
							case 40: // down arrow
								var apoc = fullScreen.data('objects')[fullScreen.data('idx')];
								if (apoc.hasClass('draggable')) { 
									var apocImg = apoc.find('img'),
										scrollPos = tracker.position(tracker.parent()).top,
										ratio = tracker.parent().height() / (apocImg.height() - $(window).height());  
									if (-apocImg.position(apoc).top < apocImg.height() - $(window).height()+54) { 
										var key = $('.keymap.scrollDown span.name');
										key.animate({color:'#0090c7'},25,function() { setTimeout(function() { key.animate({color:'#fff'},25) },100)});
										if (scrollPos+20*ratio >= tracker.parent().height() - tracker.height()) { var scrollAmt = tracker.parent().height() - tracker.height(); }
										else { var scrollAmt = scrollPos+20*ratio; }
										apocImg.css('top',apocImg.position(apoc).top-20);
										tracker.css('top',scrollAmt);
									 } 
								}
								break;
							default:
								break;
						}								
					});				
			} // end img onload
		}); // end fullScreen.fadeIn callback
	} // end goFullScreen	
	function updateOverlayInfo(fullView,idx,control,img) { 
		// add one since idx starts at 0
		var f = $('.cb-button.actual-size'),
			c = $('.cb-button.fit-to-screen');
		if (fullView) {
			f.addClass('active');
			c.removeClass('active');
		} else {
			f.removeClass('active');
			c.addClass('active');
		}
		if (arguments.length > 1) {
			$("#fcpIdx").empty().append(idx+1);
			$('#fcp').data({'control':control,'img':img});
		}
	}
	function pocAdjust(poc,img,fullView) {
		var scrollBar = $('#scrollBar'),
			fullScreen = $('#page-overlay');
		if (!poc.children('img').length) { poc.append(img); } 
		setTimeout(function() { poc.removeClass("fadeout") },200);		
		$("#ajaxloader").fadeOut(50);
		Spinners.get('.ajaxloader').stop();		
		if (fullView) {
			poc.addClass('actual-size');
			var h = img.height*($(window).width()/img.width);	
			if (h > $(window).height()-54) { 
				poc.addClass('draggable'); 
				if ((!scrollBar.is(":visible")) && (!scrollBar.is(':animated'))) { scrollBar.fadeIn(250); }			
			}
		} else { 
			poc.removeClass('actual-size draggable'); 
			if (scrollBar.is(":visible")) { scrollBar.fadeOut(333); }			
		}
		poc.css({'background-image':'url(\''+img.src+'\')','z-index':500});
	}
	function moveTracker(e,t) {
		e.preventDefault();
		//e.stopPropagation();
		var	scrollBar = $('#scrollBar'),
			fullScreen = $('#page-overlay');
		if (t.inControl) {				
			var currentPos = t.position().top,
				pc = t.position(t.parent()).top / (t.parent().height() -  t.height()),
				delta = t.initY - e.pageY,
				aimg = fullScreen.data('objects')[fullScreen.data('idx')].find('img'),
				pocDelta = delta * (scrollBar.height() / aimg.height()),
				pocPos = aimg.position().top,
				move = t.initPos - delta;
			if (pc > 1) { 
				move = scrollBar.height() - t.height(); 
				pc = 0.999; 
			} else if (pc < 0) { 
				move = 0; 
				pc = 0; 
			}
			if ((pc < 1) && (pc >= 0)) { 
				t.css('top',move);
				var pocDelta = (pc*(aimg.height() - $(window).height()));
				aimg.css('top',-pocDelta);
			}
		}
	}
	function blockPagerClick(e) {
		e.preventDefault();
		e.stopPropagation();
		$(".block-pager .control-item").each(function() { 
			if ($(this).hasClass("active")) { $(this).removeClass("active"); }
		});
		$(this).parent('.control-item').addClass("active");
		var iteration = parseInt($.trim($(this).text()));
		$(this).parents('.view').find('.node-action-overlay-innerbox.active').removeClass("active");
		$(this).parents('.view').find('.node-action-overlay-innerbox').eq(iteration).addClass("active");
		if ($(this).parents('.view').hasClass("page-width")) {
			var target_shift = iteration * -960;
		} else {
			var target_shift = iteration * -600; 
		}
		$(this).parents('.view').find(".floating-image").each(function() { 
			if (Modernizr.csstransitions) { 
				$(this).css({left:target_shift}); 
			} else { 
				$(this).animate({
						left:target_shift
					},750,$.data(document.body, 'eF'));
			 }
		});
	}	
	// Show/hide functions for header/footer
	function showBar(bar,idx,tohide) {
		var toShow = bar.find(".block").eq(idx);
		if (tohide) {
			$('#'+tohide).fadeOut(350,eF);
			bar.slideUp(350,eF,function() {
				toShow.fadeIn(350,eF);
				bar.slideDown(350,eF);
			});
		}
		else {
			toShow.fadeIn(350,eF);
			bar.slideDown(350,eF);
		}
		if (toShow.hasClass('block-webform')) { toShow.find('form input.form-text').eq(0).focus(); }
		bar.data({'section':toShow.attr('id'),'visible':true});
	}
	function hideBar(flyout,bar) {
		if (bar.attr('id') == 'footer-bar') { $('#webform-client-form-621')[0].reset(); contactForm.resetForm(); contactForm.submit = {}; }
		bar.find("ul li").each(function() { $(this).removeClass("clicked"); });
		flyout.data('visible',false);
		flyout.find(".block").each(function() { $(this).fadeOut(350,eF) });
		flyout.slideUp(350,eF);
	}
})(jQuery);;
/*  Spinners 2.0_b1
 *  (c) 2010-2011 Nick Stakenburg - http://www.nickstakenburg.com
 *
 *  Spinners is freely distributable under the terms of an MIT-style license.
 *
 *  Requires ExplorerCanvas to work in Internet Explorer:
 *  http://code.google.com/p/explorercanvas
 *
 *  GitHub: https://github.com/staaky/spinners
 */

(function(){function c(a,b){a&&(this.element=a,i.remove(a),i.removeDetached(),this.options=f.extend({radii:[5,10],color:"#000",dashWidth:1.8,dashes:12,opacity:1,padding:3,speed:.7,build:!0},b||{}),this._position=0,this._state="stopped",this.build(),i.add(this))}function b(a){this.element=a}function a(a){return a*Math.PI/180}var d={Version:"2.0_b1"},e=Array.prototype.slice,f={extend:function(a,b){for(var c in b)a[c]=b[c];return a},"break":{},_each:function(a,b){for(var c=0,d=a.length;c<d;c++)b(a[c])},each:function(a,b,c){var d=0;try{this._each(a,function(a){b.call(c,a,d++)})}catch(e){if(e!=f["break"])throw e}},bind:function(a,b){var c=e.call(arguments,2);return function(){return a.apply(b,c.concat(e.call(arguments)))}},scroll:function(a,b){if(!b)return a;var c=a.slice(0,b);return a.slice(b,a.length).concat(c)},any:function(a,b,c){var d=!1;f.each(a||[],function(a,e){if(d|=b.call(c,a,e))return f["break"]});return!!d},member:function(a,b){var c=!1;f.any(a||[],function(a){if(c=a===b)return!0});return c},select:function(a,b,c){var d=[];f.each(a||[],function(a,e){b.call(c,a,e)&&(d[d.length]=a)});return d},without:function(a){var b=e.call(arguments,1);return f.select(a,function(a){return!f.member(b,a)})}},g={drawRoundedRectangle:function(b,c){var d=f.extend({top:0,left:0,width:0,height:0,radius:0},c||{}),e=d.left,g=d.top,h=d.width,i=d.height,d=d.radius;b.beginPath(),b.moveTo(e+d,g),b.arc(e+h-d,g+d,d,a(-90),a(0),!1),b.arc(e+h-d,g+i-d,d,a(0),a(90),!1),b.arc(e+d,g+i-d,d,a(90),a(180),!1),b.arc(e+d,g+d,d,a(-180),a(-90),!1),b.closePath(),b.fill()}},h=function(){function a(a){var c=[];a.indexOf("#")==0&&(a=a.substring(1)),a=a.toLowerCase();if(a.replace(b,"")!="")return null;a.length==3?(c[0]=a.charAt(0)+a.charAt(0),c[1]=a.charAt(1)+a.charAt(1),c[2]=a.charAt(2)+a.charAt(2)):(c[0]=a.substring(0,2),c[1]=a.substring(2,4),c[2]=a.substring(4));for(a=0;a<c.length;a++)c[a]=parseInt(c[a],16);c.red=c[0],c.green=c[1],c.blue=c[2];return c}var b=RegExp("[0123456789abcdef]","g"),c=function(){function a(a,b,c){a=a.toString(c||10);return Array(b-a.length).join("0")+a}return function(b,c,d){return"#"+a(b,2,16)+a(c,2,16)+a(d,2,16)}}();return{hex2rgb:a,hex2fill:function(b,c){typeof c=="undefined"&&(c=1);var d=c,e=a(b);e[3]=d,e.opacity=d;return"rgba("+e.join()+")"},rgb2hex:c}}();f.extend(d,{enabled:!1,support:{canvas:function(){var a=document.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")}()},dom:function(){var a,b;a=b=function(){throw"Using Spinners with a CSS Selector requires a selector engine, include one of: Sizzle (jQuery 1.4+/Prototype 1.7+), NWMatcher or Slick (MooTools 1.3+)."},window.Sizzle?(a=Sizzle,b=Sizzle.matches):window.jQuery?(a=jQuery.find,b=function(a,b){return jQuery(a).is(b)}):window.NWMatcher&&NW.Dom?(a=NW.Dom.select,b=NW.Dom.match):window.Prototype&&Prototype.Selector?(a=Prototype.Selector.select,b=Prototype.Selector.match):window.Slick&&(a=function(a,b){return Slick.search(b||document,a)},b=Slick.match);return{select:a,match:b}}(),init:function(){if(!this.support.canvas&&!window.G_vmlCanvasManager)if(window.attachEvent&&navigator.userAgent.indexOf("Opera")===-1)alert("Spinners requires ExplorerCanvas (excanvas.js)");else return;window.G_vmlCanvasManager&&window.G_vmlCanvasManager.init_(document),this.enabled=!0},create:function(a,c){b.create(a,c);return this.get(a)},get:function(a){return new b(a)},play:function(a){this.get(a).play();return this},pause:function(a){this.get(a).pause();return this},toggle:function(a){this.get(a).toggle();return this},stop:function(a){this.get(a).stop();return this},remove:function(a){this.get(a).remove();return this},removeDetached:function(){i.removeDetached();return this},getDimensions:function(a){a=i.get(a)[0].getLayout().workspace.radius*2;return{width:a,height:a}}});var i={spinners:[],get:function(a){if(a){var b=[];f.each(this.spinners,function(c){c&&(a.nodeType==1?c.element==a:d.dom.match(c.element,a))&&b.push(c)});return b}},add:function(a){this.spinners.push(a)},remove:function(a){var b=[];f.each(this.spinners,function(c){(a.nodeType==1?c.element==a:d.dom.match(c.element,a))&&b.push(c.element)}),f.each(b,f.bind(function(a){this.removeByElement(a)},this))},removeByElement:function(a){if(a=this.get(a)[0])a.remove(),this.spinners=f.without(this.spinners,a)},removeDetached:function(){return function(){f.each(this.spinners,function(a){a&&!a.isAttached()&&this.remove(a.element)},this)}}()};f.extend(b,{create:function(a,b){if(a){var e=b||{},g=[];a.nodeType==1?g.push(new c(a,e)):f.each(d.dom.select(a)||[],function(a){g.push(new c(a,e))});return g}}}),f.extend(b.prototype,{items:function(){return i.get(this.element)},play:function(){f.each(this.items(),function(a){a.play()});return this},stop:function(){f.each(this.items(),function(a){a.stop()});return this},pause:function(){f.each(this.items(),function(a){a.pause()});return this},toggle:function(){f.each(this.items(),function(a){a.toggle()});return this},remove:function(){i.remove(this.element);return this}}),f.extend(c.prototype,function(){function b(){var a=this.options.speed*1e3/this.options.dashes;this.nextPosition(),this._playTimer=window.setTimeout(f.bind(b,this),a)}return{remove:function(){this.canvas&&(this.stop(),this.canvas.parentNode.removeChild(this.canvas),this.ctx=this.canvas=null)},build:function(){this.remove();var a=this.getLayout().workspace.radius,b=a*2;this.canvas=document.createElement("canvas"),this.canvas.style.zoom=1,this.canvas.height=b,this.canvas.width=b,document.body.appendChild(this.canvas),window.G_vmlCanvasManager&&G_vmlCanvasManager.initElement(this.canvas),this.ctx=this.canvas.getContext("2d"),this.ctx.globalAlpha=this.options.opacity,this.element.appendChild(this.canvas),this.ctx.translate(a,a),this.drawPosition(0);return this},getLayout:function(){if(this._layout)return this._layout;var a=this.options,b=a.dashes,c=a.radii,d=a.dashWidth,e=Math.min(c[0],c[1]),c=Math.max(c[0],c[1]),f=Math.ceil(Math.max(Math.max(d,c),Math.sqrt(c*c+d/2*(d/2))));f+=a.padding;for(var a=f,g=1/b,h=[],i=0;i<b;i++)h.push((i+1)*g);return this._layout=b={workspace:{radius:a,opacities:h},dash:{position:{top:f-c,left:f-d/2},dimensions:{width:d,height:c-e}}}},isAttached:function(){if(!this.element)return!1;var a;for(a=this.element;a&&a.parentNode;)a=a.parentNode;return!!a&&!!a.body},_nextPosition:b,nextPosition:function(){this._position==this.options.dashes-1&&(this._position=-1),this._position++,this.drawPosition(this._position)},drawPosition:function(b){var c=this.getLayout().workspace,d=c.radius*2,e=-1*c.radius,g=this.options.dashes;this.ctx.clearRect(e,e,d,d),d=a(360/g),b=f.scroll(c.opacities,b*-1);for(c=0;c<g;c++)this.drawDash(b[c],this.options.color),this.ctx.rotate(d)},drawDash:function(a,b){this.ctx.fillStyle=h.hex2fill(b,a);var c=this.getLayout(),d=c.workspace.radius,e=c.dash.position,c=c.dash.dimensions;g.drawRoundedRectangle(this.ctx,{top:e.top-d,left:e.left-d,width:c.width,height:c.height,radius:Math.min(c.height,c.width)/2})},play:function(){if(this._state!="playing"){this._state="playing";var a=this.options.speed*1e3/this.options.dashes;this._playTimer=window.setTimeout(f.bind(b,this),a);return this}},pause:function(){if(this._state!="paused")return this._pause(),this._state="paused",this},_pause:function(){this._playTimer&&(window.clearTimeout(this._playTimer),this._playTimer=null)},stop:function(){if(this._state!="stopped")return this._pause(),this._position=0,this.drawPosition(0),this._state="stopped",this},toggle:function(){this[this._state=="playing"?"pause":"play"]();return this}}}()),window.Spinners=d,d.init(),d.enabled||f.each("create get remove play stop pause toggle".split(" "),function(a){d[a]=function(){return this}})})();;

