/*
 * 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){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}});
/* 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.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
/** 
 * jQuery.jScrollPane
 * Copyright (c) 2009 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * See http://kelvinluck.com/assets/jquery/jScrollPane/
 * $Id: jScrollPane.js 90 2010-01-25 03:52:10Z kelvin.luck $
 */
(function(A){A.jScrollPane={active:[]};A.fn.jScrollPane=function(C){C=A.extend({},A.fn.jScrollPane.defaults,C);var B=function(){return false};return this.each(function(){var O=A(this);O.css("overflow","hidden");var X=this;if(A(this).parent().is(".jScrollPaneContainer")){var Ac=C.maintainPosition?O.position().top:0;var L=A(this).parent();var d=L.innerWidth();var Ad=L.outerHeight();var M=Ad;A(">.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown",L).remove();O.css({top:0})}else{var Ac=0;this.originalPadding=O.css("paddingTop")+" "+O.css("paddingRight")+" "+O.css("paddingBottom")+" "+O.css("paddingLeft");this.originalSidePaddingTotal=(parseInt(O.css("paddingLeft"))||0)+(parseInt(O.css("paddingRight"))||0);var d=O.innerWidth();var Ad=O.innerHeight();var M=Ad;O.wrap(A("<div></div>").attr({className:"jScrollPaneContainer"}).css({height:Ad+"px",width:d+"px"}));A(document).bind("emchange",function(Ae,Af,p){O.jScrollPane(C)})}if(C.reinitialiseOnImageLoad){var N=A.data(X,"jScrollPaneImagesToLoad")||A("img",O);var G=[];if(N.length){N.each(function(p,Ae){A(this).bind("load",function(){if(A.inArray(p,G)==-1){G.push(Ae);N=A.grep(N,function(Ag,Af){return Ag!=Ae});A.data(X,"jScrollPaneImagesToLoad",N);C.reinitialiseOnImageLoad=false;O.jScrollPane(C)}}).each(function(Af,Ag){if(this.complete||this.complete===undefined){this.src=this.src}})})}}var o=this.originalSidePaddingTotal;var l={height:"auto",width:d-C.scrollbarWidth-C.scrollbarMargin-o+"px"};if(C.scrollbarOnLeft){l.paddingLeft=C.scrollbarMargin+C.scrollbarWidth+"px"}else{l.paddingRight=C.scrollbarMargin+"px"}O.css(l);var m=O.outerHeight();var i=Ad/m;if(i<0.99){var H=O.parent();H.append(A("<div></div>").attr({className:"jScrollPaneTrack"}).css({width:C.scrollbarWidth+"px"}).append(A("<div></div>").attr({className:"jScrollPaneDrag"}).css({width:C.scrollbarWidth+"px"}).append(A("<div></div>").attr({className:"jScrollPaneDragTop"}).css({width:C.scrollbarWidth+"px"}),A("<div></div>").attr({className:"jScrollPaneDragBottom"}).css({width:C.scrollbarWidth+"px"}))));var z=A(">.jScrollPaneTrack",H);var P=A(">.jScrollPaneTrack .jScrollPaneDrag",H);if(C.showArrows){var g;var Ab;var S;var r;var j=function(){if(r>4||r%4==0){y(u+Ab*b)}r++};var K=function(p){A("html").unbind("mouseup",K);g.removeClass("jScrollActiveArrowButton");clearInterval(S)};var Z=function(){A("html").bind("mouseup",K);g.addClass("jScrollActiveArrowButton");r=0;j();S=setInterval(j,100)};H.append(A("<a></a>").attr({href:"javascript:;",className:"jScrollArrowUp"}).css({width:C.scrollbarWidth+"px"}).html("Scroll up").bind("mousedown",function(){g=A(this);Ab=-1;Z();this.blur();return false}).bind("click",B),A("<a></a>").attr({href:"javascript:;",className:"jScrollArrowDown"}).css({width:C.scrollbarWidth+"px"}).html("Scroll down").bind("mousedown",function(){g=A(this);Ab=1;Z();this.blur();return false}).bind("click",B));var Q=A(">.jScrollArrowUp",H);var J=A(">.jScrollArrowDown",H);if(C.arrowSize){M=Ad-C.arrowSize-C.arrowSize;z.css({height:M+"px",top:C.arrowSize+"px"})}else{var s=Q.height();C.arrowSize=s;M=Ad-s-J.height();z.css({height:M+"px",top:s+"px"})}}var w=A(this).css({position:"absolute",overflow:"visible"});var D;var Y;var b;var u=0;var V=i*Ad/2;var a=function(Ae,Ag){var Af=Ag=="X"?"Left":"Top";return Ae["page"+Ag]||(Ae["client"+Ag]+(document.documentElement["scroll"+Af]||document.body["scroll"+Af]))||0};var f=function(){return false};var v=function(){n();D=P.offset(false);D.top-=u;Y=M-P[0].offsetHeight;b=2*C.wheelSpeed*Y/m};var E=function(p){v();V=a(p,"Y")-u-D.top;A("html").bind("mouseup",T).bind("mousemove",h);if(A.browser.msie){A("html").bind("dragstart",f).bind("selectstart",f)}return false};var T=function(){A("html").unbind("mouseup",T).unbind("mousemove",h);V=i*Ad/2;if(A.browser.msie){A("html").unbind("dragstart",f).unbind("selectstart",f)}};var y=function(Ae){Ae=Ae<0?0:(Ae>Y?Y:Ae);u=Ae;P.css({top:Ae+"px"});var Af=Ae/Y;w.css({top:((Ad-m)*Af)+"px"});O.trigger("scroll");if(C.showArrows){Q[Ae==0?"addClass":"removeClass"]("disabled");J[Ae==Y?"addClass":"removeClass"]("disabled")}};var h=function(p){y(a(p,"Y")-D.top-V)};var q=Math.max(Math.min(i*(Ad-C.arrowSize*2),C.dragMaxHeight),C.dragMinHeight);P.css({height:q+"px"}).bind("mousedown",E);var k;var R;var I;var t=function(){if(R>8||R%4==0){y((u-((u-I)/2)))}R++};var Aa=function(){clearInterval(k);A("html").unbind("mouseup",Aa).unbind("mousemove",e)};var e=function(p){I=a(p,"Y")-D.top-V};var U=function(p){v();e(p);R=0;A("html").bind("mouseup",Aa).bind("mousemove",e);k=setInterval(t,100);t()};z.bind("mousedown",U);H.bind("mousewheel",function(Ae,Ag){v();n();var Af=u;y(u-Ag*b);var p=Af!=u;return !p});var F;var W;function c(){var p=(F-u)/C.animateStep;if(p>1||p<-1){y(u+p)}else{y(F);n()}}var n=function(){if(W){clearInterval(W);delete F}};var x=function(Af,p){if(typeof Af=="string"){$e=A(Af,O);if(!$e.length){return}Af=$e.offset().top-O.offset().top}H.scrollTop(0);n();var Ae=-Af/(Ad-m)*Y;if(p||!C.animateTo){y(Ae)}else{F=Ae;W=setInterval(c,C.animateInterval)}};O[0].scrollTo=x;O[0].scrollBy=function(Ae){var p=-parseInt(w.css("top"))||0;x(p+Ae)};v();x(-Ac,true);A("*",this).bind("focus",function(Ah){var Ag=A(this);var Aj=0;while(Ag[0]!=O[0]){Aj+=Ag.position().top;Ag=Ag.offsetParent()}var p=-parseInt(w.css("top"))||0;var Ai=p+Ad;var Af=Aj>p&&Aj<Ai;if(!Af){var Ae=Aj-C.scrollbarMargin;if(Aj>p){Ae+=A(this).height()+15+C.scrollbarMargin-Ad}x(Ae)}});if(location.hash){x(location.hash)}A(document).bind("click",function(Ae){$target=A(Ae.target);if($target.is("a")){var p=$target.attr("href");if(p.substr(0,1)=="#"){x(p)}}});A.jScrollPane.active.push(O[0])}else{O.css({height:Ad+"px",width:d-this.originalSidePaddingTotal+"px",padding:this.originalPadding});O.parent().unbind("mousewheel")}})};A.fn.jScrollPane.defaults={scrollbarWidth:10,scrollbarMargin:5,wheelSpeed:18,showArrows:false,arrowSize:0,animateTo:false,dragMinHeight:1,dragMaxHeight:99999,animateInterval:100,animateStep:3,maintainPosition:true,scrollbarOnLeft:false,reinitialiseOnImageLoad:false};A(window).bind("unload",function(){var C=A.jScrollPane.active;for(var B=0;B<C.length;B++){C[B].scrollTo=C[B].scrollBy=null}})})(jQuery);
/*-------------------------------------------------------------------- 
 * jQuery plugin: customInput()
 * by Maggie Wachs and Scott Jehl, http://www.filamentgroup.com
 * Copyright (c) 2009 Filament Group
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 * Article: http://www.filamentgroup.com/lab/accessible_custom_designed_checkbox_radio_button_inputs_styled_css_jquery/  
 * Usage example below (see comment "Run the script...").
--------------------------------------------------------------------*/
jQuery.fn.customInput=function(){$(this).each(function(i){if($(this).is('[type=checkbox],[type=radio]')){var input=$(this);var label=$('label[for='+input.attr('id')+']');var inputType=(input.is('[type=checkbox]'))?'checkbox':'radio';input.parent().addClass('ui-custom-'+inputType);var allInputs=$('input[name='+input.attr('name')+']');label.hover(function(){$(this).addClass('ui-state-hover');if(inputType=='checkbox'&&input.is(':checked')){$(this).addClass('ui-state-checked-hover')}},function(){$(this).removeClass('ui-state-hover ui-state-checked-hover')});input.bind('updateState',function(){if(input.is(':checked')){if(input.is(':radio')){allInputs.each(function(){$('label[for='+$(this).attr('id')+']').removeClass('ui-state-checked')})};label.addClass('ui-state-checked')}else{label.removeClass('ui-state-checked ui-state-checked-hover ui-state-checked-focus')}}).trigger('updateState').click(function(){$(this).trigger('updateState')}).focus(function(){label.addClass('ui-state-focus');if(inputType=='checkbox'&&input.is(':checked')){$(this).addClass('ui-state-checked-focus')}}).blur(function(){label.removeClass('ui-state-focus ui-state-checked-focus')})}})};
/*
 * jQuery UI selectmenu
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
 /*
 * jQuery UI selectmenu
 *
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
(function($){$.widget("ui.selectmenu",{_init:function(){var self=this,o=this.options;this.ids=[this.element.attr('id')+'-'+'button',this.element.attr('id')+'-'+'menu'];this._safemouseup=true;this.newelement=$('<a class="'+this.widgetBaseClass+' ui-widget ui-state-default ui-corner-all" id="'+this.ids[0]+'" role="button" href="#" aria-haspopup="true" aria-owns="'+this.ids[1]+'"></a>').insertAfter(this.element);var tabindex=this.element.attr('tabindex');if(tabindex){this.newelement.attr('tabindex',tabindex)}this.newelement.data('selectelement',this.element);this.selectmenuIcon=$('<span class="'+this.widgetBaseClass+'-icon ui-icon"></span>').prependTo(this.newelement).addClass((o.style=="popup")?'ui-icon-triangle-2-n-s':'ui-icon-triangle-1-s');$('label[for='+this.element.attr('id')+']').attr('for',this.ids[0]).bind('click',function(){self.newelement[0].focus();return false});this.newelement.bind('mousedown',function(event){self._toggle(event);if(o.style=="popup"){self._safemouseup=false;setTimeout(function(){self._safemouseup=true},300)}return false}).bind('click',function(){return false}).keydown(function(event){var ret=true;switch(event.keyCode){case $.ui.keyCode.ENTER:ret=true;break;case $.ui.keyCode.SPACE:ret=false;self._toggle(event);break;case $.ui.keyCode.UP:case $.ui.keyCode.LEFT:ret=false;self._moveSelection(-1);break;case $.ui.keyCode.DOWN:case $.ui.keyCode.RIGHT:ret=false;self._moveSelection(1);break;case $.ui.keyCode.TAB:ret=true;break;default:ret=false;self._typeAhead(event.keyCode,'mouseup');break}return ret}).bind('mouseover focus',function(){$(this).addClass(self.widgetBaseClass+'-focus ui-state-hover')}).bind('mouseout blur',function(){$(this).removeClass(self.widgetBaseClass+'-focus ui-state-hover')});$(document).mousedown(function(event){self.close(event)});this.element.click(function(){this._refreshValue()}).focus(function(){this.newelement[0].focus()});var cornerClass=(o.style=="dropdown")?" ui-corner-bottom":" ui-corner-all";this.list=$('<ul class="'+self.widgetBaseClass+'-menu ui-widget ui-widget-content'+cornerClass+'" aria-hidden="true" role="listbox" aria-labelledby="'+this.ids[0]+'" id="'+this.ids[1]+'"></ul>').appendTo('body');var selectOptionData=[];this.element.find('option').each(function(){selectOptionData.push({value:$(this).attr('value'),text:self._formatText(jQuery(this).text()),selected:$(this).attr('selected'),classes:$(this).attr('class'),parentOptGroup:$(this).parent('optgroup').attr('label')})});var activeClass=(self.options.style=="popup")?" ui-state-active":"";for(var i in selectOptionData){var thisLi=$('<li role="presentation"><a href="#" tabindex="-1" role="option" aria-selected="false">'+selectOptionData[i].text+'</a></li>').data('index',i).addClass('ui-selectmenu-byorder'+i).addClass(selectOptionData[i].classes).data('optionClasses',selectOptionData[i].classes||'').mouseup(function(event){if(self._safemouseup){var changed=$(this).data('index')!=self._selectedIndex();self.value($(this).data('index'));self.select(event);if(changed){self.change(event)}self.close(event,true)}return false}).click(function(){return false}).bind('mouseover focus',function(){self._selectedOptionLi().addClass(activeClass);self._focusedOptionLi().removeClass(self.widgetBaseClass+'-item-focus ui-state-hover');$(this).removeClass('ui-state-active').addClass(self.widgetBaseClass+'-item-focus ui-state-hover')}).bind('mouseout blur',function(){if($(this).is(self._selectedOptionLi())){$(this).addClass(activeClass)}$(this).removeClass(self.widgetBaseClass+'-item-focus ui-state-hover')});if(selectOptionData[i].parentOptGroup){var optGroupName=self.widgetBaseClass+'-group-'+selectOptionData[i].parentOptGroup;if(this.list.find('li.'+optGroupName).size()){this.list.find('li.'+optGroupName+':last ul').append(thisLi)}else{$('<li role="presentation" class="'+self.widgetBaseClass+'-group '+optGroupName+'"><span class="'+self.widgetBaseClass+'-group-label">'+selectOptionData[i].parentOptGroup+'</span><ul></ul></li>').appendTo(this.list).find('ul').append(thisLi)}}else{thisLi.appendTo(this.list)}this.list.bind('mousedown mouseup',function(){return false});if(o.icons){for(var j in o.icons){if(thisLi.is(o.icons[j].find)){thisLi.data('optionClasses',selectOptionData[i].classes+' '+self.widgetBaseClass+'-hasIcon').addClass(self.widgetBaseClass+'-hasIcon');var iconClass=o.icons[j].icon||"";thisLi.find('a:eq(0)').prepend('<span class="'+self.widgetBaseClass+'-item-icon ui-icon '+iconClass+'"></span>')}}}}this.list.find('li:last').addClass("ui-corner-bottom");if(o.style=='popup'){this.list.find('li:first').addClass("ui-corner-top")}if(o.transferClasses){var transferClasses=this.element.attr('class')||'';this.newelement.add(this.list).addClass(transferClasses)}var selectWidth=this.element.width();this.newelement.width((o.width)?o.width:selectWidth);if(o.style=='dropdown'){this.list.width((o.menuWidth)?o.menuWidth:((o.width)?o.width:selectWidth))}else{this.list.width((o.menuWidth)?o.menuWidth:((o.width)?o.width-o.handleWidth:selectWidth-o.handleWidth))}if(o.maxHeight&&o.maxHeight<this.list.height()){this.list.height(o.maxHeight)}this._optionLis=this.list.find('li:not(.'+self.widgetBaseClass+'-group)');this.list.keydown(function(event){var ret=true;switch(event.keyCode){case $.ui.keyCode.UP:case $.ui.keyCode.LEFT:ret=false;self._moveFocus(-1);break;case $.ui.keyCode.DOWN:case $.ui.keyCode.RIGHT:ret=false;self._moveFocus(1);break;case $.ui.keyCode.HOME:ret=false;self._moveFocus(':first');break;case $.ui.keyCode.PAGE_UP:ret=false;self._scrollPage('up');break;case $.ui.keyCode.PAGE_DOWN:ret=false;self._scrollPage('down');break;case $.ui.keyCode.END:ret=false;self._moveFocus(':last');break;case $.ui.keyCode.ENTER:case $.ui.keyCode.SPACE:ret=false;self.close(event,true);$(event.target).parents('li:eq(0)').trigger('mouseup');break;case $.ui.keyCode.TAB:ret=true;self.close(event,true);break;case $.ui.keyCode.ESCAPE:ret=false;self.close(event,true);break;default:ret=false;self._typeAhead(event.keyCode,'focus');break}return ret});if(o.style=='dropdown'){this.newelement.addClass(self.widgetBaseClass+"-dropdown");this.list.addClass(self.widgetBaseClass+"-menu-dropdown")}else{this.newelement.addClass(self.widgetBaseClass+"-popup");this.list.addClass(self.widgetBaseClass+"-menu-popup")}this.newelement.prepend('<span class="'+self.widgetBaseClass+'-status">'+selectOptionData[this._selectedIndex()].text+'</span>');this.element.hide();if(this.element.attr('disabled')==true){this.disable()}this.value(this._selectedIndex())},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+'-disabled'+' '+this.namespace+'-state-disabled').removeAttr('aria-disabled');$('label[for='+this.newelement.attr('id')+']').attr('for',this.element.attr('id')).unbind('click');this.newelement.remove();this.list.remove();this.element.show()},_typeAhead:function(code,eventType){var self=this;if(!self._prevChar){self._prevChar=['',0]}var C=String.fromCharCode(code);c=C.toLowerCase();var focusFound=false;function focusOpt(elem,ind){focusFound=true;$(elem).trigger(eventType);self._prevChar[1]=ind};this.list.find('li a').each(function(i){if(!focusFound){var thisText=$(this).text();if(thisText.indexOf(C)==0||thisText.indexOf(c)==0){if(self._prevChar[0]==C){if(self._prevChar[1]<i){focusOpt(this,i)}}else{focusOpt(this,i)}}}});this._prevChar[0]=C},_uiHash:function(){return{value:this.value()}},open:function(event){var self=this;var disabledStatus=this.newelement.attr("aria-disabled");if(disabledStatus!='true'){this._refreshPosition();this._closeOthers(event);this.newelement.addClass('ui-state-active');this.list.appendTo('body').addClass(self.widgetBaseClass+'-open').attr('aria-hidden',false).find('li:not(.'+self.widgetBaseClass+'-group):eq('+this._selectedIndex()+') a')[0].focus();if(this.options.style=="dropdown"){this.newelement.removeClass('ui-corner-all').addClass('ui-corner-top')}this._refreshPosition();this._trigger("open",event,this._uiHash())}},close:function(event,retainFocus){if(this.newelement.is('.ui-state-active')){this.newelement.removeClass('ui-state-active');this.list.attr('aria-hidden',true).removeClass(this.widgetBaseClass+'-open');if(this.options.style=="dropdown"){this.newelement.removeClass('ui-corner-top').addClass('ui-corner-all')}if(retainFocus){this.newelement[0].focus()}this._trigger("close",event,this._uiHash())}},change:function(event){this.element.trigger('change');this._trigger("change",event,this._uiHash())},select:function(event){this._trigger("select",event,this._uiHash())},_closeOthers:function(event){$('.'+this.widgetBaseClass+'.ui-state-active').not(this.newelement).each(function(){$(this).data('selectelement').selectmenu('close',event)});$('.'+this.widgetBaseClass+'.ui-state-hover').trigger('mouseout')},_toggle:function(event,retainFocus){if(this.list.is('.'+this.widgetBaseClass+'-open')){this.close(event,retainFocus)}else{this.open(event)}},_formatText:function(text){return this.options.format?this.options.format(text):text},_selectedIndex:function(){return this.element[0].selectedIndex},_selectedOptionLi:function(){return this._optionLis.eq(this._selectedIndex())},_focusedOptionLi:function(){return this.list.find('.'+this.widgetBaseClass+'-item-focus')},_moveSelection:function(amt){var currIndex=parseInt(this._selectedOptionLi().data('index'),10);var newIndex=currIndex+amt;return this._optionLis.eq(newIndex).trigger('mouseup')},_moveFocus:function(amt){if(!isNaN(amt)){var currIndex=parseInt(this._focusedOptionLi().data('index'),10);var newIndex=currIndex+amt}else{var newIndex=parseInt(this._optionLis.filter(amt).data('index'),10)}if(newIndex<0){newIndex=0}if(newIndex>this._optionLis.size()-1){newIndex=this._optionLis.size()-1}var activeID=this.widgetBaseClass+'-item-'+Math.round(Math.random()*1000);this._focusedOptionLi().find('a:eq(0)').attr('id','');this._optionLis.eq(newIndex).find('a:eq(0)').attr('id',activeID)[0].focus();this.list.attr('aria-activedescendant',activeID)},_scrollPage:function(direction){var numPerPage=Math.floor(this.list.outerHeight()/this.list.find('li:first').outerHeight());numPerPage=(direction=='up')?-numPerPage:numPerPage;this._moveFocus(numPerPage)},_setData:function(key,value){this.options[key]=value;if(key=='disabled'){this.close();this.element.add(this.newelement).add(this.list)[value?'addClass':'removeClass'](this.widgetBaseClass+'-disabled'+' '+this.namespace+'-state-disabled').attr("aria-disabled",value)}},value:function(newValue){if(arguments.length){this.element[0].selectedIndex=newValue;this._refreshValue();this._refreshPosition()}return this.element[0].selectedIndex},_refreshValue:function(){var activeClass=(this.options.style=="popup")?" ui-state-active":"";var activeID=this.widgetBaseClass+'-item-'+Math.round(Math.random()*1000);this.list.find('.'+this.widgetBaseClass+'-item-selected').removeClass(this.widgetBaseClass+"-item-selected"+activeClass).find('a').attr('aria-selected','false').attr('id','');this._selectedOptionLi().addClass(this.widgetBaseClass+"-item-selected"+activeClass).find('a').attr('aria-selected','true').attr('id',activeID);var currentOptionClasses=this.newelement.data('optionClasses')?this.newelement.data('optionClasses'):"";var newOptionClasses=this._selectedOptionLi().data('optionClasses')?this._selectedOptionLi().data('optionClasses'):"";this.newelement.removeClass(currentOptionClasses).data('optionClasses',newOptionClasses).addClass(newOptionClasses).find('.'+this.widgetBaseClass+'-status').html(this._selectedOptionLi().find('a:eq(0)').html());this.list.attr('aria-activedescendant',activeID)},_refreshPosition:function(){this.list.css('left',this.newelement.offset().left);var menuTop=this.newelement.offset().top;var scrolledAmt=this.list[0].scrollTop;this.list.find('li:lt('+this._selectedIndex()+')').each(function(){scrolledAmt-=$(this).outerHeight()});if(this.newelement.is('.'+this.widgetBaseClass+'-popup')){menuTop+=scrolledAmt;this.list.css('top',menuTop)}else{menuTop+=this.newelement.height();this.list.css('top',menuTop)}}});$.extend($.ui.selectmenu,{getter:"value",version:"@VERSION",eventPrefix:"selectmenu",defaults:{transferClasses:true,style:'popup',width:null,menuWidth:null,handleWidth:26,maxHeight:null,icons:null,format:null}})})(jQuery);

window.thirdFocus = function($) {

	if ( $.validator ) {
		$.extend($.validator.messages, {
			required: "*必須項目です。",
			remote: "*必須項目です。",
			email: "*必須項目です。",
			url: "*必須項目です。",
			date: "*必須項目です。",
			dateISO: "*必須項目です。",
			number: "*必須項目です。",
			digits: "*必須項目です。",
			creditcard: "*必須項目です。",
			equalTo: "*必須項目です。",
			accept: "*必須項目です。",
			nippon: "*必須項目です。",
			maxlength: $.validator.format("*必須項目です。"),
			minlength: $.validator.format("*必須項目です。"),
			rangelength: $.validator.format("*必須項目です。"),
			range: $.validator.format("*必須項目です。"),
			max: $.validator.format("*必須項目です。"),
			min: $.validator.format("*必須項目です。")
		});
		$.validator.addMethod( 'nippon', function(value, element) {
			return this.optional( element )
				|| /^([ァ-ヶーぁ-ん]+)$/.test( value )
				|| /^([ぁ-ん]+)$/.test( value )
				|| /^([ァ-ヶー]+)$/.test( value )
				|| /^([ｧ-ﾝﾞﾟ]+)$/.test( value )
				|| /^([a-zA-z\s]+)$/.test( value )
				|| ( ( value.length >= 1 ) && ( value.length < 256 ) )
		}, '*必須項目です。' );
	}

	var $sticker = $('#sticker');
	if ( $sticker.size() > 0 ) {
		var $lis = $sticker.find('li'),
			$currStick = -1;
		var runStick = function() {
			$currStick++;
			if ( !$lis[ $currStick ] ) {
				$currStick = 0;
			}
			$nextStick = $( $lis[ $currStick ] );
			var callBack = function() {
				var disappear = function() {
					$( $lis[ $currStick ] ).animate(
						{
							opacity: 0
						},
						500,
						runStick
					);
				};
				setTimeout( disappear, 6000 );
			};
			$nextStick.css({
				oapcity: 0,
				left: '720px'
			}).animate(
				{
					opacity: 1,
					left: '0'
				},
				1000,
				'easeOutQuad',
				callBack
			);
		};
		runStick();
	}

	var currURL = document.location.href;
	if ( currURL.indexOf('success') != -1 ) {
		var splitedURL = currURL.split("\?");
		if ( splitedURL.length > 1 ) {
			var params = splitedURL[1].split('\&');
			if ( params.length > 1 ) {
				var buyed = {};
				for ( var i=0; i<params.length; i++ ) {
					var currKeyVal = params[i].split('=');
					if ( currKeyVal.length == 2 ) {
						buyed[ currKeyVal[ 0 ] ] = currKeyVal[ 1 ];
					}
				}
				if ( !isNaN( parseInt( buyed.item_number || false, 10 )) && ( ( buyed.tx || '').length > 1 ) ) {
				    var products = ['',
				        'MTPlu::s for Intra',
				        'MTPlu::s for Web',
				        'MTPlu::s for Basic',
				        'TinyMCE4MT',
				        'FutureUnpublish',
				        'AttachFile',
				        'EntryCopy',
				        'PopMail',
				        'SendMail',
				        'TagList',
				        'PostTweet'
				    ];
				    var productBought = products[ parseInt( buyed.item_number, 10 ) ] || false;
				    if ( productBought ) {
				        $('div.wysiwyg p:eq(0)').after( '<p>ご購入製品：' +  productBought + '<br />Transaction ID：' + buyed.tx + '</p>' );
				    }
				}
			}
		}
	}

	var $navItems = $( '#header > div.header-nav' );
	if ( $navItems.size() > 0 ) {
		var $currNav = $( $navItems[ 0 ] ),
			$currSlice = $( '#header > div.header-slice:eq(0)' );
		var isIE = /MSIE/.test( ( navigator.userAgent || '' ).toUpperCase() ),
			fxStart = {
				zIndex: 11
			},
			fxEnd =  {
				height: 'toggle'
			};
		if ( !isIE ) {
			fxStart.opacity = 0;
			fxEnd.opacity = 1;
		}
		$navItems.hover(
			function() {
				var $sel = $( this );
				if ( $sel.attr( 'id' ) != $currNav.attr( 'id' ) ) {
					$currNav.removeClass( 'ui-state-active' );
					$currNav = $sel.addClass( 'ui-state-active' );
					var $prevSlide = $currSlice.stop().attr( 'style', '' ).hide();
					$currSlice = $( '#' + $sel.attr( 'target' ) ).css( fxStart ).animate( fxEnd, function() {
						$prevSlide.hide();
					});
				}
			},
			function() {
			}
		).click(
			function() {
				document.location.href = $( this ).find( 'a:eq(0)' ).attr( 'href' );
			}
		);
	}

	var $tabs = $( '#every-plugin' );
	if ( $tabs.size() > 0 ) {
		$tabs.tabs({
			select: 0
		});
	}

	var pageIsNews = /^news/.test( $( 'body' ).attr( 'id' ) );
	if  ( pageIsNews ) {
		var $more = $( '#load-more a' );
		if ( $more.size() > 0 ) {
			var jsonData = false,
				jsonSize = 0,
				curr = -1,
				updateNews = function() {
					curr++;
					var html = [ '<div class="dyn-content">' ];
					for ( var i=curr; i<curr+5; i++ ) {
						var entry = jsonData[ i ] || false;
						if ( entry ) {
							html.push( entry );
						}
					}
					html.push( '</div>' );
					var $newEntries = $( html.join( '' ) ).hide();
					$more.parent().before( $newEntries );
					$newEntries.fadeIn(function() {
						var $share = [];
						$( this ).find( 'a.addthis_button' ).each(function( i, link ){
							$share[ i ] = link;
						})
						addthis.button( $share );
						if ( ( curr + 5) >= jsonSize ) {
							$more.parent().fadeOut(function(){
								$( this ).remove();
							});
						}
					});
				};
			$more.bind( 'click', function( e ) {
				if ( !jsonData ) {
					var newsCallBack = function( data ) {
						try {
							jsonData = eval( data );
							jsonSize = jsonData.length
						} catch( err ) {
							jsonData = false;
							jsonSize = 0;
							$more.parent().remove();
						}
						updateNews();
					};
					$.ajax({
						url: './news-entries.json',
						success: newsCallBack
					});
				}
				else {
					updateNews();
				}
				e.preventDefault();
			});
		}
	}

	var pageHasForm = ( /^contact/.test( $( 'body' ).attr( 'id' ) ) ) || ( /^downloads/.test( $( 'body' ).attr( 'id' ) ) );
	if ( pageHasForm ) {
		var $inputs = $( '#article input, #article textarea' );
		$inputs.hover(
			function() {
				$(this).parent().parent().addClass( 'ui-state-hover' );
			},
			function() {
				$(this).parent().parent().removeClass( 'ui-state-hover' );
			}
		).focus(function() {
			$(this).parent().parent().addClass( 'ui-state-active' );
		}).blur(function() {
			$(this).parent().parent().removeClass( 'ui-state-active' );
		});
		var $mailSubject = $('#mail_subject');
		if ( ( $mailSubject.size() > 0 ) && ( $mailSubject[0].tagName.toUpperCase() == 'SELECT' ) ) {
			$mailSubject.selectmenu({ style:'dropdown' });
		}
		var $mailKind = $('#mail_kind');
		if ( ( $mailKind.size() > 0 ) && ( $mailKind[0].tagName.toUpperCase() == 'SELECT' ) ) {
			$mailKind.selectmenu({ style:'dropdown' });
		}

		$('#contact-default #mail_form').validate({
			errorElement: 'em',
			errorClass: 'ui-state-error',
			validClass: 'ui-state-valid',
			highlight: function( element, errorClass, validClass ) {
				$( element ).parent().parent().addClass( errorClass ).removeClass( validClass );
			},
			unhighlight: function( element, errorClass, validClass ) {
				$( element ).parent().parent().removeClass( errorClass ).addClass( validClass );
			},
			errorPlacement: function( error, element ) {
				error.appendTo( element.parent().parent() );
			},
			rules: {
				mail_author: {
					nippon: true,
					required: true,
					minlength: 1
				},
				mail_subject: {
					nippon: true,
					required: true,
					minlength: 1
				},
				mail_company: {
					nippon: true,
					required: false,
					minlength: 1
				},
				mail_email: {
					required: true,
					email: true,
					minlength: 1
				},
				mail_email_confirm: {
					required: true,
					equalTo: "#mail_email",
					minlength: 1
				},
				mail_text: {
					nippon: true,
					required: true,
					minlength: 1
				}
			}
		});
		
		$('#contact-social #mail_form').validate({
			errorElement: 'em',
			errorClass: 'ui-state-error',
			validClass: 'ui-state-valid',
			highlight: function( element, errorClass, validClass ) {console.log('te')
				$( element ).parent().parent().addClass( errorClass ).removeClass( validClass );
			},
			unhighlight: function( element, errorClass, validClass ) {
				$( element ).parent().parent().removeClass( errorClass ).addClass( validClass );
			},
			errorPlacement: function( error, element ) {
				error.appendTo( element.parent().parent() );
			},
			rules: {
				mail_serial: {
					nippon: true,
					required: true,
					minlength: 1
				},
				mail_author: {
					nippon: true,
					required: true,
					minlength: 1
				},
				mail_subject: {
					nippon: true,
					required: true,
					minlength: 1
				},
				mail_kind: {
					nippon: true,
					required: true,
					minlength: 1
				},
				mail_version: {
					nippon: true,
					required: true,
					minlength: 1
				},
				mail_company: {
					nippon: true,
					required: false,
					minlength: 1
				},
				mail_email: {
					required: true,
					email: true,
					minlength: 1
				},
				mail_email_confirm: {
					required: true,
					equalTo: "#mail_email",
					minlength: 1
				},
				mail_text: {
					nippon: true,
					required: true,
					minlength: 1
				}
			}
		});
		
		$('#contact-testdrive #mail_form').validate({
			errorElement: 'em',
			errorClass: 'ui-state-error',
			validClass: 'ui-state-valid',
			highlight: function( element, errorClass, validClass ) {
				$( element ).parent().parent().addClass( errorClass ).removeClass( validClass );
			},
			unhighlight: function( element, errorClass, validClass ) {
				$( element ).parent().parent().removeClass( errorClass ).addClass( validClass );
			},
			errorPlacement: function( error, element ) {
				error.appendTo( element.parent().parent() );
			},
			rules: {
				mail_email: {
					required: true,
					email: true,
					minlength: 1
				},
				mail_email_confirm: {
					required: true,
					equalTo: "#mail_email",
					minlength: 1
				}
			}
		});
		$('#downloads form').validate({
			errorElement: 'em',
			errorClass: 'ui-state-error',
			validClass: 'ui-state-valid',
			highlight: function( element, errorClass, validClass ) {
				$( element ).parent().parent().addClass( errorClass ).removeClass( validClass );
			},
			unhighlight: function( element, errorClass, validClass ) {
				$( element ).parent().parent().removeClass( errorClass ).addClass( validClass );
			},
			errorPlacement: function( error, element ) {
				error.appendTo( element.parent().parent() );
			},
			rules: {
				username: {
					required: true,
					minlength: 1
				},
				password: {
					required: true,
					minlength: 1
				}
			},
			messages: {
				username: 'ユーザー名を入力します',
				password: 'パスワードを入力します'
			}
		});
	}
	
	var $payButtons = $('div.button-buy');
	if ( $payButtons.size() > 0 ) {
		$payButtons.each(function(i,form) {
			var $fm = $(this).children(0);
			$fm.attr({
				'name': 'paypal' + i,
				'id': 'paypal' + i
			});
			var $link = $( '<a href="#buy' + i + '">いますぐ購入する</a>' ).bind('click', function() {
				$(this).parent().submit();
				return false;
			});
			$fm.prepend( $link );
		});
	}
	
	var $bills = $('body#bills');
	if ( $bills.size() > 0 ) {
		var $links = $('#user-downloads'),
			$userAgreement = $('#user-agreement');
		if ( ( $userAgreement.size() > 0 ) && ( $links.size() > 0 ) ) {
		var bindAgreement = function() {
			$links[ $(this)[0].checked ? 'fadeIn' : 'fadeOut' ]();
		};
		$userAgreement.click( bindAgreement );
			if ( $userAgreement[0].checked ) {
				bindAgreement.call( $userAgreement );
			}
		}
		var $supportRules = $("#support-rules");
		if ( $supportRules.size() > 0 ) {
			$supportRules.dialog({
				width: 640,
				height: 480,
				autoOpen: false,
				modal: true
			});
			$('a[href="#support-rules"]').click(function($event){
				$event.preventDefault();
				$supportRules.dialog('open');
			});
		}
		var $supportAgreement = $('#support-rules-agreeded'),
			$comments = $('#comments'),
			$commentForm = $('#comments-form'),
			$inputs = $commentForm.find( 'input, textarea' ),
			$commentValidator;
		var bindForm = function() {
			if ( $(this)[0].checked ) {
				var fxCallBack = function() {
					$inputs.hover(
						function() {
							$(this).parent().parent().addClass( 'ui-state-hover' );
						},
						function() {
							$(this).parent().parent().removeClass( 'ui-state-hover' );
						}
					).focus(function() {
						$(this).parent().parent().addClass( 'ui-state-active' );
						mtCommentFormOnFocus();
					}).blur(function() {
						$(this).parent().parent().removeClass( 'ui-state-active' );
					});
					$('#comment-reply').click( mtSetCommentParentID );
					$('#comment-bake-cookie').click( mtRememberMeOnClick );
					$('#comment-preview' ).click(function() {
						$( 'input[name="preview"]' ).val( '1' );
					});
					var rules = {
							text: {
								nippon: true,
								required: true,
								maxlength: 5000
							}
						}, submitHandler = function( form ) {
							var mtStuff = mtCommentOnSubmit( form );
							if ( !mtStuff ) {
								return false;
							}
							else {
								form.submit();
							}
						};
					if ( $('#comments-open-data')[0].style.display == 'none' ) { } else {
						rules.author = {
							nippon: true,
							required: true,
							minlength: 1,
							maxlength: 256
						};
						rules.email = {
							required: true,
							email: true
						};
					}
					$commentValidator = $commentForm.validate({
						errorElement: 'em',
						errorClass: 'ui-state-error',
						validClass: 'ui-state-valid',
						highlight: function( element, errorClass, validClass ) {
							$( element ).parent().parent().addClass( errorClass ).removeClass( validClass );
						},
						unhighlight: function( element, errorClass, validClass ) {
							$( element ).parent().parent().removeClass( errorClass ).addClass( validClass );
						},
						errorPlacement: function( error, element ) {
							error.appendTo( element.parent().parent() );
						},
						rules: rules,
						submitHandler: submitHandler
					});
				};
				$comments.fadeIn( fxCallBack );
			}
			else {
				$commentValidator.resetForm();
				$inputs.unbind();
				$comments.fadeOut();
			}
		};
		if ( ( $supportAgreement.size() > 0 ) && ( $commentForm.size() > 0 ) ) {
			$supportAgreement.click( bindForm );
			if ( $supportAgreement[0].checked ) {
				bindForm.call( $supportAgreement );
			}
		}
		$('#user-seller-agreement div.wysiwyg').jScrollPane({
			showArrows: false
		});
		$('input').customInput();
	}

};
$( window ).ready( function() { jQuery( 'body' ).addClass( 'jquery-support' ); } );
$( window ).load( function() { thirdFocus( jQuery ); } );

