$(function(){

	$('.switch-checkbox').each(function(index, el) {

		var checked = el.checked ? 'true' : 'false';
		var margin = el.checked ? '' : ' style="margin-left: -53px"';

		el.outerHTML = '<div class="switch-checkbox-struct" data-checked="' + checked + '">'
					 + '<div class="switch-checkbox-struct-transparent-swiper" ' + margin + '>'
					 + '<div class="switch-checkbox-struct-on"><i class="fa fa-check"></i></div>'
					 + '<div class="switch-checkbox-struct-switcher">&nbsp;</div>'
					 + '<div class="switch-checkbox-struct-off"><i class="fa fa-times"></i></div>'
					 + '</div>' + el.outerHTML + '</div>';
	});

	$(document).delegate('.switch-checkbox-struct', 'click', function() {
		var switcher = $(this);
		var checked = $(this).attr('data-checked');
		if(checked == "true"){
			$(this).find('.switch-checkbox-struct-transparent-swiper').animate({
				"margin-left": '-53px'
			}, "fast", function(){
				switcher.attr('data-checked', 'false');
				switcher.find('input[type="checkbox"]').attr("checked", false);
			});
		}else{
			$(this).find('.switch-checkbox-struct-transparent-swiper').animate({
				"margin-left": '0'
			}, "fast", function(){
				switcher.attr('data-checked', 'true');
				switcher.find('input[type="checkbox"]').attr("checked", true);
			});
		}
	});
});