((function(){var a,b=Array.prototype.slice;a=function(){function a(b,c){var d,e,f;this.elem=$(b),e=$.extend({},a.defaults,c);for(d in e)f=e[d],this[d]=f;this.elem.data(this.dataName,this),this.wrapCheckboxWithDivs(),this.attachEvents(),this.disableTextSelection(),this.resizeHandle&&this.optionallyResize("handle"),this.resizeContainer&&this.optionallyResize("container"),this.initialPosition()}return a.prototype.isDisabled=function(){return this.elem.is(":disabled")},a.prototype.wrapCheckboxWithDivs=function(){return this.elem.wrap("
"),this.container=this.elem.parent(),this.offLabel=$("").appendTo(this.container),this.offSpan=this.offLabel.children("span"),this.onLabel=$("").appendTo(this.container),this.onSpan=this.onLabel.children("span"),this.handle=$("
\n
\n
\n
\n
").appendTo(this.container)},a.prototype.disableTextSelection=function(){if($.browser.msie)return $([this.handle,this.offLabel,this.onLabel,this.container]).attr("unselectable","on")},a.prototype._getDimension=function(a,b){return $.fn.actual!=null?a.actual(b):a[b]()},a.prototype.optionallyResize=function(a){var b,c,d;return d=this._getDimension(this.onLabel,"width"),c=this._getDimension(this.offLabel,"width"),a==="container"?(b=d>c?d:c,b+=this._getDimension(this.handle,"width")+this.handleMargin,this.container.css({width:b})):(b=d>c?d:c,this.handle.css({width:b}))},a.prototype.onMouseDown=function(b){var c;b.preventDefault();if(this.isDisabled())return;return c=b.pageX||b.originalEvent.changedTouches[0].pageX,a.currentlyClicking=this.handle,a.dragStartPosition=c,a.handleLeftOffset=parseInt(this.handle.css("left"),10)||0},a.prototype.onDragMove=function(b,c){var d,e;if(a.currentlyClicking!==this.handle)return;return e=(c+a.handleLeftOffset-a.dragStartPosition)/this.rightSide,e<0&&(e=0),e>1&&(e=1),d=e*this.rightSide,this.handle.css({left:d}),this.onLabel.css({width:d+this.handleRadius}),this.offSpan.css({marginRight:-d}),this.onSpan.css({marginLeft:-(1-e)*this.rightSide})},a.prototype.onDragEnd=function(b,c){var d;if(a.currentlyClicking!==this.handle)return;if(this.isDisabled())return;return a.dragging?(d=(c-a.dragStartPosition)/this.rightSide,this.elem.prop("checked",d>=.5)):this.elem.prop("checked",!this.elem.prop("checked")),a.currentlyClicking=null,a.dragging=null,this.didChange()},a.prototype.refresh=function(){return this.didChange()},a.prototype.didChange=function(){var a;return typeof this.onChange=="function"&&this.onChange(this.elem,this.elem.prop("checked")),this.isDisabled()?(this.container.addClass(this.disabledClass),!1):(this.container.removeClass(this.disabledClass),a=this.elem.prop("checked")?this.rightSide:0,this.handle.animate({left:a},this.duration),this.onLabel.animate({width:a+this.handleRadius},this.duration),this.offSpan.animate({marginRight:-a},this.duration),this.onSpan.animate({marginLeft:a-this.rightSide},this.duration))},a.prototype.attachEvents=function(){var a,b,c;return c=this,a=function(a){return c.onGlobalMove.apply(c,arguments)},b=function(d){return c.onGlobalUp.apply(c,arguments),$(document).unbind("mousemove touchmove",a),$(document).unbind("mouseup touchend",b)},this.elem.change(function(){return c.refresh()}),this.container.bind("mousedown touchstart",function(d){return c.onMouseDown.apply(c,arguments),$(document).bind("mousemove touchmove",a),$(document).bind("mouseup touchend",b)})},a.prototype.initialPosition=function(){var a,b;a=this._getDimension(this.container,"width"),this.offLabel.css({width:a-this.containerRadius}),b=this.containerRadius+1,$.browser.msie&&$.browser.version<7&&(b-=3),this.rightSide=a-this._getDimension(this.handle,"width")-b,this.elem.is(":checked")?(this.handle.css({left:this.rightSide}),this.onLabel.css({width:this.rightSide+this.handleRadius}),this.offSpan.css({marginRight:-this.rightSide})):(this.onLabel.css({width:0}),this.onSpan.css({marginLeft:-this.rightSide}));if(this.isDisabled())return this.container.addClass(this.disabledClass)},a.prototype.onGlobalMove=function(b){var c;if(!!this.isDisabled()||!a.currentlyClicking)return;return b.preventDefault(),c=b.pageX||b.originalEvent.changedTouches[0].pageX,!a.dragging&&Math.abs(a.dragStartPosition-c)>this.dragThreshold&&(a.dragging=!0),this.onDragMove(b,c)},a.prototype.onGlobalUp=function(b){var c;if(!a.currentlyClicking)return;return b.preventDefault(),c=b.pageX||b.originalEvent.changedTouches[0].pageX,this.onDragEnd(b,c),!1},a.defaults={duration:200,checkedLabel:"ON",uncheckedLabel:"OFF",resizeHandle:!0,resizeContainer:!0,disabledClass:"iPhoneCheckDisabled",containerClass:"iPhoneCheckContainer",labelOnClass:"iPhoneCheckLabelOn",labelOffClass:"iPhoneCheckLabelOff",handleClass:"iPhoneCheckHandle",handleCenterClass:"iPhoneCheckHandleCenter",handleRightClass:"iPhoneCheckHandleRight",dragThreshold:5,handleMargin:15,handleRadius:4,containerRadius:5,dataName:"iphoneStyle",onChange:function(){}},a}(),$.iphoneStyle=this.iOSCheckbox=a,$.fn.iphoneStyle=function(){var c,d,e,f,g,h,i,j,k,l,m,n;c=1<=arguments.length?b.call(arguments,0):[],e=(k=(l=c[0])!=null?l.dataName:void 0)!=null?k:a.defaults.dataName,m=this.filter(":checkbox");for(i=0,j=m.length;i