/*! ============================================================
 * bootstrapSwitch v1.7 by Larentis Mattia @SpiritualGuru
 * http://www.larentis.eu/
 *
 * Enhanced for radiobuttons by Stein, Peter @BdMdesigN
 * http://www.bdmdesign.org/
 *
 * Project site:
 * http://www.larentis.eu/switch/
 * ============================================================
 * Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0
 * ============================================================ */
;!function(a){a.fn.bootstrapSwitch=function(d){var c='input[type!="hidden"]';var b={init:function(){return this.each(function(){var q=a(this),n,g,m,p,r=q.closest("form"),i="",h=q.attr("class"),j,e,k="ON",f="OFF",o=false;a.each(["switch-mini","switch-small","switch-large"],function(s,t){if(h.indexOf(t)>=0){i=t}});q.addClass("has-switch");if(q.data("on")!==undefined){j="switch-"+q.data("on")}if(q.data("on-label")!==undefined){k=q.data("on-label")}if(q.data("off-label")!==undefined){f=q.data("off-label")}if(q.data("icon")!==undefined){o=q.data("icon")}g=a("<span>").addClass("switch-left").addClass(i).addClass(j).html(k);j="";if(q.data("off")!==undefined){j="switch-"+q.data("off")}m=a("<span>").addClass("switch-right").addClass(i).addClass(j).html(f);p=a("<label>").html("&nbsp;").addClass(i).attr("for",q.find(c).attr("id"));if(o){p.html('<i class="icon icon-'+o+'"></i>')}n=q.find(c).wrap(a("<div>")).parent().data("animated",false);if(q.data("animated")!==false){n.addClass("switch-animate").data("animated",true)}n.append(g).append(p).append(m);q.find(">div").addClass(q.find(c).is(":checked")?"switch-on":"switch-off");if(q.find(c).is(":disabled")){a(this).addClass("deactivate")}var l=function(s){s.siblings("label").trigger("mousedown").trigger("mouseup").trigger("click")};q.on("keydown",function(s){if(s.keyCode===32){s.stopImmediatePropagation();s.preventDefault();l(a(s.target).find("span:first"))}});g.on("click",function(s){l(a(this))});m.on("click",function(s){l(a(this))});q.find(c).on("change",function(x,v){var w=a(this),t=w.parent(),s=w.is(":checked"),u=t.is(".switch-off");x.preventDefault();t.css("left","");if(u===s){if(s){t.removeClass("switch-off").addClass("switch-on")}else{t.removeClass("switch-on").addClass("switch-off")}if(t.data("animated")!==false){t.addClass("switch-animate")}if(typeof v==="boolean"&&v){return}t.parent().trigger("switch-change",{el:w,value:s})}});q.find("label").on("mousedown touchstart",function(t){var s=a(this);e=false;t.preventDefault();t.stopImmediatePropagation();s.closest("div").removeClass("switch-animate");if(s.closest(".has-switch").is(".deactivate")){s.unbind("click")}else{if(s.closest(".switch-on").parent().is(".radio-no-uncheck")){s.unbind("click")}else{s.on("mousemove touchmove",function(z){var u=a(this).closest(".make-switch"),w=(z.pageX||z.originalEvent.targetTouches[0].pageX)-u.offset().left,x=(w/u.width())*100,y=25,v=75;e=true;if(x<y){x=y}else{if(x>v){x=v}}u.find(">div").css("left",(x-v)+"%")});s.on("click touchend",function(x){var w=a(this),u=a(x.target),v=u.siblings("input");x.stopImmediatePropagation();x.preventDefault();w.unbind("mouseleave");if(e){v.prop("checked",!(parseInt(w.parent().css("left"))<-25))}else{v.prop("checked",!v.is(":checked"))}e=false;v.trigger("change")});s.on("mouseleave",function(w){var v=a(this),u=v.siblings("input");w.preventDefault();w.stopImmediatePropagation();v.unbind("mouseleave");v.trigger("mouseup");u.prop("checked",!(parseInt(v.parent().css("left"))<-25)).trigger("change")});s.on("mouseup",function(u){u.stopImmediatePropagation();u.preventDefault();a(this).unbind("mousemove")})}}});if(r.data("bootstrapSwitch")!=="injected"){r.bind("reset",function(){setTimeout(function(){r.find(".make-switch").each(function(){var s=a(this).find(c);s.prop("checked",s.is(":checked")).trigger("change")})},1)});r.data("bootstrapSwitch","injected")}})},toggleActivation:function(){var e=a(this);e.toggleClass("deactivate");e.find(c).prop("disabled",e.is(".deactivate"))},isActive:function(){return !a(this).hasClass("deactivate")},setActive:function(f){var e=a(this);if(f){e.removeClass("deactivate");e.find(c).removeAttr("disabled")}else{e.addClass("deactivate");e.find(c).attr("disabled","disabled")}},toggleState:function(e){var f=a(this).find(":checkbox");f.prop("checked",!f.is(":checked")).trigger("change",e)},toggleRadioState:function(f){var e=a(this).find(":radio");e.not(":checked").prop("checked",!e.is(":checked")).trigger("change",f)},toggleRadioStateAllowUncheck:function(f,g){var e=a(this).find(":radio");if(f){e.not(":checked").trigger("change",g)}else{e.not(":checked").prop("checked",!e.is(":checked")).trigger("change",g)}},setState:function(f,e){a(this).find(c).prop("checked",f).trigger("change",e)},setOnLabel:function(f){var e=a(this).find(".switch-left");e.html(f)},setOffLabel:function(e){var f=a(this).find(".switch-right");f.html(e)},setOnClass:function(g){var f=a(this).find(".switch-left");var e="";if(g!==undefined){if(a(this).attr("data-on")!==undefined){e="switch-"+a(this).attr("data-on")}f.removeClass(e);e="switch-"+g;f.addClass(e)}},setOffClass:function(f){var g=a(this).find(".switch-right");var e="";if(f!==undefined){if(a(this).attr("data-off")!==undefined){e="switch-"+a(this).attr("data-off")}g.removeClass(e);e="switch-"+f;g.addClass(e)}},setAnimated:function(f){var e=a(this).find('input[type!="hidden"]').parent();if(f===undefined){f=false}e.data("animated",f);e.attr("data-animated",f);if(e.data("animated")!==false){e.addClass("switch-animate")}else{e.removeClass("switch-animate")}},setSizeClass:function(h){var f=a(this);var g=f.find(".switch-left");var i=f.find(".switch-right");var e=f.find("label");a.each(["switch-mini","switch-small","switch-large"],function(j,k){if(k!==h){g.removeClass(k);i.removeClass(k);e.removeClass(k)}else{g.addClass(k);i.addClass(k);e.addClass(k)}})},status:function(){return a(this).find(c).is(":checked")},destroy:function(){var g=a(this),f=g.find("div"),h=g.closest("form"),e;f.find(":not(inputSelector)").remove();e=f.children();e.unwrap().unwrap();e.unbind("change");if(h){h.unbind("reset");h.removeData("bootstrapSwitch")}return e}};if(b[d]){return b[d].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof d==="object"||!d){return b.init.apply(this,arguments)}else{a.error("Method "+d+" does not exist!")}}}}(jQuery);(function(a){a(function(){a(".make-switch")["bootstrapSwitch"]()})})(jQuery);
