naviki.main.Util = {

	/**
	 * Formats a number into a string, also the "." to a ",".
	 */
	formatNumber: function(number) {
		var value = ""+number;
		return value.replace(/\./, ","); 
	},

	/**
	 * Roudns a value with <digits> of numbers after the point 
	 */
	round: function(value, digits) {
		var factor = Math.pow(10, digits);
		return (Math.round(value*factor))/factor;
	},
	
	formatDate: function(timevalue) {
		var mydate = new Date();
		mydate.setTime(timevalue*1000);
		var month = mydate.getMonth() + 1;
		if (month < 10) {
			month = "0"+month;
		}
		var day = mydate.getDate();
		if (day < 10) {
			day = "0"+day;
		}
		return day+"."+
			month+"."+
			mydate.getFullYear();
	},
	formatDateAndTime: function(timevalue) {
		var mydate = new Date();
		mydate.setTime(timevalue*1000);
		var month = mydate.getMonth() + 1;
		if (month < 10) {
			month = "0"+month;
		}
		var day = mydate.getDate();
		if (day < 10) {
			day = "0"+day;
		}
		var minutes = mydate.getMinutes();
		if (minutes < 10) {
			minutes = "0"+minutes;
		}
		var hours = mydate.getHours();
		if (hours < 10) {
			hours = "0"+hours;
		}
		return day+"."+
			month+"."+
			mydate.getFullYear()+", "+
			hours+":"+
			minutes;
	},
	formatTime:function(seconds){
		var hours = Math.floor(seconds / (60*60));
		seconds -= hours * (60*60);
		var minutes = Math.floor(seconds / 60);
		if (minutes < 10) {
			minutes = "0"+minutes;
		}
		return hours+":"+
			minutes;
	},
	bringToTop:function() {
		// the normal bring to top function does not work correctly because of the nui- classes. So i must implement ower own.
		var aDivs = new Array();
		var Dom = YAHOO.util.Dom;
		// get all div elements.
		aDivs = document.getElementsByTagName("div");
		if (aDivs.length == 0) {
			this.cfg.setProperty("zindex", 10);
			return;
		}
		var maxIndex = -9999;
		var count = aDivs.length;
		for (var i=1;i<count;i++) {
			var div = aDivs[i];
			var sZIndex = Dom.getStyle(div, "zIndex");
			var nZIndex = (!sZIndex || isNaN(sZIndex)) ? 0 : parseInt(sZIndex, 10);
			if (nZIndex > maxIndex) {
				maxIndex = nZIndex;
			}
		}
		return maxIndex;
	}
};

