/*
	Copyright (C) 2005 Ekina Ltd. All Rights Reserved.
		
	Contains methods extending the basic JavaScript datatypes to
	include more functionality.
	
*/
if (!E2930D14_54D1_48ad_86E7_4072D8BBB776) {

    /*
        Window methods - copied from Ekina.Core.js
    */

    function $scroll() { var s = {x:0, y:0}; if (window.innerHeight && window.scrollMaxY) {	s.x = document.body.scrollWidth; s.y = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ s.x = document.body.scrollWidth; s.y = document.body.scrollHeight; } else { s.x = document.body.offsetWidth; s.y = document.body.offsetHeight; } return s; };
    function $page() { var s = $scroll(); var ws = $window(); return { width: Math.max(ws.width, s.x), height: Math.max(ws.height, s.y) }; };
    function $window() { var w = {width:0, height:0}; if (self.innerHeight) { w.width = self.innerWidth; w.height = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { w.width = document.documentElement.clientWidth; w.height = document.documentElement.clientHeight; } else if (document.body) { w.width = document.body.clientWidth; w.height = document.body.clientHeight; } return w; };
    function $viewport() { var w = $window(); return {width: w.width, height: w.height, x: document.body.scrollLeft, y: document.body.scrollTop}; };
    function $center() { var v = $viewport(); return {x: v.width / 2, y: v.height / 2}; };



	function $(id){
		return document.getElementById(id);
	};

	function alertObj(o) {
		var s = "";
		for(var i in o)
			s += i + ": " + o[i] + ", ";
		alert(s.substring(0, s.length-2));
	};
	
	function $E(parent, className, tagName) {
		tagName = tagName ? tagName : "div";
		var el = document.createElement(tagName);
		parent.appendChild(el);
		el.className = className;
		return el;
	};
	
	function $E2(parent, className, sibling, tagName) {
		tagName = tagName ? tagName : "div";
		var el = document.createElement(tagName);
		parent.insertBefore(el);
		el.className = className;
		return el;
	};
	
	function $I(parent, className, image) {
		var icon = $E(parent, className);
//		width = typeof(width) == "number" ? width : 16;
//		height = typeof(height) == "number" ? height : 16;
//		icon.style.width = width + "px";
//		icon.style.height = height + "px";
		icon.isIcon = true;
		
		$CI(icon, image);
		
		return icon;
	};
	
	function $CI(icon, newImage) {
		if (!icon.isIcon) {
			alert("Not an icon");
			return;
		}
		
		if (icon.currentImage == newImage) return;
		
		if (document.all)
			icon.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + newImage + "')";
		else
			icon.style.background = "url(" + newImage + ") no-repeat center center";
			
		icon.currentImage = newImage;
	};
	
	function $P(element, root) {
		if (!root) root = document.documentElement;
		var pos = new Point(0, 0);
		while(element && element != root) {
			pos.x += element.offsetLeft;
			pos.y += element.offsetTop;
			element = element.offsetParent;
		}
		return pos;
	};

	Array.prototype.remove = function(obj){
		for(var i = 0; i < this.length; i++)
			if(this[i] === obj)
				return this.removeAt(i);
	};

	Array.prototype.removeAt = function(index){
		var ret = this[index];
		for(var i = index; i < this.length-1; i++)
			this[i] = this[i+1];
		this[this.length-1] = null;
		this.length--;
		return ret;
	};

	Array.prototype.insert = function(index, obj){
		for(var i = this.length; i > index; i--)
			this[i] = this[i-1];
		this[index] = obj;
	};

	Array.prototype.contains = function(obj){
		for(var i = 0; i < this.length; i++)
			if(this[i] === obj)
				return true;
		return false;
	};	
		
	Array.checkArray = function(arr)
	{
		if (!arr.push) return arr.split(",");
		return arr;
	};
			
	String.prototype.trim = function(){
		return this.replace(/^\s*|\s*$/g,"");
	};

	String.prototype.startsWith = function(str, ignoreCase){
		var thisStr = ignoreCase ? this.toLowerCase() : this;
		str = ignoreCase ? str.toLowerCase() : str;
		if (ignoreCase)
			return thisStr.startsWith(str, false);
		return this.length>=str.length && this.substring(0, str.length) == str;
	};

	String.prototype.startsWithAny = function(arr, ignoreCase){
		arr = Array.checkArray(arr);
		for (var i = 0; i < arr.length; i++)    
			if (this.startsWith(arr[i], ignoreCase)) return true;
		    
		return false;
	};

	String.prototype.endsWith = function(str, ignoreCase){
		var thisStr = ignoreCase ? this.toLowerCase() : this;
		str = ignoreCase ? str.toLowerCase() : str;
		if (ignoreCase)
			return thisStr.endsWith(str, false);
		return this.length>=str.length && this.substring(this.length-str.length) == str;
	};


	String.prototype.endsWithAny = function(arr, ignoreCase){
		arr = Array.checkArray(arr);
		for (var i = 0; i < arr.length; i++)    
			if (this.endsWith(arr[i], ignoreCase)) return true;
		    
		return false;
	};

	String.prototype.contains = function(str, ignoreCase){
		var thisStr = ignoreCase ? this.toLowerCase() : this;
		str = ignoreCase ? str.toLowerCase() : str;
		if (ignoreCase)
			return thisStr.contains(str, false);
		return this.indexOf(str) >= 0;
	};

	String.prototype.containsAny = function(arr, ignoreCase){
		arr = Array.checkArray(arr);
		for (var i = 0; i < arr.length; i++)    
			if (this.contains(arr[i], ignoreCase)) return true;
		    
		return false;
	};

	String.prototype.insert = function(startIndex, str){
		return this.substring(0, startIndex) + str + this.substring(startIndex);
	};

	String.prototype.padLeft = function(totalWidth, paddingChar){
		if(!paddingChar || paddingChar.length == 0) paddingChar = " ";
		var newStr = this;
		while(newStr.length < totalWidth) newStr = paddingChar+newStr;
		return newStr;
	};

	String.prototype.padRight = function(totalWidth, paddingChar){
		if(!paddingChar || paddingChar.length == 0) paddingChar = " ";
		var newStr = this;
		while(newStr.length < totalWidth) newStr += paddingChar;
		return newStr;
	};

	String.prototype.compareTo = function(str){
		for(var i = 0; i < str.length; i++){
			var code1 = this.charCodeAt(i);
			var code2 = str.charCodeAt(i);
			if(code1 > code2) return 1;
			if(code2 > code1) return -1;
		}
		return 0;
	};

	String.prototype.reverse = function() {
		var str = "";
		for(var i = this.length-1; i > -1; i--)
			str += this.substring(i-1, i);
		return str;
	};

	String.prototype.htmlEncode = function() {
		return this.replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;");
	};

	String.format = function(str){
		for(var i = 1; i < arguments.length; str=str.replace(new RegExp("\{" + (i-1) + "\}", "g"), arguments[i++]));
		return str;
	};

	String.join = function(array, seperator, startIndex, count){
		if(!seperator) seperator = "";
		if(!startIndex) startIndex = 0;
		if(!count) count = array.length;
		var str = "";
		for(var i = startIndex; i < count; str+=((i==startIndex)?"":seperator)+array[i++].toString());
		return str;
	};

	String.concat = function(){
		var str = "";
		for(var i = 0; i < arguments.length; str+=arguments[i++].toString());
		return str;
	};

	String.compare = function(strA, strB){
		return strA.compareTo(strB);
	};
	
	String.isNullOrEmpty = function(str, trim) {
	    if(!str) return true;
	    if(trim)
	        return str.trim().length == 0;
	    return str.length == 0;
	};

	Number.prototype.compareTo = function(num){
		if(this > num) return 1;
		if(num > this) return -1;
		return 0;
	};

	Number.compare = function(numA, numB){
		return numA.compareTo(numB);
	};
	
	//Alignment enumerations
	var HorizontalAlignment = new Object();
	HorizontalAlignment.Left = 1;
	HorizontalAlignment.Center = 2;
	HorizontalAlignment.Right = 4;
	var VerticalAlignment = new Object();
	VerticalAlignment.Top = 8;
	VerticalAlignment.Center = 16;
	VerticalAlignment.Bottom = 32;
	

	var E2930D14_54D1_48ad_86E7_4072D8BBB776 = true;
}