// JScript source code
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;

// Set some variables describing browser's capabilities.
if (document.getElementById)
{
	isID = 1;
	isDHTML = 1;
}
else
{
	if (document.all)
	{
		isAll = 1;
		isDHTML = 1;
	}
	else
	{
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) &&
			(browserVersion == 4))
		{
			isLayers = 1;
			isDHTML = 1;
		}
	}
}

var bIsNS= (document.getElementById && !document.all) ? 1 : 0;
var bIsIE = document.all ? 1 : 0;

// 
//	Given the ID of an object, the function finds that object
//	from the dicument and rrturn to user.
//
function getDOMObject(id)
{
	if (isID)
	{
		return document.getElementById(id);
	}
	else
	{
		if (isAll)
		{
			return document.all[id];
		}
		else
		{
			if (isLayers)
			{
				return document.layers[id];
			}
		}
	}
	return null;
}

// 
//	Given the ID of an object, the function finds that object
//	from the document and returns its style.
//
function getDOMObjectStyle(id)
{
	var ob = getDOMObject(id);
	if (null != ob)
	{
		return ob.style;
	}
	return null;
}

//
//	Function returns the pixel depth value of the colors
//	used by browser.
//
function getColorDepth()
{
	return screen.colorDepth;
}

//
//	Function returns the height of browser window, including the
//	controls and menus around the visible area.
//	This function only works in Netscape.
//
function getBrowserHeight()
{
	if (window.outerHeight != null)
	{
		return window.outerHeight;
	}
	
	return null;
}

//
//	Function returns the width of browser window, including the
//	controls around the visible area.
//	This function only works in Netscape.
//
function getBrowserWidth()
{
	if (window.outerWidth != null)
	{
		return window.outerWidth;
	}
	
	return null;
}

//
//	Function returns the height of browser window.
//
function getLivePageHeight()
{
	if (window.innerHeight != null)
	{
		return window.innerHeight;
	}
	
	if (document.body.clientHeight != null)
	{
		return document.body.clientHeight;
	}
	
	return null;
}

//
//	Function returns the width of browser window.
//
function getLivePageWidth()
{
	if (window.innerWidth != null)
	{
		return window.innerWidth;
	}
	
	if (document.body.clientWidth != null)
	{
		return document.body.clientWidth;
	}
}

function getScrollLeft()
{
	if (window.pageXOffset != null)
	{
		return window.pageXOffset;
	}
	
	if (document.body.scrollWidth != null)
	{
		return document.body.scrollLeft;
	}
	
	return null;
}

function getScrollTop()
{
	if (window.pageYOffset != null)
	{
		return window.pageYOffset;
	}
	
	if (document.body.scrollHeight != null)
	{
		return document.body.scrollTop;
	}
	
	return null;
}

/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/

var Url = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}