// jQuery.ScrollTo
(function(d){function h(b){return"object"==typeof b?b:{top:b,left:b}}var l=d.scrollTo=function(b,c,a){d(window).scrollTo(b,c,a)};l.defaults={axis:"xy",duration:1.3<=parseFloat(d.fn.jquery)?0:1,limit:!0};l.window=function(){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){if(this.nodeName&&-1==d.inArray(this.nodeName.toLowerCase(),["iframe","#document","html","body"]))return this;var b=(this.contentWindow||this).document||this.ownerDocument||this;return/webkit/i.test(navigator.userAgent)||
"BackCompat"==b.compatMode?b.body:b.documentElement})};d.fn.scrollTo=function(b,c,a){"object"==typeof c&&(a=c,c=0);"function"==typeof a&&(a={onAfter:a});"max"==b&&(b=9E9);a=d.extend({},l.defaults,a);c=c||a.duration;a.queue=a.queue&&1<a.axis.length;a.queue&&(c/=2);a.offset=h(a.offset);a.over=h(a.over);return this._scrollable().each(function(){function n(e){i.animate(f,c,a.easing,e&&function(){e.call(this,b,a)})}if(b){var j=this,i=d(j),e=b,m,f={},p=i.is("html,body");switch(typeof e){case "number":case "string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(e)){e=
h(e);break}e=d(e,this);if(!e.length)return;case "object":if(e.is||e.style)m=(e=d(e)).offset()}d.each(a.axis.split(""),function(b,d){var c=d=="x"?"Left":"Top",k=c.toLowerCase(),g="scroll"+c,h=j[g],o=l.max(j,d);if(m){f[g]=m[k]+(p?0:h-i.offset()[k]);if(a.margin){f[g]=f[g]-(parseInt(e.css("margin"+c))||0);f[g]=f[g]-(parseInt(e.css("border"+c+"Width"))||0)}f[g]=f[g]+(a.offset[k]||0);a.over[k]&&(f[g]=f[g]+e[d=="x"?"width":"height"]()*a.over[k])}else{c=e[k];f[g]=c.slice&&c.slice(-1)=="%"?parseFloat(c)/100*
o:c}a.limit&&/^\d+$/.test(f[g])&&(f[g]=f[g]<=0?0:Math.min(f[g],o));if(!b&&a.queue){h!=f[g]&&n(a.onAfterFirst);delete f[g]}});n(a.onAfter)}}).end()};l.max=function(b,c){var a="x"==c?"Width":"Height",h="scroll"+a;if(!d(b).is("html,body"))return b[h]-d(b)[a.toLowerCase()]();var a="client"+a,j=b.ownerDocument.documentElement,i=b.ownerDocument.body;return Math.max(j[h],i[h])-Math.min(j[a],i[a])}})(jQuery);

// fancyBox 2.1.3
(function(B,x,f,q){var r=f(B),m=f(x),b=f.fancybox=function(){b.open.apply(this,arguments)},u=null,n=x.createTouch!==q,s=function(a){return a&&a.hasOwnProperty&&a instanceof f},p=function(a){return a&&"string"===f.type(a)},E=function(a){return p(a)&&0<a.indexOf("%")},k=function(a,d){var e=parseInt(a,10)||0;d&&E(a)&&(e*=b.getViewport()[d]/100);return Math.ceil(e)},v=function(a,b){return k(a,b)+"px"};f.extend(b,{version:"2.1.3",defaults:{padding:15,margin:20,width:800,height:600,minWidth:100,minHeight:100,
maxWidth:9999,maxHeight:9999,autoSize:!0,autoHeight:!1,autoWidth:!1,autoResize:!0,autoCenter:!n,fitToView:!0,aspectRatio:!1,topRatio:0.5,leftRatio:0.5,scrolling:"auto",wrapCSS:"",arrows:!0,closeBtn:!0,closeClick:!1,nextClick:!1,mouseWheel:!0,autoPlay:!1,playSpeed:3E3,preload:3,modal:!1,loop:!0,ajax:{dataType:"html",headers:{"X-fancyBox":!0}},iframe:{scrolling:"auto",preload:!0},swf:{wmode:"transparent",allowfullscreen:"true",allowscriptaccess:"always"},keys:{next:{13:"left",34:"up",39:"left",40:"up"},
prev:{8:"right",33:"down",37:"right",38:"down"},close:[27],play:[32],toggle:[70]},direction:{next:"left",prev:"right"},scrollOutside:!0,index:0,type:null,href:null,content:null,title:null,tpl:{wrap:'<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',image:'<img class="fancybox-image" src="{href}" alt="" />',iframe:'<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen'+
(f.browser.msie?' allowtransparency="true"':"")+"></iframe>",error:'<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',closeBtn:'<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',next:'<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',prev:'<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'},openEffect:"fade",openSpeed:250,openEasing:"swing",
openOpacity:!0,openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:!0,title:!0},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop},group:{},opts:{},previous:null,coming:null,current:null,
isActive:!1,isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,d){if(a&&(f.isPlainObject(d)||(d={}),!1!==b.close(!0)))return f.isArray(a)||(a=s(a)?f(a).get():[a]),f.each(a,function(e,c){var j={},g,h,i,l,k;"object"===f.type(c)&&(c.nodeType&&(c=f(c)),s(c)?(j={href:c.data("fancybox-href")||c.attr("href"),title:c.data("fancybox-title")||c.attr("title"),isDom:!0,element:c},f.metadata&&f.extend(!0,
j,c.metadata())):j=c);g=d.href||j.href||(p(c)?c:null);h=d.title!==q?d.title:j.title||"";l=(i=d.content||j.content)?"html":d.type||j.type;!l&&j.isDom&&(l=c.data("fancybox-type"),l||(l=(l=c.prop("class").match(/fancybox\.(\w+)/))?l[1]:null));p(g)&&(l||(b.isImage(g)?l="image":b.isSWF(g)?l="swf":"#"===g.charAt(0)?l="inline":p(c)&&(l="html",i=c)),"ajax"===l&&(k=g.split(/\s+/,2),g=k.shift(),k=k.shift()));i||("inline"===l?g?i=f(p(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):j.isDom&&(i=c):"html"===l?i=g:!l&&(!g&&
j.isDom)&&(l="inline",i=c));f.extend(j,{href:g,type:l,content:i,title:h,selector:k});a[e]=j}),b.opts=f.extend(!0,{},b.defaults,d),d.keys!==q&&(b.opts.keys=d.keys?f.extend({},b.defaults.keys,d.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0,!0).trigger("onReset").remove(),b.coming=null,b.current||
b._afterZoomOut(a))},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),b.isActive&&(!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),b.transitions[b.current.closeMethod]())))},play:function(a){var d=function(){clearTimeout(b.player.timer)},e=function(){d();b.current&&b.player.isActive&&(b.player.timer=
setTimeout(b.next,b.current.playSpeed))},c=function(){d();f("body").unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index<b.group.length-1))b.player.isActive=!0,f("body").bind({"afterShow.player onUpdate.player":e,"onCancel.player beforeClose.player":c,"beforeLoad.player":d}),e(),b.trigger("onPlayStart")}else c()},next:function(a){var d=b.current;d&&(p(a)||(a=d.direction.next),b.jumpto(d.index+1,a,"next"))},
prev:function(a){var d=b.current;d&&(p(a)||(a=d.direction.prev),b.jumpto(d.index-1,a,"prev"))},jumpto:function(a,d,e){var c=b.current;c&&(a=k(a),b.direction=d||c.direction[a>=c.index?"next":"prev"],b.router=e||"jumpto",c.loop&&(0>a&&(a=c.group.length+a%c.group.length),a%=c.group.length),c.group[a]!==q&&(b.cancel(),b._start(a)))},reposition:function(a,d){var e=b.current,c=e?e.wrap:null,j;c&&(j=b._getPosition(d),a&&"scroll"===a.type?(delete j.position,c.stop(!0,!0).animate(j,200)):(c.css(j),e.pos=f.extend({},
e.dim,j)))},update:function(a){var d=a&&a.type,e=!d||"orientationchange"===d;e&&(clearTimeout(u),u=null);b.isOpen&&!u&&(u=setTimeout(function(){var c=b.current;c&&!b.isClosing&&(b.wrap.removeClass("fancybox-tmp"),(e||"load"===d||"resize"===d&&c.autoResize)&&b._setDimension(),"scroll"===d&&c.canShrink||b.reposition(a),b.trigger("onUpdate"),u=null)},e&&!n?0:300))},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)?a:!b.current.fitToView,n&&(b.wrap.removeAttr("style").addClass("fancybox-tmp"),
b.trigger("onUpdate")),b.update())},hideLoading:function(){m.unbind(".loading");f("#fancybox-loading").remove()},showLoading:function(){var a,d;b.hideLoading();a=f('<div id="fancybox-loading"><div></div></div>').click(b.cancel).appendTo("body");m.bind("keydown.loading",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});b.defaults.fixed||(d=b.getViewport(),a.css({position:"absolute",top:0.5*d.h+d.y,left:0.5*d.w+d.x}))},getViewport:function(){var a=b.current&&b.current.locked||
!1,d={x:r.scrollLeft(),y:r.scrollTop()};a?(d.w=a[0].clientWidth,d.h=a[0].clientHeight):(d.w=n&&B.innerWidth?B.innerWidth:r.width(),d.h=n&&B.innerHeight?B.innerHeight:r.height());return d},unbindEvents:function(){b.wrap&&s(b.wrap)&&b.wrap.unbind(".fb");m.unbind(".fb");r.unbind(".fb")},bindEvents:function(){var a=b.current,d;a&&(r.bind("orientationchange.fb"+(n?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(d=a.keys)&&m.bind("keydown.fb",function(e){var c=e.which||e.keyCode,j=
e.target||e.srcElement;if(27===c&&b.coming)return!1;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!j||!j.type&&!f(j).is("[contenteditable]")))&&f.each(d,function(d,j){if(1<a.group.length&&j[c]!==q)return b[d](j[c]),e.preventDefault(),!1;if(-1<f.inArray(c,j))return b[d](),e.preventDefault(),!1})}),f.fn.mousewheel&&a.mouseWheel&&b.wrap.bind("mousewheel.fb",function(d,c,j,g){for(var h=f(d.target||null),i=!1;h.length&&!i&&!h.is(".fancybox-skin")&&!h.is(".fancybox-wrap");)i=h[0]&&!(h[0].style.overflow&&
"hidden"===h[0].style.overflow)&&(h[0].clientWidth&&h[0].scrollWidth>h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==c&&!i&&1<b.group.length&&!a.canShrink){if(0<g||0<j)b.prev(0<g?"down":"left");else if(0>g||0>j)b.next(0>g?"up":"right");d.preventDefault()}}))},trigger:function(a,d){var e,c=d||b.coming||b.current;if(c){f.isFunction(c[a])&&(e=c[a].apply(c,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;c.helpers&&f.each(c.helpers,function(d,
e){e&&(b.helpers[d]&&f.isFunction(b.helpers[d][a]))&&(e=f.extend(!0,{},b.helpers[d].defaults,e),b.helpers[d][a](e,c))});f.event.trigger(a+".fb")}},isImage:function(a){return p(a)&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp)((\?|#).*)?$)/i)},isSWF:function(a){return p(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var d={},e,c,a=k(a);e=b.group[a]||null;if(!e)return!1;d=f.extend(!0,{},b.opts,e);e=d.margin;c=d.padding;"number"===f.type(e)&&(d.margin=[e,e,e,e]);"number"===f.type(c)&&
(d.padding=[c,c,c,c]);d.modal&&f.extend(!0,d,{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1,mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});d.autoSize&&(d.autoWidth=d.autoHeight=!0);"auto"===d.width&&(d.autoWidth=!0);"auto"===d.height&&(d.autoHeight=!0);d.group=b.group;d.index=a;b.coming=d;if(!1===b.trigger("beforeLoad"))b.coming=null;else{c=d.type;e=d.href;if(!c)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive=
!0;if("image"===c||"swf"===c)d.autoHeight=d.autoWidth=!1,d.scrolling="visible";"image"===c&&(d.aspectRatio=!0);"iframe"===c&&n&&(d.scrolling="scroll");d.wrap=f(d.tpl.wrap).addClass("fancybox-"+(n?"mobile":"desktop")+" fancybox-type-"+c+" fancybox-tmp "+d.wrapCSS).appendTo(d.parent||"body");f.extend(d,{skin:f(".fancybox-skin",d.wrap),outer:f(".fancybox-outer",d.wrap),inner:f(".fancybox-inner",d.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){d.skin.css("padding"+b,v(d.padding[a]))});b.trigger("onReady");
if("inline"===c||"html"===c){if(!d.content||!d.content.length)return b._error("content")}else if(!e)return b._error("href");"image"===c?b._loadImage():"ajax"===c?b._loadAjax():"iframe"===c?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width=
this.width;b.coming.height=this.height;b._afterLoad()};a.onerror=function(){this.onload=this.onerror=null;b._error("image")};a.src=b.coming.href;!0!==a.complete&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(d,e){"success"===e&&(a.content=d,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,d=f(a.tpl.iframe.replace(/\{rnd\}/g,
(new Date).getTime())).attr("scrolling",n?"auto":a.iframe.scrolling).attr("src",a.href);f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),d.one("load",function(){f(this).data("ready",1);n||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=d.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a=
b.group,d=b.current,e=a.length,c=d.preload?Math.min(d.preload,e-1):0,f,g;for(g=1;g<=c;g+=1)f=a[(d.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,d=b.current,e,c,j,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,d))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{d&&(b.trigger("beforeChange",d),d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());b.unbindEvents();
e=a.content;c=a.type;j=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin,outer:a.outer,inner:a.inner,current:a,previous:d});g=a.href;switch(c){case "inline":case "ajax":case "html":a.selector?e=f("<div>").html(e).find(a.selector):s(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('<div class="fancybox-placeholder"></div>').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder",
!1)}));break;case "image":e=a.tpl.image.replace("{href}",g);break;case "swf":e='<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="'+g+'"></param>',h="",f.each(a.swf,function(a,b){e+='<param name="'+a+'" value="'+b+'"></param>';h+=" "+a+'="'+b+'"'}),e+='<embed src="'+g+'" type="application/x-shockwave-flash" width="100%" height="100%"'+h+"></embed></object>"}(!s(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow");
a.inner.css("overflow","yes"===j?"scroll":"no"===j?"hidden":j);b._setDimension();b.reposition();b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(d.prevMethod)b.transitions[d.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),d=0,e=!1,c=!1,e=b.wrap,j=b.skin,g=b.inner,h=b.current,c=h.width,i=h.height,l=h.minWidth,t=h.minHeight,m=h.maxWidth,
n=h.maxHeight,r=h.scrolling,p=h.scrollOutside?h.scrollbarWidth:0,w=h.margin,y=k(w[1]+w[3]),q=k(w[0]+w[2]),x,z,s,C,A,F,B,D,u;e.add(j).add(g).width("auto").height("auto").removeClass("fancybox-tmp");w=k(j.outerWidth(!0)-j.width());x=k(j.outerHeight(!0)-j.height());z=y+w;s=q+x;C=E(c)?(a.w-z)*k(c)/100:c;A=E(i)?(a.h-s)*k(i)/100:i;if("iframe"===h.type){if(u=h.content,h.autoHeight&&1===u.data("ready"))try{u[0].contentWindow.document.location&&(g.width(C).height(9999),F=u.contents().find("body"),p&&F.css("overflow-x",
"hidden"),A=F.height())}catch(G){}}else if(h.autoWidth||h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(C),h.autoHeight||g.height(A),h.autoWidth&&(C=g.width()),h.autoHeight&&(A=g.height()),g.removeClass("fancybox-tmp");c=k(C);i=k(A);D=C/A;l=k(E(l)?k(l,"w")-z:l);m=k(E(m)?k(m,"w")-z:m);t=k(E(t)?k(t,"h")-s:t);n=k(E(n)?k(n,"h")-s:n);F=m;B=n;h.fitToView&&(m=Math.min(a.w-z,m),n=Math.min(a.h-s,n));z=a.w-y;q=a.h-q;h.aspectRatio?(c>m&&(c=m,i=k(c/D)),i>n&&(i=n,c=k(i*D)),c<l&&(c=l,i=k(c/D)),i<t&&
(i=t,c=k(i*D))):(c=Math.max(l,Math.min(c,m)),h.autoHeight&&"iframe"!==h.type&&(g.width(c),i=g.height()),i=Math.max(t,Math.min(i,n)));if(h.fitToView)if(g.width(c).height(i),e.width(c+w),a=e.width(),y=e.height(),h.aspectRatio)for(;(a>z||y>q)&&(c>l&&i>t)&&!(19<d++);)i=Math.max(t,Math.min(n,i-10)),c=k(i*D),c<l&&(c=l,i=k(c/D)),c>m&&(c=m,i=k(c/D)),g.width(c).height(i),e.width(c+w),a=e.width(),y=e.height();else c=Math.max(l,Math.min(c,c-(a-z))),i=Math.max(t,Math.min(i,i-(y-q)));p&&("auto"===r&&i<A&&c+w+
p<z)&&(c+=p);g.width(c).height(i);e.width(c+w);a=e.width();y=e.height();e=(a>z||y>q)&&c>l&&i>t;c=h.aspectRatio?c<F&&i<B&&c<C&&i<A:(c<F||i<B)&&(c<C||i<A);f.extend(h,{dim:{width:v(a),height:v(y)},origWidth:C,origHeight:A,canShrink:e,canExpand:c,wPadding:w,hPadding:x,wrapSpace:y-j.outerHeight(!0),skinSpace:j.height()-i});!u&&(h.autoHeight&&i>t&&i<n&&!c)&&g.height("auto")},_getPosition:function(a){var d=b.current,e=b.getViewport(),c=d.margin,f=b.wrap.width()+c[1]+c[3],g=b.wrap.height()+c[0]+c[2],c={position:"absolute",
top:c[0],left:c[3]};d.autoCenter&&d.fixed&&!a&&g<=e.h&&f<=e.w?c.position="fixed":d.locked||(c.top+=e.y,c.left+=e.x);c.top=v(Math.max(c.top,c.top+(e.h-g)*d.topRatio));c.left=v(Math.max(c.left,c.left+(e.w-f)*d.leftRatio));return c},_afterZoomIn:function(){var a=b.current;a&&(b.isOpen=b.isOpened=!0,b.wrap.css("overflow","visible").addClass("fancybox-opened"),b.update(),(a.closeClick||a.nextClick&&1<b.group.length)&&b.inner.css("cursor","pointer").bind("click.fb",function(d){!f(d.target).is("a")&&!f(d.target).parent().is("a")&&
(d.preventDefault(),b[a.closeClick?"close":"next"]())}),a.closeBtn&&f(a.tpl.closeBtn).appendTo(b.skin).bind(n?"touchstart.fb":"click.fb",function(a){a.preventDefault();b.close()}),a.arrows&&1<b.group.length&&((a.loop||0<a.index)&&f(a.tpl.prev).appendTo(b.outer).bind("click.fb",b.prev),(a.loop||a.index<b.group.length-1)&&f(a.tpl.next).appendTo(b.outer).bind("click.fb",b.next)),b.trigger("afterShow"),!a.loop&&a.index===a.group.length-1?b.play(!1):b.opts.autoPlay&&!b.player.isActive&&(b.opts.autoPlay=
!1,b.play()))},_afterZoomOut:function(a){a=a||b.current;f(".fancybox-wrap").trigger("onReset").remove();f.extend(b,{group:{},opts:{},router:!1,current:null,isActive:!1,isOpened:!1,isOpen:!1,isClosing:!1,wrap:null,skin:null,outer:null,inner:null});b.trigger("afterClose",a)}});b.transitions={getOrigPosition:function(){var a=b.current,d=a.element,e=a.orig,c={},f=50,g=50,h=a.hPadding,i=a.wPadding,l=b.getViewport();!e&&(a.isDom&&d.is(":visible"))&&(e=d.find("img:first"),e.length||(e=d));s(e)?(c=e.offset(),
e.is("img")&&(f=e.outerWidth(),g=e.outerHeight())):(c.top=l.y+(l.h-g)*a.topRatio,c.left=l.x+(l.w-f)*a.leftRatio);if("fixed"===b.wrap.css("position")||a.locked)c.top-=l.y,c.left-=l.x;return c={top:v(c.top-h*a.topRatio),left:v(c.left-i*a.leftRatio),width:v(f+i),height:v(g+h)}},step:function(a,d){var e,c,f=d.prop;c=b.current;var g=c.wrapSpace,h=c.skinSpace;if("width"===f||"height"===f)e=d.end===d.start?1:(a-d.start)/(d.end-d.start),b.isClosing&&(e=1-e),c="width"===f?c.wPadding:c.hPadding,c=a-c,b.skin[f](k("width"===
f?c:c-g*e)),b.inner[f](k("width"===f?c:c-g*e-h*e))},zoomIn:function(){var a=b.current,d=a.pos,e=a.openEffect,c="elastic"===e,j=f.extend({opacity:1},d);delete j.position;c?(d=this.getOrigPosition(),a.openOpacity&&(d.opacity=0.1)):"fade"===e&&(d.opacity=0.1);b.wrap.css(d).animate(j,{duration:"none"===e?0:a.openSpeed,easing:a.openEasing,step:c?this.step:null,complete:b._afterZoomIn})},zoomOut:function(){var a=b.current,d=a.closeEffect,e="elastic"===d,c={opacity:0.1};e&&(c=this.getOrigPosition(),a.closeOpacity&&
(c.opacity=0.1));b.wrap.animate(c,{duration:"none"===d?0:a.closeSpeed,easing:a.closeEasing,step:e?this.step:null,complete:b._afterZoomOut})},changeIn:function(){var a=b.current,d=a.nextEffect,e=a.pos,c={opacity:1},f=b.direction,g;e.opacity=0.1;"elastic"===d&&(g="down"===f||"up"===f?"top":"left","down"===f||"right"===f?(e[g]=v(k(e[g])-200),c[g]="+=200px"):(e[g]=v(k(e[g])+200),c[g]="-=200px"));"none"===d?b._afterZoomIn():b.wrap.css(e).animate(c,{duration:a.nextSpeed,easing:a.nextEasing,complete:function(){setTimeout(b._afterZoomIn,
20)}})},changeOut:function(){var a=b.previous,d=a.prevEffect,e={opacity:0.1},c=b.direction;"elastic"===d&&(e["down"===c||"up"===c?"top":"left"]=("up"===c||"left"===c?"-":"+")+"=200px");a.wrap.animate(e,{duration:"none"===d?0:a.prevSpeed,easing:a.prevEasing,complete:function(){f(this).trigger("onReset").remove()}})}};b.helpers.overlay={defaults:{closeClick:!0,speedOut:200,showEarly:!0,css:{},locked:!n,fixed:!0},overlay:null,fixed:!1,create:function(a){a=f.extend({},this.defaults,a);this.overlay&&this.close();
this.overlay=f('<div class="fancybox-overlay"></div>').appendTo("body");this.fixed=!1;a.fixed&&b.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(a){var d=this,a=f.extend({},this.defaults,a);this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(a);this.fixed||(r.bind("resize.overlay",f.proxy(this.update,this)),this.update());a.closeClick&&this.overlay.bind("click.overlay",function(a){f(a.target).hasClass("fancybox-overlay")&&
(b.isActive?b.close():d.close())});this.overlay.css(a.css).show()},close:function(){f(".fancybox-overlay").remove();r.unbind("resize.overlay");this.overlay=null;!1!==this.margin&&(f("body").css("margin-right",this.margin),this.margin=!1);this.el&&this.el.removeClass("fancybox-lock")},update:function(){var a="100%",b;this.overlay.width(a).height("100%");f.browser.msie?(b=Math.max(x.documentElement.offsetWidth,x.body.offsetWidth),m.width()>b&&(a=m.width())):m.width()>r.width()&&(a=m.width());this.overlay.width(a).height(m.height())},
onReady:function(a,b){f(".fancybox-overlay").stop(!0,!0);this.overlay||(this.margin=m.height()>r.height()||"scroll"===f("body").css("overflow-y")?f("body").css("margin-right"):!1,this.el=x.all&&!x.querySelector?f("html"):f("body"),this.create(a));a.locked&&this.fixed&&(b.locked=this.overlay.append(b.wrap),b.fixed=!1);!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,b){b.locked&&(this.el.addClass("fancybox-lock"),!1!==this.margin&&f("body").css("margin-right",k(this.margin)+
b.scrollbarWidth));this.open(a)},onUpdate:function(){this.fixed||this.update()},afterClose:function(a){this.overlay&&!b.isActive&&this.overlay.fadeOut(a.speedOut,f.proxy(this.close,this))}};b.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(a){var d=b.current,e=d.title,c=a.type;f.isFunction(e)&&(e=e.call(d.element,d));if(p(e)&&""!==f.trim(e)){d=f('<div class="fancybox-title fancybox-title-'+c+'-wrap">'+e+"</div>");switch(c){case "inside":c=b.skin;break;case "outside":c=
b.wrap;break;case "over":c=b.inner;break;default:c=b.skin,d.appendTo("body"),f.browser.msie&&d.width(d.width()),d.wrapInner('<span class="child"></span>'),b.current.margin[2]+=Math.abs(k(d.css("margin-bottom")))}d["top"===a.position?"prependTo":"appendTo"](c)}}};f.fn.fancybox=function(a){var d,e=f(this),c=this.selector||"",j=function(g){var h=f(this).blur(),i=d,j,k;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(j=a.groupAttr||"data-fancybox-group",k=h.attr(j),k||(j="rel",
k=h.get(0)[j]),k&&(""!==k&&"nofollow"!==k)&&(h=c.length?f(c):e,h=h.filter("["+j+'="'+k+'"]'),i=h.index(this)),a.index=i,!1!==b.open(h,a)&&g.preventDefault())},a=a||{};d=a.index||0;!c||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start",j):m.undelegate(c,"click.fb-start").delegate(c+":not('.fancybox-item, .fancybox-nav')","click.fb-start",j);this.filter("[data-fancybox-start=1]").trigger("click");return this};m.ready(function(){f.scrollbarWidth===q&&(f.scrollbarWidth=function(){var a=f('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"),
b=a.children(),b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===q){var a=f.support,d=f('<div style="position:fixed;top:20px;"></div>').appendTo("body"),e=20===d[0].offsetTop||15===d[0].offsetTop;d.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")})})})(window,document,jQuery);

(function(e){var d=e.fancybox;d.helpers.buttons={defaults:{skipSingle:!1,position:"top",tpl:'<div id="fancybox-buttons"><ul><li><a class="btnPrev" title="Previous" href="javascript:;"></a></li><li><a class="btnPlay" title="Auto Play" href="javascript:;"></a></li><li><a class="btnNext" title="Next" href="javascript:;"></a></li><li><a class="btnToggle" title="Switch Dimensions" href="javascript:;"></a></li><li><a class="btnClose" title="Close" href="javascript:jQuery.fancybox.close();"></a></li></ul></div>'},
list:null,buttons:null,beforeLoad:function(c,a){c.skipSingle&&2>a.group.length?(a.helpers.buttons=!1,a.closeBtn=!0):a.margin["bottom"===c.position?2:0]+=30},onPlayStart:function(){this.buttons&&this.buttons.play.attr("title","Pause slideshow").addClass("btnPlayOn")},onPlayEnd:function(){this.buttons&&this.buttons.play.attr("title","Start slideshow").removeClass("btnPlayOn")},afterShow:function(c,a){var b=this.buttons;b||(this.list=e(c.tpl).addClass(c.position).appendTo("body"),b={prev:this.list.find(".btnPrev").click(d.prev),
next:this.list.find(".btnNext").click(d.next),play:this.list.find(".btnPlay").click(d.play),toggle:this.list.find(".btnToggle").click(d.toggle)});0<a.index||a.loop?b.prev.removeClass("btnDisabled"):b.prev.addClass("btnDisabled");a.loop||a.index<a.group.length-1?(b.next.removeClass("btnDisabled"),b.play.removeClass("btnDisabled")):(b.next.addClass("btnDisabled"),b.play.addClass("btnDisabled"));this.buttons=b;this.onUpdate(c,a)},onUpdate:function(c,a){var b;this.buttons&&(b=this.buttons.toggle.removeClass("btnDisabled btnToggleOn"),
a.canShrink?b.addClass("btnToggleOn"):a.canExpand||b.addClass("btnDisabled"))},beforeClose:function(){this.list&&this.list.remove();this.buttons=this.list=null}}})(jQuery);

// jQuery.Cookie
(function(e,h,i){function j(b){return b}function k(b){return decodeURIComponent(b.replace(l," "))}var l=/\+/g,d=e.cookie=function(b,c,a){if(c!==i){a=e.extend({},d.defaults,a);null===c&&(a.expires=-1);if("number"===typeof a.expires){var f=a.expires,g=a.expires=new Date;g.setDate(g.getDate()+f)}c=d.json?JSON.stringify(c):String(c);return h.cookie=[encodeURIComponent(b),"=",d.raw?c:encodeURIComponent(c),a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+
a.domain:"",a.secure?"; secure":""].join("")}c=d.raw?j:k;a=h.cookie.split("; ");for(f=0;g=a[f]&&a[f].split("=");f++)if(c(g.shift())===b)return b=c(g.join("=")),d.json?JSON.parse(b):b;return null};d.defaults={};e.removeCookie=function(b,c){return null!==e.cookie(b)?(e.cookie(b,null,c),!0):!1}})(jQuery,document);

var _ajax_uploader = _ajax_uploader || {};

_ajax_uploader.extend=function(first,second){for(var prop in second){first[prop]=second[prop]}};_ajax_uploader.indexOf=function(arr,elt,from){if(arr.indexOf){return arr.indexOf(elt,from)}from=from||0;var len=arr.length;if(from<0){from+=len}for(;from<len;from++){if(from in arr&&arr[from]===elt){return from}}return -1};_ajax_uploader.getUniqueId=(function(){var id=0;return function(){return id++}})();

// Events
_ajax_uploader.attach=function(element,type,fn){if(element.addEventListener){element.addEventListener(type,fn,false)}else{if(element.attachEvent){element.attachEvent("on"+type,fn)}}};_ajax_uploader.detach=function(element,type,fn){if(element.removeEventListener){element.removeEventListener(type,fn,false)}else{if(element.attachEvent){element.detachEvent("on"+type,fn)}}};_ajax_uploader.preventDefault=function(e){if(e.preventDefault){e.preventDefault()}else{e.returnValue=false}};

// Node manipulations
_ajax_uploader.insertBefore=function(a,b){b.parentNode.insertBefore(a,b)};_ajax_uploader.remove=function(element){element.parentNode.removeChild(element)};_ajax_uploader.contains=function(parent,descendant){if(parent==descendant){return true}if(parent.contains){return parent.contains(descendant)}else{return !!(descendant.compareDocumentPosition(parent)&8)}};_ajax_uploader.toElement=(function(){var div=document.createElement("div");return function(html){div.innerHTML=html;var element=div.firstChild;div.removeChild(element);return element}})();


// Node properties and attributes
_ajax_uploader.css=function(element,styles){if(styles.opacity!=null){if(typeof element.style.opacity!="string"&&typeof(element.filters)!="undefined"){styles.filter="alpha(opacity="+Math.round(100*styles.opacity)+")"}}_ajax_uploader.extend(element.style,styles)};_ajax_uploader.hasClass=function(element,name){var re=new RegExp("(^| )"+name+"( |$)");return re.test(element.className)};_ajax_uploader.addClass=function(element,name){if(!_ajax_uploader.hasClass(element,name)){element.className+=" "+name}};_ajax_uploader.removeClass=function(element,name){var re=new RegExp("(^| )"+name+"( |$)");element.className=element.className.replace(re," ").replace(/^\s+|\s+$/g,"")};_ajax_uploader.setText=function(element,text){element.innerText=text;element.textContent=text};_ajax_uploader.setHTML=function(element,html){element.innerHTML=html};

// Selecting elements
_ajax_uploader.children=function(element){var children=[],child=element.firstChild;while(child){if(child.nodeType==1){children.push(child)}child=child.nextSibling}return children};_ajax_uploader.getByClass=function(element,className){if(element.querySelectorAll){return element.querySelectorAll("."+className)}var result=[];var candidates=element.getElementsByTagName("*");var len=candidates.length;for(var i=0;i<len;i++){if(_ajax_uploader.hasClass(candidates[i],className)){result.push(candidates[i])}}return result};

/**
 * obj2url() takes a json-object as argument and generates
 * a querystring. pretty much like jQuery.param()
 * 
 * how to use:
 *
 *    `_ajax_uploader.obj2url({a:'b',c:'d'},'http://any.url/upload?otherParam=value');`
 *
 * will result in:
 *
 *    `http://any.url/upload?otherParam=value&a=b&c=d`
 *
 * @param  Object JSON-Object
 * @param  String current querystring-part
 * @return String encoded querystring
 */
_ajax_uploader.obj2url=function(obj,temp,prefixDone){var uristrings=[],prefix="&",add=function(nextObj,i){var nextTemp=temp?(/\[\]$/.test(temp))?temp:temp+"["+i+"]":i;if((nextTemp!="undefined")&&(i!="undefined")){uristrings.push((typeof nextObj==="object")?_ajax_uploader.obj2url(nextObj,nextTemp,true):(Object.prototype.toString.call(nextObj)==="[object Function]")?encodeURIComponent(nextTemp)+"="+encodeURIComponent(nextObj()):encodeURIComponent(nextTemp)+"="+encodeURIComponent(nextObj))}};if(!prefixDone&&temp){prefix=(/\?/.test(temp))?(/\?$/.test(temp))?"":"&":"?";uristrings.push(temp);uristrings.push(_ajax_uploader.obj2url(obj))}else{if((Object.prototype.toString.call(obj)==="[object Array]")&&(typeof obj!="undefined")){for(var i=0,len=obj.length;i<len;++i){add(obj[i],i)}}else{if((typeof obj!="undefined")&&(obj!==null)&&(typeof obj==="object")){for(var i in obj){add(obj[i],i)}}else{uristrings.push(encodeURIComponent(temp)+"="+encodeURIComponent(obj))}}}return uristrings.join(prefix).replace(/^&/,"").replace(/%20/g,"+")};


// Uploader Classes
var _ajax_uploader=_ajax_uploader||{};_ajax_uploader.FileUploaderBasic=function(o){this._options={debug:false,action:"/server/upload",params:{},button:null,multiple:true,maxConnections:3,allowedExtensions:[],sizeLimit:0,minSizeLimit:0,onSubmit:function(id,fileName){},onProgress:function(id,fileName,loaded,total){},onComplete:function(id,fileName,responseJSON){},onCancel:function(id,fileName){},messages:{typeError:"{file} Is an invalid file. Only accept the following files: {extensions}",sizeError:"{file} {file} is too larger, Max size: {sizeLimit}.",minSizeError:"{file} {file} is too smaller, Min size:  {minSizeLimit}.",emptyError:"{file} is failed, please select again.",onLeave:"File is uploading, cancle it?."},showMessage:function(message){$.alert(message)}};_ajax_uploader.extend(this._options,o);this._filesInProgress=0;this._handler=this._createUploadHandler();if(this._options.button){this._button=this._createUploadButton(this._options.button)}this._preventLeaveInProgress()};_ajax_uploader.FileUploaderBasic.prototype={setParams:function(params){this._options.params=params},getInProgress:function(){return this._filesInProgress},_createUploadButton:function(element){var self=this;return new _ajax_uploader.UploadButton({element:element,multiple:this._options.multiple&&_ajax_uploader.UploadHandlerXhr.isSupported(),onChange:function(input){self._onInputChange(input)}})},_createUploadHandler:function(){var self=this,handlerClass;if(_ajax_uploader.UploadHandlerXhr.isSupported()){handlerClass="UploadHandlerXhr"}else{handlerClass="UploadHandlerForm"}var handler=new _ajax_uploader[handlerClass]({debug:this._options.debug,action:this._options.action,maxConnections:this._options.maxConnections,onProgress:function(id,fileName,loaded,total){self._onProgress(id,fileName,loaded,total);self._options.onProgress(id,fileName,loaded,total)},onComplete:function(id,fileName,result){self._onComplete(id,fileName,result);self._options.onComplete(id,fileName,result)},onCancel:function(id,fileName){self._onCancel(id,fileName);self._options.onCancel(id,fileName)}});return handler},_preventLeaveInProgress:function(){var self=this;_ajax_uploader.attach(window,"beforeunload",function(e){if(!self._filesInProgress){return}var e=e||window.event;e.returnValue=self._options.messages.onLeave;return self._options.messages.onLeave})},_onSubmit:function(id,fileName){this._filesInProgress++},_onProgress:function(id,fileName,loaded,total){},_onComplete:function(id,fileName,result){this._filesInProgress--;if(result.error){this._options.showMessage(result.error)}},_onCancel:function(id,fileName){this._filesInProgress--},_onInputChange:function(input){if(this._handler instanceof _ajax_uploader.UploadHandlerXhr){this._uploadFileList(input.files)}else{if(this._validateFile(input)){this._uploadFile(input)}}this._button.reset()},_uploadFileList:function(files){for(var i=0;i<files.length;i++){if(!this._validateFile(files[i])){return}}for(var i=0;i<files.length;i++){this._uploadFile(files[i])}},_uploadFile:function(fileContainer){var id=this._handler.add(fileContainer);var fileName=this._handler.getName(id);if(this._options.onSubmit(id,fileName)!==false){this._onSubmit(id,fileName);this._handler.upload(id,this._options.params)}},_validateFile:function(file){var name,size;if(file.value){name=file.value.replace(/.*(\/|\\)/,"")}else{name=file.fileName!=null?file.fileName:file.name;size=file.fileSize!=null?file.fileSize:file.size}if(!this._isAllowedExtension(name)){this._error("typeError",name);return false}else{if(size===0){this._error("emptyError",name);return false}else{if(size&&this._options.sizeLimit&&size>this._options.sizeLimit){this._error("sizeError",name);return false}else{if(size&&size<this._options.minSizeLimit){this._error("minSizeError",name);return false}}}}return true},_error:function(code,fileName){var message=this._options.messages[code];function r(name,replacement){message=message.replace(name,replacement)}r("{file}",this._formatFileName(fileName));r("{extensions}",this._options.allowedExtensions.join(", "));r("{sizeLimit}",this._formatSize(this._options.sizeLimit));r("{minSizeLimit}",this._formatSize(this._options.minSizeLimit));this._options.showMessage(message)},_formatFileName:function(name){if(name.length>33){name=name.slice(0,19)+"..."+name.slice(-13)}return name},_isAllowedExtension:function(fileName){var ext=(-1!==fileName.indexOf("."))?fileName.replace(/.*[.]/,"").toLowerCase():"";var allowed=this._options.allowedExtensions;if(!allowed.length){return true}for(var i=0;i<allowed.length;i++){if(allowed[i].toLowerCase()==ext){return true}}return false},_formatSize:function(bytes){var i=-1;do{bytes=bytes/1024;i++}while(bytes>99);return Math.max(bytes,0.1).toFixed(1)+["kB","MB","GB","TB","PB","EB"][i]}};

       
/**
 * Class that creates upload widget with drag-and-drop and file list
 * @inherits _ajax_uploader.FileUploaderBasic
 */
_ajax_uploader.FileUploader=function(o){if(!!navigator.userAgent.match(/like Mac OS X/)||GET_UPLOAD_ENABLE!="Y"){return false}_ajax_uploader.FileUploaderBasic.apply(this,arguments);_ajax_uploader.extend(this._options,{element:null,listElement:null,template:'<div class="_ajax_upload-button upload_but" style="float:left;margin-right:10px;"></div><ul id="upload-ul" class="_ajax_upload-list upload tny-clear" style="clear:both;"></ul>',fileTemplate:'<li><span class="loading file_icon"></span><p class="_ajax_upload-file  loadname"></p><p class="_ajax_upload-size  loadkb"></p><p class="_ajax_upload-inset"><a href="javascript:;" class="fr delect_file"  onclick="if (confirm(\'Confirm deleting files?\')) { _ajax_uploader_delete_attach(this.href, $(this).parent().parent()) } return false;" title="Delete this attachment">Delete</a></p></li>',classes:{button:"_ajax_upload-button",drop:"_ajax_upload-drop-area",dropActive:"_ajax_upload-drop-area-active",list:"_ajax_upload-list",file:"_ajax_upload-file",spinner:"loading",size:"_ajax_upload-size",success:"_ajax_upload-success",fail:"error_border",inset:"_ajax_upload-inset"}});_ajax_uploader.extend(this._options,o);this._element=this._options.element;this._element.innerHTML=this._options.template;this._listElement=this._options.listElement||this._find(this._element,"list");this._classes=this._options.classes;this._button=this._createUploadButton(this._find(this._element,"button"))};function insetImages(obj){var iframeId=document.getElementById("answer_content_ifr")?document.getElementById("answer_content_ifr"):document.getElementById("question_detail_ifr");var objElements=iframeId.contentWindow.document.getElementById("tinymce");var rel=obj.parentNode.parentNode.getElementsByTagName("span")[0].getAttribute("rel");var html='<img src="'+rel+'"/>';objElements.designMode="On";if(getBrowser()=="ie"){objElements.focus();o=iframeId.document.selection.createRange();o.pasteHTML(html)}else{objElements.focus();var rng=iframeId.contentWindow.getSelection().getRangeAt(0);var frg=rng.createContextualFragment(html);rng.insertNode(frg)}};
 
//Get the browser version  
function getBrowser(){var agentValue=window.navigator.userAgent.toLowerCase();if(agentValue.indexOf("msie")>0){return"ie"}else{if(agentValue.indexOf("firefox")>0){return"ff"}else{if(agentValue.indexOf("chrome")>0){return"chrome"}}}};

// inherit from Basic Uploader
_ajax_uploader.extend(_ajax_uploader.FileUploader.prototype,_ajax_uploader.FileUploaderBasic.prototype);_ajax_uploader.extend(_ajax_uploader.FileUploader.prototype,{_find:function(parent,type){var element=_ajax_uploader.getByClass(parent,this._options.classes[type])[0];if(!element){throw new Error("element not found "+type)}return element},_setupDragDrop:function(){var self=this,dropArea=this._find(this._element,"drop");var dz=new _ajax_uploader.UploadDropZone({element:dropArea,onEnter:function(e){_ajax_uploader.addClass(dropArea,self._classes.dropActive);e.stopPropagation()},onLeave:function(e){e.stopPropagation()},onLeaveNotDescendants:function(e){_ajax_uploader.removeClass(dropArea,self._classes.dropActive)},onDrop:function(e){dropArea.style.display="none";_ajax_uploader.removeClass(dropArea,self._classes.dropActive);self._uploadFileList(e.dataTransfer.files)}});dropArea.style.display="none";_ajax_uploader.attach(document,"dragenter",function(e){if(!dz._isValidFileDrag(e)){return}dropArea.style.display="block"});_ajax_uploader.attach(document,"dragleave",function(e){if(!dz._isValidFileDrag(e)){return}var relatedTarget=document.elementFromPoint(e.clientX,e.clientY);if(!relatedTarget||relatedTarget.nodeName=="HTML"){dropArea.style.display="none"}})},_onSubmit:function(id,fileName){_ajax_uploader.FileUploaderBasic.prototype._onSubmit.apply(this,arguments);this._addToList(id,fileName)},_onProgress:function(id,fileName,loaded,total){_ajax_uploader.FileUploaderBasic.prototype._onProgress.apply(this,arguments);var item=this._getItemByFileId(id);var size=this._find(item,"size");size.style.display="";var text;if(loaded!=total){text=Math.round(loaded/total*100)+"%"}else{text=this._formatSize(total)}_ajax_uploader.setHTML(size,text)},_onComplete:function(id,fileName,result){_ajax_uploader.FileUploaderBasic.prototype._onComplete.apply(this,arguments);var item=this._getItemByFileId(id);if(result.success){if(typeof(result.delete_url)!="undefined"){_ajax_uploader.getByClass(item,"delect_file")[0].href=result.delete_url.replace(/&amp;/g,"&")}if(typeof(result.thumb)!="undefined"){$(this._find(item,"spinner")).css("background-image","url("+result.thumb+")").attr("rel",result.thumb);if(typeof(result.attach_id)!="undefined"){$("<a/>").attr("href","javascript:;").attr("onclick","insert_attach(this,"+result.attach_id+",'"+result.attach_tag+"')").html("Insert").appendTo($(this._find(item,"inset")))}}else{if(typeof(result.class_name)!="undefined"){_ajax_uploader.addClass(this._find(item,"spinner"),result.class_name)}else{_ajax_uploader.addClass(item,this._classes.success)}}}else{if(!$.browser.msie){_ajax_uploader.getByClass(item,"delect_file")[0].style.display="none"}_ajax_uploader.addClass(this._find(item,"spinner"),"error");_ajax_uploader.addClass(item,this._classes.fail);_ajax_uploader.getByClass(item,"delect_file")[0].style.display="none"}_ajax_uploader.removeClass(this._find(item,"spinner"),this._classes.spinner)},_addToList:function(id,fileName){var item=_ajax_uploader.toElement(this._options.fileTemplate);item.ymFileId=id;var fileElement=this._find(item,"file");_ajax_uploader.setText(fileElement,this._formatFileName(fileName));this._find(item,"size").style.display="none";this._listElement.appendChild(item)},_getItemByFileId:function(id){var item=this._listElement.firstChild;while(item){if(item.ymFileId==id){return item}item=item.nextSibling}},_bindCancelEvent:function(){var self=this,list=this._listElement;_ajax_uploader.attach(list,"click",function(e){e=e||window.event;var target=e.target||e.srcElement;if(_ajax_uploader.hasClass(target,self._classes.cancel)){_ajax_uploader.preventDefault(e);var item=target.parentNode;self._handler.cancel(item.ymFileId);_ajax_uploader.remove(item)}})}});_ajax_uploader.UploadDropZone=function(o){this._options={element:null,onEnter:function(e){},onLeave:function(e){},onLeaveNotDescendants:function(e){},onDrop:function(e){}};_ajax_uploader.extend(this._options,o);this._element=this._options.element;this._disableDropOutside();this._attachEvents()};_ajax_uploader.UploadDropZone.prototype={_disableDropOutside:function(e){if(!_ajax_uploader.UploadDropZone.dropOutsideDisabled){_ajax_uploader.attach(document,"dragover",function(e){if(e.dataTransfer){e.dataTransfer.dropEffect="none";e.preventDefault()}});_ajax_uploader.UploadDropZone.dropOutsideDisabled=true}},_attachEvents:function(){var self=this;_ajax_uploader.attach(self._element,"dragover",function(e){if(!self._isValidFileDrag(e)){return}var effect=e.dataTransfer.effectAllowed;if(effect=="move"||effect=="linkMove"){e.dataTransfer.dropEffect="move"}else{e.dataTransfer.dropEffect="copy"}e.stopPropagation();e.preventDefault()});_ajax_uploader.attach(self._element,"dragenter",function(e){if(!self._isValidFileDrag(e)){return}self._options.onEnter(e)});_ajax_uploader.attach(self._element,"dragleave",function(e){if(!self._isValidFileDrag(e)){return}self._options.onLeave(e);var relatedTarget=document.elementFromPoint(e.clientX,e.clientY);if(_ajax_uploader.contains(this,relatedTarget)){return}self._options.onLeaveNotDescendants(e)});_ajax_uploader.attach(self._element,"drop",function(e){if(!self._isValidFileDrag(e)){return}e.preventDefault();self._options.onDrop(e)})},_isValidFileDrag:function(e){var dt=e.dataTransfer,isWebkit=navigator.userAgent.indexOf("AppleWebKit")>-1;return dt&&dt.effectAllowed!="none"&&(dt.files||(!isWebkit&&dt.types.contains&&dt.types.contains("Files")))}};_ajax_uploader.UploadButton=function(o){this._options={element:null,multiple:false,name:"file",onChange:function(input){},hoverClass:"_ajax_upload-button-hover",focusClass:"_ajax_upload-button-focus"};_ajax_uploader.extend(this._options,o);this._element=this._options.element;_ajax_uploader.css(this._element,{position:"relative",overflow:"hidden",direction:"ltr"});this._input=this._createInput()};_ajax_uploader.UploadButton.prototype={getInput:function(){return this._input},reset:function(){if(this._input.parentNode){_ajax_uploader.remove(this._input)}_ajax_uploader.removeClass(this._element,this._options.focusClass);this._input=this._createInput()},_createInput:function(){var input=document.createElement("input");if(this._options.multiple){input.setAttribute("multiple","multiple")}input.setAttribute("type","file");input.setAttribute("name",this._options.name);_ajax_uploader.css(input,{position:"absolute",right:0,top:0,fontFamily:"Arial",fontSize:"118px",margin:0,padding:0,cursor:"pointer",opacity:0});this._element.appendChild(input);var self=this;_ajax_uploader.attach(input,"change",function(){self._options.onChange(input)});_ajax_uploader.attach(input,"mouseover",function(){_ajax_uploader.addClass(self._element,self._options.hoverClass)});_ajax_uploader.attach(input,"mouseout",function(){_ajax_uploader.removeClass(self._element,self._options.hoverClass)});_ajax_uploader.attach(input,"focus",function(){_ajax_uploader.addClass(self._element,self._options.focusClass)});_ajax_uploader.attach(input,"blur",function(){_ajax_uploader.removeClass(self._element,self._options.focusClass)});if(window.attachEvent){input.setAttribute("tabIndex","-1")}return input}};

/**
 * Class for uploading files, uploading itself is handled by child classes
 */
_ajax_uploader.UploadHandlerAbstract=function(o){this._options={debug:false,action:GET_BASE_URL+"/upload.php",maxConnections:999,onProgress:function(id,fileName,loaded,total){},onComplete:function(id,fileName,response){},onCancel:function(id,fileName){}};_ajax_uploader.extend(this._options,o);this._queue=[];this._params=[]};_ajax_uploader.UploadHandlerAbstract.prototype={log:function(str){if(this._options.debug&&window.console){console.log("[uploader] "+str)}},add:function(file){},upload:function(id,params){var len=this._queue.push(id);var copy={};_ajax_uploader.extend(copy,params);this._params[id]=copy;if(len<=this._options.maxConnections){this._upload(id,this._params[id])}},cancel:function(id){this._cancel(id);this._dequeue(id)},cancelAll:function(){for(var i=0;i<this._queue.length;i++){this._cancel(this._queue[i])}this._queue=[]},getName:function(id){},getSize:function(id){},getQueue:function(){return this._queue},_upload:function(id){},_cancel:function(id){},_dequeue:function(id){var i=_ajax_uploader.indexOf(this._queue,id);this._queue.splice(i,1);var max=this._options.maxConnections;if(this._queue.length>=max&&i<max){var nextId=this._queue[max-1];this._upload(nextId,this._params[nextId])}}};

/**
 * Class for uploading files using form and iframe
 * @inherits _ajax_uploader.UploadHandlerAbstract
 */
_ajax_uploader.UploadHandlerForm=function(o){_ajax_uploader.UploadHandlerAbstract.apply(this,arguments);this._inputs={}};

// @inherits _ajax_uploader.UploadHandlerAbstract
_ajax_uploader.extend(_ajax_uploader.UploadHandlerForm.prototype,_ajax_uploader.UploadHandlerAbstract.prototype);_ajax_uploader.extend(_ajax_uploader.UploadHandlerForm.prototype,{add:function(fileInput){fileInput.setAttribute("name","ymfile");var id="_ajax_upload-handler-iframe"+_ajax_uploader.getUniqueId();this._inputs[id]=fileInput;if(fileInput.parentNode){_ajax_uploader.remove(fileInput)}return id},getName:function(id){return this._inputs[id].value.replace(/.*(\/|\\)/,"")},_cancel:function(id){this._options.onCancel(id,this.getName(id));delete this._inputs[id];var iframe=document.getElementById(id);if(iframe){iframe.setAttribute("src","javascript:false;");_ajax_uploader.remove(iframe)}},_upload:function(id,params){var input=this._inputs[id];if(!input){throw new Error("file with passed id was not added, or already uploaded or cancelled")}var fileName=this.getName(id);var iframe=this._createIframe(id);var form=this._createForm(iframe,params);form.appendChild(input);var self=this;this._attachLoadEvent(iframe,function(){self.log("iframe loaded");var response=self._getIframeContentJSON(iframe);self._options.onComplete(id,fileName,response);self._dequeue(id);delete self._inputs[id];setTimeout(function(){_ajax_uploader.remove(iframe)},1)});form.submit();_ajax_uploader.remove(form);return id},_attachLoadEvent:function(iframe,callback){_ajax_uploader.attach(iframe,"load",function(){if(!iframe.parentNode){return}if(iframe.contentDocument&&iframe.contentDocument.body&&iframe.contentDocument.body.innerHTML=="false"){return}callback()})},_getIframeContentJSON:function(iframe){var doc=iframe.contentDocument?iframe.contentDocument:iframe.contentWindow.document,response;this.log("converting iframe's innerHTML to JSON");this.log("innerHTML = "+doc.body.innerHTML);try{response=eval("("+doc.body.innerHTML+")")}catch(err){response={}}return response},_createIframe:function(id){var iframe=_ajax_uploader.toElement('<iframe src="javascript:false;" name="'+id+'" />');iframe.setAttribute("id",id);iframe.style.display="none";document.body.appendChild(iframe);return iframe},_createForm:function(iframe,params){var form=_ajax_uploader.toElement('<form method="post" enctype="multipart/form-data"></form>');var queryString=_ajax_uploader.obj2url(params,this._options.action);form.setAttribute("action",queryString);form.setAttribute("target",iframe.name);form.style.display="none";document.body.appendChild(form);return form}});

/**
 * Class for uploading files using xhr
 * @inherits _ajax_uploader.UploadHandlerAbstract
 */
_ajax_uploader.UploadHandlerXhr=function(o){_ajax_uploader.UploadHandlerAbstract.apply(this,arguments);this._files=[];this._xhrs=[];this._loaded=[]};

// static method
_ajax_uploader.UploadHandlerXhr.isSupported=function(){var input=document.createElement("input");input.type="file";return("multiple" in input&&typeof File!="undefined"&&typeof(new XMLHttpRequest()).upload!="undefined")};

// @inherits _ajax_uploader.UploadHandlerAbstract
_ajax_uploader.extend(_ajax_uploader.UploadHandlerXhr.prototype,_ajax_uploader.UploadHandlerAbstract.prototype);_ajax_uploader.extend(_ajax_uploader.UploadHandlerXhr.prototype,{add:function(file){if(!(file instanceof File)){throw new Error("Passed obj in not a File (in _ajax_uploader.UploadHandlerXhr)")}return this._files.push(file)-1},getName:function(id){var file=this._files[id];return file.fileName!=null?file.fileName:file.name},getSize:function(id){var file=this._files[id];return file.fileSize!=null?file.fileSize:file.size},getLoaded:function(id){return this._loaded[id]||0},_upload:function(id,params){var file=this._files[id],name=this.getName(id),size=this.getSize(id);this._loaded[id]=0;var xhr=this._xhrs[id]=new XMLHttpRequest();var self=this;xhr.upload.onprogress=function(e){if(e.lengthComputable){self._loaded[id]=e.loaded;self._options.onProgress(id,name,e.loaded,e.total)}};xhr.onreadystatechange=function(){if(xhr.readyState==4){self._onComplete(id,xhr)}};params=params||{};params.ymfile=name;var queryString=_ajax_uploader.obj2url(params,this._options.action);xhr.open("POST",queryString,true);xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("X-File-Name",encodeURIComponent(name));xhr.setRequestHeader("Content-Type","application/octet-stream");xhr.send(file)},_onComplete:function(id,xhr){if(!this._files[id]){return}var name=this.getName(id);var size=this.getSize(id);this._options.onProgress(id,name,size,size);if(xhr.status==200){this.log("xhr - server response received");this.log("responseText = "+xhr.responseText);var response;try{response=eval("("+xhr.responseText+")")}catch(err){response={}}this._options.onComplete(id,name,response)}else{this._options.onComplete(id,name,{})}this._files[id]=null;this._xhrs[id]=null;this._dequeue(id)},_cancel:function(id){this._options.onCancel(id,this.getName(id));this._files[id]=null;if(this._xhrs[id]){this._xhrs[id].abort();this._xhrs[id]=null}}});function _ajax_uploader_delete_attach(url,el){var this_el=el;$.get(url,function(result){if(result.errno=="-1"){$.alert(result.err)}else{this_el.fadeOut();this_el.remove()}},"json")}function _ajax_uploader_append_file(selecter,v){var url="";if(typeof(v.thumb)!="undefined"){if(typeof(v.thumb)!="string"){url=v.thumb["90x90"]}else{url=v.thumb}}var html='<li><span class="file_icon '+v.class_name+'" '+(url==null||url==""?"":'style="background-image:url('+url+')"')+'></span><p class="_ajax_upload-file loadname" title="'+v.file_name+'">'+(v.file_name).substring(0,10)+'...</p><p class="_ajax_upload-inset "><a href="'+v.delete_link+'" onclick="if (confirm(\'Confirm deleting files?\')) { _ajax_uploader_delete_attach(this.href, $(this).parent().parent()) } return false;" class="delect_file fr">Delete</a>';if(typeof(v.thumb)!="undefined"&&typeof(v.attach_id)!="undefined"){html+='<a href="javascript:;" onclick="insert_attach(this, '+v.attach_id+",'"+v.attach_tag+"')\">Insert</a></p>"}else{html+="</p>"}html+="</li>";$(selecter).append(html)};