/*
Class.create = function ()
{
    return function ()
    {
	this.extend = function (object){ return Object.extend(this, object); };
	this.initialize.apply(this, arguments);
    };
};
*/


function WatchCreate(watch)
{
	if(typeof watch == 'string')
		watch = $(watch);
	Object.extend(watch, new Watch() );
	
	return watch;
};

if(typeof Watch == 'undefined')
	Watch = Class.create();
Object.extend(Watch.prototype, {
	initialize: function()
	{
		this._long = 20;
		this._short = 15;
		
		this.ctx = null;
		
	},
	
	drawnow: function()
	{
		var date = new Date();
		
		if(this.ctx == null)
			this.ctx = this.getContext('2d');


		this.ctx.clearRect(0, 0, this.getWidth(), this.getHeight());
		
		this.ctx.strokeStyle = "#888888";

		var hour = (date.getHours() % 12) + date.getMinutes() / 60;
		this.ctx.lineWidth = 2;
		this.ctx.beginPath();
		this.ctx.moveTo(this.getWidth()/2, this.getHeight()/2);
		this.ctx.lineTo(this.getWidth()/2 + this._short * Math.sin( hour / 12 * 2 * Math.PI ),this.getHeight()/2 - this._short * Math.cos( hour /  12 * 2 * Math.PI ));
		this.ctx.stroke();

		this.ctx.lineWidth = 1.5;
		this.ctx.beginPath();
		this.ctx.moveTo(this.getWidth()/2, this.getHeight()/2);
		this.ctx.lineTo(this.getWidth()/2 + this._long * Math.sin( date.getMinutes() / 60 * 2 * Math.PI ),this.getHeight()/2 - this._long * Math.cos( date.getMinutes() / 60 * 2 * Math.PI ));
		this.ctx.stroke();
		
		setTimeout(this.drawnow.bind(this), 1000*60);
	}
	
});




