/* debugger (flehan) */
function createOutput() {

	if(!$("#output").length) {
		(function($){if($.browser.mozilla){$.fn.disableTextSelect=function(){return this.each(function(){$(this).css({"MozUserSelect":"none"})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).css({"MozUserSelect":""})})}}else{if($.browser.msie){$.fn.disableTextSelect=function(){return this.each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).unbind("selectstart.disableTextSelect")})}}else{$.fn.disableTextSelect=function(){return this.each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).unbind("mousedown.disableTextSelect")})}}}})(jQuery)
	
		var d	= document;
		var o	= d.createElement("div");
		o.id	= "output";
		d.getElementsByTagName("body")[0].appendChild(o);
//		var oData	= "<div class=\"move\">[move]</div><div id=\"outputdata\"></div>";
		var oData	= "<div id=\"outputdata\">";
		o.innerHTML = oData;
		
		$(o).css({'position':'fixed','top':'300px','left':'0px','width':'400px','height':'100px','color':'#fff','fon-family':'arial','font-size':'11px','font-weight':'normal','background':'#000','border':'1px solid #fff','padding':'4px','z-index':'999999','text-align':'left','overflow':'auto','filter':'alpha(opacity=80)','-moz-opacity':'0.80','-khtml-opacity':'0.08','opacity':'0.8','direction':'ltr'});
		$(".move",o).css({'display':'block','position':'fixed','cursor':'pointer','background':'#fff','color':'#000','left':'370px','top':'4px'});
	
		if (d.cookie.indexOf("output=") != -1) {
			var pos = d.cookie.split("output=")[1].split(";")[0];
			$(o).css("top",pos.split("|")[0]+"px").css("left",pos.split("|")[1]+"px");
		}
		$(".move",o).disableTextSelect();

		$(".move",o).mousedown(function(e) { $(o).mousemove(function(e) {$(o).css("top",e.pageY-$(window).scrollTop()-10+"px").css("left",e.pageX-20+"px")}) });
		$(".move",o).mouseup(function(e) { $(o).unbind("mousemove");d.cookie = "output=" + ($(o).position().top-$(window).scrollTop())+"|"+$(o).position().left;});

		//		$(".move",o).mousedown(function(e) { $(o).mousemove(function(e) {$(o).css("top",e.pageY-$(window).scrollTop()-($(o).height()/2)+"px").css("left",e.pageX-($(o).width()/2)+"px")}) });
//		$(".move",o).mouseup(function(e) { $(o).unbind("mousemove");d.cookie = "output=" + ($(o).position().top-$(window).scrollTop())+"|"+$(o).position().left;});
		
		if (navigator.appVersion.indexOf("MSIE 6.0") != -1) {
			$(o).css("top",$(window).scrollTop()+10+"px");
			$(o).css("position","absolute");
			$(window).scroll(function(){$(o).css("top",$(window).scrollTop()+10+"px")})
		}
	}
}

function doOut(str) {
	if ($("#output")) {

		if(!$("#output").data("lines")) { $("#output").data("lines", 0) }

		var line = $("#output").data("lines") + 1;
		$("#output").data("lines", line);
		$("#outputdata").html("<strong>"+line+":</strong> "+str+"<br>"+$("#outputdata").html());
	}
}

$(document).ready(function() {
	if (location.href.indexOf("debug=1") != -1) {
		createOutput();
	}
});
