/*
 *		jSwitch v0.01a
 *		
 *		Checkbox switch jQueryUI plugin
 *		(c) 2011, Istvan Szabadi
 */

	function uicb(selector){
		function updatecb(){
			$(".ui-cb-box").each(function(){
				if( $(this).attr("title")=="off" ){
					$(".cb-status",this).css("width","0%");
					$(".cb-knob",this).css("left","15%");
				}else{
					$(".cb-status",this).css("width","100%");
					$(".cb-knob",this).css("left","85%");
				}
			});			
		}			
		$(selector).each(function(){
			$(this).hide();
			$(this).after(''+
			'<div title="off" id="uicb' + $(this).attr("name") + '" class="ui-cb-box ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" style="width: 25px;">'+
				'<div class="cb-status ui-slider-range ui-widget-header ui-corner-left" style="width: 0%; "></div>'+
				'<span class="cb-knob ui-slider-handle ui-state-default ui-corner-all" href="#" style="left: 15%; "></span>'+
			'</div>');
			if ( $(this).attr("checked")=="checked" )  $(".ui-cb-box", $(this).parent() ).attr("title","on");
			updatecb();
		});
		$(".ui-cb-box").click(function(){
			if(  $(this).attr("title")=="on"  ){
				$( "input:checkbox", $(this).parent() ).removeAttr("checked").change();
				$(this).attr("title","off");
			}else{
				$( "input:checkbox", $(this).parent() ).attr("checked","checked").change();
				$(this).attr("title","on");
			}
			updatecb();
		});
	}

