function TzineClock() {
	//private vars
	var gVars = {};

    var timeSet = false;

    var containerSet = false;

    var callBackFunction = false;
	
	//private methods
	
	function setUp()
	{
		var dialElem;
		
        // Creating a new element and setting the color as a class name:
        dialElem = $('<div>')
              .attr('class','green clock').html(
            '<div class="display"></div>'+
            '<div class="front left"></div>'+
            '<div class="rotate left">'+
                '<div class="bg left"></div>'+
            '</div>'+
            '<div class="rotate right">'+
                '<div class="bg right"></div>'+
            '</div>');

        // Appending to the container:
        $(this).append(dialElem);

        // Assigning some of the elements as variables for speed:
        dialElem.rotateLeft = dialElem.find('.rotate.left');
        dialElem.rotateRight = dialElem.find('.rotate.right');
        dialElem.display = dialElem.find('.display');

        // Adding the dial as a global variable. Will be available as gVars.colorName
        gVars['green'] = dialElem;
		
		
		// Setting up a interval, executed every 1000 milliseconds:
        var time = timeSet; /* 60 seconds */
		var timerInterval = setInterval(function(){
			time = time-1;
            if (time == -1){
                clearInterval(timerInterval);
                /* call to callback function */
                if (typeof(callBackFunction) == 'function'){
                    callBackFunction();
                }
                animation(gVars.green, -1, 60);
            }else{
                animation(gVars.green, time, 60);
            }
		},1000);
	}
	
	function animation(clock, current, total)
	{
		// Calculating the current angle:
		var angle = (360/total)*(current+1);
	
		var element;
        var rotateRightHidden = false;
		if(current==30)
		{
			// Hiding the right half of the background:
			clock.rotateRight.hide();
			
			// Resetting the rotation of the left part:
			rotateElement(clock.rotateRight,0);
            rotateRightHidden = true;
		}
		
		if(angle<=180)
		{
			// The left part is rotated, and the right is currently hidden:
			element = clock.rotateLeft;
		}
		else
		{
			// The first part of the rotation has completed, so we start rotating the right part:
			if (!rotateRightHidden)
                clock.rotateRight.show();
            
			clock.rotateLeft.show();
			
			rotateElement(clock.rotateLeft,180);
			
			element = clock.rotateRight;
			angle = angle-180;
		}

		rotateElement(element,angle);
		
		// Setting the text inside of the display element, inserting a leading zero if needed:
        if (current>=0)
            clock.display.html(current<10?'0'+current:current);
	}
	
	function rotateElement(element,angle)
	{
		// Rotating the element, depending on the browser:
		var rotate = 'rotate('+angle+'deg)';
		
		if(element.css('MozTransform')!=undefined)
			element.css('MozTransform',rotate);
			
		else if(element.css('WebkitTransform')!=undefined)
			element.css('WebkitTransform',rotate);
	
		// A version for internet explorer using filters, works but is a bit buggy (no surprise here):
		else if(element.css("filter")!=undefined)
		{
			var cos = Math.cos(Math.PI * 2 / 360 * angle);
			var sin = Math.sin(Math.PI * 2 / 360 * angle);
			
			element.css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+cos+",M12=-"+sin+",M21="+sin+",M22="+cos+",SizingMethod='auto expand',FilterType='nearest neighbor')");
	
			element.css("left",-Math.floor((element.width()-200)/2));
			element.css("top",-Math.floor((element.height()-200)/2));
		}
	}
	
	//public methods
	this.init = function(container, opts){

        timeSet = opts.time; /* init the time variable */
        callBackFunction = opts.callBackFunction; /* init the time variable */
        containerSet = container;

		if(!container)
		{
			try{
				console.log("Invalid selector!");
		} catch(e){}
			
			return false;
		}
		
		if(!opts)
            opts = {};
      
		var defaults = {
			/* Additional options will be added in future versions of the plugin. */
		};
		
		/* Merging the provided options with the default ones (will be used in future versions of the plugin): */
		$.each(defaults,function(k,v){
			opts[k] = opts[k] || defaults[k];
		})

		// Calling the setUp function and passing the container,
		// will be available to the setUp function as "this":
		setUp.call(container);
	};
}

///*!
// * jquery.tzineClock.js - Tutorialzine Colorful Clock Plugin
// *
// * Copyright (c) 2009 Martin Angelov
// * http://tutorialzine.com/
// *
// * Licensed under MIT
// * http://www.opensource.org/licenses/mit-license.php
// *
// * Launch  : December 2009
// * Version : 1.0
// * Released: Monday 28th December, 2009 - 00:00
// */
//
//(function($){
//	
//	// A global array used by the functions of the plug-in:
//	var gVars = {};
//
//	// Extending the jQuery core:
//	$.fn.tzineClock = function(opts){
//	
//		// "this" contains the elements that were selected when calling the plugin: $('elements').tzineClock();
//		// If the selector returned more than one element, use the first one:
//		
//		var container = this.eq(0);
//	
//		if(!container)
//		{
//			try{
//				console.log("Invalid selector!");
//			} catch(e){}
//			
//			return false;
//		}
//		
//		if(!opts)
//            opts = {};
//      
//		var defaults = {
//			/* Additional options will be added in future versions of the plugin. */
//		};
//		
//		/* Merging the provided options with the default ones (will be used in future versions of the plugin): */
//		$.each(defaults,function(k,v){
//			opts[k] = opts[k] || defaults[k];
//		})
//
//		// Calling the setUp function and passing the container,
//		// will be available to the setUp function as "this":
//		setUp.call(container);
//		
//		return this;
//	}
//	
//	function setUp()
//	{
//		// The colors of the dials:
//		var colors = ['green'];
//		
//		var tmp;
//		
//		for(var i=0;i<1;i++)
//		{
//			// Creating a new element and setting the color as a class name:
//			
//			tmp = $('<div>').attr('class',colors[i]+' clock').html(
//				'<div class="display"></div>'+
//				
//				'<div class="front left"></div>'+
//				
//				'<div class="rotate left">'+
//					'<div class="bg left"></div>'+
//				'</div>'+
//				
//				'<div class="rotate right">'+
//					'<div class="bg right"></div>'+
//				'</div>'
//			);
//			
//			// Appending to the container:
//			$(this).append(tmp);
//			
//			// Assigning some of the elements as variables for speed:
//			tmp.rotateLeft = tmp.find('.rotate.left');
//			tmp.rotateRight = tmp.find('.rotate.right');
//			tmp.display = tmp.find('.display');
//			
//			// Adding the dial as a global variable. Will be available as gVars.colorName
//			gVars[colors[i]] = tmp;
//		}
//		
//		// Setting up a interval, executed every 1000 milliseconds:
//        var time = 60; /* 60 seconds */
//		var timerInterval = setInterval(function(){
//		
//			var currentTime = new Date();
//			var h = currentTime.getHours();
//			var m = currentTime.getMinutes();
//			//var s = currentTime.getSeconds();
//            //var s = 60; /* 60 seconds */
//			time = time-1;
//			animation(gVars.green, time, 60);
//			//animation(gVars.blue, m, 60);
//			//animation(gVars.orange, h, 24);
//
//            if (time == -1){
//                clearInterval(timerInterval);
//                /* call to callback function */
//            }
//		},1000);
//	}
//	
//	function animation(clock, current, total)
//	{
//		// Calculating the current angle:
//		var angle = (360/total)*(current+1);
//	
//		var element;
//        var rotateRightHidden = false;
//		if(current==30)
//		{
//			// Hiding the right half of the background:
//			clock.rotateRight.hide();
//            //clock.rotateLeft.hide();
//
//            
//
//			
//			// Resetting the rotation of the left part:
//			rotateElement(clock.rotateRight,0);
//            //clock.find('div.rotate:last').css('display','none').css('border','1px solid red');
//            rotateRightHidden = true;
//		}
//		
//		if(angle<=180)
//		{
//			// The left part is rotated, and the right is currently hidden:
//			element = clock.rotateLeft;
//		}
//		else
//		{
//			// The first part of the rotation has completed, so we start rotating the right part:
//			if (!rotateRightHidden)
//                clock.rotateRight.show();
//            
//			clock.rotateLeft.show();
//			
//			rotateElement(clock.rotateLeft,180);
//			
//			element = clock.rotateRight;
//			angle = angle-180;
//		}
//
//		rotateElement(element,angle);
//		
//		// Setting the text inside of the display element, inserting a leading zero if needed:
//		clock.display.html(current<10?'0'+current:current);
//	}
//	
//	function rotateElement(element,angle)
//	{
//		// Rotating the element, depending on the browser:
//		var rotate = 'rotate('+angle+'deg)';
//		
//		if(element.css('MozTransform')!=undefined)
//			element.css('MozTransform',rotate);
//			
//		else if(element.css('WebkitTransform')!=undefined)
//			element.css('WebkitTransform',rotate);
//	
//		// A version for internet explorer using filters, works but is a bit buggy (no surprise here):
//		else if(element.css("filter")!=undefined)
//		{
//			var cos = Math.cos(Math.PI * 2 / 360 * angle);
//			var sin = Math.sin(Math.PI * 2 / 360 * angle);
//			
//			element.css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+cos+",M12=-"+sin+",M21="+sin+",M22="+cos+",SizingMethod='auto expand',FilterType='nearest neighbor')");
//	
//			element.css("left",-Math.floor((element.width()-200)/2));
//			element.css("top",-Math.floor((element.height()-200)/2));
//		}
//	
//	}
//	
//})(jQuery)
