/*======================================================================================*\
 * 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 dd;
	var mm;
	var hh;
	var ii;
	var ss;
	var style;
	var clock_separator = "|";


	/*==================================================================================*\
	 *	Function:	updateClock
	 *	Purpose:	updates clock
	 *	Author:		Florian Tschoerner
	 *	Params:		none
	 *	Return:		none
	\*==================================================================================*/

	function updateClock(elem, type) {
		if (document.getElementById(elem)) {
			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();
			}

			var inner;
			switch (type) {
				case "time":
						var inner = hh + ":" + ii + ":" + ss;
					break;
				case "date":
						inner = dd + "." + mm + "." + tDate.getFullYear();
					break;
				default:
						inner = dd + "." + mm + "." + tDate.getFullYear() + ' ' + clock_separator + ' ' + hh + ":" + ii + ":" + ss;
					break;
			}				
			
			document.getElementById(elem).innerHTML = inner;
		   
			setTimeout("updateClock('"+elem+"', '"+type+"')", 1000);
		}
	}



	/*==================================================================================*\
	 *	Function:	startClock
	 *	Purpose:	called on loading window
	 *	Author:		Florian Tschoerner
	 *	Params:		none
	 *	Return:		none
	\*==================================================================================*/

	function startClock(elem, type) {
		setTimeout("updateClock('"+elem+"', '"+type+"')", 0);
	}

/*======================================================================================*/