(function($){
 $.fn.checkbox = function(options) {
    
  var defaults = {
   img_check: "",
   img_no_check: "",
   width:20,
   height:20,
   check: false,
   onchange: function(){},
   effect:false
  };
  var options = $.extend(defaults, options);
  
  jQuery("<img>").attr("src", options.img_no_check);
   jQuery("<img>").attr("src", options.img_check);
  
  return this.each(function() {  
  
	  var checked = options.check;
	  
	  var parent = $(this).parent();
	  var input = $(this);
	  var rand = Math.ceil(Math.random()*100);
	  
	  
	   
	   if(options.img_no_check != "" && options.img_check != ""){
		   
		   parent = parent.css("backgroundImage","url("+options.img_no_check+")");
		  if(typeof(input.attr("id")) != "undefined" && input.attr("id") != ""){
			parent.attr("id", input.attr("id")+"_div_contener_checkbox");
		  }
		  
		   if(options.check){
			   parent = parent.css("backgroundImage","url("+options.img_check+")");
		   }
		   	 input.attr("checked",checked);
		   
			parent.css("backgroundRepeat","no-repeat").css("width",options.width+"px").css("height",options.height+"px").css("cursor","pointer");
			input.css("display","none");
			
			parent.click(function(){
						
						if(parent.css("backgroundImage") == 'url("'+options.img_check+'")'){
								parent.css("backgroundImage","url("+options.img_no_check+")");
								checked = false;
							
							 
						}else{
								parent.css("backgroundImage","url("+options.img_check+")");
							 	checked = true;
							
							 
							 
							
						}
						 input.attr("checked",checked);
						 
						 options.onchange(input);
						 
			});
			
			
	   } else{
		   alert("Veuillez renseigner les options img_check et img_no_check afin de faire fonctionner ce plugin");
	   }	
	});
 
 };
})(jQuery);

