//Shows debug information
//Requires jquery
var debug =true;
var browserHeight;
		var oriHeight=null;
		$(document).ready(function(){
			fixHeight();
			$(window).resize(function(){
				fixHeight();
			});
			if($('#debug').html().length > 1)
				out($('#debug').html());
			//out($('#debug').html().length);
		});
		function fixHeight(){ //will work if body contains div with id="background" without height set
			if(navigator.userAgent.indexOf("MSIE")>0){
				browserHeight=$(window).height();
			}else{
				browserHeight=window.innerHeight;
			}
			if(oriHeight==null){
				oriHeight=document.body.offsetHeight;
				//$("#background").css("height",oriHeight);
			}
			if(browserHeight>$('body').innerHeight() || (oriHeight!=null && browserHeight>oriHeight)){
				//$("#background").css("height",browserHeight);
			}
		}
		
function out(str){
	if(debug){
		var Stamp = new Date();
		var Hours = Stamp.getHours();
		if(Hours<10)
			Hours="0"+Hours;
		var Mins = Stamp.getMinutes();
		if(Mins<10)
			Mins="0"+Mins;
		var Seconds = Stamp.getSeconds();
		if(Seconds<10)
			Seconds="0"+Seconds;
		str=""+Hours+":"+Mins+":"+Seconds+" "+xa(str,0);
		height=browserHeight/1.7;
		width=$('body').innerWidth()/2;
		ieAddWidth=0;
		if(navigator.userAgent.indexOf("MSIE")>0){
			ieAddWidth=-20;
		}
		try{
			var tmp=document.getElementById('debugDIV').id;
			$('#debugDIV').prepend(str+"<br><br>");
			$('#debugDIV').css("top",(browserHeight-height-5));
			$('#debugDIV').css("height",height+"px");
			$('#debugDIV').css("left",($('body').innerWidth()-width+ieAddWidth-5));
			$('#debugDIV').css("width",width+"px");
		}catch (e) {
			$(document.body).append("<div id='debugDIV' style='font-size:11px;top:"+(browserHeight+$(document).scrollTop()-height-5)+"px;left:"+($('body').innerWidth()-width+ieAddWidth-5)+"px;height:"+height+"px;width:"+width+"px;overflow:auto;z-index:1000;background-color:#c0c0c0;border:1px solid #000000;position:absolute;text-align:left;' onclick='this.style.width=$(\"body\").innerWidth()/2;this.style.left=($(\"body\").innerWidth()-$(\"body\").innerWidth()/2+ieAddWidth-5);if(this.style.height==\"15px\"){this.style.top=(browserHeight+$(document).scrollTop()-(browserHeight/1.3+5));this.style.height=browserHeight/1.3+\"px\";}else{this.style.height=\"15px\";this.style.top=(browserHeight+$(document).scrollTop()-20);}$(window).scroll();'>"+str+"</div>");
			$('#debugDIV').fadeTo(0,0.8);
			$(window).resize(function(){
				width=$('body').innerWidth()/2;
				$('#debugDIV').css("top",(browserHeight+$(document).scrollTop()-$("#debugDIV").css('height').split("px")[0]-5));
				$('#debugDIV').css("left",($('body').innerWidth()-width+ieAddWidth-5));
				$('#debugDIV').css("width",width+"px");
			});
			$(window).scroll(function(){
				$('#debugDIV').css("top",(browserHeight+$(document).scrollTop()-$("#debugDIV").css('height').split("px")[0]-5));
				$('#debugDIV').css("left",($('body').innerWidth()-width+ieAddWidth-5));
				$('#debugDIV').css("width",width+"px");
			});
		}
	}
}

function xa(arr,steps){
	//out(1);
	var res="";
	var step="";
	var color="black";
	for(j=0;j<steps;j++)
		step=step+"&nbsp;&nbsp;&nbsp;";
	//alert(typeof(arr));
	if(typeof(arr)=="object"){
		//out(2);
		for (i in arr){
			//out(3);
			flag=false;
			if(typeof(arr[i])=="object")
				flag=true;
			res=res+"<br><b style='font-size:11px;'>"+step+"["+i+"]</b> = { "+xa(arr[i],steps+1)+"</b>";
			if(flag){
				res=res+"<br>"+step;
			}
			res=res+" }";
			//out(4);
		}
	}else{
		if(typeof(arr)=="int")
			color="blue";
		if(typeof(arr)=="string")
			color="darkred";
		if(typeof(arr)=="char")
			color="yellow";
		if(typeof(arr)=="boolean")
			color="green";
		//out(5);
		res="<b style='color:"+color+";font-size:11px;'>"+arr+"</b>";
	}
	//out(6);
	return res;
}
function placeContent(content){
	$("#content").html(content);
}
