function log($message) {
	try {
		console.log($message);
	}
	catch(e) {
		
	}
}
// 
// log('stuff');
// alert('stuff');

$(document).ready( function() {
	var debug_box = $('div.debug');
	if(debug_box.length > 0) {
		
		var php_load_microtime = $('#microtime', debug_box).html();
		//log("php_load_microtime = " + php_load_microtime);
		var time = microtime(true);
		//log("microtime = " + time);
		
		var domReadyTime = Math.round((time-php_load_microtime)*1000);
		
		debug_box.append("<p>DOM Ready Time: " + domReadyTime + " msecs. </p>");
	}
});

$(window).load( function() {
	var debug_box = $('div.debug');
	if(debug_box.length > 0) {
		
		var php_load_microtime = $('#microtime', debug_box).html();
		//log("php_load_microtime = " + php_load_microtime);
		var time = microtime(true);
		//log("microtime = " + time);
		
		var domReadyTime = Math.round((time-php_load_microtime)*1000);
		
		debug_box.append("<p>Window Load Time: " + domReadyTime + " msecs. </p>");
	}
});

function microtime (get_as_float) {
	// http://kevin.vanzonneveld.net
	// +   original by: Paulo Ricardo F. Santos
	// *     example 1: timeStamp = microtime(true);
	// *     results 1: timeStamp > 1000000000 && timeStamp < 2000000000

	var now = new Date().getTime() / 1000;
	var s = parseInt(now, 10);

	return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s;
}
