// made by maxx, copied from bc
var Utils = {
	
	debug: false,
	
	responseDebug: false,
	requestDebug: false,
	
	sendRequest: function( url, parameter, handle ){
		var message =
			"<b>url</b> = "+url+" <br/>"+
			"<b>handle</b> = "+handle+" <br/>"+
			"<b>parameters</b> = "+parameter+" <br/>";
		if( Utils.requestDebug ){
			Utils.appendDebugMessage( "REQUEST:", message );
		}
		new Ajax.Request(
			url,
			{
				method: 'post',
				parameters: parameter,
			
				onLoading:  function() {},
				onComplete:   function(transport) {
					var  jsonObj;
					try {
						if( Utils.responseDebug ){
							Utils.appendDebugMessage( "RESPONSE:", transport.responseText );
						}
						jsonObj = eval( "(" +transport.responseText+ ")" );
						handle( jsonObj );
					} catch (e) {
						Utils.appendDebugMessage("Exception", e.toString());
					}
				},
				onException:  function(event, ex) {
					Utils.appendDebugMessage( "Exception: ", ex ); 
				}
			}
		);
	},
	appendDebugMessage: function( headline, message ){
		if( Utils.debug ){
			document.body.appendChild(
				Builder.node(
					'div',
					{ style: "padding:5px;"},
					[
						Builder.node(
							'div',
							{style: "padding:5px;border:1px solid black;"},
							headline
						),
						Builder.node(
							'div',
							{style: "padding:5px;border:1px solid black;"},
							message
						)
					]
				)
			);
		}
	},
	getDocumentSize: function(){
		var xScroll = 0;
		var yScroll = 0;

		if (window.innerHeight && window.scrollMaxY) {
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		}else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		}else { // Explorer Mac...would also work in Explorer 6 Strict,Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) { // all except Explorer
			windowWidth = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement &&
			document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		// for small pages with total height less then height of the viewport
		var docHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
		// for small pages with total width less then width of the viewport
		var docWidth = (xScroll < windowWidth) ? xScroll : windowWidth;
		return {"width": docWidth, "height": docHeight};
	},
	emptyFunction: function(){}
	
	
}