var timer=null;
var timerrun=false;
function stoptime() {
	if(timerrun)
	clearTimeout(timer);
	timerrun=false;
}
function starttime() {
	stoptime();
	showtime();
}
function showtime() {
	var all=new Date();
	var hours=all.getHours();
	var minutes=all.getMinutes();
	var seconds=all.getSeconds();
	var timevalue=" " + ((hours>12) ? hours-12 : hours) 
	timevalue += ((minutes<10) ? ":0" : ":") + minutes
	timevalue += ((seconds<10) ? ":0" : ":") + seconds
	timevalue +=(hours>=12) ? "pm" : "am"
	el = document.getElementById("timeBar").innerHTML = timevalue;
	timer=setTimeout('showtime()',1000);
	timerrun=true;
}
$(function(){
	starttime();
	$.getJSON("/geo/getgeobarinfo",
		function(info){
			$("#geoBar").html(info.city);
			var weatherInfo="";
			if (info.condition != "" && info.condition != null) {
				weatherInfo += ' ('+info.condition+') ';
			}
			if (info.temperature != "" && info.temperature != null){
				weatherInfo += info.temperature+'&deg;c';
			}
			$("#weatherBar").html(weatherInfo);
		}
	)
})
