;(function($){$.ui={plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]]);}},call:function(instance,name,args){var set=instance.plugins[name];if(!set){return;}
for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args);}}}},cssCache:{},css:function(name){if($.ui.cssCache[name]){return $.ui.cssCache[name];}
var tmp=$('<div class="ui-gen">').addClass(name).css({position:'absolute',top:'-5000px',left:'-5000px',display:'block'}).appendTo('body');$.ui.cssCache[name]=!!((!(/auto|default/).test(tmp.css('cursor'))||(/^[1-9]/).test(tmp.css('height'))||(/^[1-9]/).test(tmp.css('width'))||!(/none/).test(tmp.css('backgroundImage'))||!(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))));try{$('body').get(0).removeChild(tmp.get(0));}catch(e){}
return $.ui.cssCache[name];},disableSelection:function(e){e.unselectable="on";e.onselectstart=function(){return false;};if(e.style){e.style.MozUserSelect="none";}},enableSelection:function(e){e.unselectable="off";e.onselectstart=function(){return true;};if(e.style){e.style.MozUserSelect="";}},hasScroll:function(e,a){var scroll=/top/.test(a||"top")?'scrollTop':'scrollLeft',has=false;if(e[scroll]>0)return true;e[scroll]=1;has=e[scroll]>0?true:false;e[scroll]=0;return has;}};var _remove=$.fn.remove;$.fn.remove=function(){$("*",this).add(this).trigger("remove");return _remove.apply(this,arguments);};function getter(namespace,plugin,method){var methods=$[namespace][plugin].getter||[];methods=(typeof methods=="string"?methods.split(/,?\s+/):methods);return($.inArray(method,methods)!=-1);}
$.widget=function(name,prototype){var namespace=name.split(".")[0];name=name.split(".")[1];$.fn[name]=function(options){var isMethodCall=(typeof options=='string'),args=Array.prototype.slice.call(arguments,1);if(isMethodCall&&getter(namespace,name,options)){var instance=$.data(this[0],name);return(instance?instance[options].apply(instance,args):undefined);}
return this.each(function(){var instance=$.data(this,name);if(isMethodCall&&instance&&$.isFunction(instance[options])){instance[options].apply(instance,args);}else if(!isMethodCall){$.data(this,name,new $[namespace][name](this,options));}});};$[namespace][name]=function(element,options){var self=this;this.widgetName=name;this.widgetBaseClass=namespace+'-'+name;this.options=$.extend({},$.widget.defaults,$[namespace][name].defaults,options);this.element=$(element).bind('setData.'+name,function(e,key,value){return self.setData(key,value);}).bind('getData.'+name,function(e,key){return self.getData(key);}).bind('remove',function(){return self.destroy();});this.init();};$[namespace][name].prototype=$.extend({},$.widget.prototype,prototype);};$.widget.prototype={init:function(){},destroy:function(){this.element.removeData(this.widgetName);},getData:function(key){return this.options[key];},setData:function(key,value){this.options[key]=value;if(key=='disabled'){this.element[value?'addClass':'removeClass'](this.widgetBaseClass+'-disabled');}},enable:function(){this.setData('disabled',false);},disable:function(){this.setData('disabled',true);}};$.widget.defaults={disabled:false};$.ui.mouse={mouseInit:function(){var self=this;this.element.bind('mousedown.'+this.widgetName,function(e){return self.mouseDown(e);});if($.browser.msie){this._mouseUnselectable=this.element.attr('unselectable');this.element.attr('unselectable','on');}
this.started=false;},mouseDestroy:function(){this.element.unbind('.'+this.widgetName);($.browser.msie&&this.element.attr('unselectable',this._mouseUnselectable));},mouseDown:function(e){(this._mouseStarted&&this.mouseUp(e));this._mouseDownEvent=e;var self=this,btnIsLeft=(e.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(e.target).is(this.options.cancel):false);if(!btnIsLeft||elIsCancel||!this.mouseCapture(e)){return true;}
this._mouseDelayMet=!this.options.delay;if(!this._mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self._mouseDelayMet=true;},this.options.delay);}
if(this.mouseDistanceMet(e)&&this.mouseDelayMet(e)){this._mouseStarted=(this.mouseStart(e)!==false);if(!this._mouseStarted){e.preventDefault();return true;}}
this._mouseMoveDelegate=function(e){return self.mouseMove(e);};this._mouseUpDelegate=function(e){return self.mouseUp(e);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);return false;},mouseMove:function(e){if($.browser.msie&&!e.button){return this.mouseUp(e);}
if(this._mouseStarted){this.mouseDrag(e);return false;}
if(this.mouseDistanceMet(e)&&this.mouseDelayMet(e)){this._mouseStarted=(this.mouseStart(this._mouseDownEvent,e)!==false);(this._mouseStarted?this.mouseDrag(e):this.mouseUp(e));}
return!this._mouseStarted;},mouseUp:function(e){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this.mouseStop(e);}
return false;},mouseDistanceMet:function(e){return(Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance);},mouseDelayMet:function(e){return this._mouseDelayMet;},mouseStart:function(e){},mouseDrag:function(e){},mouseStop:function(e){},mouseCapture:function(e){return true;}};$.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);(function($){$.widget("ui.draggable",$.extend($.ui.mouse,{init:function(){var o=this.options;if(o.helper=='original'&&!(/(relative|absolute|fixed)/).test(this.element.css('position')))
this.element.css('position','relative');this.element.addClass('ui-draggable');(o.disabled&&this.element.addClass('ui-draggable-disabled'));this.mouseInit();},mouseStart:function(e){var o=this.options;if(this.helper||o.disabled||$(e.target).is('.ui-resizable-handle'))return false;var handle=!this.options.handle||!$(this.options.handle,this.element).length?true:false;$(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==e.target)handle=true;});if(!handle)return false;if($.ui.ddmanager)$.ui.ddmanager.current=this;this.helper=$.isFunction(o.helper)?$(o.helper.apply(this.element[0],[e])):(o.helper=='clone'?this.element.clone():this.element);if(!this.helper.parents('body').length)this.helper.appendTo((o.appendTo=='parent'?this.element[0].parentNode:o.appendTo));if(this.helper[0]!=this.element[0]&&!(/(fixed|absolute)/).test(this.helper.css("position")))this.helper.css("position","absolute");this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)};this.cssPosition=this.helper.css("position");this.offset=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.offset.click={left:e.pageX-this.offset.left,top:e.pageY-this.offset.top};this.offsetParent=this.helper.offsetParent();var po=this.offsetParent.offset();if(this.offsetParent[0]==document.body&&$.browser.mozilla)po={top:0,left:0};this.offset.parent={top:po.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:po.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};var p=this.element.position();this.offset.relative=this.cssPosition=="relative"?{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.offsetParent[0].scrollTop,left:p.left-(parseInt(this.helper.css("left"),10)||0)+this.offsetParent[0].scrollLeft}:{top:0,left:0};this.originalPosition=this.generatePosition(e);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if(o.cursorAt){if(o.cursorAt.left!=undefined)this.offset.click.left=o.cursorAt.left+this.margins.left;if(o.cursorAt.right!=undefined)this.offset.click.left=this.helperProportions.width-o.cursorAt.right+this.margins.left;if(o.cursorAt.top!=undefined)this.offset.click.top=o.cursorAt.top+this.margins.top;if(o.cursorAt.bottom!=undefined)this.offset.click.top=this.helperProportions.height-o.cursorAt.bottom+this.margins.top;}
if(o.containment){if(o.containment=='parent')o.containment=this.helper[0].parentNode;if(o.containment=='document'||o.containment=='window')this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,$(o.containment=='document'?document:window).width()-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),($(o.containment=='document'?document:window).height()||document.body.parentNode.scrollHeight)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)];if(!(/^(document|window|parent)$/).test(o.containment)){var ce=$(o.containment)[0];var co=$(o.containment).offset();this.containment=[co.left+(parseInt($(ce).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left,co.top+(parseInt($(ce).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top,co.left+Math.max(ce.scrollWidth,ce.offsetWidth)-(parseInt($(ce).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),co.top+Math.max(ce.scrollHeight,ce.offsetHeight)-(parseInt($(ce).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)];}}
this.propagate("start",e);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if($.ui.ddmanager&&!o.dropBehaviour)$.ui.ddmanager.prepareOffsets(this,e);this.helper.addClass("ui-draggable-dragging");this.mouseDrag(e);return true;},convertPositionTo:function(d,pos){if(!pos)pos=this.position;var mod=d=="absolute"?1:-1;return{top:(pos.top
+this.offset.relative.top*mod
+this.offset.parent.top*mod
-(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollTop)*mod
+(this.cssPosition=="fixed"?$(document).scrollTop():0)*mod
+this.margins.top*mod),left:(pos.left
+this.offset.relative.left*mod
+this.offset.parent.left*mod
-(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollLeft)*mod
+(this.cssPosition=="fixed"?$(document).scrollLeft():0)*mod
+this.margins.left*mod)};},generatePosition:function(e){var o=this.options;var position={top:(e.pageY
-this.offset.click.top
-this.offset.relative.top
-this.offset.parent.top
+(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollTop)
-(this.cssPosition=="fixed"?$(document).scrollTop():0)),left:(e.pageX
-this.offset.click.left
-this.offset.relative.left
-this.offset.parent.left
+(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollLeft)
-(this.cssPosition=="fixed"?$(document).scrollLeft():0))};if(!this.originalPosition)return position;if(this.containment){if(position.left<this.containment[0])position.left=this.containment[0];if(position.top<this.containment[1])position.top=this.containment[1];if(position.left>this.containment[2])position.left=this.containment[2];if(position.top>this.containment[3])position.top=this.containment[3];}
if(o.grid){var top=this.originalPosition.top+Math.round((position.top-this.originalPosition.top)/o.grid[1])*o.grid[1];position.top=this.containment?(!(top<this.containment[1]||top>this.containment[3])?top:(!(top<this.containment[1])?top-o.grid[1]:top+o.grid[1])):top;var left=this.originalPosition.left+Math.round((position.left-this.originalPosition.left)/o.grid[0])*o.grid[0];position.left=this.containment?(!(left<this.containment[0]||left>this.containment[2])?left:(!(left<this.containment[0])?left-o.grid[0]:left+o.grid[0])):left;}
return position;},mouseDrag:function(e){this.position=this.generatePosition(e);this.positionAbs=this.convertPositionTo("absolute");this.position=this.propagate("drag",e)||this.position;if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+'px';if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+'px';if($.ui.ddmanager)$.ui.ddmanager.drag(this,e);return false;},mouseStop:function(e){if($.ui.ddmanager&&!this.options.dropBehaviour)
$.ui.ddmanager.drop(this,e);if(this.options.revert){var self=this;$(this.helper).animate(this.originalPosition,parseInt(this.options.revert,10)||500,function(){self.propagate("stop",e);self.clear();});}else{this.propagate("stop",e);this.clear();}
return false;},clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.options.helper!='original'&&!this.cancelHelperRemoval)this.helper.remove();this.helper=null;this.cancelHelperRemoval=false;},plugins:{},uiHash:function(e){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,options:this.options};},propagate:function(n,e){$.ui.plugin.call(this,n,[e,this.uiHash()]);return this.element.triggerHandler(n=="drag"?n:"drag"+n,[e,this.uiHash()],this.options[n]);},destroy:function(){if(!this.element.data('draggable'))return;this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable');this.mouseDestroy();}}));$.extend($.ui.draggable,{defaults:{appendTo:"parent",axis:false,cancel:":input",delay:0,distance:1,helper:"original"}});$.ui.plugin.add("draggable","cursor",{start:function(e,ui){var t=$('body');if(t.css("cursor"))ui.options._cursor=t.css("cursor");t.css("cursor",ui.options.cursor);},stop:function(e,ui){if(ui.options._cursor)$('body').css("cursor",ui.options._cursor);}});$.ui.plugin.add("draggable","zIndex",{start:function(e,ui){var t=$(ui.helper);if(t.css("zIndex"))ui.options._zIndex=t.css("zIndex");t.css('zIndex',ui.options.zIndex);},stop:function(e,ui){if(ui.options._zIndex)$(ui.helper).css('zIndex',ui.options._zIndex);}});$.ui.plugin.add("draggable","opacity",{start:function(e,ui){var t=$(ui.helper);if(t.css("opacity"))ui.options._opacity=t.css("opacity");t.css('opacity',ui.options.opacity);},stop:function(e,ui){if(ui.options._opacity)$(ui.helper).css('opacity',ui.options._opacity);}});$.ui.plugin.add("draggable","iframeFix",{start:function(e,ui){$(ui.options.iframeFix===true?"iframe":ui.options.iframeFix).each(function(){$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css($(this).offset()).appendTo("body");});},stop:function(e,ui){$("div.DragDropIframeFix").each(function(){this.parentNode.removeChild(this);});}});$.ui.plugin.add("draggable","scroll",{start:function(e,ui){var o=ui.options;var i=$(this).data("draggable");o.scrollSensitivity=o.scrollSensitivity||20;o.scrollSpeed=o.scrollSpeed||20;i.overflowY=function(el){do{if(/auto|scroll/.test(el.css('overflow'))||(/auto|scroll/).test(el.css('overflow-y')))return el;el=el.parent();}while(el[0].parentNode);return $(document);}(this);i.overflowX=function(el){do{if(/auto|scroll/.test(el.css('overflow'))||(/auto|scroll/).test(el.css('overflow-x')))return el;el=el.parent();}while(el[0].parentNode);return $(document);}(this);if(i.overflowY[0]!=document&&i.overflowY[0].tagName!='HTML')i.overflowYOffset=i.overflowY.offset();if(i.overflowX[0]!=document&&i.overflowX[0].tagName!='HTML')i.overflowXOffset=i.overflowX.offset();},drag:function(e,ui){var o=ui.options;var i=$(this).data("draggable");if(i.overflowY[0]!=document&&i.overflowY[0].tagName!='HTML'){if((i.overflowYOffset.top+i.overflowY[0].offsetHeight)-e.pageY<o.scrollSensitivity)
i.overflowY[0].scrollTop=i.overflowY[0].scrollTop+o.scrollSpeed;if(e.pageY-i.overflowYOffset.top<o.scrollSensitivity)
i.overflowY[0].scrollTop=i.overflowY[0].scrollTop-o.scrollSpeed;}else{if(e.pageY-$(document).scrollTop()<o.scrollSensitivity)
$(document).scrollTop($(document).scrollTop()-o.scrollSpeed);if($(window).height()-(e.pageY-$(document).scrollTop())<o.scrollSensitivity)
$(document).scrollTop($(document).scrollTop()+o.scrollSpeed);}
if(i.overflowX[0]!=document&&i.overflowX[0].tagName!='HTML'){if((i.overflowXOffset.left+i.overflowX[0].offsetWidth)-e.pageX<o.scrollSensitivity)
i.overflowX[0].scrollLeft=i.overflowX[0].scrollLeft+o.scrollSpeed;if(e.pageX-i.overflowXOffset.left<o.scrollSensitivity)
i.overflowX[0].scrollLeft=i.overflowX[0].scrollLeft-o.scrollSpeed;}else{if(e.pageX-$(document).scrollLeft()<o.scrollSensitivity)
$(document).scrollLeft($(document).scrollLeft()-o.scrollSpeed);if($(window).width()-(e.pageX-$(document).scrollLeft())<o.scrollSensitivity)
$(document).scrollLeft($(document).scrollLeft()+o.scrollSpeed);}}});$.ui.plugin.add("draggable","snap",{start:function(e,ui){var inst=$(this).data("draggable");inst.snapElements=[];$(ui.options.snap===true?'.ui-draggable':ui.options.snap).each(function(){var $t=$(this);var $o=$t.offset();if(this!=inst.element[0])inst.snapElements.push({item:this,width:$t.outerWidth(),height:$t.outerHeight(),top:$o.top,left:$o.left});});},drag:function(e,ui){var inst=$(this).data("draggable");var d=ui.options.snapTolerance||20;var x1=ui.absolutePosition.left,x2=x1+inst.helperProportions.width,y1=ui.absolutePosition.top,y2=y1+inst.helperProportions.height;for(var i=inst.snapElements.length-1;i>=0;i--){var l=inst.snapElements[i].left,r=l+inst.snapElements[i].width,t=inst.snapElements[i].top,b=t+inst.snapElements[i].height;if(!((l-d<x1&&x1<r+d&&t-d<y1&&y1<b+d)||(l-d<x1&&x1<r+d&&t-d<y2&&y2<b+d)||(l-d<x2&&x2<r+d&&t-d<y1&&y1<b+d)||(l-d<x2&&x2<r+d&&t-d<y2&&y2<b+d)))continue;if(ui.options.snapMode!='inner'){var ts=Math.abs(t-y2)<=20;var bs=Math.abs(b-y1)<=20;var ls=Math.abs(l-x2)<=20;var rs=Math.abs(r-x1)<=20;if(ts)ui.position.top=inst.convertPositionTo("relative",{top:t-inst.helperProportions.height,left:0}).top;if(bs)ui.position.top=inst.convertPositionTo("relative",{top:b,left:0}).top;if(ls)ui.position.left=inst.convertPositionTo("relative",{top:0,left:l-inst.helperProportions.width}).left;if(rs)ui.position.left=inst.convertPositionTo("relative",{top:0,left:r}).left;}
if(ui.options.snapMode!='outer'){var ts=Math.abs(t-y1)<=20;var bs=Math.abs(b-y2)<=20;var ls=Math.abs(l-x1)<=20;var rs=Math.abs(r-x2)<=20;if(ts)ui.position.top=inst.convertPositionTo("relative",{top:t,left:0}).top;if(bs)ui.position.top=inst.convertPositionTo("relative",{top:b-inst.helperProportions.height,left:0}).top;if(ls)ui.position.left=inst.convertPositionTo("relative",{top:0,left:l}).left;if(rs)ui.position.left=inst.convertPositionTo("relative",{top:0,left:r-inst.helperProportions.width}).left;}};}});$.ui.plugin.add("draggable","connectToSortable",{start:function(e,ui){var inst=$(this).data("draggable");inst.sortables=[];$(ui.options.connectToSortable).each(function(){if($.data(this,'sortable')){var sortable=$.data(this,'sortable');inst.sortables.push({instance:sortable,shouldRevert:sortable.options.revert});sortable.refreshItems();sortable.propagate("activate",e,inst);}});},stop:function(e,ui){var inst=$(this).data("draggable");$.each(inst.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;inst.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance.mouseStop(e);this.instance.element.triggerHandler("sortreceive",[e,$.extend(this.instance.ui(),{sender:inst.element})],this.instance.options["receive"]);this.instance.options.helper=this.instance.options._helper;}else{this.instance.propagate("deactivate",e,inst);}});},drag:function(e,ui){var inst=$(this).data("draggable"),self=this;var checkPos=function(o){var l=o.left,r=l+o.width,t=o.top,b=t+o.height;return(l<(this.positionAbs.left+this.offset.click.left)&&(this.positionAbs.left+this.offset.click.left)<r&&t<(this.positionAbs.top+this.offset.click.top)&&(this.positionAbs.top+this.offset.click.top)<b);};$.each(inst.sortables,function(i){if(checkPos.call(inst,this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=$(self).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return ui.helper[0];};e.target=this.instance.currentItem[0];this.instance.mouseCapture(e,true);this.instance.mouseStart(e,true,true);this.instance.offset.click.top=inst.offset.click.top;this.instance.offset.click.left=inst.offset.click.left;this.instance.offset.parent.left-=inst.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=inst.offset.parent.top-this.instance.offset.parent.top;inst.propagate("toSortable",e);}
if(this.instance.currentItem)this.instance.mouseDrag(e);}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance.mouseStop(e,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder)this.instance.placeholder.remove();inst.propagate("fromSortable",e);}};});}});$.ui.plugin.add("draggable","stack",{start:function(e,ui){var group=$.makeArray($(ui.options.stack.group)).sort(function(a,b){return(parseInt($(a).css("zIndex"),10)||ui.options.stack.min)-(parseInt($(b).css("zIndex"),10)||ui.options.stack.min);});$(group).each(function(i){this.style.zIndex=ui.options.stack.min+i;});this[0].style.zIndex=ui.options.stack.min+group.length;}});})(jQuery);(function($){$.widget("ui.resizable",$.extend($.ui.mouse,{init:function(){var self=this,o=this.options;var elpos=this.element.css('position');this.originalElement=this.element;this.element.addClass("ui-resizable").css({position:/static/.test(elpos)?'relative':elpos});$.extend(o,{_aspectRatio:!!(o.aspectRatio),helper:o.helper||o.ghost||o.animate?o.helper||'proxy':null,knobHandles:o.knobHandles===true?'ui-resizable-knob-handle':o.knobHandles});var aBorder='1px solid #DEDEDE';o.defaultTheme={'ui-resizable':{display:'block'},'ui-resizable-handle':{position:'absolute',background:'#F2F2F2',fontSize:'0.1px'},'ui-resizable-n':{cursor:'n-resize',height:'4px',left:'0px',right:'0px',borderTop:aBorder},'ui-resizable-s':{cursor:'s-resize',height:'4px',left:'0px',right:'0px',borderBottom:aBorder},'ui-resizable-e':{cursor:'e-resize',width:'4px',top:'0px',bottom:'0px',borderRight:aBorder},'ui-resizable-w':{cursor:'w-resize',width:'4px',top:'0px',bottom:'0px',borderLeft:aBorder},'ui-resizable-se':{cursor:'se-resize',width:'4px',height:'4px',borderRight:aBorder,borderBottom:aBorder},'ui-resizable-sw':{cursor:'sw-resize',width:'4px',height:'4px',borderBottom:aBorder,borderLeft:aBorder},'ui-resizable-ne':{cursor:'ne-resize',width:'4px',height:'4px',borderRight:aBorder,borderTop:aBorder},'ui-resizable-nw':{cursor:'nw-resize',width:'4px',height:'4px',borderLeft:aBorder,borderTop:aBorder}};o.knobTheme={'ui-resizable-handle':{background:'#F2F2F2',border:'1px solid #808080',height:'8px',width:'8px'},'ui-resizable-n':{cursor:'n-resize',top:'0px',left:'45%'},'ui-resizable-s':{cursor:'s-resize',bottom:'0px',left:'45%'},'ui-resizable-e':{cursor:'e-resize',right:'0px',top:'45%'},'ui-resizable-w':{cursor:'w-resize',left:'0px',top:'45%'},'ui-resizable-se':{cursor:'se-resize',right:'0px',bottom:'0px'},'ui-resizable-sw':{cursor:'sw-resize',left:'0px',bottom:'0px'},'ui-resizable-nw':{cursor:'nw-resize',left:'0px',top:'0px'},'ui-resizable-ne':{cursor:'ne-resize',right:'0px',top:'0px'}};o._nodeName=this.element[0].nodeName;if(o._nodeName.match(/canvas|textarea|input|select|button|img/i)){var el=this.element;if(/relative/.test(el.css('position'))&&$.browser.opera)
el.css({position:'relative',top:'auto',left:'auto'});el.wrap($('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:el.css('position'),width:el.outerWidth(),height:el.outerHeight(),top:el.css('top'),left:el.css('left')}));var oel=this.element;this.element=this.element.parent();this.element.data('resizable',this);this.element.css({marginLeft:oel.css("marginLeft"),marginTop:oel.css("marginTop"),marginRight:oel.css("marginRight"),marginBottom:oel.css("marginBottom")});oel.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});if($.browser.safari&&o.preventDefault)oel.css('resize','none');o.proportionallyResize=oel.css({position:'static',zoom:1,display:'block'});this.element.css({margin:oel.css('margin')});this._proportionallyResize();}
if(!o.handles)o.handles=!$('.ui-resizable-handle',this.element).length?"e,s,se":{n:'.ui-resizable-n',e:'.ui-resizable-e',s:'.ui-resizable-s',w:'.ui-resizable-w',se:'.ui-resizable-se',sw:'.ui-resizable-sw',ne:'.ui-resizable-ne',nw:'.ui-resizable-nw'};if(o.handles.constructor==String){o.zIndex=o.zIndex||1000;if(o.handles=='all')o.handles='n,e,s,w,se,sw,ne,nw';var n=o.handles.split(",");o.handles={};var insertionsDefault={handle:'position: absolute; display: none; overflow:hidden;',n:'top: 0pt; width:100%;',e:'right: 0pt; height:100%;',s:'bottom: 0pt; width:100%;',w:'left: 0pt; height:100%;',se:'bottom: 0pt; right: 0px;',sw:'bottom: 0pt; left: 0px;',ne:'top: 0pt; right: 0px;',nw:'top: 0pt; left: 0px;'};for(var i=0;i<n.length;i++){var handle=$.trim(n[i]),dt=o.defaultTheme,hname='ui-resizable-'+handle,loadDefault=!$.ui.css(hname)&&!o.knobHandles,userKnobClass=$.ui.css('ui-resizable-knob-handle'),allDefTheme=$.extend(dt[hname],dt['ui-resizable-handle']),allKnobTheme=$.extend(o.knobTheme[hname],!userKnobClass?o.knobTheme['ui-resizable-handle']:{});var applyZIndex=/sw|se|ne|nw/.test(handle)?{zIndex:++o.zIndex}:{};var defCss=(loadDefault?insertionsDefault[handle]:''),axis=$(['<div class="ui-resizable-handle ',hname,'" style="',defCss,insertionsDefault.handle,'"></div>'].join('')).css(applyZIndex);o.handles[handle]='.ui-resizable-'+handle;this.element.append(axis.css(loadDefault?allDefTheme:{}).css(o.knobHandles?allKnobTheme:{}).addClass(o.knobHandles?'ui-resizable-knob-handle':'').addClass(o.knobHandles));}
if(o.knobHandles)this.element.addClass('ui-resizable-knob').css(!$.ui.css('ui-resizable-knob')?{}:{});}
this._renderAxis=function(target){target=target||this.element;for(var i in o.handles){if(o.handles[i].constructor==String)
o.handles[i]=$(o.handles[i],this.element).show();if(o.transparent)
o.handles[i].css({opacity:0});if(this.element.is('.ui-wrapper')&&o._nodeName.match(/textarea|input|select|button/i)){var axis=$(o.handles[i],this.element),padWrapper=0;padWrapper=/sw|ne|nw|se|n|s/.test(i)?axis.outerHeight():axis.outerWidth();var padPos=['padding',/ne|nw|n/.test(i)?'Top':/se|sw|s/.test(i)?'Bottom':/^e$/.test(i)?'Right':'Left'].join("");if(!o.transparent)
target.css(padPos,padWrapper);this._proportionallyResize();}
if(!$(o.handles[i]).length)continue;}};this._renderAxis(this.element);o._handles=$('.ui-resizable-handle',self.element);if(o.disableSelection)
o._handles.each(function(i,e){$.ui.disableSelection(e);});o._handles.mouseover(function(){if(!o.resizing){if(this.className)
var axis=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);self.axis=o.axis=axis&&axis[1]?axis[1]:'se';}});if(o.autoHide){o._handles.hide();$(self.element).addClass("ui-resizable-autohide").hover(function(){$(this).removeClass("ui-resizable-autohide");o._handles.show();},function(){if(!o.resizing){$(this).addClass("ui-resizable-autohide");o._handles.hide();}});}
this.mouseInit();},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,options:this.options,originalSize:this.originalSize,originalPosition:this.originalPosition};},propagate:function(n,e){$.ui.plugin.call(this,n,[e,this.ui()]);if(n!="resize")this.element.triggerHandler(["resize",n].join(""),[e,this.ui()],this.options[n]);},destroy:function(){var el=this.element,wrapped=el.children(".ui-resizable").get(0);this.mouseDestroy();var _destroy=function(exp){$(exp).removeClass("ui-resizable ui-resizable-disabled").removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();};_destroy(el);if(el.is('.ui-wrapper')&&wrapped){el.parent().append($(wrapped).css({position:el.css('position'),width:el.outerWidth(),height:el.outerHeight(),top:el.css('top'),left:el.css('left')})).end().remove();_destroy(wrapped);}},mouseStart:function(e){if(this.options.disabled)return false;var handle=false;for(var i in this.options.handles){if($(this.options.handles[i])[0]==e.target)handle=true;}
if(!handle)return false;var o=this.options,iniPos=this.element.position(),el=this.element,num=function(v){return parseInt(v,10)||0;},ie6=$.browser.msie&&$.browser.version<7;o.resizing=true;o.documentScroll={top:$(document).scrollTop(),left:$(document).scrollLeft()};if(el.is('.ui-draggable')||(/absolute/).test(el.css('position'))){var sOffset=$.browser.msie&&!o.containment&&(/absolute/).test(el.css('position'))&&!(/relative/).test(el.parent().css('position'));var dscrollt=sOffset?o.documentScroll.top:0,dscrolll=sOffset?o.documentScroll.left:0;el.css({position:'absolute',top:(iniPos.top+dscrollt),left:(iniPos.left+dscrolll)});}
if($.browser.opera&&/relative/.test(el.css('position')))
el.css({position:'relative',top:'auto',left:'auto'});this._renderProxy();var curleft=num(this.helper.css('left')),curtop=num(this.helper.css('top'));this.offset=this.helper.offset();this.position={left:curleft,top:curtop};this.size=o.helper||ie6?{width:el.outerWidth(),height:el.outerHeight()}:{width:el.width(),height:el.height()};this.originalSize=o.helper||ie6?{width:el.outerWidth(),height:el.outerHeight()}:{width:el.width(),height:el.height()};this.originalPosition={left:curleft,top:curtop};this.sizeDiff={width:el.outerWidth()-el.width(),height:el.outerHeight()-el.height()};this.originalMousePosition={left:e.pageX,top:e.pageY};o.aspectRatio=(typeof o.aspectRatio=='number')?o.aspectRatio:((this.originalSize.height/this.originalSize.width)||1);if(o.preserveCursor)
$('body').css('cursor',this.axis+'-resize');this.propagate("start",e);return true;},mouseDrag:function(e){var el=this.helper,o=this.options,props={},self=this,smp=this.originalMousePosition,a=this.axis;var dx=(e.pageX-smp.left)||0,dy=(e.pageY-smp.top)||0;var trigger=this._change[a];if(!trigger)return false;var data=trigger.apply(this,[e,dx,dy]),ie6=$.browser.msie&&$.browser.version<7,csdif=this.sizeDiff;if(o._aspectRatio||e.shiftKey)
data=this._updateRatio(data,e);data=this._respectSize(data,e);this.propagate("resize",e);el.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!o.helper&&o.proportionallyResize)
this._proportionallyResize();this._updateCache(data);this.element.triggerHandler("resize",[e,this.ui()],this.options["resize"]);return false;},mouseStop:function(e){this.options.resizing=false;var o=this.options,num=function(v){return parseInt(v,10)||0;},self=this;if(o.helper){var pr=o.proportionallyResize,ista=pr&&(/textarea/i).test(pr.get(0).nodeName),soffseth=ista&&$.ui.hasScroll(pr.get(0),'left')?0:self.sizeDiff.height,soffsetw=ista?0:self.sizeDiff.width;var s={width:(self.size.width-soffsetw),height:(self.size.height-soffseth)},left=(parseInt(self.element.css('left'),10)+(self.position.left-self.originalPosition.left))||null,top=(parseInt(self.element.css('top'),10)+(self.position.top-self.originalPosition.top))||null;if(!o.animate)
this.element.css($.extend(s,{top:top,left:left}));if(o.helper&&!o.animate)this._proportionallyResize();}
if(o.preserveCursor)
$('body').css('cursor','auto');this.propagate("stop",e);if(o.helper)this.helper.remove();return false;},_updateCache:function(data){var o=this.options;this.offset=this.helper.offset();if(data.left)this.position.left=data.left;if(data.top)this.position.top=data.top;if(data.height)this.size.height=data.height;if(data.width)this.size.width=data.width;},_updateRatio:function(data,e){var o=this.options,cpos=this.position,csize=this.size,a=this.axis;if(data.height)data.width=(csize.height/o.aspectRatio);else if(data.width)data.height=(csize.width*o.aspectRatio);if(a=='sw'){data.left=cpos.left+(csize.width-data.width);data.top=null;}
if(a=='nw'){data.top=cpos.top+(csize.height-data.height);data.left=cpos.left+(csize.width-data.width);}
return data;},_respectSize:function(data,e){var el=this.helper,o=this.options,pRatio=o._aspectRatio||e.shiftKey,a=this.axis,ismaxw=data.width&&o.maxWidth&&o.maxWidth<data.width,ismaxh=data.height&&o.maxHeight&&o.maxHeight<data.height,isminw=data.width&&o.minWidth&&o.minWidth>data.width,isminh=data.height&&o.minHeight&&o.minHeight>data.height;if(isminw)data.width=o.minWidth;if(isminh)data.height=o.minHeight;if(ismaxw)data.width=o.maxWidth;if(ismaxh)data.height=o.maxHeight;var dw=this.originalPosition.left+this.originalSize.width,dh=this.position.top+this.size.height;var cw=/sw|nw|w/.test(a),ch=/nw|ne|n/.test(a);if(isminw&&cw)data.left=dw-o.minWidth;if(ismaxw&&cw)data.left=dw-o.maxWidth;if(isminh&&ch)data.top=dh-o.minHeight;if(ismaxh&&ch)data.top=dh-o.maxHeight;var isNotwh=!data.width&&!data.height;if(isNotwh&&!data.left&&data.top)data.top=null;else if(isNotwh&&!data.top&&data.left)data.left=null;return data;},_proportionallyResize:function(){var o=this.options;if(!o.proportionallyResize)return;var prel=o.proportionallyResize,el=this.helper||this.element;if(!o.borderDif){var b=[prel.css('borderTopWidth'),prel.css('borderRightWidth'),prel.css('borderBottomWidth'),prel.css('borderLeftWidth')],p=[prel.css('paddingTop'),prel.css('paddingRight'),prel.css('paddingBottom'),prel.css('paddingLeft')];o.borderDif=$.map(b,function(v,i){var border=parseInt(v,10)||0,padding=parseInt(p[i],10)||0;return border+padding;});}
prel.css({height:(el.height()-o.borderDif[0]-o.borderDif[2])+"px",width:(el.width()-o.borderDif[1]-o.borderDif[3])+"px"});},_renderProxy:function(){var el=this.element,o=this.options;this.elementOffset=el.offset();if(o.helper){this.helper=this.helper||$('<div style="overflow:hidden;"></div>');var ie6=$.browser.msie&&$.browser.version<7,ie6offset=(ie6?1:0),pxyoffset=(ie6?2:-1);this.helper.addClass(o.helper).css({width:el.outerWidth()+pxyoffset,height:el.outerHeight()+pxyoffset,position:'absolute',left:this.elementOffset.left-ie6offset+'px',top:this.elementOffset.top-ie6offset+'px',zIndex:++o.zIndex});this.helper.appendTo("body");if(o.disableSelection)
$.ui.disableSelection(this.helper.get(0));}else{this.helper=el;}},_change:{e:function(e,dx,dy){return{width:this.originalSize.width+dx};},w:function(e,dx,dy){var o=this.options,cs=this.originalSize,sp=this.originalPosition;return{left:sp.left+dx,width:cs.width-dx};},n:function(e,dx,dy){var o=this.options,cs=this.originalSize,sp=this.originalPosition;return{top:sp.top+dy,height:cs.height-dy};},s:function(e,dx,dy){return{height:this.originalSize.height+dy};},se:function(e,dx,dy){return $.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,dx,dy]));},sw:function(e,dx,dy){return $.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,dx,dy]));},ne:function(e,dx,dy){return $.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,dx,dy]));},nw:function(e,dx,dy){return $.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,dx,dy]));}}}));$.extend($.ui.resizable,{defaults:{cancel:":input",distance:1,delay:0,preventDefault:true,transparent:false,minWidth:10,minHeight:10,aspectRatio:false,disableSelection:true,preserveCursor:true,autoHide:false,knobHandles:false}});$.ui.plugin.add("resizable","containment",{start:function(e,ui){var o=ui.options,self=$(this).data("resizable"),el=self.element;var oc=o.containment,ce=(oc instanceof $)?oc.get(0):(/parent/.test(oc))?el.parent().get(0):oc;if(!ce)return;self.containerElement=$(ce);if(/document/.test(oc)||oc==document){self.containerOffset={left:0,top:0};self.containerPosition={left:0,top:0};self.parentData={element:$(document),left:0,top:0,width:$(document).width(),height:$(document).height()||document.body.parentNode.scrollHeight};}
else{self.containerOffset=$(ce).offset();self.containerPosition=$(ce).position();self.containerSize={height:$(ce).innerHeight(),width:$(ce).innerWidth()};var co=self.containerOffset,ch=self.containerSize.height,cw=self.containerSize.width,width=($.ui.hasScroll(ce,"left")?ce.scrollWidth:cw),height=($.ui.hasScroll(ce)?ce.scrollHeight:ch);self.parentData={element:ce,left:co.left,top:co.top,width:width,height:height};}},resize:function(e,ui){var o=ui.options,self=$(this).data("resizable"),ps=self.containerSize,co=self.containerOffset,cs=self.size,cp=self.position,pRatio=o._aspectRatio||e.shiftKey,cop={top:0,left:0},ce=self.containerElement;if(ce[0]!=document&&/static/.test(ce.css('position')))
cop=self.containerPosition;if(cp.left<(o.helper?co.left:cop.left)){self.size.width=self.size.width+(o.helper?(self.position.left-co.left):(self.position.left-cop.left));if(pRatio)self.size.height=self.size.width*o.aspectRatio;self.position.left=o.helper?co.left:cop.left;}
if(cp.top<(o.helper?co.top:0)){self.size.height=self.size.height+(o.helper?(self.position.top-co.top):self.position.top);if(pRatio)self.size.width=self.size.height/o.aspectRatio;self.position.top=o.helper?co.top:0;}
var woset=(o.helper?self.offset.left-co.left:(self.position.left-cop.left))+self.sizeDiff.width,hoset=(o.helper?self.offset.top-co.top:self.position.top)+self.sizeDiff.height;if(woset+self.size.width>=self.parentData.width){self.size.width=self.parentData.width-woset;if(pRatio)self.size.height=self.size.width*o.aspectRatio;}
if(hoset+self.size.height>=self.parentData.height){self.size.height=self.parentData.height-hoset;if(pRatio)self.size.width=self.size.height/o.aspectRatio;}},stop:function(e,ui){var o=ui.options,self=$(this).data("resizable"),cp=self.position,co=self.containerOffset,cop=self.containerPosition,ce=self.containerElement;var helper=$(self.helper),ho=helper.offset(),w=helper.innerWidth(),h=helper.innerHeight();if(o.helper&&!o.animate&&/relative/.test(ce.css('position')))
$(this).css({left:(ho.left-co.left),top:(ho.top-co.top),width:w,height:h});if(o.helper&&!o.animate&&/static/.test(ce.css('position')))
$(this).css({left:cop.left+(ho.left-co.left),top:cop.top+(ho.top-co.top),width:w,height:h});}});$.ui.plugin.add("resizable","grid",{resize:function(e,ui){var o=ui.options,self=$(this).data("resizable"),cs=self.size,os=self.originalSize,op=self.originalPosition,a=self.axis,ratio=o._aspectRatio||e.shiftKey;o.grid=typeof o.grid=="number"?[o.grid,o.grid]:o.grid;var ox=Math.round((cs.width-os.width)/(o.grid[0]||1))*(o.grid[0]||1),oy=Math.round((cs.height-os.height)/(o.grid[1]||1))*(o.grid[1]||1);if(/^(se|s|e)$/.test(a)){self.size.width=os.width+ox;self.size.height=os.height+oy;}
else if(/^(ne)$/.test(a)){self.size.width=os.width+ox;self.size.height=os.height+oy;self.position.top=op.top-oy;}
else if(/^(sw)$/.test(a)){self.size.width=os.width+ox;self.size.height=os.height+oy;self.position.left=op.left-ox;}
else{self.size.width=os.width+ox;self.size.height=os.height+oy;self.position.top=op.top-oy;self.position.left=op.left-ox;}}});$.ui.plugin.add("resizable","animate",{stop:function(e,ui){var o=ui.options,self=$(this).data("resizable");var pr=o.proportionallyResize,ista=pr&&(/textarea/i).test(pr.get(0).nodeName),soffseth=ista&&$.ui.hasScroll(pr.get(0),'left')?0:self.sizeDiff.height,soffsetw=ista?0:self.sizeDiff.width;var style={width:(self.size.width-soffsetw),height:(self.size.height-soffseth)},left=(parseInt(self.element.css('left'),10)+(self.position.left-self.originalPosition.left))||null,top=(parseInt(self.element.css('top'),10)+(self.position.top-self.originalPosition.top))||null;self.element.animate($.extend(style,top&&left?{top:top,left:left}:{}),{duration:o.animateDuration||"slow",easing:o.animateEasing||"swing",step:function(){var data={width:parseInt(self.element.css('width'),10),height:parseInt(self.element.css('height'),10),top:parseInt(self.element.css('top'),10),left:parseInt(self.element.css('left'),10)};if(pr)pr.css({width:data.width,height:data.height});self._updateCache(data);self.propagate("animate",e);}});}});$.ui.plugin.add("resizable","ghost",{start:function(e,ui){var o=ui.options,self=$(this).data("resizable"),pr=o.proportionallyResize,cs=self.size;if(!pr)self.ghost=self.element.clone();else self.ghost=pr.clone();self.ghost.css({opacity:.25,display:'block',position:'relative',height:cs.height,width:cs.width,margin:0,left:0,top:0}).addClass('ui-resizable-ghost').addClass(typeof o.ghost=='string'?o.ghost:'');self.ghost.appendTo(self.helper);},resize:function(e,ui){var o=ui.options,self=$(this).data("resizable"),pr=o.proportionallyResize;if(self.ghost)self.ghost.css({position:'relative',height:self.size.height,width:self.size.width});},stop:function(e,ui){var o=ui.options,self=$(this).data("resizable"),pr=o.proportionallyResize;if(self.ghost&&self.helper)self.helper.get(0).removeChild(self.ghost.get(0));}});$.ui.plugin.add("resizable","alsoResize",{start:function(e,ui){var o=ui.options,self=$(this).data("resizable"),_store=function(exp){$(exp).each(function(){$(this).data("resizable-alsoresize",{width:parseInt($(this).width(),10),height:parseInt($(this).height(),10),left:parseInt($(this).css('left'),10),top:parseInt($(this).css('top'),10)});});};if(typeof(o.alsoResize)=='object'){if(o.alsoResize.length){o.alsoResize=o.alsoResize[0];_store(o.alsoResize);}
else{$.each(o.alsoResize,function(exp,c){_store(exp);});}}else{_store(o.alsoResize);}},resize:function(e,ui){var o=ui.options,self=$(this).data("resizable"),os=self.originalSize,op=self.originalPosition;var delta={height:(self.size.height-os.height)||0,width:(self.size.width-os.width)||0,top:(self.position.top-op.top)||0,left:(self.position.left-op.left)||0},_alsoResize=function(exp,c){$(exp).each(function(){var start=$(this).data("resizable-alsoresize"),style={},css=c&&c.length?c:['width','height','top','left'];$.each(css||['width','height','top','left'],function(i,prop){var sum=(start[prop]||0)+(delta[prop]||0);if(sum&&sum>=0)
style[prop]=sum||null;});$(this).css(style);});};if(typeof(o.alsoResize)=='object'){$.each(o.alsoResize,function(exp,c){_alsoResize(exp,c);});}else{_alsoResize(o.alsoResize);}},stop:function(e,ui){$(this).removeData("resizable-alsoresize-start");}});})(jQuery);var SWFUpload=function(settings){this.initSWFUpload(settings);};SWFUpload.prototype.initSWFUpload=function(settings){try{this.customSettings={};this.settings=settings;this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings();this.loadFlash();this.displayDebugInfo();}catch(ex){delete SWFUpload.instances[this.movieName];throw ex;}};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.1.0";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290};SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5};SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(settingName,defaultValue){this.settings[settingName]=(this.settings[settingName]==undefined)?defaultValue:this.settings[settingName];};this.ensureDefault("upload_url","");this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("requeue_on_error",false);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload_f9.swf");this.ensureDefault("flash_color","#FFFFFF");this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;delete this.ensureDefault;};SWFUpload.prototype.loadFlash=function(){var targetElement,container;if(document.getElementById(this.movieName)!==null){throw"ID "+this.movieName+" is already in use. The Flash Object could not be added";}
targetElement=document.getElementsByTagName("body")[0];if(targetElement==undefined){throw"Could not find the 'body' element.";}
container=document.createElement("div");container.style.width="1px";container.style.height="1px";targetElement.appendChild(container);container.innerHTML=this.getFlashHTML();};SWFUpload.prototype.getFlashHTML=function(){return['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="1" height="1" style="-moz-user-focus: ignore;">','<param name="movie" value="',this.settings.flash_url,'" />','<param name="bgcolor" value="',this.settings.flash_color,'" />','<param name="quality" value="high" />','<param name="menu" value="false" />','<param name="allowScriptAccess" value="always" />','<param name="flashvars" value="'+this.getFlashVars()+'" />','</object>'].join("");};SWFUpload.prototype.getFlashVars=function(){var paramString=this.buildParamString();return["movieName=",encodeURIComponent(this.movieName),"&amp;uploadURL=",encodeURIComponent(this.settings.upload_url),"&amp;useQueryString=",encodeURIComponent(this.settings.use_query_string),"&amp;requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),"&amp;params=",encodeURIComponent(paramString),"&amp;filePostName=",encodeURIComponent(this.settings.file_post_name),"&amp;fileTypes=",encodeURIComponent(this.settings.file_types),"&amp;fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&amp;fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&amp;fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&amp;fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&amp;debugEnabled=",encodeURIComponent(this.settings.debug_enabled)].join("");};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName);}
if(this.movieElement===null){throw"Could not find Flash element";}
return this.movieElement;};SWFUpload.prototype.buildParamString=function(){var postParams=this.settings.post_params;var paramStringPairs=[];if(typeof(postParams)==="object"){for(var name in postParams){if(postParams.hasOwnProperty(name)){paramStringPairs.push(encodeURIComponent(name.toString())+"="+encodeURIComponent(postParams[name].toString()));}}}
return paramStringPairs.join("&amp;");};SWFUpload.prototype.destroy=function(){try{this.stopUpload();var movieElement=null;try{movieElement=this.getMovieElement();}catch(ex){}
if(movieElement!=undefined&&movieElement.parentNode!=undefined&&typeof(movieElement.parentNode.removeChild)==="function"){var container=movieElement.parentNode;if(container!=undefined){container.removeChild(movieElement);if(container.parentNode!=undefined&&typeof(container.parentNode.removeChild)==="function"){container.parentNode.removeChild(container);}}}
SWFUpload.instances[this.movieName]=null;delete SWFUpload.instances[this.movieName];delete this.movieElement;delete this.settings;delete this.customSettings;delete this.eventQueue;delete this.movieName;return true;}catch(ex1){return false;}};SWFUpload.prototype.displayDebugInfo=function(){this.debug(["---SWFUpload Instance Info---\n","Version: ",SWFUpload.version,"\n","Movie Name: ",this.movieName,"\n","Settings:\n","\t","upload_url:             ",this.settings.upload_url,"\n","\t","use_query_string:       ",this.settings.use_query_string.toString(),"\n","\t","file_post_name:         ",this.settings.file_post_name,"\n","\t","post_params:            ",this.settings.post_params.toString(),"\n","\t","file_types:             ",this.settings.file_types,"\n","\t","file_types_description: ",this.settings.file_types_description,"\n","\t","file_size_limit:        ",this.settings.file_size_limit,"\n","\t","file_upload_limit:      ",this.settings.file_upload_limit,"\n","\t","file_queue_limit:       ",this.settings.file_queue_limit,"\n","\t","flash_url:              ",this.settings.flash_url,"\n","\t","flash_color:            ",this.settings.flash_color,"\n","\t","debug:                  ",this.settings.debug.toString(),"\n","\t","custom_settings:        ",this.settings.custom_settings.toString(),"\n","Event Handlers:\n","\t","swfupload_loaded_handler assigned:  ",(typeof(this.settings.swfupload_loaded_handler)==="function").toString(),"\n","\t","file_dialog_start_handler assigned: ",(typeof(this.settings.file_dialog_start_handler)==="function").toString(),"\n","\t","file_queued_handler assigned:       ",(typeof(this.settings.file_queued_handler)==="function").toString(),"\n","\t","file_queue_error_handler assigned:  ",(typeof(this.settings.file_queue_error_handler)==="function").toString(),"\n","\t","upload_start_handler assigned:      ",(typeof(this.settings.upload_start_handler)==="function").toString(),"\n","\t","upload_progress_handler assigned:   ",(typeof(this.settings.upload_progress_handler)==="function").toString(),"\n","\t","upload_error_handler assigned:      ",(typeof(this.settings.upload_error_handler)==="function").toString(),"\n","\t","upload_success_handler assigned:    ",(typeof(this.settings.upload_success_handler)==="function").toString(),"\n","\t","upload_complete_handler assigned:   ",(typeof(this.settings.upload_complete_handler)==="function").toString(),"\n","\t","debug_handler assigned:             ",(typeof(this.settings.debug_handler)==="function").toString(),"\n"].join(""));};SWFUpload.prototype.addSetting=function(name,value,default_value){if(value==undefined){return(this.settings[name]=default_value);}else{return(this.settings[name]=value);}};SWFUpload.prototype.getSetting=function(name){if(this.settings[name]!=undefined){return this.settings[name];}
return"";};SWFUpload.prototype.callFlash=function(functionName,argumentArray){argumentArray=argumentArray||[];var self=this;var callFunction=function(){var movieElement=self.getMovieElement();var returnValue;if(typeof(movieElement[functionName])==="function"){if(argumentArray.length===0){returnValue=movieElement[functionName]();}else if(argumentArray.length===1){returnValue=movieElement[functionName](argumentArray[0]);}else if(argumentArray.length===2){returnValue=movieElement[functionName](argumentArray[0],argumentArray[1]);}else if(argumentArray.length===3){returnValue=movieElement[functionName](argumentArray[0],argumentArray[1],argumentArray[2]);}else{throw"Too many arguments";}
if(returnValue!=undefined&&typeof(returnValue.post)==="object"){returnValue=self.unescapeFilePostParams(returnValue);}
return returnValue;}else{throw"Invalid function name";}};return callFunction();};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile");};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles");};SWFUpload.prototype.startUpload=function(fileID){this.callFlash("StartUpload",[fileID]);};SWFUpload.prototype.cancelUpload=function(fileID){this.callFlash("CancelUpload",[fileID]);};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload");};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats");};SWFUpload.prototype.setStats=function(statsObject){this.callFlash("SetStats",[statsObject]);};SWFUpload.prototype.getFile=function(fileID){if(typeof(fileID)==="number"){return this.callFlash("GetFileByIndex",[fileID]);}else{return this.callFlash("GetFile",[fileID]);}};SWFUpload.prototype.addFileParam=function(fileID,name,value){return this.callFlash("AddFileParam",[fileID,name,value]);};SWFUpload.prototype.removeFileParam=function(fileID,name){this.callFlash("RemoveFileParam",[fileID,name]);};SWFUpload.prototype.setUploadURL=function(url){this.settings.upload_url=url.toString();this.callFlash("SetUploadURL",[url]);};SWFUpload.prototype.setPostParams=function(paramsObject){this.settings.post_params=paramsObject;this.callFlash("SetPostParams",[paramsObject]);};SWFUpload.prototype.addPostParam=function(name,value){this.settings.post_params[name]=value;this.callFlash("SetPostParams",[this.settings.post_params]);};SWFUpload.prototype.removePostParam=function(name){delete this.settings.post_params[name];this.callFlash("SetPostParams",[this.settings.post_params]);};SWFUpload.prototype.setFileTypes=function(types,description){this.settings.file_types=types;this.settings.file_types_description=description;this.callFlash("SetFileTypes",[types,description]);};SWFUpload.prototype.setFileSizeLimit=function(fileSizeLimit){this.settings.file_size_limit=fileSizeLimit;this.callFlash("SetFileSizeLimit",[fileSizeLimit]);};SWFUpload.prototype.setFileUploadLimit=function(fileUploadLimit){this.settings.file_upload_limit=fileUploadLimit;this.callFlash("SetFileUploadLimit",[fileUploadLimit]);};SWFUpload.prototype.setFileQueueLimit=function(fileQueueLimit){this.settings.file_queue_limit=fileQueueLimit;this.callFlash("SetFileQueueLimit",[fileQueueLimit]);};SWFUpload.prototype.setFilePostName=function(filePostName){this.settings.file_post_name=filePostName;this.callFlash("SetFilePostName",[filePostName]);};SWFUpload.prototype.setUseQueryString=function(useQueryString){this.settings.use_query_string=useQueryString;this.callFlash("SetUseQueryString",[useQueryString]);};SWFUpload.prototype.setRequeueOnError=function(requeueOnError){this.settings.requeue_on_error=requeueOnError;this.callFlash("SetRequeueOnError",[requeueOnError]);};SWFUpload.prototype.setDebugEnabled=function(debugEnabled){this.settings.debug_enabled=debugEnabled;this.callFlash("SetDebugEnabled",[debugEnabled]);};SWFUpload.prototype.queueEvent=function(handlerName,argumentArray){if(argumentArray==undefined){argumentArray=[];}else if(!(argumentArray instanceof Array)){argumentArray=[argumentArray];}
var self=this;if(typeof(this.settings[handlerName])==="function"){this.eventQueue.push(function(){this.settings[handlerName].apply(this,argumentArray);});setTimeout(function(){self.executeNextEvent();},0);}else if(this.settings[handlerName]!==null){throw"Event handler "+handlerName+" is unknown or is not a function";}};SWFUpload.prototype.executeNextEvent=function(){var f=this.eventQueue?this.eventQueue.shift():null;if(typeof(f)==="function"){f.apply(this);}};SWFUpload.prototype.unescapeFilePostParams=function(file){var reg=/[$]([0-9a-f]{4})/i;var unescapedPost={};var uk;if(file!=undefined){for(var k in file.post){if(file.post.hasOwnProperty(k)){uk=k;var match;while((match=reg.exec(uk))!==null){uk=uk.replace(match[0],String.fromCharCode(parseInt("0x"+match[1],16)));}
unescapedPost[uk]=file.post[k];}}
file.post=unescapedPost;}
return file;};SWFUpload.prototype.flashReady=function(){var movieElement=this.getMovieElement();if(typeof(movieElement.StartUpload)!=="function"){throw"ExternalInterface methods failed to initialize.";}
this.queueEvent("swfupload_loaded_handler");};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler");};SWFUpload.prototype.fileQueued=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("file_queued_handler",file);};SWFUpload.prototype.fileQueueError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("file_queue_error_handler",[file,errorCode,message]);};SWFUpload.prototype.fileDialogComplete=function(numFilesSelected,numFilesQueued){this.queueEvent("file_dialog_complete_handler",[numFilesSelected,numFilesQueued]);};SWFUpload.prototype.uploadStart=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("return_upload_start_handler",file);};SWFUpload.prototype.returnUploadStart=function(file){var returnValue;if(typeof(this.settings.upload_start_handler)==="function"){file=this.unescapeFilePostParams(file);returnValue=this.settings.upload_start_handler.call(this,file);}else if(this.settings.upload_start_handler!=undefined){throw"upload_start_handler must be a function";}
if(returnValue===undefined){returnValue=true;}
returnValue=!!returnValue;this.callFlash("ReturnUploadStart",[returnValue]);};SWFUpload.prototype.uploadProgress=function(file,bytesComplete,bytesTotal){file=this.unescapeFilePostParams(file);this.queueEvent("upload_progress_handler",[file,bytesComplete,bytesTotal]);};SWFUpload.prototype.uploadError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("upload_error_handler",[file,errorCode,message]);};SWFUpload.prototype.uploadSuccess=function(file,serverData){file=this.unescapeFilePostParams(file);this.queueEvent("upload_success_handler",[file,serverData]);};SWFUpload.prototype.uploadComplete=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("upload_complete_handler",file);};SWFUpload.prototype.debug=function(message){this.queueEvent("debug_handler",message);};SWFUpload.prototype.debugMessage=function(message){if(this.settings.debug){var exceptionMessage,exceptionValues=[];if(typeof(message)==="object"&&typeof(message.name)==="string"&&typeof(message.message)==="string"){for(var key in message){if(message.hasOwnProperty(key)){exceptionValues.push(key+": "+message[key]);}}
exceptionMessage=exceptionValues.join("\n")||"";exceptionValues=exceptionMessage.split("\n");exceptionMessage="EXCEPTION: "+exceptionValues.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(exceptionMessage);}else{SWFUpload.Console.writeLine(message);}}};SWFUpload.Console={};SWFUpload.Console.writeLine=function(message){var console,documentForm;try{console=document.getElementById("SWFUpload_Console");if(!console){documentForm=document.createElement("form");document.getElementsByTagName("body")[0].appendChild(documentForm);console=document.createElement("textarea");console.id="SWFUpload_Console";console.style.fontFamily="monospace";console.setAttribute("wrap","off");console.wrap="off";console.style.overflow="auto";console.style.width="700px";console.style.height="350px";console.style.margin="5px";documentForm.appendChild(console);}
console.value+=message+"\n";console.scrollTop=console.scrollHeight-console.clientHeight;}catch(ex){alert("Exception: "+ex.name+" Message: "+ex.message);}};var SWFUpload;if(typeof(SWFUpload)==="function"){SWFUpload.prototype.initSettings=function(oldInitSettings){return function(){if(typeof(oldInitSettings)==="function"){oldInitSettings.call(this);}
this.refreshCookies(false);};}(SWFUpload.prototype.initSettings);SWFUpload.prototype.refreshCookies=function(sendToFlash){if(sendToFlash===undefined){sendToFlash=true;}
sendToFlash=!!sendToFlash;var postParams=this.settings.post_params;var i,cookieArray=document.cookie.split(';'),caLength=cookieArray.length,c,eqIndex,name,value;for(i=0;i<caLength;i++){c=cookieArray[i];while(c.charAt(0)===" "){c=c.substring(1,c.length);}
eqIndex=c.indexOf("=");if(eqIndex>0){name=c.substring(0,eqIndex);value=c.substring(eqIndex+1);postParams[name]=value;}}
if(sendToFlash){this.setPostParams(postParams);}};}
var SWFUpload;if(typeof(SWFUpload)==="function"){SWFUpload.queue={};SWFUpload.prototype.initSettings=(function(oldInitSettings){return function(){if(typeof(oldInitSettings)==="function"){oldInitSettings.call(this);}
this.customSettings.queue_cancelled_flag=false;this.customSettings.queue_upload_count=0;this.settings.user_upload_complete_handler=this.settings.upload_complete_handler;this.settings.upload_complete_handler=SWFUpload.queue.uploadCompleteHandler;this.settings.queue_complete_handler=this.settings.queue_complete_handler||null;};})(SWFUpload.prototype.initSettings);SWFUpload.prototype.startUpload=function(fileID){this.customSettings.queue_cancelled_flag=false;this.callFlash("StartUpload",false,[fileID]);};SWFUpload.prototype.cancelQueue=function(){this.customSettings.queue_cancelled_flag=true;this.stopUpload();var stats=this.getStats();while(stats.files_queued>0){this.cancelUpload();stats=this.getStats();}};SWFUpload.queue.uploadCompleteHandler=function(file){var user_upload_complete_handler=this.settings.user_upload_complete_handler;var continueUpload;if(file.filestatus===SWFUpload.FILE_STATUS.COMPLETE){this.customSettings.queue_upload_count++;}
if(typeof(user_upload_complete_handler)==="function"){continueUpload=(user_upload_complete_handler.call(this,file)===false)?false:true;}else{continueUpload=true;}
if(continueUpload){var stats=this.getStats();if(stats.files_queued>0&&this.customSettings.queue_cancelled_flag===false){this.startUpload();}else if(this.customSettings.queue_cancelled_flag===false){this.queueEvent("queue_complete_handler",[this.customSettings.queue_upload_count]);this.customSettings.queue_upload_count=0;}else{this.customSettings.queue_cancelled_flag=false;this.customSettings.queue_upload_count=0;}}};}
(function($){$.fn.bgIframe=jQuery.fn.bgiframe=function(s){if(!($.browser.msie&&typeof XMLHttpRequest=='function'))return this;s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+
(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if(!$('iframe.bgiframe',this)[0])
this.insertBefore(document.createElement(html),this.firstChild);});};})(jQuery);jQuery.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=jQuery.extend({},jQuery.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?jQuery.Autocompleter.defaults.delay:10},options);options.highlight=options.highlight||function(value){return value;};return new jQuery.Autocompleter(this[0],options);}});jQuery.Autocompleter=function(input,options){var autocompleter=this;var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var $wrap=$input.parent().addClass(options.wrapClass);if(options.valueField!==false){var $hidden=$('<input type="hidden" name="'+$input.attr('name')+'" />').insertBefore($input);$input.removeAttr('name');var rel={};}
if(options.trigger){var $trigger=$('<div>&nbsp;</div>');$hiddenParent=$input.parents(':hidden');if($hiddenParent.size()>0){var oldHeight=$hiddenParent.css('height');var oldOverflow=$hiddenParent.css('overflow');$hiddenParent.css('height',0).css('overflow','hidden').show();}
createTrigger();if($hiddenParent.size()>0){$hiddenParent.hide().css('height',oldHeight).css('overflow',oldOverflow);}}
var timeout;var previousValue="";var cache=jQuery.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var select=jQuery.Autocompleter.Select(options,input,selectCurrent);var defaultValue=options.selected||$input.val();if(defaultValue){$input.val('');function handleDefaultValue(defaultValue){var selected=cache.findSelected(defaultValue);if(selected){rel[selected.result]={value:selected.data[options.valueField],data:selected.data}
$input.val($input.val()+options.multipleSeparator+selected.result);}}
if(options.multiple){var defaultValues=defaultValue.split($.trim(options.multipleSeparator));$.each(defaultValues,function(i,value){var value=$.trim(value);handleDefaultValue(value);});}else{handleDefaultValue(defaultValue);}
cleanInput(false,true);updateHidden();}
if($input.val()==''){$input.val(options.emptyText).addClass('emptyText');}
if(options.disabled){$input.attr('disabled','disabled');$trigger.hide();}
var currentResults={};this.getResult=function(){cleanInput(options.multiple);return currentResults;}
this.result=function(handler){$input.bind("result",handler);return this;};this.clear=function(){$input.val(!hasFocus?options.emptyText:'');currentResults=[];return this;}
this.search=function(handler){$input.trigger("search",[handler]);return this;};this.flushCache=function(){$input.trigger("flushCache");return this;};this.setOptions=function(options){$input.trigger("setOptions",[options]);return this;};this.showList=function(options){$input.trigger("showList",[options]);return this;};this.focus=function(){$input.focus();return this;}
$input.keydown(function(event){lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}
break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true,true);}
break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(event.keyCode!=KEY.TAB){event.preventDefault();}
if(selectCurrent()){if(!options.multiple&&event.keyCode!=KEY.TAB)
$input.blur();}else if(event.keyCode!=KEY.TAB){cleanInput(options.multiple);}
break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).keypress(function(){}).focus(function(){setTimeout(function(){if($input.val()==options.emptyText){$input.val('').removeClass('emptyText');}},100);hasFocus++;}).blur(function(){hasFocus=0;setTimeout(select.hide,100);if(options.trigger){$trigger.removeClass('active');}}).click(function(){if($input.val()==options.emptyText){$input.val('').removeClass('emptyText');}
if(hasFocus++>1&&!select.visible()){onChange(0,true,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}
if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value,autocompleter]);}
jQuery.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){for(var k in arguments[1]){options[k]=arguments[1][k];if(k=="data")cache.populate();}}).bind("showList",function(){var filter=arguments[1]&&arguments[1].filter||{};if(filter.field&&filter.value){var oldSearchFields=options.searchFields;options.searchFields=[filter.field];request(filter.value,receiveData,hideResultsNow);options.searchFields=oldSearchFields;setTimeout(function(){$input.focus();},100);}});hideResultsNow();function createTrigger(){$input.css('width',$input.innerWidth()-20).css('paddingRight',20-parseInt($input.css('paddingRight')));var position=$input.position();$trigger.addClass(options.triggerClass).appendTo($wrap).css({top:position.top+2,left:position.left+$input.outerWidth()-$trigger.outerWidth()-2}).hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');}).mousedown(function(ev){$input.focus();ev.preventDefault();if(!select.visible()){cleanInput(options.multiple);}
onChange(0,true,true);});}
function selectCurrent(){var selected=select.selected();if(!selected)
return false;$input.trigger("result",[selected.data,selected.value,autocompleter]);var v=selected.result;previousValue=v;if(options.valueField){rel[selected.result]={value:selected.data[options.valueField],data:selected.data};}
if(options.multiple){cleanInput(true);v=$input.val()+v;}
$input.val(v);cleanInput(options.multiple);hideResultsNow();if(options.valueField){updateHidden();}
if(options.onItemSelect)setTimeout(function(){options.onItemSelect()},1);return true;}
function cleanInput(addSeperator,mustMatch){mustMatch=mustMatch||options.mustMatch;addSeperator=addSeperator||false;var values=[];var dup={};var words=trimWords($input.val());var val='';$.each(words,function(i,w){val=!mustMatch?((rel[w]&&rel[w].value)||w):(rel[w]&&rel[w].value);if(val){if(!dup[val]){values.push(w);}
dup[val]=true;}});var vf=values.join(options.multipleSeparator);if((vf!='')&&addSeperator){vf+=options.multipleSeparator;}
$input.val(vf);}
function updateHidden(){var values=[];var words=trimWords($input.val());var val='';var newResults=[];$.each(words,function(i,w){val=!options.mustMatch?((rel[w]&&rel[w].value)||w):(rel[w]&&rel[w].value);if(val){values.push(val);newResults.push(rel[w]&&rel[w].data||w);}});currentResults=newResults;var vf=values.join(options.multipleSeparator);$hidden.val(vf);}
function onChange(crap,skipPrevCheck,fromTrigger){fromTrigger=fromTrigger||false;if(lastKeyPressCode==KEY.DEL){select.hide();return;}
var currentValue=$.trim($input.val());if(!skipPrevCheck&&currentValue==previousValue)
return;previousValue=currentValue;currentValue=lastWord(currentValue,true);if(currentValue.length>options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)
currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else if(fromTrigger){request('*',receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value,addLastEmpty){addLastEmpty=addLastEmpty||false;if(!value){return[""];}
var words=value.split($.trim(options.multipleSeparator));var result=[];$.each(words,function(i,value){if($.trim(value)){result[i]=$.trim(value);}
else if(addLastEmpty&&(value==' '||value=='')){result[i]='';}});return result;}
function lastWord(value,addEmpty){if(!options.multiple)
return value;var words=trimWords(value,true);return words[words.length-1];}
function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=8){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));jQuery.Autocompleter.Selection(input,previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){select.hide();select.reset();if(options.trigger){$trigger.removeClass('active');}
clearTimeout(timeout);stopLoading();};function receiveData(q,data){if(data&&data.length){stopLoading();select.display(data,q);autoFill(q,data[0].result);select.show();if(options.trigger){$trigger.addClass('active');}}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)
term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var params=$.map([lastWord(term),options.max],encodeURI).join('/')+'/';var url=options.url+params;$.getJSON(url,function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);});}else{failure(term);}};function parse(jsonResp){var parsed=[];if(jsonResp.success&&jsonResp.data.results){$.each(jsonResp.data.results,function(i,data){parsed[parsed.length]={data:data,value:options.formatValue&&options.formatValue(data,options.valueField&&data[options.valueField]||data['value'])||options.valueField&&data[options.valueField]||data['value'],formatted:options.formatItem&&options.formatItem(data,options.valueField&&data[options.valueField]||data['value'])||options.valueField&&data[options.valueField]||data['value'],result:options.formatResult&&options.formatResult(data,options.valueField&&data[options.valueField]||data['value'])||options.valueField&&data[options.valueField]||data['value']};});}
return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};jQuery.Autocompleter.defaults={inputClass:'ac-input',resultsClass:'ac-results',loadingClass:'ac-loading',triggerClass:'ac-trigger',wrapClass:'ac-parent',minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:true,selected:false,disabled:false,cacheLength:10,mustMatch:false,extraParams:{},emptyText:'',selectFirst:true,valueField:false,trigger:false,max:0,size:10,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?!<[^<>]*)("+term+")(?![^<>]*>)","gi"),"<strong>$1</strong>");}};jQuery.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)
s=s.toLowerCase();var i=s.indexOf(sub);if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}
if(!data[q]){length++;}
data[q]=value;}
function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];jQuery.each(options.data,function(i,data){var row={data:data,value:options.valueField&&data[options.valueField].toString()||data['value'],formatted:options.formatItem&&options.formatItem(data,options.valueField&&data[options.valueField]||data['value'])||options.valueField&&data[options.valueField].toString()||data['value'],result:options.formatResult&&options.formatResult(data,options.valueField&&data[options.valueField]||data['value'])||options.valueField&&data[options.valueField].toString()||data['value']};var firstChar=row.result.charAt(0).toLowerCase();if(!stMatchSets[firstChar])
stMatchSets[firstChar]=[];stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}});jQuery.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}
populate();function flush(){data={};length=0;}
return{flush:flush,add:add,populate:populate,findSelected:function(val){var selected=false;if(!options.cacheLength||!length)
return null;if(!options.url){for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if((x.value==val)||(x.result==val)){selected=x;return false}});if(selected){return selected;}}}}
return false;},load:function(q){if(!options.cacheLength||!length)
return null;var csub=[];if(q==='*'){for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){csub.push(x);return csub;});}}}
if(!options.url&&options.matchContains){for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){x.value=x.value.replace(/<\/?[^>]+(>|$)/g,"");if(options.searchFields){var searchIn='';$.each(options.searchFields,function(i,field){if(x.data[field]){searchIn+=x.data[field]+' ';}})}
if(matchSubset(searchIn||x.result,q)){csub.push(x);}});}}
return csub;}else
if(data[q]){return data[q];}else
if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];jQuery.each(c,function(i,x){if(options.searchFields){var searchIn='';$.each(options.searchFields,function(i,field){if(x.data[field]){searchIn+=x.data[field]+' ';}})}
if(matchSubset(searchIn||x.result,q)){csub[csub.length]=x;}});return csub;}}}
return null;}};};jQuery.Autocompleter.Select=function(options,input,select){var CLASSES={ACTIVE:"ac-over"};var element=jQuery("<div>").hide().addClass(options.resultsClass).css("position","absolute").appendTo("body");var list=$("<ul>").appendTo(element).mouseover(function(event){active=jQuery("li",list).removeClass().index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}).mouseout(function(event){$(target(event)).removeClass();}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;});var listItems,active=-1,data,term="";if(options.width>0)
element.css("width",options.width);function target(event){var element=event.target;while(element.tagName!="LI")
element=element.parentNode;return element;}
function moveSelect(step){active+=step;wrapSelection();listItems.removeClass().eq(active).addClass(CLASSES.ACTIVE).get(0).scrollIntoView(false);};function wrapSelection(){if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}
function limitNumberOfItems(available){return(options.max>0)&&(options.max<available)?options.max:available;}
function reset(){list.empty();data=[];}
function fillList(){list.empty();active=-1;var num=limitNumberOfItems(data.length);for(var i=0;i<num;i++){if(!data[i])
continue;var formatted=data[i].formatted;$("<li>").html((term==='*')?formatted:options.highlight(formatted,term)).appendTo(list)[0].index=i;}
listItems=list.find("li");if(options.selectFirst){listItems.eq(0).addClass(CLASSES.ACTIVE);active=0;}
list.bgiframe();}
return{display:function(d,q){data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},hide:function(){element.hide();active=-1;},visible:function(){return element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},reset:function(){reset();},show:function(){var offset=$(input).offset();element.show();if(listItems.length>options.size){var listHeight=($(listItems[0]).outerHeight()*options.size)-1;}else{var listHeight=listItems.parent().height()-1;}
element.height(listHeight).hide();var top=offset.top+$(input).outerHeight();if((top+listHeight)>=($(window).height()+$(window).scrollTop())){var newTop=offset.top-listHeight-2;top=(newTop>0)?newTop:top;}
element.css({top:top,left:offset.left,width:typeof options.width=="string"||options.width>0?options.width:$(input).outerWidth()-2}).show();},selected:function(){return data&&listItems&&listItems.filter("."+CLASSES.ACTIVE)[0]&&data[listItems.filter("."+CLASSES.ACTIVE)[0].index];}};};jQuery.Autocompleter.Selection=function(field,start,end){if(field.createTextRange){var selRange=field.createTextRange();selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}else if(field.setSelectionRange){field.setSelectionRange(start,end);}else{if(field.selectionStart){field.selectionStart=start;field.selectionEnd=end;}}
field.focus();};(function($){$.fn.addOption=function()
{var add=function(el,v,t,sO)
{var option=document.createElement("option");option.value=v,option.text=t;var o=el.options;var oL=o.length;if(!el.cache)
{el.cache={};for(var i=0;i<oL;i++)
{el.cache[o[i].value]=i;}}
if(typeof el.cache[v]=="undefined")el.cache[v]=oL;el.options[el.cache[v]]=option;if(sO)
{option.selected=true;}};var a=arguments;if(a.length==0)return this;var sO=true;var m=false;var items,v,t;if(typeof(a[0])=="object")
{m=true;items=a[0];}
if(a.length>=2)
{if(typeof(a[1])=="boolean")sO=a[1];else if(typeof(a[2])=="boolean")sO=a[2];if(!m)
{v=a[0];t=a[1];}}
this.each(function()
{if(this.nodeName.toLowerCase()!="select")return;if(m)
{for(var item in items)
{add(this,item,items[item],sO);}}
else
{add(this,v,t,sO);}});return this;};$.fn.ajaxAddOption=function(url,params,select,fn,args)
{if(typeof(url)!="string")return this;if(typeof(params)!="object")params={};if(typeof(select)!="boolean")select=true;this.each(function()
{var el=this;$.getJSON(url,params,function(r)
{$(el).addOption(r,select);if(typeof fn=="function")
{if(typeof args=="object")
{fn.apply(el,args);}
else
{fn.call(el);}}});});return this;};$.fn.removeOption=function()
{var a=arguments;if(a.length==0)return this;var ta=typeof(a[0]);var v,index;if(ta=="string"||ta=="object"||ta=="function")v=a[0];else if(ta=="number")index=a[0];else return this;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return;if(this.cache)this.cache=null;var remove=false;var o=this.options;if(!!v)
{var oL=o.length;for(var i=oL-1;i>=0;i--)
{if(v.constructor==RegExp)
{if(o[i].value.match(v))
{remove=true;}}
else if(o[i].value==v)
{remove=true;}
if(remove&&a[1]===true)remove=o[i].selected;if(remove)
{o[i]=null;}
remove=false;}}
else
{if(a[1]===true)
{remove=o[index].selected;}
else
{remove=true;}
if(remove)
{this.remove(index);}}});return this;};$.fn.sortOptions=function(ascending)
{var a=typeof(ascending)=="undefined"?true:!!ascending;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return;var o=this.options;var oL=o.length;var sA=[];for(var i=0;i<oL;i++)
{sA[i]={v:o[i].value,t:o[i].text}}
sA.sort(function(o1,o2)
{o1t=o1.t.toLowerCase(),o2t=o2.t.toLowerCase();if(o1t==o2t)return 0;if(a)
{return o1t<o2t?-1:1;}
else
{return o1t>o2t?-1:1;}});for(var i=0;i<oL;i++)
{o[i].text=sA[i].t;o[i].value=sA[i].v;}});return this;};$.fn.selectOptions=function(value,clear)
{var v=value;var vT=typeof(value);var c=clear||false;if(vT!="string"&&vT!="function"&&vT!="object")return this;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return this;var o=this.options;var oL=o.length;for(var i=0;i<oL;i++)
{if(v.constructor==RegExp)
{if(o[i].value.match(v))
{o[i].selected=true;}
else if(c)
{o[i].selected=false;}}
else
{if(o[i].value==v)
{o[i].selected=true;}
else if(c)
{o[i].selected=false;}}}});return this;};$.fn.copyOptions=function(to,which)
{var w=which||"selected";if($(to).size()==0)return this;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return this;var o=this.options;var oL=o.length;for(var i=0;i<oL;i++)
{if(w=="all"||(w=="selected"&&o[i].selected))
{$(to).addOption(o[i].value,o[i].text);}}});return this;};$.fn.containsOption=function(value,fn)
{var found=false;var v=value;var vT=typeof(v);var fT=typeof(fn);if(vT!="string"&&vT!="function"&&vT!="object")return fT=="function"?this:found;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return this;if(found&&fT!="function")return false;var o=this.options;var oL=o.length;for(var i=0;i<oL;i++)
{if(v.constructor==RegExp)
{if(o[i].value.match(v))
{found=true;if(fT=="function")fn.call(o[i]);}}
else
{if(o[i].value==v)
{found=true;if(fT=="function")fn.call(o[i]);}}}});return fT=="function"?this:found;};$.fn.selectedValues=function()
{var v=[];this.find("option:selected").each(function()
{v[v.length]=this.value;});return v;};})(jQuery);(function($)
{$.fn.tooltip=function(opts)
{opts=$.extend({opacity:1,top:20,left:-20,box:null,txt:''},opts);function _create(){if(!opts.box){opts.box=$('<div class="tooltip-box">'+'<div class="tooltip-content">&nbsp;</div>'+'<div class="tooltip-spike"></div>'+'</div>').appendTo('body');opts.box.css('opacity',opts.opacity);}
opts.box.find('div.tooltip-content').html(opts.txt);opts.box.show();}
function _hide(){opts.box.hide();}
function _setPos(element){if(opts.box){opts.box.removeClass('bottom').removeClass('left');var pos=element.offset();var top=pos.top-opts.box.outerHeight()-opts.top;if(top<$(window).scrollTop()){top=pos.top+element.outerHeight()+opts.top;opts.box.addClass('bottom');}
var left=pos.left+element.outerWidth()+opts.left;if((left+opts.box.outerWidth())>($(window).width()+$(window).scrollLeft())){left=pos.left-opts.box.outerWidth()-opts.left;opts.box.addClass('left');}
opts.box.css({top:top,left:left});}
else{setTimeout(function(){_setPos(top,left);},100);}}
return this.each(function(){var self=$(this);self.mouseover(function(){opts.txt=self.attr('title');self.attr('title','');_create();_setPos(self);}).mouseout(function(){self.attr('title',opts.txt);opts.txt='';_hide();})});};}(jQuery));(function($){$.event.special.mousewheel={setup:function(){var handler=$.event.special.mousewheel.handler;if($.browser.mozilla)
$(this).bind('mousemove.mousewheel',function(event){$.data(this,'mwcursorposdata',{pageX:event.pageX,pageY:event.pageY,clientX:event.clientX,clientY:event.clientY});});if(this.addEventListener)
this.addEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
this.onmousewheel=handler;},teardown:function(){var handler=$.event.special.mousewheel.handler;$(this).unbind('mousemove.mousewheel');if(this.removeEventListener)
this.removeEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
this.onmousewheel=function(){};$.removeData(this,'mwcursorposdata');},handler:function(event){var args=Array.prototype.slice.call(arguments,1);event=$.event.fix(event||window.event);$.extend(event,$.data(this,'mwcursorposdata')||{});var delta=0,returnValue=true;if(event.wheelDelta)delta=event.wheelDelta/120;if(event.detail)delta=-event.detail/3;if($.browser.opera)delta=-event.wheelDelta;event.data=event.data||{};event.type="mousewheel";args.unshift(delta);args.unshift(event);return $.event.handle.apply(this,args);}};$.fn.extend({mousewheel:function(fn){return fn?this.bind("mousewheel",fn):this.trigger("mousewheel");},unmousewheel:function(fn){return this.unbind("mousewheel",fn);}});})(jQuery);(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var running=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var div=$(this),ul=$("ul",div),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v;}
var li=$("li",ul),itemLength=li.size(),curr=o.start;div.css("visibility","visible");li.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});div.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var liSize=o.vertical?height(li):width(li);var ulSize=liSize*itemLength;var divSize=liSize*v;ul.css(sizeCss,ulSize+"px").css(animCss,-(curr*liSize));div.css(sizeCss,divSize+"px");if(o.btnPrev)
$(o.btnPrev).click(function(){return go(curr-o.scroll);});if(o.btnNext)
$(o.btnNext).click(function(){return go(curr+o.scroll);});if(o.btnGo)
$.each(o.btnGo,function(i,val){$(val).click(function(){return go(o.circular?o.visible+i:i);});});if(o.mouseWheel&&div.mousewheel)
div.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll);});if(o.auto)
setInterval(function(){go(curr+o.scroll);},o.auto+o.speed);function vis(){return li.slice(curr).slice(0,v);};function go(to){if(!running){if(o.beforeStart)
o.beforeStart.call(this,vis());if(o.circular){if(to<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*liSize)+"px");curr=to==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll;}else if(to>=itemLength-v+1){ul.css(animCss,-((v)*liSize)+"px");curr=to==itemLength-v+1?v+1:v+o.scroll;}else curr=to;}else{if(to<0||to>itemLength-v)return;else curr=to;}
running=true;ul.animate(animCss=="left"?{left:-(curr*liSize)}:{top:-(curr*liSize)},o.speed,o.easing,function(){if(o.afterEnd)
o.afterEnd.call(this,vis());running=false;});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled");}}
return false;};});};function css(el,prop){return parseInt($.css(el[0],prop))||0;};function width(el){return el[0].offsetWidth+css(el,'marginLeft')+css(el,'marginRight');};function height(el){return el[0].offsetHeight+css(el,'marginTop')+css(el,'marginBottom');};})(jQuery);(function($){$.template=function(html,options){return new $.template.instance(html,options);};$.template.instance=function(html,options){if(options&&options['regx'])options.regx=this.regx[options.regx];this.options=$.extend({compile:false,regx:this.regx.standard},options||{});this.html=html;if(this.options.compile){this.compile();}
this.isTemplate=true;};$.template.regx=$.template.instance.prototype.regx={jsp:/\$\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,ext:/\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,jtemplates:/\{\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}\}/g};$.template.regx.standard=$.template.regx.jsp;$.template.helpers=$.template.instance.prototype.helpers={substr:function(value,start,length){return String(value).substr(start,length);}};$.extend($.template.instance.prototype,{apply:function(values){if(this.options.compile){return this.compiled(values);}else{var tpl=this;var fm=this.helpers;var fn=function(m,name,format,args){if(format){if(format.substr(0,5)=="this."){return tpl.call(format.substr(5),values[name],values);}else{if(args){var re=/^\s*['"](.*)["']\s*$/;args=args.split(',');for(var i=0,len=args.length;i<len;i++){args[i]=args[i].replace(re,"$1");}
args=[values[name]].concat(args);}else{args=[values[name]];}
return fm[format].apply(fm,args);}}else{return values[name]!==undefined?values[name]:"";}};return this.html.replace(this.options.regx,fn);}},compile:function(){var sep=$.browser.mozilla?"+":",";var fm=this.helpers;var fn=function(m,name,format,args){if(format){args=args?','+args:"";if(format.substr(0,5)!="this."){format="fm."+format+'(';}else{format='this.call("'+format.substr(5)+'", ';args=", values";}}else{args='';format="(values['"+name+"'] == undefined ? '' : ";}
return"'"+sep+format+"values['"+name+"']"+args+")"+sep+"'";};var body;if($.browser.mozilla){body="this.compiled = function(values){ return '"+
this.html.replace(/\\/g,'\\\\').replace(/(\r\n|\n)/g,'\\n').replace(/'/g,"\\'").replace(this.options.regx,fn)+"';};";}else{body=["this.compiled = function(values){ return ['"];body.push(this.html.replace(/\\/g,'\\\\').replace(/(\r\n|\n)/g,'\\n').replace(/'/g,"\\'").replace(this.options.regx,fn));body.push("'].join('');};");body=body.join('');}
eval(body);return this;}});var $_old={domManip:$.fn.domManip,text:$.fn.text,html:$.fn.html};$.fn.domManip=function(args,table,reverse,callback){if(args[0].isTemplate){args[0]=args[0].apply(args[1]);delete args[1];}
var r=$_old.domManip.apply(this,arguments);return r;};$.fn.html=function(value,o){if(value&&value.isTemplate)var value=value.apply(o);var r=$_old.html.apply(this,[value]);return r;};$.fn.text=function(value,o){if(value&&value.isTemplate)var value=value.apply(o);var r=$_old.text.apply(this,[value]);return r;};})(jQuery);var Handlers=Handlers||{};var Ugame=function(){var handleResponse=function(json,status,handler){if(handler){handler.apply(this,[(json.success=='true'?true:false),json.data]);}}
jQuery.extend(jQuery.expr[':'],{icontains:"jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"});return{idSeed:0,htmlDecodeEl:false,id:function(el,prefix){var el=el?$(el).get(0):false;prefix=prefix||"ugame-gen";var id=prefix+(++this.idSeed);return el?(el.id?el.id:(el.id=id)):id;},addHandlers:function(methods){$.extend(Handlers,methods);},decode:function(json){return eval("("+json+')');},htmlDecode:function(str){this.htmlDecodeEl=this.htmlDecodeEl||$('<a id="html-decode"></a>');return this.htmlDecodeEl.html(str).text();},urlEncode:function(clearString){var output='';var x=0;clearString=clearString.toString();var regex=/(^[a-zA-Z0-9_.]*)/;while(x<clearString.length){var match=regex.exec(clearString.substr(x));if(match!=null&&match.length>1&&match[1]!=''){output+=match[1];x+=match[1].length;}else{if(clearString[x]==' ')
output+='+';else{var charCode=clearString.charCodeAt(x);var hexVal=charCode.toString(16);output+='%'+(hexVal.length<2?'0':'')+hexVal.toUpperCase();}
x++;}}
return output;},makeRequest:function(options){if(!options||!(options.module||options.url))
return false;if(typeof options.params=='string'){var params=options.params;}else if(options.params&&options.params.length>0){var params=options.params.join('/');}
var url=options.url||'/'+options.module+'/'
+(options.controller?options.controller+'/':'index/')
+(options.action?options.action+'/':'index/')
+(params?params:'');if(options.form){if(typeof(options.form)=='string'){var formData=$('#'+options.form).serialize();}else if($(options.form).length==1){var formData=$(options.form).serialize();}else{var formData=[];$.each(options.form,function(){formData.push($('#'+this).serialize());})
formData=formData.join('&');}}
var postData=options.postData?jQuery.param(options.postData):'';var data=(formData?(formData+'&'):'')+postData;if(options.postQuery){data=data+'&'+options.postQuery;}
var handlerFn=(typeof options.handler=='string')?Handlers[options.handler]:((typeof options.handler=='function')?options.handler:false);$.ajax({url:url,success:handleResponse.createDelegate(options.scope||window,handlerFn,true),dataType:'json',data:data||null,type:data?'POST':'GET'});}}}();$.extend(Function.prototype,{createCallback:function(){var args=arguments;var method=this;return function(){return method.apply(window,args);};},createDelegate:function(obj,args,appendArgs){var method=this;return function(){var callArgs=args||arguments;if(appendArgs===true){callArgs=Array.prototype.slice.call(arguments,0);callArgs=callArgs.concat(args);}else if(typeof appendArgs=="number"){callArgs=Array.prototype.slice.call(arguments,0);var applyArgs=[appendArgs,0].concat(args);Array.prototype.splice.apply(callArgs,applyArgs);}
return method.apply(obj||window,callArgs);};}});$.fn.extend({tinyMCE:function(simple,noImages){simple=simple||false;noImages=noImages||false;var ids=[];$(this).each(function(){ids.push(this.id);});ids=ids.join(',');var width=$(this).width()+10;var buttonConfig=(simple?['bold,italic,underline','justifyleft,justifycenter,justifyright,justifyfull','bullist,numlist','image','link,unlink']:['bold,italic,underline','justifyleft,justifycenter,justifyright,justifyfull','bullist,numlist','formatselect,blockquote'+(!noImages?',image':''),'undo,redo','link,unlink','removeformat']).join(',|,');buttonConfig=(noImages?buttonConfig.replace('image,|,',''):buttonConfig)
var plugins='ugamelink'+(!noImages?',ugameimage':'');tinyMCE_GZ.init({themes:'advanced',plugins:plugins,languages:'en',disk_cache:false},function(){tinyMCE.init({mode:'exact',theme:'advanced',content_css:"/public/css/tinyMCE.css?"+new Date().getTime(),plugins:plugins,width:width,cleanup:true,theme_advanced_buttons1:buttonConfig,theme_advanced_buttons2:'',theme_advanced_buttons3:'',theme_advanced_toolbar_location:'top',relative_urls:false,elements:ids});});},stripId:function(sep){sep=sep||'-';return this[0].id.substr(this[0].id.lastIndexOf('-')+1);},findParent:function(expr,maxDepth,returnEl){var p=this[0],b=document.body,depth=0;maxDepth=maxDepth||50;while(p&&p.nodeType==1&&depth<maxDepth&&p!=b){if($(p).is(expr)){return returnEl?p:$(p);}
depth++;p=p.parentNode;}
return null;},expandList:function(itemCount,options){options=$.extend({showText:'Show more',hideText:'Show less',rowSpan:0},options);return this.each(function(){var self=$(this).css({overflow:'visible',height:'auto'});var items=self.children();var rows=(options.rowSpan>0)?items.length/options.rowSpan:items.length;if(rows>itemCount){itemCount=(options.rowSpan>0)?itemCount*options.rowSpan:itemCount;items.slice(itemCount).hide();var showText=options.showText+' ('+(items.length-itemCount)+')';$('<li class="expandList-option"><a class="toggle-list" href="#">'+showText+'</a></li>').appendTo(self).find('a').click(function(ev){ev.target.blur();ev.preventDefault();if($(this).hasClass('opened')){$(this).html(showText).removeClass('opened');items.slice(itemCount).hide();}else{$(this).html(options.hideText).addClass('opened');items.show();}});}});},carousel:function(visible,options){options=$.extend({visible:visible,scroll:1,mouseWheel:true,speed:100},options||{});return this.each(function(){var self=$(this);if(self.children().length<=visible){self.addClass('carousel-disabled');return false;}
var wrap=self.wrap('<div class="carousel-wrap"></div>').parent();var container=wrap.wrap('<div class="ugame-carousel"></div>').parent();var left=$('<a href="#" class="carousel-button carousel-left lir">left</a>').prependTo(container);var right=$('<a href="#" class="carousel-button carousel-right lir">right</a>').appendTo(container);options.btnPrev='#'+Ugame.id(left);options.btnNext='#'+Ugame.id(right);wrap.jCarouselLite(options);});},center:function(){return this.each(function(){$(this).css({position:'absolute'});var leftPos=($(window).width()-$(this).outerWidth())/2+$(window).scrollLeft();var topPos=($(window).height()-$(this).outerHeight())/2+$(window).scrollTop();if(topPos<0)topPos=0;if(leftPos<0)leftPos=0;$(this).css({left:leftPos+'px',top:topPos+'px',zIndex:'1000'});});},mask:function(maskRe){var KEY={BACKSPACE:8,TAB:9,RETURN:13,ESC:27,END:35,HOME:36,DELETE:46};function isNavKey(k){return(k>=33&&k<=40)||k==KEY.RETURN||k==KEY.TAB||k==KEY.ESC;}
this.keypress(function(ev){var k=ev.keyCode;if(!$.browser.msie&&(isNavKey(k)||k==KEY.BACKSPACE||(k==KEY.DELETE&&ev.button==-1))){return;}
if($.browser.msie&&(k==KEY.BACKSPACE||k==KEY.DELETE||isNavKey(k)||k==KEY.HOME||k==KEY.END)){return;}
var c=ev.charCode||ev.keyCode;if(!maskRe.test(String.fromCharCode(c)||'')){return false;}});return this;}});Ugame.Window=function(title,config){var window,overlay;var $titleEl,$buttonsEl,$bodyEl;var iconCls='';var id=Ugame.id();var buttons={};var moved=false;var config=$.extend({},{content:'',modal:true,draggable:false,title:title||'Ugame',content:'',width:200,zIndex:90,buttons:[{name:'close',caption:'Close',align:'right',handler:function(){this.hide();}}]},config);var popupTemplate=['<div class="ugame-window">','<h1 class="window-title">','<span class="window-header-title"></span>','<span class="absolute window-top-left">&nbsp;</span>','<span class="absolute window-top-right">&nbsp;</span>','</h1>','<div class="window-middle-left">','<div class="window-middle-right">','<div class="window-body"></div>','<div class="window-buttons"></div>','</div>','</div>','<div class="window-bottom">','<span class="absolute window-bottom-left">&nbsp;</span>','<span class="absolute window-bottom-right">&nbsp;</span>','</div>','</div>'].join('');var buttonTemplate=['<a href="#" class="big-button form-button window-button">','<span class="big-button-left">[caption]</span>','<span class="big-button-right">&nbsp;</span>','</a>'].join('');var createButton=function(text,cb,align,hidden){var btn=$(buttonTemplate.replace('[caption]',text)).addClass('align-'+align).appendTo($buttonsEl).click(function(ev){ev.preventDefault();ev.target.blur();cb();})
if(hidden){btn.hide();}
return btn;}
var returnObj={renderWindow:function(){if(!window){window=$(popupTemplate).appendTo(document.body).hide();window.id=id;$bodyEl=window.find('.window-body');$titleEl=window.find('.window-header-title');$buttonsEl=window.find('.window-buttons');this.setTitle(config.title);this.setButtons(config.buttons);this.setContent(config.content);this.setWidth(config.width);if(config.draggable){window.draggable({containment:'document',scroll:true,cursor:'move',handle:$titleEl,stop:function(){moved=true;}});$titleEl.css('cursor','move');}}
return window},hasMoved:function(){return moved;},getOverlay:function(){if(!overlay){overlay=$('<div></div>').prependTo(document.body).height($(document.body).height()).css({position:'absolute',top:0,left:0,zIndex:90,width:'100%',opacity:0,backgroundColor:'#000',display:'none'});}
return overlay;},show:function(){var win=this.renderWindow();if(config&&config.cls){win.addClass(config.cls);}
function showWindow(){win.css('opacity',0).show().center().css('opacity',1);if(config.autoFocus){$(config.autoFocus).focus();}else if(config.autoSelect){$(config.autoSelect).focus().select();}
win.trigger('show',[this]);}
if(config.modal){this.getOverlay().before(win).show().stop().fadeTo('fast',0.4,function(){showWindow();});return this;}
showWindow();return this;},hide:function(keepOverlay){var win=this.renderWindow();win.hide();if(config&&config.cls){win.removeClass(config.cls);}
if(overlay&&!keepOverlay){overlay.fadeTo('fast',0,function(){overlay.hide();});}
return this;},setButtons:function(btns,add){this.renderWindow();var that=this;add=add||false;if(!add){$.each(buttons,function(){$(this).remove();});}
$.each(btns,function(){that.addButton(this);});},addButton:function(btn){this.renderWindow();buttons=buttons||[];var button=buttons[btn.name||Ugame.id()]=createButton(btn.caption,btn.handler.createDelegate(btn.scope||this,[this,window],true),btn.align||'right',btn.hidden||false);return button;},removeButton:function(name){if(name&&buttons[name]){$(this).remove();delete buttons[name];}},getButton:function(name){if(name&&buttons[name]){return buttons[name];}
return false;},showButton:function(name){if(name&&buttons[name]){buttons[name].show();}
return this;},hideButton:function(name){if(name&&buttons[name]){buttons[name].hide();}
return this;},setTitle:function(title){this.renderWindow();$titleEl.html(title);},setContent:function(content){var win=this.renderWindow();$bodyEl.empty().append(content);},getBody:function(){this.renderWindow();return $bodyEl;},getEl:function(){return this.renderWindow();},setWidth:function(width){window.width(width);return this;},center:function(){window.center();return this;}}
if(config.autoRender){returnObj.renderWindow();}
return returnObj;}
Ugame.Msg=function(){var opt,window;var $iconEl,$msgEl;var iconCls='';var queue=null;var handleButton=function(button){window.hide();if(typeof opt.fn=='function'){opt.fn.apply(opt.scope||window,[button]);}}
var updateButtons=function(b){window.getButton('ok').hide();window.getButton('cancel').hide();window.getButton('yes').hide();window.getButton('no').hide();var btn;for(var k in b){btn=window.getButton(k);if(btn){btn.show();}}};return{getWindow:function(titleText){if(!window){var bt=this.buttonText;window=new Ugame.Window(titleText||"&#160;",{content:'<div class="mb-icon"></div><p class="mb-message"></p>',cls:'ugame-mb',width:300,zIndex:91,buttons:[{name:'cancel',caption:bt['cancel'],handler:handleButton.createCallback('cancel')},{name:'no',caption:bt['no'],handler:handleButton.createCallback('no')},{name:'yes',caption:bt['yes'],handler:handleButton.createCallback('yes')},{name:'ok',caption:bt['ok'],handler:handleButton.createCallback('ok')}]});var $bodyEl=window.getBody();$msgEl=$bodyEl.find('.mb-message');$iconEl=$bodyEl.find('.mb-icon');}
return window;},setText:function(text){$msgEl.html(text||'&#160;');return this;},setTitle:function(title){window.setTitle(title||"&#160;");return this;},setIcon:function(icon){if(icon&&icon!=''){$iconEl.show().removeClass(iconCls).addClass(icon);iconCls=icon;}else{$iconEl.hide();iconCls='';}
return this;},alert:function(title,msg,fn,scope){this.show({title:title,msg:msg,buttons:this.OK,fn:fn,scope:scope});return this;},warning:function(title,msg,fn,scope){this.show({title:title,msg:msg,buttons:this.OK,fn:fn,scope:scope,icon:this.WARNING});return this;},info:function(title,msg,fn,scope){this.show({title:title,msg:msg,buttons:this.OK,fn:fn,scope:scope,icon:this.INFO});return this;},error:function(title,msg,fn,scope){this.show({title:title||'Ugame error',msg:msg,buttons:this.OK,fn:fn,scope:scope,icon:this.ERROR});return this;},confirm:function(title,msg,fn,scope){this.show({title:title,msg:msg,buttons:this.YESNO,fn:fn,scope:scope,icon:this.QUESTION});return this;},updateWindow:function(){this.setTitle(opt.title||"&#160;");this.setText(opt.msg||"&#160;");this.setIcon(opt.icon);updateButtons(opt.buttons);},show:function(options){opt=options;var win=this.getWindow(opt.title);this.updateWindow();win.show();return this;},OK:{ok:true},YESNO:{yes:true,no:true},OKCANCEL:{ok:true,cancel:true},YESNOCANCEL:{yes:true,no:true,cancel:true},INFO:'info',WARNING:'warning',QUESTION:'question',ERROR:'error',buttonText:{ok:Static.buttons&&Static.buttons.ok||'Ok',cancel:Static.buttons&&Static.buttons.cancel||'Cancel',yes:Static.buttons&&Static.buttons.yes||'Yes',no:Static.buttons&&Static.buttons.no||'No'}}}();(function($){$.ui=$.ui||{};$.ui.autocomplete=$.ui.autocomplete||{};var active;var KEYS={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188};$.fn.autocompleteMode=function(container,input,size,opt){var original=input.val();var selected=-1;var self=this;$.data(document.body,"autocompleteMode",true);var select=function(){active=$("> *",container).removeClass("active").slice(selected,selected+1).addClass("active");if(opt.listSize){active.get(0).scrollIntoView(false);}
input.trigger("itemSelected.autocomplete",[$.data(active[0],"originalObject")]);};$("body").one("cancel.autocomplete",function(){input.trigger("cancel.autocomplete");$("body").trigger("off.autocomplete");input.val(original);});$("body").one("activate.autocomplete",function(){var result=$.data(active[0]||container&&container.children()[0],"originalObject");input.val(result&&opt.formatResult(result)||'');input.trigger("itemSelected.autocomplete",[result]);input.trigger("activate.autocomplete",[result]);$("body").trigger("off.autocomplete");});$("body").one("off.autocomplete",function(e,reset){container.remove();$.data(document.body,"autocompleteMode",false);input.unbind("keydown.autocomplete");$("body").add(window).unbind("click.autocomplete").unbind("cancel.autocomplete").unbind("activate.autocomplete");});$(window).bind("click.autocomplete",function(){$("body").trigger("cancel.autocomplete");});container.mouseover(function(e){if(e.target==container[0])
return;selected=$("> *",container).index($(e.target).is('li')?$(e.target)[0]:$(e.target).parents('li')[0]);select();}).bind("click.autocomplete",function(e){$("body").trigger("activate.autocomplete");$.data(document.body,"suppressKey",false);});input.bind("keydown.autocomplete",function(e){switch(e.which){case KEYS.ESC:$("body").trigger("cancel.autocomplete");break;case KEYS.RETURN:case KEYS.TAB:$("body").trigger("activate.autocomplete");break;case KEYS.UP:selected=selected<=0?size-1:selected-1;select();break;case KEYS.DOWN:selected=selected>=size-1?0:selected+1;select();break;default:return true;break;}
$.data(document.body,"suppressKey",true);})};$.fn.autocomplete2=function(opt){opt=$.extend({},{listSize:6,timeout:250,getList:function(input){input.trigger("updateList",[opt.data]);},formatItem:function(data){return opt.formatResult(data);},formatResult:function(data){return opt.valueField&&data[opt.valueField]||data['value']||data;},match:function(typed){return this.match(new RegExp(typed));},highlight:function(value,term){return value.replace(new RegExp("(?!<[^<>]*)("+term+")(?![^<>]*>)","gi"),"<strong>$1</strong>");},wrapper:'<ul class="combobox-results"></ul>'},opt);if($.ui.autocomplete.ext){for(var ext in $.ui.autocomplete.ext){if(opt[ext]){opt=$.extend(opt,$.ui.autocomplete.ext[ext](opt));delete opt[ext];}}}
return this.each(function(){$(this).keypress(function(e){var typingTimeout=$.data(this,"typingTimeout");if(typingTimeout)
window.clearTimeout(typingTimeout);if($.data(document.body,"suppressKey"))
return $.data(document.body,"suppressKey",false);else if($.data(document.body,"autocompleteMode")&&e.charCode<32&&e.keyCode!=8&&e.keyCode!=46)
return false;else if(e.which==KEYS.TAB){return true}
else{$.data(this,"typingTimeout",window.setTimeout(function(){$(e.target).trigger("autocomplete");},opt.timeout));}}).bind("autocomplete",function(){var self=$(this);self.one("updateList",function(e,data){list=$(data).filter(function(){return opt.match.call(this,self.val());}).map(function(){var node=$('<li>'+opt.highlight(opt.formatItem(this),self.val())+'</li>')[0];$.data(node,"originalObject",this);return node;});$("body").trigger("off.autocomplete");if(!list.length)
return false;var container=list.wrapAll(opt.wrapper).parents(":last").children();var offset=self.offset();opt.container=container.css({top:offset.top+self.outerHeight(),left:offset.left,width:self.innerWidth()}).appendTo("body");if(opt.listSize){container.css({height:(opt.listSize<list.length)?($(list[0]).outerHeight()*opt.listSize)-1:container.height()});}
$("body").autocompleteMode(container,self,list.length,opt);});opt.getList(self);});});};})(jQuery);(function($){$.ui=$.ui||{};$.ui.autocomplete=$.ui.autocomplete||{};$.ui.autocomplete.ext=$.ui.autocomplete.ext||{};$.ui.autocomplete.ext.ajax=function(opt){opt.timeout=1000;var ajax=opt.ajax;return{getList:function(input){ajax(input.val(),function(data){input.trigger("updateList",[data])},opt);}};};$.ui.autocomplete.ext.searchFields=function(opt){var searchFields=opt.searchFields;opt.match=opt.searchFields instanceof Array?function(typed){var data=this;var searches=$.map(searchFields,function(field){return data[field];});return searches.join(' ').match(new RegExp(typed));}:function(typed){return this[opt.searchFields].match(new RegExp(typed));}};})(jQuery);Ugame.Wizard=function(config){var _screens=[];var _screenInfo=[];var _screensMap={};var _wizardEl=false;var _activeScreen=false;var _overlay=false;var config=$.extend({},{screens:[],renderTo:document.body,defaultScreen:0,autoSetScreen:true,addButtonFn:false},config);var _screenTemplate=$.template(['<div class="wizard-screen">','<div class="screen-body"></div>','</div>'].join(''));var _buttonTemplate=$.template(['<a href="#" class="big-button form-button wizard-button">','<span class="big-button-left">${caption}</span>','<span class="big-button-right">&nbsp;</span>','</a>'].join(''));var _createButton=function(container,text,cb,align,hidden){var btn=$(_buttonTemplate.apply({caption:text})).addClass('align-'+align).appendTo(container).click(function(ev){ev.preventDefault();ev.target.blur();cb();})
if(hidden){btn.hide();}
return btn;};var wizard={prev:function(data){this.jump(-1,data);},next:function(data){this.jump(1,data);},jump:function(amount,data){this.setScreen(_activeScreen+amount,data||false)},refresh:function(){this.setScreen(_activeScreen,true);},getCurrentIndex:function(){return _activeScreen;},disable:function(index){_screenInfo[index].disabled=true;},enable:function(index){_screenInfo[index].disabled=false;},setLoading:function(loading){_overlay=_overlay||$('<div class="wizard-loading-overlay"></div>').prependTo(this.getEl()).css({position:'absolute',top:0,left:0,zIndex:90,width:'100%',opacity:0.8,backgroundColor:'#E9E9E9',display:'none'});if(loading){var el=this.getEl();if(el.height()==0){el.height(40);}
_overlay.height(el.height()-1).show();}
else{this.getEl().css('height','');_overlay.hide();}
this.getEl().trigger('setLoading',[loading,_activeScreen]);},getEl:function(){_wizardEl=_wizardEl||$('<div class="ugame-wizard"></div>').appendTo(config.renderTo);return _wizardEl;},getScreen:function(index){index=_screensMap[index]||index;return _screens[index]||false;},setScreen:function(index,data){var screenConfig=_screenInfo[index];if(screenConfig.disabled){this.setScreen((_activeScreen>index)?index-1:index+1,data);return;}
var screen=this.getScreen(index);if(screen){if(_activeScreen!==false){this.getScreen(_activeScreen).hide();}
screen.show();this.getEl().trigger('setScreen',[this,index,_activeScreen,screenConfig]);_activeScreen=index;if(screenConfig.update&&data){screenConfig.update.apply(screen,[this,data||null,index])}
if(screenConfig.autoSelect){screen.find(screenConfig.autoSelect).focus().select();}else if(screenConfig.autoFocus){screen.find(screenConfig.autoFocus).focus();}}},addScreen:function(screen){screen=$.extend({},{content:'<div></div>',buttons:[{name:'next',caption:'Next Step',align:'right',handler:function(){wizard.next();}}]},screen);var screenEl=$(_screenTemplate.apply()).appendTo(this.getEl()).hide();var screenId=Ugame.id(screenEl,'wizard-screen-');var bodyEl=screenEl.find('.screen-body').append($(screen.content).show());var buttonEl=false;screen.name=screen.name||screenId;screen.index=_screens.length;_screensMap[screen.name]=screen.index;_screenInfo.push(screen);_screens.push(screenEl);var that=this;if(screen.init){screen.init.apply(screenEl,[this,screen.index]);}
$.each(screen.buttons,function(i,button){var btn=(config.addButtonFn&&config.addButtonFn.apply(that,[button,screen.index]))||_createButton((buttonEl=buttonEl||$('<div class="screen-buttons"></div>').appendTo(screenEl)),button.caption,button.handler.createDelegate(button.scope||that,[that,screenEl,screen.index],true),button.align||'right',button.hidden||false);if(button.submit){screenEl.find('form').submit(function(ev){ev.preventDefault();btn.click();return false;})}});}}
$.each(config.screens,function(i,screen){wizard.addScreen(screen);});if(config.autoSetScreen){wizard.setScreen(config.defaultScreen);}
return wizard;};Ugame.WizardWindow=function(title,config){var _screenButtonMap={};var _window=new Ugame.Window(title,config);var _wizard=new Ugame.Wizard($.extend({},config,{autoSetScreen:false,addButtonFn:function(button,screenIndex){button.scope=this;button.hidden=true;var btn=_window.addButton(button);_screenButtonMap['window-screen-'+screenIndex]=_screenButtonMap['window-screen-'+screenIndex]||[];_screenButtonMap['window-screen-'+screenIndex].push(btn);return btn;}}));_wizard.getEl().bind('setScreen',function(ev,wizard,index,oldIndex,screenConfig){if(oldIndex!==false){$.each(_screenButtonMap['window-screen-'+oldIndex],function(i,button){button.hide();});}
$.each(_screenButtonMap['window-screen-'+index],function(i,button){button.show();});if(screenConfig.width){_window.setWidth(screenConfig.width);}
if(!config.draggable||!_window.hasMoved())_window.center();}).bind('setLoading',function(ev,loading,index){$.each(_screenButtonMap['window-screen-'+index],function(i,button){if(loading){button.hide();}else{button.show();}});})
_window.setContent(_wizard.getEl());_window.getEl().bind('show',function(ev,window){_wizard.setScreen(config.defaultScreen||0,true);})
_window.getWizard=function(){return _wizard;}
_wizard.getWindow=function(){return _window;}
return _window;}
Ugame.Uploader=function(config){var config=$.extend({},{uploadUrl:'/ajax/upload/',postData:{},postFileName:'ugame-uploader-file',fileSizeLimit:4096,fileTypes:['.*'],fileDescription:'All files',uploadLimit:0,queueLimit:0,singleFile:false,debug:false,progressBar:false},config);if(config.progressBar){var progressBar=$(config.progressBar);progressBar.prepend(['<div class="ugame-progress">','<span class="ugame-progress-text">','Uploading: <span class="ugame-uploader-current">0</span> out of <span class="ugame-uploader-total">0</span>','</span>','<div class="ugame-progress-bar">','<span class="ugame-progress-text">','Uploading: <span class="ugame-uploader-current">0</span> out of <span class="ugame-uploader-total">0</span>','</span>','</div>','</div>'].join('')).addClass('ugame-uploader');var progressEl=progressBar.find('.ugame-progress');var progressBarEl=progressEl.find('.ugame-progress-bar');var progressElWidth=0;progressBar.hide();}
var swfUploader=new SWFUpload({upload_url:config.uploadUrl,flash_url:'/public/js/libs/SWFUpload/swfupload_f9.swf',post_params:config.postData,file_post_name:config.postFileName,file_size_limit:config.fileSizeLimit.toString(),file_types:config.fileTypes.join(';'),file_types_description:config.fileDescription,file_upload_limit:config.uploadLimit.toString(),file_queue_limit:config.queueLimit.toString(),file_dialog_start_handler:fileDialogStart,file_dialog_complete_handler:fileDialogComplete,file_queued_handler:fileQueued,file_queue_error_handler:fileQueueError,upload_start_handler:uploadStart,upload_progress_handler:uploadProgress,upload_error_handler:uploadError,upload_success_handler:uploadSuccess,upload_complete_handler:uploadComplete,debug:config.debug});var eventId=SWFUpload.movieCount;var totalQueueSize=0;var totalQueueProgress=0;var totalQueueLength=0;var currentQueueUpload=0;var stopUpload=false;function fileDialogStart(){$(document.body).trigger('fileDialogStart-'+eventId,[uploader]);}
function fileDialogComplete(newSelected){var stats=swfUploader.getStats();$(document.body).trigger('fileDialogComplete-'+eventId,[newSelected,stats.files_queued,stats,uploader]);}
function fileQueued(fileInfo){$(document.body).trigger('fileQueued-'+eventId,[fileInfo,uploader]);}
function fileQueueError(file,code,message){switch(code){case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:Ugame.Msg.alert('Error','The selected files you wish to add exceedes the remaining allowed files in the queue.'+'There are '+message+' remaining slots.');break;case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:Ugame.Msg.alert('Error','The selected file "'+file.name+'" is too big. The maximum filesize is '+uploader.formatBytes(config.fileSizeLimit));break;}
$(document.body).trigger('fileQueueError-'+eventId,[file,code,message,uploader]);}
function uploadStart(){currentQueueUpload=currentQueueUpload+1;if(config.progressBar){progressBar.find('.ugame-uploader-current').text(currentQueueUpload);uploader.showProgress();progressElWidth=progressEl.width()-2;progressBarEl.find('.ugame-progress-text').width(progressEl.width()-2);}
$(document.body).trigger('uploadStart-'+eventId,[uploader]);return true;}
function uploadProgress(file,currentSize,totalSize){var queueProgress=totalQueueProgress+currentSize;if(config.progressBar){var factor=(queueProgress/totalQueueSize);progressBarEl.width(factor*progressElWidth);}
$(document.body).trigger('uploadProgress-'+eventId,[uploader]);}
function uploadSuccess(file,response){totalQueueProgress=totalQueueProgress+file.size;$(document.body).trigger('uploadSuccess-'+eventId,[file,response,uploader,stopUpload]);}
function uploadComplete(file){if(stopUpload){return false;};$(document.body).trigger('uploadComplete-'+eventId,[file,uploader]);var stats=swfUploader.getStats();if(stats.files_queued==0){if(config.progressBar){uploader.hideProgress();progressBar.find('.ugame-uploader-current').text('0');progressBarEl.width(0);}
$(document.body).trigger('queueComplete-'+eventId,[uploader]);}}
function uploadError(file,error,code){switch(error){case-200:Ugame.Msg.alert('Error','File not found 404.');break;case-230:Ugame.Msg.alert('Error','Security Error. Not allowed to post to different url.');break;}
$(document.body).trigger('uploadError-'+eventId,[file,error,code]);}
var uploader={setUploadUrl:function(url){swfUploader.setUploadURL(url);return this;},setPostFileName:function(name){swfUploader.setPostFileName(name);return this;},setPostParams:function(params){swfUploader.setPostParams(params);},setQueueLimit:function(limit){swfUploader.setFileQueueLimit(limit);},setUploadLimit:function(limit){swfUploader.setFileUploadLimit(limit);},bind:function(event,fn,data){data=data||{};$(document.body).bind(event+'-'+eventId,data,fn);return this},uploadQueue:function(){currentQueueUpload=0;totalQueueProgress=0;totalQueueSize=0;stopUpload=false;$(document.body).trigger('queueStart-'+eventId,[this]);var stats=swfUploader.getStats();totalQueueLength=stats.files_queued;var i=0;var fileInfo;do{fileInfo=swfUploader.getFile(i);i++;if(fileInfo&&fileInfo.filestatus===-1)
totalQueueSize=totalQueueSize+fileInfo.size;}while(fileInfo!==null);if(config.progressBar){progressBar.find('.ugame-uploader-total').text(stats.files_queued);this.showProgress();}
swfUploader.startUpload();},cancelQueue:function(){swfUploader.cancelQueue();return this;},cancelUpload:function(id){swfUploader.cancelUpload(id);return this;},stopUpload:function(){stopUpload=true;return this;},browse:function(){config.singleFile?swfUploader.selectFile():swfUploader.selectFiles();},getSwfUploader:function(){return swfUploader;},showProgress:function(){progressBar.show();return this;},hideProgress:function(){progressBar.hide();return this;},formatStatus:function(status){switch(status){case 0:return("Ready");case 1:return("Uploading...");case 2:return("Completed");case 3:return("Error");case 4:return("Cancelled");}},formatBytes:function(bytes){if(isNaN(bytes)){return('');}
var unit,val;if(bytes<999){unit='B';val=(!bytes&&this.progressRequestCount>=1)?'~':bytes;}else if(bytes<999999){unit='kB';val=Math.round(bytes/1000);}else if(bytes<999999999){unit='MB';val=Math.round(bytes/100000)/10;}else if(bytes<999999999999){unit='GB';val=Math.round(bytes/100000000)/10;}else{unit='TB';val=Math.round(bytes/100000000000)/10;}
return(val+' '+unit);}};return uploader;};;(function($){$.widget("ui.stars",{init:function(){var self=this,o=this.options;o.isSelect=o.inputType=="select";this.$selec=o.isSelect?$("select",this.element):null;this.$rboxs=o.isSelect?$("option",this.$selec):$(":radio",this.element);this.$stars=this.$rboxs.map(function(i){if(i==0){o.split=typeof o.split!="number"?0:o.split;o.val2id=[];o.id2val=[];o.id2title=[];o.name=o.isSelect?self.$selec.get(0).name:this.name;o.disabled=o.disabled||(o.isSelect?$(self.$selec).attr('disabled'):$(this).attr('disabled'));o.items=0;}
o.items++;o.val2id[this.value]=i;o.id2val[i]=this.value;o.id2title[i]=(o.isSelect?this.text:this.title)||this.value;if(o.selected==i||(o.selected==-1&&(o.isSelect?this.defaultSelected:this.defaultChecked))){o.checked=i;o.value=o.id2val[i];o.title=o.id2title[i];}
var $s=$("<div/>").addClass(o.starClass);var $a=$('<a/>').attr("title",o.showTitles?o.id2title[i]:"").text(this.value);if(o.split){var oddeven=(i%o.split);var stwidth=Math.floor(o.starWidth/o.split);$s.width(stwidth);$a.css("margin-left","-"+(oddeven*stwidth)+"px");}
return $s.append($a).get(0);});this.$cancel=$("<div/>").addClass(o.cancelClass).append($("<a/>").attr("title",o.showTitles?o.cancelTitle:"").text(o.cancelValue));this.$value=$('<input type="hidden" name="'+o.name+'" />');o.cancelShow&=!o.disabled&&!o.oneVoteOnly;if(o.cancelShow)this.element.append(this.$cancel);this.element.append(this.$stars);this.element.append(this.$value);o.isSelect?this.$selec.remove():this.$rboxs.remove();if(o.checked===undefined){o.checked=-1;o.value=o.cancelValue;o.title="";if(o.cancelShow)this._disableCancel();}
else{fillTo(o.checked,false);this.$value.val(o.value);}
if(o.disabled)this.disable();$(window).bind("unload",function(){self.$cancel.unbind(".stars");self.$stars.unbind(".stars");self.$selec=self.$rboxs=this.$stars=this.$value=this.$cancel=null;});function fillNone(){self.$stars.removeClass([o.starOnClass,o.starHoverClass].join(' '));self._showCap("");}
function fillTo(index,hover){if(index!=-1){var addClass=hover?o.starHoverClass:o.starOnClass;var remClass=hover?o.starOnClass:o.starHoverClass;self.$stars.eq(index).prevAll("."+o.starClass).andSelf().removeClass(remClass).addClass(addClass);self.$stars.eq(index).nextAll("."+o.starClass).removeClass([o.starHoverClass,o.starOnClass].join(' '));self._showCap(o.id2title[index]);}
else fillNone();}
this.$stars.bind("click.stars",function(){if(!o.forceSelect&&o.disabled)return false;var i=self.$stars.index(this);o.checked=i;o.value=o.id2val[i];o.title=o.id2title[i];self.$value.attr({disabled:o.disabled?"disabled":"",value:o.value});fillTo(i,false);self._disableCancel();if(!o.forceSelect){self.callback("star");}}).bind("mouseover.stars",function(){if(o.disabled)return false;var i=self.$stars.index(this);fillTo(i,true);}).bind("mouseout.stars",function(){if(o.disabled)return false;fillTo(self.options.checked,false);});this.$cancel.bind("click.stars",function(){if(!o.forceSelect&&(o.disabled||(o.value==o.cancelValue)))return false;o.checked=-1;o.value=o.cancelValue;o.title="";self.$value.attr({value:o.value,disabled:"disabled"});fillNone();self._disableCancel();if(!o.forceSelect){self.callback("cancel");}}).bind("mouseover.stars",function(){if(self._disableCancel())return false;self.$cancel.addClass(o.cancelHoverClass);fillNone();self._showCap(o.cancelTitle);}).bind("mouseout.stars",function(){if(self._disableCancel())return false;self.$cancel.removeClass(o.cancelHoverClass);self.$stars.triggerHandler("mouseout.stars");});},select:function(val){var o=this.options;o.forceSelect=true;if(val==o.cancelValue)this.$cancel.triggerHandler("click.stars");else this.$stars.eq(o.val2id[val]).triggerHandler("click.stars");o.forceSelect=false;},selectID:function(id){var o=this.options;o.forceSelect=true;if(id==-1)this.$cancel.triggerHandler("click.stars");else this.$stars.eq(id).triggerHandler("click.stars");o.forceSelect=false;},enable:function(){this.options.disabled=false;this._disableAll();},disable:function(){this.options.disabled=true;this._disableAll();},_disableCancel:function(){var o=this.options,disabled=o.disabled||o.oneVoteOnly||(o.value==o.cancelValue);if(disabled)this.$cancel.removeClass(o.cancelHoverClass).addClass(o.cancelDisabledClass);else this.$cancel.removeClass(o.cancelDisabledClass);this.$cancel.css("opacity",disabled?0.5:1);return disabled;},_disableAll:function(){var o=this.options;this._disableCancel();if(o.disabled)this.$stars.filter("div").addClass(o.starDisabledClass);else this.$stars.filter("div").removeClass(o.starDisabledClass);},_showCap:function(s){var o=this.options;if(o.captionEl)o.captionEl.text(s);},destroy:function(){this.options.isSelect?this.$selec.appendTo(this.element):this.$rboxs.appendTo(this.element);this.$cancel.unbind('.stars').remove();this.$stars.unbind('.stars').remove();this.$value.remove();this.element.unbind('.stars').removeData('stars');},callback:function(type){var o=this.options;o.callback(this,type,o.value);if(o.oneVoteOnly&&!o.disabled)this.disable();}});$.ui.stars.defaults={inputType:"radio",split:0,selected:-1,disabled:false,cancelTitle:"Cancel Rating",cancelValue:0,cancelShow:true,oneVoteOnly:false,showTitles:false,captionEl:null,callback:function(el,type,value){},starWidth:16,cancelClass:'ui-stars-cancel',starClass:'ui-stars-star',starOnClass:'ui-stars-star-on',starHoverClass:'ui-stars-star-hover',starDisabledClass:'ui-stars-star-disabled',cancelHoverClass:'ui-stars-cancel-hover',cancelDisabledClass:'ui-stars-cancel-disabled'};})(jQuery);Ugame.addHandlers({trackingStarted:function(success,data){$('.start-tracking').hide();$('.stop-tracking').show();},trackingStopped:function(success,data){$('.stop-tracking').hide();$('.start-tracking').show();},loggingIn:function(success,data){if(success){document.location.href='/';}else{Ugame.Msg.error('Invalid Login!',data.error);}}});$(function(){var browserClass='';$.each($.browser,function(i,val){if(val&&(i!='version')){browserClass=(i=='msie')?'ie'+$.browser.version.replace('.0',''):i;}});$(document.body).addClass(browserClass);if(DataBridge.noMainGame){Ugame.Msg.warning('No Games in Your Profile','You don\'t have any games assigned to your profile yet! It is absolutely necessary for you to choose at least one game before you continue using UGAME, the social network for gamers.<br /><br />To add a game to your profile <a href="/dashboard/gaming/">go to your dashboard</a>.',function(pressed){document.location.href='/dashboard/gaming/'});}
$('.ugame-tooltip').tooltip();if($('#goto-friend-field').length>0){var data=[];$.each(DataBridge.friends,function(i,item){item['type']='friend';item['searchValue']=item.urlname+' '+item.nickname+' '+item.lastname+' '+item.firstname;data.push(item);});$.each(DataBridge.teams,function(i,item){item['type']='team';item['searchValue']=item.name;data.push(item);});$.each(DataBridge.guilds,function(i,item){item['type']='guild';item['searchValue']=item.name;data.push(item);});$.each(DataBridge.groups,function(i,item){item['type']='group';item['searchValue']=item.name;data.push(item);});$('#goto-friend-field').autocomplete(data,{size:6,minChars:1,valueField:'id',multiple:false,trigger:true,mustMatch:true,width:300,emptyText:'Jump to a friend, group or team...',searchFields:['searchValue'],formatItem:function(data){var item='<strong>'+data.type.charAt(0).toUpperCase()+data.type.substr(1)+'</strong>: ';switch(data.type){case'friend':item+=data.firstname+' "'+data.nickname+'" '+data.lastname;break;case'team':case'guild':case'group':item+=data.name;break;}
return item;},formatResult:function(data){switch(data.type){case'friend':var item=data.urlname;break;case'team':case'guild':case'group':var item=data.name;break;}
return item;}}).result(function(ev,data){switch(data.type){case'friend':document.location.href='/users/'+data.urlname+'/';break;case'team':document.location.href='/teams/'+data.urlname+'/';break;case'guild':document.location.href='/guilds/'+data.urlname+'/';break;case'group':document.location.href='/groups/'+data.id+'/';break;}});}
$('.user-option-arrow').click(function(ev){ev.target.blur();ev.preventDefault();var item=$(this).parent();var close=function(items){items.removeClass('list-open').children('ul.user-sub-options').addClass('hide');}
close(item.siblings('li.list-open'));item.toggleClass('list-open').children('ul.user-sub-options').toggleClass('hide');if(item.hasClass('list-open')){$(document.body).one('click',function(ev){if($(ev.target).parents('ul.user-sub-options').length==0){close(item);}});}
return false;});$('#module-search .module-search-section').click(function(ev){ev.target.blur();ev.preventDefault();var moduleList=$(this).siblings('ul.module-search-list').show();var activeSectionEl=$(this);$(document.body).one('click',function(ev){if($(ev.target).parents('ul.module-search-list').length>0){ev.target.blur();ev.preventDefault();var sectionItem=$(ev.target).parents('li').andSelf().filter('li');sectionItem.prependTo(moduleList).addClass('active').siblings().removeClass('active');activeSectionEl.html(sectionItem.text());$('#search-input').focus();}
moduleList.hide();});return false;});var moduleSearch=$('#module-search-'+UgameBridge.module);if(moduleSearch.length>0){moduleSearch.prependTo($('#module-search ul.module-search-list')).addClass('active').siblings().removeClass('active');$('#module-search .module-search-section').html(moduleSearch.text());};$('#module-search .module-search-right').click(function(ev){ev.target.blur();ev.preventDefault();var activeSection=$(this).siblings('ul.module-search-list').find('li.active');var searchQuery=Ugame.urlEncode($('#search-input').val());window.location.replace('/'+activeSection.stripId()+'/?tab=search&s='+searchQuery);});$('#search-input').keydown(function(ev){if(ev.keyCode==13){$('#module-search .module-search-right').click();return false;}});$('#advanced-search-header > a').click(function(ev){ev.target.blur();ev.preventDefault();var activeSection=$('#module-search ul.module-search-list > li.active');window.location.replace('/'+activeSection.stripId()+'/?tab=advsearch');});$('.friend-add, .friend-remove').click(function(ev){ev.preventDefault();ev.target.blur();var id=$(this).stripId();var action=$(this).hasClass('friend-add')?'add':'remove';Ugame.Msg.confirm(Static.buddyMessageBox[action].title,Static.buddyMessageBox[action].message.start+' <b><img src=\"/public/img/flags/'+DataBridge.potentialFriends[id].origin+'.gif\" alt=\"\" /> '+DataBridge.potentialFriends[id].nickname+'</b> '+
Static.buddyMessageBox[action].message.end,function(pressed){if(pressed=='yes'){Ugame.makeRequest({url:'/ajax/friends/'+action+'/'+id,handler:function(success,data){if(success){$('#'+this.action+'Friend-'+this.id).remove();$(document.body).trigger('friendChanged',[this.id,this.action]);}else{Ugame.Msg.error('Can\'t add as friend',data.error);}},scope:{action:action,id:id}});}});});$('.idol-add, .idol-remove').click(function(ev){ev.preventDefault();ev.target.blur();var id=$(this).stripId();var action=$(this).hasClass('idol-add')?'add':'remove';var userInfo=DataBridge.potentialIdols||Da