/*======================================================================================*\
 * Copyright (c) 2008 BLUEWING.BIZ - All Rights Reserved.
 * ======================================================================================
 * No part of this file may be reproduced or transmitted in any form or by any means, 
 * electronic or mechanical, including photocopying and recording, for any purpose 
 * without the express written permission of the owner of copyright.
 * ======================================================================================
 * @filesource       root/js/common.js
 * @copyright        Copyright 2007-2008, Bluewing, Florian Tschoerner
 * @link             http://www.bluewing.biz
 * @package          bluewing
 * @since            Bluewing v 2.0.1
 * @version          
 * @modifiedby       
 * @lastmodified     18.06.2008
 * @license          http://www.opensource.org/licenses/mit-license.php The MIT License
\*======================================================================================*/

	var clockID = 0;
	var dd;
	var mm;
	var hh;
	var ii;
	var ss;



	/*==================================================================================*\
	 *	Function:	updateClock
	 *	Purpose:	updates clock
	 *	Author:		Florian Tschoerner
	 *	Params:		none
	 *	Return:		none
	\*==================================================================================*/

	function updateClock() {
		if (document.getElementById("clock")) {
			if(clockID) {
				clearTimeout(clockID);
				clockID  = 0;
			}

			var tDate = new Date();

			if (typeof cTime != 'undefined') {
				cTime = cTime+1000;
				tDate.setTime(cTime);		
			}

			if (tDate.getDate() < 10) {
				dd = "0"+tDate.getDate();
			} else {
				dd = tDate.getDate();
			}
			var mon = 1+tDate.getMonth(); // getMonth starts counting at 0=january
			if (mon < 10) {
				mm = "0"+mon;
			} else {
				mm = mon;
			}
			if (tDate.getHours() < 10) {
				hh = "0"+tDate.getHours();
			} else {
				hh = tDate.getHours();
			}
			if (tDate.getMinutes() < 10) {
				ii = "0"+tDate.getMinutes();
			} else {
				ii = tDate.getMinutes();
			}
			if (tDate.getSeconds() < 10) {
				ss = "0"+tDate.getSeconds();
			} else {
				ss = tDate.getSeconds();
			}

			document.getElementById("clock").innerHTML = dd+"."+mm+"."+tDate.getFullYear()+" "+hh+":"+ii+":"+ss;
		   
			clockID = setTimeout("updateClock()", 1000);
		}
	}



	/*==================================================================================*\
	 *	Function:	startClock
	 *	Purpose:	called on loading window
	 *	Author:		Florian Tschoerner
	 *	Params:		none
	 *	Return:		none
	\*==================================================================================*/

	function startClock() {
		clockID = setTimeout("updateClock()", 0);
	}



	/*==================================================================================*\
	 *	Function:	killClock
	 *	Purpose:	called on unloading window
	 *	Author:		Florian Tschoerner
	 *	Params:		none
	 *	Return:		none
	\*==================================================================================*/

	function killClock() {
		if(clockID) {
			clearTimeout(clockID);
			clockID  = 0;
		}
	}

/*======================================================================================*/
