/*
* Jquery jqDraw plugin V1.0
* Written by Ejder Yurdakul 03/01/2011
* http://freelancephp.be
* Description This plugin gives user ability to draw in a DOM element.
* params:
* options.color: color of the line
* options.thickness: width of the line 
* returns void
*/
(function($){$.fn.draw=function(op){if(typeof op=="string"){switch(op){case"reset":var h=$("#jqdraw-target",this).height();$("#jqdraw-target").attr("height",h-1);$("#jqdraw-target").attr("height",h);break;case"disable":$("#jqdraw-target",this).addClass("jqdraw-disabled");break;case"enable":$("#jqdraw-target",this).removeClass("jqdraw-disabled");break;default:return false;break;}}else{var o=$.extend({},$.fn.draw.defaults,op);var _e=this;var _p=this.offset();this.empty();var jqcanvas=$("<canvas/>").attr({"width":this.width(),"height":this.height(),"id":"jqdraw-target"}).appendTo(this);var c=document.getElementById("jqdraw-target");var ct=c.getContext("2d");ct.strokeStyle=o.color;var sd=false;$(document).mousemove(function(e){if(!$("#jqdraw-target").is(".jqdraw-disabled")){if(e.target.getAttribute("id")=="jqdraw-target"){if(!sd){sd=true;ct.beginPath();ct.moveTo((e.clientX-_p.left),(e.clientY-_p.top));}else{ct.lineTo((e.clientX-_p.left),(e.clientY-_p.top));ct.stroke();}}else{if(sd){sd=false;ct.closePath();}}}});}};})(jQuery);$.fn.draw.defaults={color:"#00a2ff",thickness:1};
