//alert("constants.js");
// for window resizing. Depends on css

function kCanvasWidthReduction() { return 3; }
function kMapWidthReduction() { return 200 - getWidthCorrection(); }
function kMapHeightReduction() { return getHeight('header') 
									  + getHeight('footer') 
									  + getHeight('baro') 
									  + getHeight('dropdowns') 
									  - getHeightCorrection(); }
//function kLeftColumnHeightReduction () { return kMapHeightReduction() + 10 /*- kBaroHeight*/; }
function kLeftColumnHeightReduction() { return getHeight('header') 
									  + getHeight('footer') 
									  - getHeightCorrection() + 10; }

var kHomeDir = "";
var kHomePage = kHomeDir + "index.php";
var RADAR_TIME_FRAME = 6;	// Anzahl Stunden

function getObjectClass ( obj ) {
	if (obj && obj.constructor && obj.constructor.toString) {
		var arr = obj.constructor.toString().match(/function\s*(\w+)/);
		return arr && arr.length == 2 ? arr[1] : undefined;
	}
	return undefined;
}

function _$ ( element ) {
	if ( typeof element == "string" )
		return document.getElementById(element);
	return element;
}

var countdown_counter = 0;
var countdown_timer = false;

function countdown() {
	_$('done').innerHTML = countdown_counter--;
}
function printStats() {
	ajax ( "download.php","job=stats", function( reply ) {
		var stats = eval(reply);
		var movers = _$('movers_stat');
		if ( movers ) {
			movers.innerHTML = stats.movers;
			_$('movers_plural').innerHTML = stats.movers != 1 ? "s are" : " is";
			_$('trackers_stat').innerHTML = stats.trackers;
			_$('trackers_plural').innerHTML = stats.trackers != 1 ? "s" : "";
			_$('users_stat').innerHTML = stats.users;
			_$('visitors_stat').innerHTML = stats.visitors;
			_$('visitors_plural').innerHTML = stats.visitors != 1 ? "s" : "";
		}
	});
	if ( countdown_timer === false )
		countdown_timer = window.setInterval(countdown,1000);
	countdown_counter = 30;
	window.setTimeout( printStats, 30000);
}
