/* start jquery.cookie.js */
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
/* end jquery.cookie.js */
/* start jquery.ui.js */
/*!
 * jQuery UI 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI
 */
(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.16",
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({propAttr:c.fn.prop||c.fn.attr,_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=
this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,
"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":
"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,
outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a,
"tabindex"),d=isNaN(b);return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&
a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&
c.ui.isOverAxis(b,e,i)}})}})(jQuery);
;/*
 * jQuery UI Effects 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Effects/
 */
jQuery.effects||function(f,j){function m(c){var a;if(c&&c.constructor==Array&&c.length==3)return c;if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)];if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return[parseInt(a[1],
16),parseInt(a[2],16),parseInt(a[3],16)];if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];if(/rgba\(0, 0, 0, 0\)/.exec(c))return n.transparent;return n[f.trim(c).toLowerCase()]}function s(c,a){var b;do{b=f.curCSS(c,a);if(b!=""&&b!="transparent"||f.nodeName(c,"body"))break;a="backgroundColor"}while(c=c.parentNode);return m(b)}function o(){var c=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,
a={},b,d;if(c&&c.length&&c[0]&&c[c[0]])for(var e=c.length;e--;){b=c[e];if(typeof c[b]=="string"){d=b.replace(/\-(\w)/g,function(g,h){return h.toUpperCase()});a[d]=c[b]}}else for(b in c)if(typeof c[b]==="string")a[b]=c[b];return a}function p(c){var a,b;for(a in c){b=c[a];if(b==null||f.isFunction(b)||a in t||/scrollbar/.test(a)||!/color/i.test(a)&&isNaN(parseFloat(b)))delete c[a]}return c}function u(c,a){var b={_:0},d;for(d in a)if(c[d]!=a[d])b[d]=a[d];return b}function k(c,a,b,d){if(typeof c=="object"){d=
a;b=null;a=c;c=a.effect}if(f.isFunction(a)){d=a;b=null;a={}}if(typeof a=="number"||f.fx.speeds[a]){d=b;b=a;a={}}if(f.isFunction(b)){d=b;b=null}a=a||{};b=b||a.duration;b=f.fx.off?0:typeof b=="number"?b:b in f.fx.speeds?f.fx.speeds[b]:f.fx.speeds._default;d=d||a.complete;return[c,a,b,d]}function l(c){if(!c||typeof c==="number"||f.fx.speeds[c])return true;if(typeof c==="string"&&!f.effects[c])return true;return false}f.effects={};f.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor",
"borderTopColor","borderColor","color","outlineColor"],function(c,a){f.fx.step[a]=function(b){if(!b.colorInit){b.start=s(b.elem,a);b.end=m(b.end);b.colorInit=true}b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2],10),255),0)+")"}});var n={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,
0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,
211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},q=["add","remove","toggle"],t={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};f.effects.animateClass=function(c,a,b,
d){if(f.isFunction(b)){d=b;b=null}return this.queue(function(){var e=f(this),g=e.attr("style")||" ",h=p(o.call(this)),r,v=e.attr("class");f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});r=p(o.call(this));e.attr("class",v);e.animate(u(h,r),{queue:false,duration:a,easing:b,complete:function(){f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});if(typeof e.attr("style")=="object"){e.attr("style").cssText="";e.attr("style").cssText=g}else e.attr("style",g);d&&d.apply(this,arguments);f.dequeue(this)}})})};
f.fn.extend({_addClass:f.fn.addClass,addClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{add:c},a,b,d]):this._addClass(c)},_removeClass:f.fn.removeClass,removeClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{remove:c},a,b,d]):this._removeClass(c)},_toggleClass:f.fn.toggleClass,toggleClass:function(c,a,b,d,e){return typeof a=="boolean"||a===j?b?f.effects.animateClass.apply(this,[a?{add:c}:{remove:c},b,d,e]):this._toggleClass(c,a):f.effects.animateClass.apply(this,
[{toggle:c},a,b,d])},switchClass:function(c,a,b,d,e){return f.effects.animateClass.apply(this,[{add:a,remove:c},b,d,e])}});f.extend(f.effects,{version:"1.8.16",save:function(c,a){for(var b=0;b<a.length;b++)a[b]!==null&&c.data("ec.storage."+a[b],c[0].style[a[b]])},restore:function(c,a){for(var b=0;b<a.length;b++)a[b]!==null&&c.css(a[b],c.data("ec.storage."+a[b]))},setMode:function(c,a){if(a=="toggle")a=c.is(":hidden")?"show":"hide";return a},getBaseline:function(c,a){var b;switch(c[0]){case "top":b=
0;break;case "middle":b=0.5;break;case "bottom":b=1;break;default:b=c[0]/a.height}switch(c[1]){case "left":c=0;break;case "center":c=0.5;break;case "right":c=1;break;default:c=c[1]/a.width}return{x:c,y:b}},createWrapper:function(c){if(c.parent().is(".ui-effects-wrapper"))return c.parent();var a={width:c.outerWidth(true),height:c.outerHeight(true),"float":c.css("float")},b=f("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),
d=document.activeElement;c.wrap(b);if(c[0]===d||f.contains(c[0],d))f(d).focus();b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(e,g){a[g]=c.css(g);if(isNaN(parseInt(a[g],10)))a[g]="auto"});c.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}return b.css(a).show()},removeWrapper:function(c){var a,b=document.activeElement;
if(c.parent().is(".ui-effects-wrapper")){a=c.parent().replaceWith(c);if(c[0]===b||f.contains(c[0],b))f(b).focus();return a}return c},setTransition:function(c,a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0)d[g]=unit[0]*b+unit[1]});return d}});f.fn.extend({effect:function(c){var a=k.apply(this,arguments),b={options:a[1],duration:a[2],callback:a[3]};a=b.options.mode;var d=f.effects[c];if(f.fx.off||!d)return a?this[a](b.duration,b.callback):this.each(function(){b.callback&&b.callback.call(this)});
return d.call(this,b)},_show:f.fn.show,show:function(c){if(l(c))return this._show.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(l(c))return this._hide.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(l(c)||typeof c==="boolean"||f.isFunction(c))return this.__toggle.apply(this,arguments);else{var a=k.apply(this,
arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%","pt"],function(d,e){if(a.indexOf(e)>0)b=[parseFloat(a),e]});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return-d*(a/=e)*(a-2)+b},easeInOutQuad:function(c,a,b,d,e){if((a/=e/2)<1)return d/
2*a*a+b;return-d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a+b;return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return-d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a+b;return-d/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(c,a,b,
d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a*a+b;return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2,10*(a/e-1))+b},easeOutExpo:function(c,
a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0)return b;if(a==e)return b+d;if((a/=e/2)<1)return d/2*Math.pow(2,10*(a-1))+b;return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return-d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1)return-d/2*(Math.sqrt(1-a*a)-1)+b;return d/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(c,a,b,
d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);return-(h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g))+b},easeOutElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);return h*Math.pow(2,-10*a)*Math.sin((a*e-c)*2*Math.PI/g)+d+b},easeInOutElastic:function(c,a,b,d,e){c=1.70158;var g=
0,h=d;if(a==0)return b;if((a/=e/2)==2)return b+d;g||(g=e*0.3*1.5);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);if(a<1)return-0.5*h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)+b;return h*Math.pow(2,-10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)*0.5+d+b},easeInBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;return d*(a/=e)*a*((g+1)*a-g)+b},easeOutBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;return d*((a=a/e-1)*a*((g+1)*a+g)+1)+b},easeInOutBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;
if((a/=e/2)<1)return d/2*a*a*(((g*=1.525)+1)*a-g)+b;return d/2*((a-=2)*a*(((g*=1.525)+1)*a+g)+2)+b},easeInBounce:function(c,a,b,d,e){return d-f.easing.easeOutBounce(c,e-a,0,d,e)+b},easeOutBounce:function(c,a,b,d,e){return(a/=e)<1/2.75?d*7.5625*a*a+b:a<2/2.75?d*(7.5625*(a-=1.5/2.75)*a+0.75)+b:a<2.5/2.75?d*(7.5625*(a-=2.25/2.75)*a+0.9375)+b:d*(7.5625*(a-=2.625/2.75)*a+0.984375)+b},easeInOutBounce:function(c,a,b,d,e){if(a<e/2)return f.easing.easeInBounce(c,a*2,0,d,e)*0.5+b;return f.easing.easeOutBounce(c,
a*2-e,0,d,e)*0.5+d*0.5+b}})}(jQuery);
;/*
 * jQuery UI Effects Bounce 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Effects/Bounce
 *
 * Depends:
 *	jquery.effects.core.js
 */
(function(e){e.effects.bounce=function(b){return this.queue(function(){var a=e(this),l=["position","top","bottom","left","right"],h=e.effects.setMode(a,b.options.mode||"effect"),d=b.options.direction||"up",c=b.options.distance||20,m=b.options.times||5,i=b.duration||250;/show|hide/.test(h)&&l.push("opacity");e.effects.save(a,l);a.show();e.effects.createWrapper(a);var f=d=="up"||d=="down"?"top":"left";d=d=="up"||d=="left"?"pos":"neg";c=b.options.distance||(f=="top"?a.outerHeight({margin:true})/3:a.outerWidth({margin:true})/
3);if(h=="show")a.css("opacity",0).css(f,d=="pos"?-c:c);if(h=="hide")c/=m*2;h!="hide"&&m--;if(h=="show"){var g={opacity:1};g[f]=(d=="pos"?"+=":"-=")+c;a.animate(g,i/2,b.options.easing);c/=2;m--}for(g=0;g<m;g++){var j={},k={};j[f]=(d=="pos"?"-=":"+=")+c;k[f]=(d=="pos"?"+=":"-=")+c;a.animate(j,i/2,b.options.easing).animate(k,i/2,b.options.easing);c=h=="hide"?c*2:c/2}if(h=="hide"){g={opacity:0};g[f]=(d=="pos"?"-=":"+=")+c;a.animate(g,i/2,b.options.easing,function(){a.hide();e.effects.restore(a,l);e.effects.removeWrapper(a);
b.callback&&b.callback.apply(this,arguments)})}else{j={};k={};j[f]=(d=="pos"?"-=":"+=")+c;k[f]=(d=="pos"?"+=":"-=")+c;a.animate(j,i/2,b.options.easing).animate(k,i/2,b.options.easing,function(){e.effects.restore(a,l);e.effects.removeWrapper(a);b.callback&&b.callback.apply(this,arguments)})}a.queue("fx",function(){a.dequeue()});a.dequeue()})}})(jQuery);
;
/* end jquery.ui.js */
/* start common.js */
/**
 * This is the common JS file which can be used both in admin top, admin view & edit and front-end.
 *
 * 
 */
 
/****************** Validation fucntions ****************/
// those functions can be also used for forms validation.
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
function validate_email(mail)
{
	return(new RegExp(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail.trim()));
}
function validate_url(url)
{
	return(new RegExp(/^(?:\w{3,5}:\/\/)?((\w)+\.)?(\w)+\.(\w)+(?:\/?.*)$/).test(url.trim()));
}
function validate_ip(ip)
{
	var check=function(v){try{return (v<=255 && v>=0)}catch(x){return false}}; 
	var re=ip.trim().split(".") 
	return (re.length==4)?(check(re[0]) && check(re[1]) && check(re[2]) && check(re[3])):false 
}
function validate_bool(v)
{
	return v == '0' || v == '1';
}
function validate_number(num)
{
	return !isNaN(num);//parseInt(num) > 0 && parseInt(num) == num;
}
function validate_custom(val,expr)
{
	return(new RegExp(expr).test(val.trim()));
}
function validate_val(val)
{
	return(new RegExp(/^[a-zA-Z0-9_]+$/).test(val.trim()));
}
function validate_zip(val)
{
	return(new RegExp(/^[0-9\-]+$/).test(val.trim()));
}
function validate_us_zip(val)
{
	return(new RegExp(/^[0-9]{5}(\-[0-9]{4})?$/).test(val.trim()));
}
function validate_ca_post_code(val)
{
	return(new RegExp(/^[A-Z][0-9][A-Z][ \-]?[0-9][A-Z][0-9]$/i).test(val.trim()));
}
function validate_zip_post_code(val)
{
	return validate_us_zip(val) || validate_ca_post_code(val);
}
function validate_phone(val)
{
	return(new RegExp(/^[0-9\-\(\\)]+$/).test(val.trim()));
}
function validate_checked(names)
{
	for(var i = 0; i< names.length; i++)
	{
		if(names[i].checked)
			return true;
	}
	return false;
}
function validate_card(number) {
	try {
		if (number.length == 0 || number.length < 12 || number.length > 19)
			return false;
		var Exp = /[34569]/;
		var objExp = new RegExp(Exp);
		if (objExp.test(number.charAt(0) == false))
			return false;
		var tempNumber = reverse(number); // 反转
		var tempS = 0;
		var tempD = 0;
		for ( var i = 0; i < tempNumber.length; i++) {
			if (i % 2 == 0) {
				tempS = tempS + tempNumber.charAt(i) * 1;
			} else {
				var temp = tempNumber.charAt(i) * 2;
				if (temp > 9) {
					tempD = tempD + (temp / 10 | 0) + temp % 10;
				} else
					tempD = tempD + temp;
			}
		}
		var sum = tempS + tempD;
		if (sum % 10 == 0)
			return true;
		else
			return false;
	} catch (ex) {
		return false;
	}
}
function reverse(source) {
	var s = source;
	var ss = "";
	for (i = s.length - 1; i >= 0; i--) {
		ss = ss + s.charAt(i);
	}
	return ss;
}
/****************** encode and decode email address functions ****************/
function goto_my_email(str,para)
{
	str = get_email_addr(str);
	window.location='mail\u0074o\u003a'+str+(para?para:'');
}
function set_email_addr(str)
{
	var a = [];
	for(var i=0;i<str.length;i++)
		a.push(str.charCodeAt(i));
	return a.join('O');
}
function get_email_addr(str)
{
	var a = str.split('O');
	var s = "";
	for(var i=0;i<a.length;i++)
		s += String.fromCharCode(a[i]);
	return s;
}
/****************** Get or set the URL query string****************/
/**
  * @param object fields: it should be like {key:value}
  * @param string url: optional, the url which will be set
  */
function set_url_query(fields,url)
{
	if(!url)
		url = location.href;

	var pos = url.indexOf('#');
	var _anchor = "";
	if(pos>-1)
	{
		_anchor = url.substring(pos,url.length);
		url = url.substring(0,pos);
	}
	if(fields.constructor == Object)
	{
		for(var key in fields)
		{
			if(!get_url_query(key,url))
			{ 
				if(url.indexOf("?")<1)
					url+="?"+key+"="+fields[key];
				else
				{
					url = url.replace('&'+key+"=",'');
					url+="&"+key+"="+fields[key];
				}
			}
			else
				url=url.replace(key+"="+get_url_query(key,url),key+"="+fields[key]);

		}
	}
	return url+_anchor;
}
/**
  * @param string or array query_keys: it should be like [key1, key2]
  * @param string url: optional, the url which will be set
  */ 
function get_url_query(query_keys,url)
{
	if(!url)
		url=location.href;

	if(query_keys.constructor == Array)
	{
		var param = {};
		for(var i in query_keys)
		{
			param[query_keys[i]] = get_url_query(query_keys[i], url);
		}
	}
	else
	{
		var param = '';
		url=url.substr(url.search(/\?/)+1);
		url=url.split(/&/);
		for(var icount = 0; icount<url.length; icount++)
		{
			if(url[icount].search("^"+query_keys+"=")!=-1)
			{
				param=url[icount].substr(query_keys.length+1)
			}
		}
	}
	return param;
}

function htmlspecialchars(str,ent_compat)
{
	str = str.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
	if(ent_compat)
		str = str.replace(/\"/g,'&quot;').replace(/\'/g,'&#039;');
	return str;
}
function htmlspecialchars_decode(str,ent_compat)
{
	str = str.replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
	if(ent_compat)
		str = str.replace(/&quot;/g,'"').replace(/&#039;/g,'\'');
	return str;
}
/**************************** get or copy the object css styles ************************************/
var g_common_styles_fields = ['color', 'backgroundColor', 'fontWeight', 'fontStyle', 'textAlign'];
// this function need Jquery
function crop_style(to_obj, from_obj, styles)
{
	if(!styles)
		styles = g_common_styles_fields;
	to_obj.css(get_styles(from_obj, styles));
}
// this function need Jquery
function get_styles(from_obj, styles)
{
	if(!from_obj)
		return false;
	if(!styles)
		styles = g_common_styles_fields;
	var style = {};
	for(var i in styles)
	{
		style[styles[i]] = from_obj.css(styles[i]);
	}
	if($.browser.msie)
	{
		if(from_obj[0])
		{
			style['fontSize'] = from_obj[0].currentStyle.fontSize;
			style['fontFamily'] = from_obj[0].currentStyle.fontFamily;
			style['lineHeight'] = from_obj[0].currentStyle.lineHeight ;
			style['fontWeight'] = from_obj[0].currentStyle.fontWeight ;
		}
	}
	else
	{
		style['fontSize'] = from_obj.css('fontSize');
		style['fontFamily'] = from_obj.css('fontFamily');
		style['lineHeight'] = from_obj.css('lineHeight');
		style['fontWeight'] = from_obj.css('fontWeight');
	}
	
	//var get_from_parents = ['backgroundColor','fontFamily','fontSize'];
	var parent_obj = from_obj.parent();
	var n = 0;
	while(parent_obj[0])
	{
		if($.browser.msie && $.browser.version!='8.0')
		{
			if(style['fontFamily']=='inherit')
				style['fontFamily'] = parent_obj.css('fontFamily');
			if(style['fontSize']=='100%')
				style['fontSize'] = parent_obj[0].currentStyle.fontSize;
		}
		if(style['backgroundColor'] == 'transparent' && n < 5 && !parent_obj.is('body'))
			style['backgroundColor'] = parent_obj.css('backgroundColor');
		parent_obj = parent_obj.parent();
		n++ ;
	}
	return style;
}

/* end common.js */
/* start application.js */
var _timer;
var _hoverTimer;

$(function(){

	// SERVICES NAV
	$('aside.services nav a').hover(function(){
		$(this).css({'border-bottom':'1px solid transparent','border-top':'1px solid transparent'});
		$(this).prev().css('border-bottom','1px solid transparent');
		$(this).next().css('border-top','1px solid transparent');
		if($('aside.services nav a:first').hasClass('current')||$(this).index()==0){
			$('aside.services nav').css('border-top','1px solid transparent');
		}
		if($('aside.services nav a:last').hasClass('current')||$(this).index()==($('aside.services nav a').length-1)){
			$('aside.services nav').css('border-bottom','1px solid transparent');
		}
	},function(){
		if(!$(this).hasClass('current')){
			if(!$(this).prev().hasClass('current')){
				$(this).prev().css('border-bottom','1px solid #dfdfdf');
				$(this).css('border-top','1px solid #fff');
			}
			if(!$(this).next().hasClass('current')){
				$(this).next().css('border-top','1px solid #fff');
				$(this).css('border-bottom','1px solid #dfdfdf');
			}
		}
		if($('aside.services nav a:first').hasClass('current')){
			$('aside.services nav').css('border-top','1px solid transparent');
		}else{
			$('aside.services nav').css('border-top','1px solid #dfdfdf');
		}
		if($('aside.services nav a:last').hasClass('current')){
			$('aside.services nav').css('border-bottom','1px solid transparent');
		}else{
			$('aside.services nav').css('border-bottom','1px solid #fff');
		}
	});
	$('aside.services nav a.current').trigger('mouseover');
	
	
	// WORK NAV + GRID ANIMATION
	$('div.work').hover(function(e){
		if(!$(this).hasClass('inactive')){
			var x = $('img',this).attr('src');
			$('p.active','div.work').trigger('mouseleave');
			_hoverTimer = clearTimeout(_hoverTimer);
			_hoverTimer = setTimeout("$('div.work img[src=\""+x+"\"]').next('p').addClass('active').animate({top:0},175)",300);
		}
	},function(e){
		if(!$(this).hasClass('inactive')){
			if($(this).hasClass('large')){
				$('p',this).removeClass('active').clearQueue().animate({top:218},100);
			}else{
				$('p',this).removeClass('active').clearQueue().animate({top:183},100);
			}
		}
	}).bind('click',function(e){
		if(!$(this).hasClass('inactive')){
			document.location = $('p a',this).attr('href');
		}
	});
	
	$('nav.work a').click(function(e){
		e.preventDefault();
		
		$('nav.work a.current').removeClass('current');
		$(this).addClass('current');
		var u = $(this).attr('href');
		u = u.substring(1);
		$.cookie('work_type',u);
		$.cookie('work_name',$(this).text());
		showWork(u);
	});
	
	if($('nav.work').length)
	{
		$.cookie('work_type','');
		$.cookie('work_name','');
		$.cookie('work_num',$('.works div.work').length);
	}
	
	if($('nav.work-sub').length)
	{
		var work_num = $.cookie('work_num');
		if(!work_num) work_num = 15;
		var r = /work\/0?([0-9]+)\/?/;
		r.test(location.href);
		var id = parseInt(RegExp.$1);
		if(id==1)
			$('.pagination .prev').addClass('disabled');
		else if(id==work_num)
			$('.pagination .next').addClass('disabled');
		$('.pagination .prev:not(.disabled)').click(function(e){
			e.preventDefault();
			var new_id = id-1;
			if(new_id < 10)
				new_id = '0' + new_id;
			location.href = 'http://www.emersonmedia.com/work/' + new_id;
		});
		$('.pagination .next:not(.disabled)').click(function(e){
			e.preventDefault();
			var new_id = id+1;
			if(new_id < 10)
				new_id = '0' + new_id;
			location.href = 'http://www.emersonmedia.com/work/' + new_id;
		});
		// set work type
		if($.cookie('work_type'))
		{
			var work_type =  $.cookie('work_type');
			if(work_type && work_type != 'all') 
			{
				var work_name =  $.cookie('work_name');
				$('nav.work-sub .work-type').html('&gt; <a href="http://www.emersonmedia.com/work#'+work_type+'">'+work_name+'</a>');
			}
		}
	}
	
	
	var h = location.hash;
	if(h){
		h = h.replace('#','');
		$('div.work:not(.large)').fadeIn(500,function(){
			$('nav.work a.current').removeClass('current');
			$('nav.work a.'+h).addClass('current');
			showWork(h);
		});
	}else{
		$('div.work').each(function(){
			$(this).fadeIn(Math.max(500,Math.random()*3000));
		});
	}
	
	
	// WORK SUB SCROLL NAV
	$(window).bind('scroll',function(){
		var sTop = $(this).scrollTop();
		if(sTop>140){
			$('aside.work-sub').css({position:'fixed','top':20});
			$('aside.work-sub nav.pagination a').fadeIn(1000);
		}else{
			$('aside.work-sub').css({position:'relative','top':0});
			$('aside.work-sub nav.pagination a').fadeOut(500);
		}
	});
	
	// validate quote form
	$('form#quote').submit(function(){
		var fields_requried = ['name','email','message'];
		var result = true;
		var form = $(this);
		$.each(fields_requried, function(i,n){
			var f = form.find(':input[name='+n+']');
			if(!$.trim(f.val()))
			{
				alert("Please fill out all required fields. We will keep your information confidential.");
				f.focus();
				result = false;
				return false;
			}
		});
		if(!result) return false;
		if(!validate_email(form.find(':input[name=email]').val()))
		{
			alert("Please enter a valid email address.");
			form.find(':input[name=email]').focus();
			return false;
		}
		return true;
	});
	
	// SERVICES GRAYBOX
	$('.graybox nav a').click(function(){
		var c = $(this).attr('class');
		$('.graybox nav').removeClass().addClass(c)
		$('.graybox div:visible:not(.graybox-bottom)').clearQueue().hide();
		$('div.'+c).clearQueue().show();
	});
	$('.graybox strong a').click(function(){
		var href = $(this).attr('href');
		if(href.indexOf('#') < 0) return;
		href = href.substring(href.indexOf('#')+1);
		$('.graybox nav a.'+href).click();
	});

	// SERVICES TABS
	$('nav.tabs a').click(function(){
		var c = $(this).attr('class');
		$('nav.tabs').removeClass().addClass(c).addClass('tabs');
		$('div.tab:visible').clearQueue().hide();
		$('div.tab.'+c).clearQueue().show()
	});
	
	// HOME SLIDER
	$('.home nav.pagination a').click(function(e){
		e.preventDefault();
		var i = $(this).index()+1;
		setSlide(i);
	});
	
	if($('body.home').length)
		loadStats();
	
	_timer = setTimeout('setSlide()',5000);
});


// WORK NAV
function showWork(u){
	if(u=='all'){
		$('div.work').clearQueue().removeClass('inactive').css('visibility','visible').fadeTo(1000,1);
	}else{
		if ( $.browser.msie && parseInt($.browser.version,10)>7) {
			$('div.work:not(.'+u+')').css('visibility','hidden');
		}else{
			$('div.work:not(.'+u+')').clearQueue().addClass('inactive').fadeTo(500,.1);
		}
		$('div.work.'+u).clearQueue().removeClass('inactive').css('visibility','visible').fadeTo(1000,1);
	}
}


// HOME SLIDER
function setSlide(x){
	if(x){
		_timer = clearTimeout(_timer);
		var i = x-1;
	}else{
		var i = $('.slider .slide:visible').index() + 1;
		if(i>=$('.slider .slide').length){
			i = 0;
		}
	}
	if(i!=$('.slider .slide:visible').index()){
		$('.slider .slide:visible').clearQueue().animate({left:-960,opacity:0},400,function(){$(this).hide();}).children('.learnmore').fadeOut(100);
		$('.slider .slide:eq('+i+')').clearQueue().css({left:960,opacity:0.3}).show().animate({left:0,opacity:1},750,function(){
			$('.home nav.pagination a.active').removeClass('active');
			$('.home nav.pagination a:eq('+i+')').addClass('active');
			if(!x){
				_timer = setTimeout('setSlide()',5000);
			}
		}).children('.learnmore').fadeIn(400);
	}
}

// Output email
function doMailto(fname, fullstring){
	var emailE = 'emersonmedia.com';
	emailE = (fname + '@' + emailE);
	if(fullstring == 1)
		document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>');
	else
		document.write('<a href="mailto:' + emailE + '">');
}

// Real-Time Metrics for home page or About us Page
function loadStats()
{
	var stats = $('div.stats');
	$.getJSON('http://wishlist.emersonmedia.com/metrics?callback=?',{hash:'OVaKrIMHPqkCceuYWDDZNxQdx'},function(data){
		stats.find('.stat').show();
		stats.find('.loading').hide();
		
		for(var k in data)
		{
			if(k == 'category_types')
				genChart(data[k]);
			else
				stats.find('.stat.'+ k + ' span').text(data[k]);
		}
	})
}

function genChart(d)
{
	var o_chart = $('div.stats div.chart');
	if(!o_chart.length) 
		return ;
	o_chart.show();
	var data = new google.visualization.DataTable();
	data.addColumn('string', 'Task name');
	data.addColumn('number', 'task numbers');
	var i = 0;
	for(var n in d)
	{
		data.addRows(1);
		data.setValue(i, 0, n);
		data.setValue(i, 1, d[n]);
		i++;
	}
	var chart = new google.visualization.PieChart(o_chart[0]);
	chart.draw(data, {width: 250, height:190, backgroundColor:'#1F1551',
		chartArea:{left:30,top:0,width:177,height:177},
		colors:['blue','red','orange','green','purple'],
		tooltipText: 'percentage',
		legend: 'none'
		//,legendTextStyle:{color: '#C6C4D3', fontSize: 14}
	});
}
/* end application.js */

