/**
 * <code>public class <b>Array</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.Array</code> is the javascript class which contains methods for common work with arrays<br>
 *
 * Defines static variable: <code>none</code><br>
 * Available as <code>new componence.util.Array()</code><br>
 * Packege <b><code>componence.util</code></b>
 */

if(!window.componence) var componence = {};
if(!componence.util) componence.util = {};

/**
 * <code>componence.util.Array</code> is the javascript class which contains methods for common work with arrays<br>
 *
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
componence.util.Array = function(){
	
	/**
	 * Current version of <code>componence.util.Array</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	if(typeof Array.prototype.indexOf != "function") {
		/**
		 * Searches for the first occurence of the given argument, testing for 
		 * equality using the equals method.
		 *
		 * @param e Object element of array
		 * @type int
		 * @return the index of the first occurrence of the argument in this list; returns -1 if the object is not found. 
		 */
		Array.prototype.indexOf = function(e) {
			for(var i=0; i<this.length; i++)
				if(this[i] == e) return i;
			return -1;
		};
	}
	
	
	if ( typeof Array.prototype.lastIndexOf != "function" ) {
		/**
		 * Returns the index of the last occurrence of the specified object in this list.
		 *
		 * @param e Object the desired element.
		 * @type int
		 * @return the index of the last occurrence of the specified object in this list; returns -1 if the object is not found.
		 */
		Array.prototype.lastIndexOf = function(e) {
			for(var i=this.length-1; i>=0; i-- )
				if(this[i] == e) return i;
			return -1;
		};
	}
	
	/**
	 * Removes the element.
	 *
	 * @param e Object object of array element which must be delete
	 * @return void
	 * @type void
	 */
	if ( typeof Array.prototype.remove != "function" ) {
		Array.prototype.remove = function(e) {
			var i = this.indexOf( e );
			if(i != -1) this.splice(i, 1);
		};
	}
	
	/**
	 * Removes all of the elements from this list. The list will be empty after this call returns
	 *
	 * @type void
	 */
	if ( typeof Array.prototype.clear != "function" ) {
		Array.prototype.clear = function() {
			
			/**
			 * the number of elements in this list.
			 * @access private
			 * @type int
			 */
			this.length = 0;
		};
	}
	
	/**
	 * copy() creates and returns a new array which contains the same elements 
	 * as array. It does not modify array. Numerical and boolean array elements
	 * are copied by value while all other types are copied by reference.
	 *
	 * @type Array
	 * @return A new array that contains the same elements as array
	 */
	if ( typeof Array.prototype.copy != "function" ) {
		Array.prototype.copy = function() {
			var c = [];
			for (var i = 0; i < this.length; i++) 
				c[i] = this[i];
			return c;
		};
	}

	/**
	 * Created for IE 5.0 becouse splice method work in 5.5+ only
	 * pop() removes the last element of array (the one with the highest index) 
	 * and returns this value. array is modified.
	 *
	 * @type int
	 * @return The last element of array.
	 */
	if ( typeof Array.prototype.pop != "function" ) {
		Array.prototype.pop = function() {
			var /*:LastElement:*/ l = null;
			if ( this.length > 0 ) {
				l = this[this.length-1];
				this.length--;
			}
			return l;
		};
	}
	

	/**
	 * Created for IE 5.0 becouse splice method work in 5.5+ only
	 * push() appends each of it's arguments, in the order they appear in the 
	 * function call, to array. array is modified.
	 *
	 * @param value[] Array One or more values to be appended to the end of array.
	 * @type int
	 * @return The new length of array.
	 */
	if ( typeof Array.prototype.push != "function" ) {
		Array.prototype.push = function() {
			var /*:length:*/ l = this.length;
			var /*:arguments:*/ a = arguments;
			for (var i = 0; i < a.length; i++) 
				this[l + i] = a[i];
			return this.length;
		};
	}
	

	/**
	 * Created for IE 5.0 becouse splice method work in 5.5+ only
	 * shift() removes the first element of array (the one with index 0) and 
	 * returns this value. array is modified and all remaining array elements 
	 * are moved on index down to fill the newly vacated spot.
	 *
	 * @type Object
	 * @return The first element of array.
	 */
	if ( typeof Array.prototype.shift != "function" ) {
		Array.prototype.shift = function() {
			var /*:FirstElement:*/ f = this[0];
			this.splice( 0, 1 );
			return f;
		};
	}

	
	/**
	 * Created for IE 5.0 becouse splice method work in 5.5+ only
	 * unshift() insert each of it's arguments, in the order they appear in the 
	 * function call, at the beginning of array. array is modified with existing 
	 * array elements moving to positions with higher indices.
	 *
	 * @param v Object value One or more values to be inserted at the beginning of array.
	 * @type int
	 * @returns The new length of array.
	 */
	if ( typeof Array.prototype.unshift != "function" ) {
		Array.prototype.unshift = function( v ) {
			this.splice( 0, 0, v );
			return this.length;
		};
	}
	

	/**
	 * Created for IE 5.0 becouse splice method work in 5.5+ only
	 * splice() deletes zero or more elements from array starting at start and 
	 * replaces them with zero or more elements specified in the argument list. 
	 * array is modified with any remaining elements being moved to different 
	 * array indices if required.<br>
	 *
	 * Note that a bug in Netscape 4.x causes the implementation of this function 
	 * to return an element value instead of an array if only a single element is 
	 * deleted. Netscape 4.x will also return nothing if no elements are deleted 
	 * instead of an empty array. This function does not suffer from the same problems.
	 *
	 * @param s int The array index in array at which to start the insertion / deletion of elements.
	 * @param c int The number of elements to delete from array. This includes the element at start. If this argument is omitted, all elements from the one at start to the end of the array are deleted.
	 * @param value One or more values to be inserted into array at the index specified by start.
	 * @return An array containing all the elements deleted from array.
	 * @type Array
	 */
	if ( typeof Array.prototype.splice != "function" ) {
		Array.prototype.splice = function(s, c) {
			var /*:Temporary:*/ t = this.copy();
			var /*:arguments:*/ a = arguments;
			if (c == null || c == '') 
				c = this.length - s;

			for (var i = s; i < s + a.length - 2; i++) 
				this[i] = a[i - s + 2];

			for (var i = s + a.length - 2; i < this.length - c + a.length - 2; i++) 
				this[i] = t[i + c - a.length + 2];
			
			/**
			 * @access private
			 */
			this.length = this.length - c + (a.length - 2);
			return t.slice(s, s + c);
		};
	}

	/**
	 * concat() creates and returns a new array which is the result of concatenating 
	 * each of the method's arguments to array. It does not modify array.
	 * 
	 * @type Array
	 * @param value[] Array One or more values to be appended to the end of array.
	 * @return A new array that is formed by concatenating each of the specified arguments to array
	 */
	if ( typeof Array.prototype.concat != "function" ) {
		Array.prototype.concat = function ( s ) {
			var /*:firstArray:*/ f = this.copy();
			for (var i = 0; i < s.length; i++)
				f[f.length] = s[i];
			return f;
		};
	}

	/**
	 * slice() creates a new array containing all the elements between the positions 
	 * indicated by start and end excluding the element at the position specified by end. 
	 * It does not modify array.<br>
	 * 
	 * Note that a bug in Internet Explorer 4 causes negative start values to be 
	 * interpreted as 0 in the core version of the Array.slice() function implemented 
	 * in that browser. This function does not suffer from the same problem.
	 *
	 * @param s int The array index in array at which to start the slice. The element at this position will be at index 0 in the new array. If this value is negative, it specifies a position measured from the end of the array (ie. -1 is the last element).
	 * @param e int The array index in array immediately after the end of the slice. The element at end - 1 will occupy the last position in the new array. If this argument is omitted, then the slice will contain all elements from start to the end of the array. If end is a negative number, it indicates an array position measured from the end of the array.
	 * @type Array
	 * @return An array containing all the elements in the specified slice of array.
	 */
	if ( typeof Array.prototype.slice != "function" ) {
		Array.prototype.slice = function( s, e) {
			var /*:Temporary:*/ t;
			var /*:length:*/ l = this.length;
			var /*:Array:*/ a = [];
			if (e == null || e == '')
				e = l;
			else if (e < 0)
				e = l + e;
			if (s < 0) 
				s = l + s;
			if (e < s) {
				t = e;
				e = s;
				s = t;
			}

			for (var i = 0; i < e - s; i++) 
				a[i] = this[s + i];
			
			return a;
		};
	}
};


/**
 * Constructs an empty list.
 *
 * @access private
 * @deprecated
 * @version	2.1.19
 * @constructor
 * @lastmodified
 * @extends JSObject
 */
function JSArray() {
	return new componence.util.Array();
}
//Array.prototype = new componence.util.Array();
/**
 * <code>public class <b>ArrayList</b><br>
 * extends componence.util.Array</code><br><br>
 *
 * <code>componence.util.ArrayList</code> is the javascript class which contains methods for common work with arrays<br>
 *
 * Depends on: <code>componence.util.Array</code><br>
 * Defines static variable: <code>none</code><br>
 * Available as <code>new componence.util.ArrayList()</code><br>
 * Packege <b><code>componence.util</code></b>
 */

/**
 * <code>componence.util.ArrayList</code> is the javascript class which contains methods for common work with arrays<br>
 * Constructs an empty list.
 *
 * @version	2.1.19
 * @constructor
 * @lastmodified
 * @extends componence.util.Array
 */
componence.util.ArrayList = function() {
	// this.extend(componence.util.Array);
	// fix for prototype.js 1.6.0.3
	Object.extend(this, new componence.util.Array());
	
	/**
	 * Current version of <code>componence.util.ArrayList</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	/**
	 * return true if object <code>e</code> contains in array
	 *
	 * @access public
	 * @param e Object element of array
	 * @type boolean
	 * @return true if object <code>e</code> contains in array
	 * @see componence.util.Array.indexOf
	 */
	function contains(e) {
		return this.indexOf(e) != -1;
	}
	Array.prototype.contains = contains;
	this.contains = contains;

	/**
	 * Inserts the specified element at the specified position in this list. 
	 * Shifts the element currently at that position (if any) and any subsequent 
	 * elements to the right (adds one to their indices).
	 *
	 * @access public
	 * @param e Object element to be inserted.
	 * @param i int index at which the specified element is to be inserted.
	 * @type void
	 * @see componence.util.Array.splice
	 */
	function insertAt(e, i) {
		this.splice(i, 0, e);
	}
	Array.prototype.insertAt = insertAt;
	this.insertAt = insertAt;

	/**
	 * public method
	 * return void
	 * @param n Object new element of array
	 * @param e Object object in array
	 * @type void
	 * @see componence.util.Array.indexOf
	 * @see componence.util.Array.push
	 * @see componence.util.Array.splice
	 */
	function insertBefore(n, e) {
		var i = this.indexOf(e);
		if (i == -1) this.push(n);
		else this.splice(i, 0, n);
	}
	Array.prototype.insertBefore = insertBefore;
	this.insertBefore = insertBefore;

	/**
	 * Removes the element at the specified position in this list. 
	 * Shifts any subsequent elements to the left (subtracts one from their indices).
	 *
	 * @param i int the index of the element to removed.
	 * @type void
	 * @see componence.util.Array.splice
	 */
	function removeAt(i) {
		this.splice(i, 1);
	}
	Array.prototype.removeAt = removeAt;
	this.removeAt = removeAt;
	
	/**
	 * Appends the specified element to the end of this list.
	 *
	 * @param e Object element to be appended to this list.
	 * @type boolean
	 * @see componence.util.Array.push
	 */
	function add(e) {
		return this.push(e);
	}
	Array.prototype.add = add;
	this.add = Array.prototype.add;

	/*
	 * init
	 */
	var list = new Array();
	var a = arguments;
	if( a.length > 0 )
		for(var i=0; i < a.length; i++ )
			list[list.length] = a[i];
	return list;
};

/**
 * Constructs an empty list.
 *
 * @access private
 * @deprecated
 * @version	2.1.19
 * @constructor
 * @lastmodified
 * @extends componence.util.Array
 */
function JSArrayList() {
	return new componence.util.ArrayList();
}
/**
 * <code>public class <b>Cookies</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.Cookies</code> is the javascript class which contains methods for common work with cookies.<br>
 *
 * Defines static variable: <code>Cookies</code><br>
 * Available as <code>new componence.util.Cookies()</code><br>
 * Packege <b><code>componence.util</code></b>
 */

/**
 * <code>componence.util.Cookies</code> is the javascript class which contains methods for common work with cookies.<br>
 *
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
componence.util.Cookies = function() {
	
	/**
	 * Current version of <code>componence.util.Cookies</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	/**
	 * Sets data in cookie string
	 *
	 * @access public
	 * @param n String name of cookie
	 * @param v String value of cookie
	 * @param c int how many days must be store cookie in system
	 * @type void
	 */
	function set(n, v, c) {
		var /*:Expires:*/ e = "";
		if ( c ) {
			var /*:Date:*/ d = new Date();
			d.setTime( d.getTime() + c * 24 * 60 * 60 * 1000 );
			e = "; expires=" + d.toGMTString();
		}
		document.cookie = escape( n ) + "=" + v + e + "; path=/";
	}
	this.set = set;
	
	/**
	 * Returns value from cookie string by name
	 *
	 * @access public
	 * @param n String name
	 * @type String
	 */
	function get(n) {
		var /*:sCookie:*/ c = document.cookie;
		var /*:sPrefix:*/ p = n + "=";
		var /*:iBegin:*/  b = c.indexOf("; " + p);
		if ( b == -1 ) {
			b = c.indexOf( p );
			if ( b != 0 ) return "";
		} else b += 2;
		var /*:iEnd:*/ e = c.indexOf( ";", b );
		if ( e == -1 ) 
			e = c.length;
		return unescape( c.substring( b + p.length, e ) );
	}
	this.get = get;
	
	/**
	 * Delete cookie from system
	 *
	 * @access public
	 * @param n String name of cookie
	 * @type void
	 * @see set
	 */
	function unset( n ) {
		return this.set( n, "" );
	}
	this.unset = unset;
};


/**
 * This class is used to work with cookies
 *
 * @access private
 * @deprecated
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
function JSCookie() {
	return new componence.util.Cookies();
}

/*
 * Create Cookies global object
 */
var Cookies = new componence.util.Cookies();
/**
 * <code>public class <b>DateFormatter</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.DateFormatter</code> is the javascript 
 * class which contains methods for common work with date formats.<br>
 *
 * Defines static variable: <code>DateFormatter</code><br>
 * Available as <code>new componence.util.DateFormatter()</code><br>
 * Packege <b><code>componence.util</code></b>
 */

/**
 * <code>componence.util.DateFormatter</code> is the javascript 
 * class which contains methods for common work with date formats.<br>
 *
 *  <ul>Here's the list of tokens we support:
 *  <li>m (or M) : month number, one or two digits.</li>
 *  <li>mm (or MM) : month number, strictly two digits (i.e. April is 04).</li>
 *  <li>d (or D) : day number, one or two digits.</li>
 *  <li>dd (or DD) : day number, strictly two digits.</li>
 *  <li>y (or Y) : year, two or four digits.</li>
 *  <li>yy (or YY) : year, strictly two digits.</li>
 *  <li>yyyy (or YYYY) : year, strictly four digits.</li>
 *  <li>mon : abbreviated month name (April is apr, Apr, APR, etc.)</li>
 *  <li>Mon : abbreviated month name, mixed-case (i.e. April is Apr only).</li>
 *  <li>MON : abbreviated month name, all upper-case (i.e. April is APR only).</li>
 *  <li>mon_strict : abbreviated month name, all lower-case (i.e. April is apr only).</li>
 *  <li>month : full month name (April is april, April, APRIL, etc.)</li>
 *  <li>Month : full month name, mixed-case (i.e. April only).</li>
 *  <li>MONTH: full month name, all upper-case (i.e. APRIL only).</li>
 *  <li>month_strict : full month name, all lower-case (i.e. april only).</li>
 *  <li>h (or H) : hour, one or two digits.</li>
 *  <li>hh (or HH) : hour, strictly two digits.</li>
 *  <li>min (or MIN): minutes, one or two digits.</li>
 *  <li>mins (or MINS) : minutes, strictly two digits.</li>
 *  <li>s (or S) : seconds, one or two digits.</li>
 *  <li>ss (or SS) : seconds, strictly two digits.</li>
 *  <li>ampm (or AMPM) : am/pm setting.  Valid values to match this token are
 *	am, pm, AM, PM, a.m., p.m., A.M., P.M.</li>
 * </ul>
 * @constructor
 * @version
 * @lastmodified
 */
componence.util.DateFormatter = function() {

	/**
	 * Current version of <code>componence.util.DateFormatter</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	/** 
	 * Be careful with this pattern.  Longer tokens should be placed before shorter
	 * tokens to disambiguate them.  For example, parsing "mon_strict" should 
	 * result in one token "mon_strict" and not two tokens "mon" and a literal
	 * "_strict".
	 * @access private
	 * @type RegExp
	 */
	this.tokPat = new RegExp("^month_strict|month|Month|MONTH|yyyy|YYYY|mins|MINS|mon_strict|ampm|AMPM|mon|Mon|MON|min|MIN|dd|DD|mm|MM|yy|YY|hh|HH|ss|SS|m|M|d|D|y|Y|h|H|s|S|w|W");

	/**
	 * lowerMonArr is used to map months to their numeric values.
	 * @access private
	 * @type Object
	 */
	this.lowerMonArr = {jan:1, feb:2, mar:3, apr:4, may:5, jun:6, jul:7, aug:8, sep:9, oct:10, nov:11, dec:12 };

	/** 
	 * monPatArr contains regular expressions used for matching abbreviated months
	 * in a date string.
	 * @access private
	 * @type Array
	 */
	this.monPatArr = new Array();
	
	/** 
	 * monPatArr contains regular expressions used for matching abbreviated months
	 * in a date string.
	 * @access private
	 * @type RegExp
	 */
	this.monPatArr['mon_strict'] = new RegExp(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/);
	
	/** 
	 * monPatArr contains regular expressions used for matching abbreviated months
	 * in a date string.
	 * @access private
	 * @type RegExp
	 */
	this.monPatArr['Mon'] = new RegExp(/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/);
	
	/** 
	 * monPatArr contains regular expressions used for matching abbreviated months
	 * in a date string.
	 * @access private
	 * @type RegExp
	 */
	this.monPatArr['MON'] = new RegExp(/JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC/);
	
	/** 
	 * monPatArr contains regular expressions used for matching abbreviated months
	 * in a date string.
	 * @access private
	 * @type RegExp
	 */
	this.monPatArr['mon'] = new RegExp("jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",'i');

	/**
	 * monthPatArr contains regular expressions used for matching full months
	 * in a date string.
	 * @access private
	 * @type Array
	 */
	this.monthPatArr = new Array();
	
	/**
	 * monthPatArr contains regular expressions used for matching full months
	 * in a date string.
	 * @access private
	 * @type RegExp
	 */
	this.monthPatArr['month'] = new RegExp(/^january|february|march|april|may|june|july|august|september|october|november|december/i);
	
	/**
	 * monthPatArr contains regular expressions used for matching full months
	 * in a date string.
	 * @access private
	 * @type RegExp
	 */
	this.monthPatArr['Month'] = new RegExp(/^January|February|March|April|May|June|July|August|September|October|November|December/);
	
	/**
	 * monthPatArr contains regular expressions used for matching full months
	 * in a date string.
	 * @access private
	 * @type RegExp
	 */
	this.monthPatArr['MONTH'] = new RegExp(/^JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER/);
	
	/**
	 * monthPatArr contains regular expressions used for matching full months
	 * in a date string.
	 * @access private
	 * @type RegExp
	 */
	this.monthPatArr['month_strict'] = new RegExp(/^january|february|march|april|may|june|july|august|september|october|november|december/);

	/** 
	 * cutoffYear is the cut-off for assigning "19" or "20" as century.  Any
	 * two-digit year >= cutoffYear will get a century of "19", and everything
	 * else gets a century of "20".
	 * @access private
	 * @type int
	 */
	this.cutoffYear = 50;

	/** 
	 * JSFormatToken is a datatype we use for storing extracted tokens from the
	 * format string.
	 * @access private
	 * @param tk String token
	 * @param tp String type
	 * @type Class
	 */
	function JSFormatToken(tk, tp) {
		/**
		 * @access private
		 */
		this.token = tk;
		
		/**
		 * @access private
		 */
		this.type  = tp;
	}
	/**
	 * @access private
	 */
	this.JSFormatToken = JSFormatToken;


	/**
	 * @access private
	 */
	function /*:Object:*/ parseFormatString( /*:String:*/ formatStr ) {
		var tokArr = new Array();
		var tokInd = 0;
		var strInd = 0;
		var foundTok = 0;
		while ( strInd < formatStr.length ) {
			if ( formatStr.charAt( strInd ) == "%" && ( matchArray = formatStr.substr( strInd + 1 ).match( this.tokPat ) ) != null ) {
				strInd += matchArray[0].length + 1;
				tokArr[tokInd++] = new this.JSFormatToken( matchArray[0], "symbolic" );
			} else {
				/*
				 * No token matched current position, so current character should 
				 * be saved as a required literal.
				 */
				if ( tokInd > 0 && tokArr[tokInd - 1].type == "literal" ) {
					/*
					 * Literal tokens can be combined.Just add to the last token.
					 */
					tokArr[tokInd - 1].token += formatStr.charAt( strInd++ );
				} else {
					tokArr[tokInd++] = new this.JSFormatToken( formatStr.charAt( strInd++ ), "literal" );
				}
			}
		}
		return tokArr;
	}
	/**
	 * @access private
	 */
	this.parseFormatString  = parseFormatString;

	/** 
	 *  buildDate does all the real work.It takes a date string and format string,
	 *  tries to match the two up, and returns a Date object (with the supplied date
	 *  string value).If a date string doesn't contain all the fields that a Date
	 *  object contains (for example, a date string with just the month), all
	 *  unprovided fields are defaulted to those characteristics of the current
	 *  date. Time fields that aren't provided default to 0.Thus, a date string
	 *  like "3/30/2000" in "%mm/%dd/%yyyy" format results in a Date object for that
	 *  date at midnight.formatStr is a free-form string that indicates special
	 *  tokens via the % character.Here are some examples that will return a Date
	 *  object:<br>
   *  <code>
	 *  buildDate('3/30/2000','%mm/%dd/%y') // March 30, 2000<br>
	 *  buildDate('March 30, 2000','%Mon %d, %y') // Same as above.<br>
	 *  buildDate('Here is the date: 30-3-00','Here is the date: %dd-%m-%yy')<br>
	 * </code>
   * <br>
	 *  If the format string does not match the string provided, an error message
	 *  (i.e. String object) is returned.Thus, to see if buildDate succeeded, the
	 *  caller can use the "typeof" command on the return value. For example,
	 *  here's the dateCheck function, which returns true if a given date is
	 *  valid,and false otherwise (and reports an error in the false case):<br>
   * <code>
	 *  function dateCheck( dateStr, formatStr ) {<br>
	 *  &nbsp; var myObj = buildDate( dateStr, formatStr );<br>
	 *	&nbsp; if ( typeof myObj == "object" ) {<br>
	 *	&nbsp; &nbsp; // We got a Date object, so good.<br>
	 *	&nbsp; &nbsp; return true;<br>
	 *	&nbsp; } else {<br>
	 *	&nbsp; &nbsp; // We got an error string.<br>
	 *	&nbsp; &nbsp; alert( myObj );<br>
	 *	&nbsp; &nbsp; return false;<br>
	 *  &nbsp; }<br>
	 *  }
	 * </code>
	 * @type Date
	 * @see JSDateFormatter
	 * @param dateStr String string with date
	 * @param formatStr String string with format of date
	 */
	function buildDate(dateStr, formatStr ) {
		/*
		 * parse the format string first.
		 */
		var tokArr = this.parseFormatString( formatStr );
		var strInd = 0;
		var tokInd = 0;
		var intMonth;
		var intDay;
		var intYear;
		var intHour;
		var intMin;
		var intSec;
		var ampm = "";
		var strOffset;
		/*
		 * Create a date object with the current date so that if the user only
		 * gives a month or day string, we can still return a valid date.
		 */
		var curdate = new Date();
		intMonth = curdate.getMonth() + 1;
		intDay = curdate.getDate();
		intYear = curdate.getFullYear();
		/*
		 * Default time to midnight, so that if given just date info, we return
		 * a Date object for that date at midnight.
		 */
		intHour = 0;
		intMin = 0;
		intSec = 0;
		/*
		 * Walk across dateStr, matching the parsed formatStr until we find a 
		 * mismatch or succeed.
		 */
		while ( strInd < dateStr.length && tokInd < tokArr.length ) {
			/*
			 * Start with the easy case of matching a literal. 
			 */
			if ( tokArr[tokInd].type == "literal" ) {
				if ( dateStr.indexOf( tokArr[tokInd].token, strInd ) == strInd ) {
					/*
					 * The current position in the string does match the format pattern. 
					 */
					strInd += tokArr[tokInd++].token.length;
					continue;
				} else {
					/* ACK!
					 * There was a mismatch; return error.
					 */
					return "\"" + dateStr + "\" does not conform to the expected format: " + formatStr;
				}
			}
			/*
			 * If we get here, we're matching to a symbolic token.
			 */
			switch ( tokArr[tokInd].token ) {
				case 'm':
				case 'M':
				case 'd':
				case 'D':
				case 'h':
				case 'H':
				case 'min':
				case 'MIN':
				case 'w':
				case 'W':
				case 's':
				case 'S':
					/*
					 * Extract one or two characters from the date-time string and if 
					 * it's a number, save it as the month, day, hour, or minute, as
					 * appropriate.
					 */
					curChar = dateStr.charAt( strInd );
					nextChar = dateStr.charAt( strInd + 1 );
					matchArr = dateStr.substr( strInd ).match(/^\d{1,2}/);
					if ( matchArr == null ) {
						/*
						 * First character isn't a number; there's a mismatch between
						 * the pattern and date string, so return error.
						 */
						switch ( tokArr[tokInd].token.toLowerCase() ) {
							case 'd': var unit = "day"; break;
							case 'm': var unit = "month"; break;
							case 'h': var unit = "hour"; break;
							case 'min': var unit = "minute"; break;
							case 's': var unit = "second"; break;
						}
						return "Bad " + unit + " \"" + curChar + "\" or \"" + curChar +	nextChar + "\".";
					}
					strOffset = matchArr[0].length;
					switch ( tokArr[tokInd].token.toLowerCase() ) {
						case 'd': intDay = parseInt( matchArr[0], 10 ); break;
						case 'm': intMonth = parseInt( matchArr[0], 10 ); break;
						case 'h': intHour = parseInt( matchArr[0], 10 ); break;
						case 'min': intMin = parseInt( matchArr[0], 10 ); break;
						case 's': intSec = parseInt( matchArr[0], 10 ); break;
					}
				break;
				case 'mm':
				case 'MM':
				case 'dd':
				case 'DD':
				case 'hh':
				case 'HH':
				case 'mins':
				case 'MINS':
				case 'ss':
				case 'SS':
					/*
					 * Extract two characters from the date string and if it's a 
					 * number, save it as the month, day, or hour, as appropriate.
					 */
					strOffset = 2;
					matchArr = dateStr.substr( strInd ).match(/^\d{2}/);
					if ( matchArr == null ) {
						/*
						 * The two characters aren't a number; there's a mismatch 
						 * between the pattern and date string, so return an error
						 * message.
						 */
						switch ( tokArr[tokInd].token.toLowerCase() ) {
							case 'dd': var unit = "day"; break;
							case 'mm': var unit = "month"; break;
							case 'hh': var unit = "hour"; break;
							case 'mins': var unit = "minute"; break;
							case 'ss': var unit = "second"; break;
						}
						return "Bad " + unit + " \"" + dateStr.substr( strInd, 2 ) + "\".";
					}
					switch ( tokArr[tokInd].token.toLowerCase() ) {
						case 'dd': intDay = parseInt( matchArr[0], 10 ); break;
						case 'mm': intMonth = parseInt( matchArr[0], 10 ); break;
						case 'hh': intHour = parseInt( matchArr[0], 10 ); break;
						case 'mins': intMin = parseInt( matchArr[0], 10 ); break;
						case 'ss': intSec = parseInt( matchArr[0], 10 ); break;
					}
				break;
				case 'y':
				case 'Y':
					/*
					 * Extract two or four characters from the date string and if it's
					 * a number, save it as the year.Convert two-digit years to four
					 * digit years by assigning a century of '19' if the year is >= 
					 * cutoffYear, and '20' otherwise.
					 */
					if ( dateStr.substr( strInd, 4 ).search(/\d{4}/) != -1 ) {
						intYear = parseInt( dateStr.substr( strInd, 4 ), 10 ); // Four digit year.
						strOffset = 4;
					} else {
						if ( dateStr.substr( strInd, 2 ).search(/\d{2}/) != -1 ) {
							intYear = parseInt( dateStr.substr( strInd, 2 ), 10 ); // Two digit year.
							if ( intYear >= this.cutoffYear ) {
								intYear += 1900;
							} else {
								intYear += 2000;
							}
							strOffset = 2;
						} else {
							/*
							 * Bad year;
							 * return error.
							 */
							return "Bad year \"" + dateStr.substr( strInd, 2 ) + "\". Must be two or four digits.";
						}
					}
				break;
				case 'yy':
				case 'YY':
					/*
					 * Extract two characters from the date string and if it's a 
					 * number, save it as the year.Convert two-digit years to four 
					 * digit years by assigning a century of '19' if the year is >= 
					 * cutoffYear, and '20' otherwise.
					 */
					if ( dateStr.substr( strInd, 2 ).search(/\d{2}/) != -1 ) {
						intYear = parseInt( dateStr.substr( strInd, 2 ), 10 ); // Two digit year.
						if ( intYear >= this.cutoffYear ) {
							intYear += 1900;
						} else {
							intYear += 2000;
						}
						strOffset = 2;
					} else {
						/*
						 * Bad year;
						 * return error
						 */
						return "Bad year \"" + dateStr.substr( strInd, 2 ) + "\". Must be two digits.";
					}
				break;
				case 'yyyy':
				case 'YYYY':
					/*
					 * Extract four characters from the date string and if it's a 
					 * number, save it as the year.
					 */
					if ( dateStr.substr( strInd, 4 ).search(/\d{4}/) != -1 ) {
						intYear = parseInt( dateStr.substr( strInd, 4 ), 10 ); // Four digit year.
						strOffset = 4;
					} else {
						/*
						 * Bad year;
						 * return error.
						 */
						return "Bad year \"" + dateStr.substr( strInd, 4 ) + "\". Must be four digits.";
					}
				break;
				case 'mon':
				case 'Mon':
				case 'MON':
				case 'mon_strict':
					/*
					 * Extract three characters from dateStr and parse them as 
					 * lower-case, mixed-case, or upper-case abbreviated months,
					 * as appropriate.
					 */
					monPat = this.monPatArr[tokArr[tokInd].token];
					if ( dateStr.substr( strInd, 3 ).search( monPat ) != -1 ) {
						intMonth = this.lowerMonArr[ dateStr.substr( strInd, 3 ).toLowerCase() ];
					} else {
						/*
						 * Bad month,
						 * return error.
						 */
						switch ( tokArr[tokInd].token ) {
							case 'mon_strict': caseStat = "lower-case"; break;
							case 'Mon': caseStat = "mixed-case"; break;
							case 'MON': caseStat = "upper-case"; break;
							case 'mon': caseStat = "between Jan and Dec"; break;
						}
						return "Bad month \"" + dateStr.substr( strInd, 3 ) + "\". Must be " + caseStat + ".";
					}
					strOffset=3;
				break;
				case 'month':
				case 'Month':
				case 'MONTH':
				case 'month_strict':
					/*
					 * Extract a full month name at strInd from
					 * dateStr if possible.
					 */
					monPat = this.monthPatArr[ tokArr[tokInd].token ];
					matchArray = dateStr.substr( strInd ).match( monPat );
					if ( matchArray == null ) {
						/*
						 * Bad month,
						 * return error.
						 */
						return "Can't find a month beginning at \"" + dateStr.substr( strInd ) + "\".";
					}
					/*
					 * It's a good month.
					 */
					intMonth = this.lowerMonArr[ matchArray[0].substr( 0, 3 ).toLowerCase() ];
					strOffset = matchArray[0].length;
				break;
				case 'ampm':
				case 'AMPM':
					matchArr = dateStr.substr( strInd ).match(/^(am|pm|AM|PM|a\.m\.|p\.m\.|A\.M\.|P\.M\.)/);
					if ( matchArr == null ) {
						/*
						 * There's no am/pm in the string.
						 * Return error msg.
						 */
						return "Missing am/pm designation.";
					}
					/*
					 * Store am/pm value for later (as just am or pm,
					 * to make things easier later).
					 */
					if ( matchArr[0].substr( 0, 1 ).toLowerCase() == "a" ) {
						ampm = "am";
					} else {
						ampm = "pm";
					}
					strOffset = matchArr[0].length;
				break;
			}
			strInd += strOffset;
			tokInd++;
		}
		if ( tokInd != tokArr.length || strInd != dateStr.length ) {
			/*
			 * We got through the whole date string or format string, but there's 
			 * more data in the other, so there's a mismatch.
			 */
			return "\"" + dateStr + "\" is either missing desired information or has more information than the expected format: " + formatStr;
		}
		/*
		 * Make sure all components are in the right ranges.
		 */
		if ( intMonth < 1 || intMonth > 12 ) {
			return "Month must be between 1 and 12.";
		}
		if ( intDay < 1 || intDay > 31 ) {
			return "Day must be between 1 and 31.";
		}
		/*
		 * Make sure user doesn't put 31 for a month that
		 * only has 30 days
		 */
		if ( ( intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11 ) && intDay == 31 ) {
			return "Month " + intMonth + " doesn't have 31 days!";
		}
		/*
		 * Check for February date validity
		 * (including leap years) 
		 */
		if ( intMonth == 2 ) {
			/*
			 * figure out if "year" is a leap year; don't forget that
			 * century years are only leap years if divisible by 400
			 */
			var isleap = ( intYear % 4 == 0 && ( intYear % 100 != 0 || intYear % 400 == 0) );
			if ( intDay > 29 || ( intDay == 29 && !isleap ) ) {
				return "February " + intYear + " doesn't have " + intDay + " days!";
			}
		}
		/*
		 * Check that if am/pm is not provided,
		 * hours are between 0 and 23.
		 */
		if ( ampm == "" ) {
			if ( intHour < 0 || intHour > 23 ) {
				return "Hour must be between 0 and 23 for military time.";
		 }
		} else {
			/*
			 * non-military time,
			 * so make sure it's between 1 and 12.
			 */
			if ( intHour < 1 || intHour > 12 ) {
				return "Hour must be between 1 and 12 for standard time.";
			}
		}
		/*
		 * If user specified amor pm,
		 * convert intHour to military.
		 */
		if ( ampm == "am" && intHour == 12 ) {
			intHour = 0;
		}
		if ( ampm == "pm" && intHour < 12 ) {
			intHour += 12;
		}
		if ( intMin < 0 || intMin > 59 ) {
			return "Minute must be between 0 and 59.";
		}
		if ( intSec < 0 || intSec > 59 ) {
			return "Second must be between 0 and 59.";
		}
		return new Date( intYear, intMonth - 1, intDay, intHour, intMin, intSec );
	}
	this.buildDate = buildDate;
	
	/**
	 * Transform object of Date in String.
	 *
	 * @param date Date date , which be processed in to string
	 * @param format String string with date format
	 * @return string of date
	 * @type string
	 */
	function dateToString(date, format) {
		var m = date.getMonth();
		m++;
		var mm = ( m < 10 ) ? "0" + m : m;
		var d = date.getDate(); 
		var dd = ( d < 10 ) ? "0" + d : d;
		var y = date.getFullYear(); 
		var yy = StringUtils.right( String( y ) ,2 );
	  var yyyy = y;
		var h = date.getHours();
		var hh = ( h < 10 ) ? "0" + h : h;
		var s = date.getSeconds();
		var ss = ( s < 10 ) ? "0" + s : s;
		var min = date.getMinutes();
		var mins = ( min < 10 ) ? "0" + min : min;

		var token =  this.parseFormatString( format );
		for (var i = 0; i < token.length; i++ ) {
			if ( token[i].type == "symbolic" ) {
				switch ( token[i].token ) {
			    case "m" :
			    case "M" :
		        format = StringUtils.replaceAll( format, "%" + token[i].token, m );
		        break;
					case "mm" :
			    case "MM" :
		        format = StringUtils.replaceAll( format, "%" + token[i].token, mm );
		        break;
					case "d" :
					case "D" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, d );
						break;
					case "dd" :
					case "DD" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, dd );
						break;
					case "y" :
					case "Y" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, y );
						break;
					case "yy" :
					case "YY" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, yy );
						break;
					case "yyyy" :
					case "YYYY" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, yyyy );
						break;
					case "h" :
					case "H" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, h );
						break;
					case "hh" :
					case "HH" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, hh );
						break;
					case "s" :
					case "S" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, s );
						break;
					case "ss" :
					case "SS" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, ss );
						break;
					case "min" :
					case "MIN" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, min );
						break;
					case "mins" :
					case "MINS" :
						format = StringUtils.replaceAll( format, "%" + token[i].token, mins );
						break;
				}
			}
		}
		return format;
	}
	this.dateToString = dateToString;

	/**
	 * validation of date 
	 * @param dateStr String string with date
	 * @param formatStr String format of date
 	 * @type boolean
	 * @return true if <code>dateStr</code> is valid date
	 */
	function dateCheck(dateStr, formatStr) {
		var myObj = this.buildDate( dateStr, formatStr );
		if ( typeof myObj == "object" ) {
			/*
			 * We got a Date object, so good.
			 */
			return true;
		} else {
			/*
			 * We got an error string.
			 */
			return false;
		}
	}
	this.dateCheck = dateCheck;
	
	/**
	 * Usage: <br>
	 * <code>
	 * compareDates( ["date1, format1"], "<", ["date2", "forma2"] )<br>
	 * compareDates( ["date1, format1"], "<=", ["date2", "forma2"] )<br>
	 * compareDates( ["date1, format1"], "==", ["date2", "forma2"] )<br>
	 * compareDates( ["date1, format1"], ">", ["date2", "forma2"] )<br>
	 * compareDates( ["date1, format1"], ">=", ["date2", "forma2"] )<br>
	 * </code>
	 * @param dateArray1 Array
	 * @param expr String
	 * @param dateArray2 Array
	 * @type boolean
	 */
	function compareDates(dateArray1, expr, dateArray2  ) {
		if ( typeof dateArray1 != "object" || typeof dateArray2 != "object" ) {
			return alert( "Can't compare " + dateArray1 + " with " + dateArray2 );
		}
		var result1 = DateFormatter.buildDate( dateArray1[0], dateArray1[1] );
		var result2 = DateFormatter.buildDate( dateArray2[0], dateArray2[1] );
		
		return ( eval( this.getTime( result1 ) + "" + expr + "" + this.getTime( result2 ) ) );
		
	}
	this.compareDates = compareDates;
	
	/**
	 * @access private
	 */
	this.getTime = function( /*:Date:*/ date ) {
		return new Date( date ).getTime();
	};
};

/**
 * <code>JSDateFormatter</code> is the javascript 
 * class which contains methods for common work with date formats.<br>
 * 
 * @access private
 * @deprecated
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
function JSDateFormatter() {
	return new componence.util.DateFormatter();
}

var DateFormatter = new componence.util.DateFormatter();
/**
 * <code>public class <b>DateUtils</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.DateUtils</code> is the javascript 
 * class which contains methods for common work with dates.<br>
 *
 * Defines static variable: <code>DateUtils</code><br>
 * Available as <code>new componence.util.DateUtils()</code><br>
 * Packege <b><code>componence.util</code></b>
 */

/**
 * <code>componence.util.DateUtils</code> is the javascript 
 * class which contains methods for common work with dates.<br>
 * 
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
componence.util.DateUtils = function() {
	
	/**
	 * Current version of <code>componence.util.DateUtils</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	/**
	 * Compares this object against the specified object.
	 *
	 * @access public
	 * @param obj Date the object to compare with
	 * @type boolean
	 * @return true if the objects are the same; false otherwise.
	 */
	if(typeof Date.prototype.equals != "function") {
		Date.prototype.equals = function(obj) {
			return (this.getTime() == obj.getTime());
		};
	}
	
	/**
	 * Compares date
	 *
	 * @access public
	 * @param obj Date the object to compare with
	 * @type int
	 * @return -1, 0, 1
	 * @see Date.prototype.equals
	 */
	if(typeof Date.prototype.compare != "function") {
		Date.prototype.compare = function(obj) {
			var t1 = this.getTime();
			var t2 = obj.getTime();
			return (t1 < t2) ? -1 : (t1 == t2 ) ? 0 : 1;
		};
	}
	
	/**
	 * Returns how many days in <code>month</code>
	 *
	 * @access public
	 * @param month int current month, must be in 1 - 12
	 * @param year int current year
	 * @return how many days in <code>month</code>
	 * @type int
	 */
	function howManyDays(month, year){
		var m = month;
		var y = year;
		if ( m > 12) 
			m = m % 12;
		m = m - 1;
		if ( m == 0 || m == 2 || m == 4 || m == 6 || m == 7 || m == 9 || m == 11 )
			return 31;
		if ( m == 1 ) 
			return( y % 4 == 0 ) ? 29 : 28;
		if ( m == 3 || m == 5 || m == 8 || m == 10 )
			return 30;
	}
	Date.prototype.howManyDays = howManyDays;
	this.howManyDays = howManyDays;
	
	/**
	 * Returns how many days between <code>d1</code> and <code>date2</code>
	 *
	 * @access public
	 * @param d1 Date first date
	 * @param d2 Date second date
	 * @return how many days between <code>d1</code> and <code>d2</code>
	 * @type int
	 */
	function daysBetween(d1, d2){
		var /*:ONE_DAY:*/ o = 1000 * 60 * 60 * 24;
		var /*:start:*/ s = date1.getTime();
		var /*:end:*/ e = date2.getTime();
		var /*:difference:*/ d = Math.abs(s - e);
		return Math.round( d / o );
	}
	Date.prototype.daysBetween = daysBetween;
	this.daysBetween = daysBetween;


	/**
	 * Julian date is defined as the day of the year (1-366)<br>
	 * return as the day of the year (1-366)
	 * 
	 * @access public
	 * @param d Date date which will be processed
	 * @return as the day of the year (1-366)
	 * @type int
	 */
	function getJulianDate(d){
		var /*:MILLIS_PER_DAY:*/ m = 24*60*60*1000;
		var /*:newYearDay:*/ n = new Date( d.getFullYear(), 0, 1 );
		return Math.ceil( ( d.getTime() - n.getTime() ) / m ) + 1;
	}
	Date.prototype.getJulianDate = getJulianDate;
	this.getJulianDate = getJulianDate;

	/**
	 * Week starts on monday<br>
	 * Week 1 is first week with 4 days, i.e. first week with a thursday<br>
	 * return how many weeks in date <code>d</code>
	 *
	 * @access public
	 * @param d Date date which will be processed
	 * @return return how many weeks in date <code>d</code>
	 * @type int
	 */
	function getWeekNumber(d) {
		var /*:THURSDAY:*/ t = 4;
		/* Lemma 1: Weeknum of a thursday is always in correct year
		 *  we call this thursday "determinant_day"
		 */
		var /*:determinantDay:*/ r = new Date( d.getFullYear(), d.getMonth(), d.getDate() );
		r.setDate( r.getDate() - r.getDay() + t );
		return Math.ceil( getJulianDate(r) / 7 );
	}
	Date.prototype.getWeekNumber = getWeekNumber;
	this.getWeekNumber = getWeekNumber;

	/**
	 * count of weeks in year
	 *
	 * @access public
	 * @type int
	 */
	this.weeksInYear = 52;

	var a = arguments;
	if( a.length > 0 ) return new Date(a[0]);
	
};

/**
 * JSDate is the javascript class which contains common functions for
 * work with date
 * 
 * @access private
 * @deprecated
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
function JSDate() {
	return new componence.util.DateUtils();
}

//Date.prototype = new componence.util.DateUtils();

/*
 * Create global VisualElementManager object
 */
var DateUtils = new componence.util.DateUtils();
/**
 * <code>public class <b>HashMap</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.HashMap</code> is the hash table based implementation of the Map interface. 
 * This implementation provides all of the optional map operations, 
 * and permits null values and the null key. (The HashMap  class is roughly 
 * equivalent to Hashtable, except that it is unsynchronized and permits nulls.) 
 * This class makes no guarantees as to the order of the map; in particular, it 
 * does not guarantee that the order will remain constant over time.<br>
 *
 * Defines static variable: <code>none</code><br>
 * Available as <code>new componence.util.HashMap()</code><br>
 * Packege <b><code>componence.util</code></b>
 *
 * @link http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html
 */

/**
 * Constructs an empty HashMap
 * 
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
componence.util.HashMap = function() {
	
	/**
	 * Current version of <code>componence.util.HashMap</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	/**
	 * @access private
	 * @type Object
	 */
	this.hash = {};

	/**
	 * Returns the value to which the specified key is mapped in this identity hash map, or 
	 * null if the map contains no mapping for this key. A return value of null does not 
	 * necessarily indicate that the map contains no mapping for the key; it is also possible 
	 * that the map explicitly maps the key to null. The containsKey method may be used to 
	 * distinguish these two cases.
	 *
	 * @access public
	 * @param key String the key whose associated value is to be returned.
	 * @return the value to which this map maps the specified key, or null if the map contains no mapping for this key
	 * @type Object
	 * @see put
	 */
	function get( key ) {
		return this.hash[key];
	}
	this.get = get;
	
	/**
	 * Returns a set view of the keys contained in this map. 
	 *
	 * @access public
	 * @return a set view of the keys contained in this map.
	 * @type Array
	 */
	function keySet() {
		var k = [];
		for( var key in this.hash ) k[k.length] = key;
		return k;
	}
	this.keySet = keySet;

	/**
	 * Associates the specified value with the specified key in this map. 
	 * If the map previously contained a mapping for this key, the old value is replaced.
	 *
	 * @access public
	 * @param key String key with which the specified value is to be associated.
	 * @param value Object value to be associated with the specified key.
	 * @type void
	 * @see get
	 */
	function put(key, value) {
		this.hash[key] = value;
		this.hash.length++;
	}
	this.put = put;

	/**
	 * Returns true if this map contains a mapping for the specified key.
	 *
	 * @access public
	 * @param key String The key whose presence in this map is to be tested
	 * @type boolean
	 * @return true if this map contains a mapping for the specified key.
	 * @see get
	 */
	function containsKey( key ) {
		var r = String( this.get( key ) );
		return ( r != 'undefined' && r != 'null' );
	}
	this.containsKey = containsKey;
	
	/**
	 * Returns true if this map contains no key-value mappings.
	 * 
	 * @access public
	 * @type boolean
	 * @return true if this map contains no key-value mappings.
	 */
	function isEmpty() {
		return (this.size() == 0);
	}
	this.isEmpty = isEmpty;
	
	/**
	 * Removes all mappings from this map.<br>
	 * <b>Overrides:</b> Array.prototype.clear
	 * 
	 * @access public
	 * @type void
	 */
	function clear() {
		/**
		 * @access private
		 */
		this.hash = {};
	}
	this.clear = clear;
	
	/**
	 * Returns the number of key-value mappings in this map.
	 * 
	 * @access public
	 * @type int
	 */
	function size() {
		return this.hash.length;
	}
	this.size = size;
};


/**
 * Constructs an empty HashMap
 * 
 * @access private
 * @deprecated
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
function JSHashMap() {
	return new componence.util.HashMap();
}
/**
 * <code>public class <b>Browser</b><br>
 * extends Object</code><br><br>
 *
 * A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale  to tailor information for the user. For example, displaying a number is a locale-sensitive operation--the number should be formatted according to the customs/conventions of the user's native country, region, or culture.<br>
 *
 * Depends on: <code>componence.ComponentConfig</code><br>
 * Defines static variable: <code>Object Locale</code><br>
 * Available as <code>new componence.util.Locale()</code><br>
 * Packege <b><code>componence.util</code></b>
 */

/**
 * Construct a locale
 * 
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
componence.util.Locale = function() {
	
	/**
	 * Current version of <code>componence.util.Locale</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	var /*:ComponentConfig:*/ cfg = window.ComponentConfig;

	
	/**
	 * @access public
	 * @type String
	 * @see ComponentConfig.defaultLanguage
	 */
	this.currentLocale = ( userLanguage ) ? userLanguage : "en";
	
	/**
	 * @access public
	 * @type String
	 * @see ComponentConfig.defaultLanguage
	 */
	this.defaultLocale = ( cfg ) ? cfg.defaultLanguage : "en";
	
	/**
	 * @access public
	 * @type boolean
	 * @see ComponentConfig.autoDetectLanguage
	 */
	this.autoDetect = ( cfg ) ? cfg.autoDetectLanguage : true;
	
	/**
	 * @access public
	 * @type String
	 * @see ComponentConfig.localePath, ComponentConfig.scriptPath
	 */
	this.scriptPath = ( cfg ) ? ( ( cfg.localePath ) ? cfg.localePath : cfg.scriptPath ) : "";
	
	/**
	 * @access private
	 * @type Array
	 */
	this.includedLocales = [];
	
	/**
	 * @access public
	 * @type Object
	 */
	this.availableLocales = {
		en : {
			charset   : "windows-1252",
			name      : "English",
			shortName : "en"
		},
	
		nl : {
			charset   : "windows-1252",
			name      : "Nederlands",
			shortName : "nl"
		},
	
		ru : {
			charset   : "windows-1251",
			name      : "1056;1091;1089;1089;1082;1080;1081;",
			shortName : "ru"
		},
	
		uk : {
			charset   : "windows-1251",
			name      : "1059;1082;1088;1072;1111;1085;1089;1100;1082;1072;",
			shortName : "uk"
		}
	};
	
	/**
	 * Returns a list of all installed locales.
	 *
	 * @access public
	 * @type Object
	 */
	function getAvailableLocales() {
		return this.availableLocales;
	}
	this.getAvailableLocales = getAvailableLocales;
	
	/**
	 * Sets the current locale for this instance
	 * 
	 * @access public
	 * @param newLocale String the new current locale
	 * @type void
	 */
	function setCurrent(newLocale ) {
		/**
		 * @access private
		 */
		this.currentLocale = newLocale;
		this.include("common");
		setCookieLocale( newLocale );
		
	}
	this.setCurrent = setCurrent;

	/**
	 * Sets the current locale for this instance
	 * 
	 * @access public
	 * @param newLocale String the new current locale
	 * @type void
	 */
	function setDefault( newLocale ) {
		/**
		 * @access private
		 */
		this.defaultLocale = newLocale;
	}
	this.setDefault = setDefault;
	
	/**
	 * Gets the current value of the current locale for this instance
	 * 
	 * @access public
	 * @return the current locale for this instance
	 * @type String
	 */
	function getCurrent() {
		return this.currentLocale;
	}
	this.getCurrent = getCurrent;

	/**
	 * Gets the current value of the default locale for this instance
	 * 
	 * @access public
	 * @return the default locale for this instance
	 * @type String
	 */
	function getDefault() {
		return this.defaultLocale;
	}
	this.getDefault = getDefault;
	
	/**
	 * Returns character set for current locale. (format windows-1252)
	 *
	 * @access public
	 * @type String
	 * @see getCurrent
	 */
	function getCharset() {
		return this.availableLocales[this.getCurrent()].charset;
	}
	this.getCharset = getCharset;
	
	/**
	 * Return name of current locale.
	 *
	 * @access public
	 * @type String
	 * @see getCurrent
	 */
	function getName() {
		var /*:Temporary:*/ t = String( this.availableLocales[this.getCurrent()].name );
		t = t.split(";");
		if( t.length == 1 ) {
			return String( this.availableLocales[this.getCurrent()].name );
		}
		var /*:Name:*/ n = "";
		for( var i = 0; i < t.length; i++ ) {
			n += String.fromCharCode( t[i] );
		}
		return n;
	}
	this.getName = getName;

	/**
	 * Return short name of current locale. (en, nl, ru, uk, etc)
	 *
	 * @access public
	 * @type String
	 * @see getCurrent
	 */
	function getShortName() {
		return this.availableLocales[this.getCurrent()].shortName;
	}
	this.getShortName = getShortName;
	
	/**
	 * Includes required locale file<br>For example:<br>
	 * <code>
	 * Locale.include("rtf");
	 * </code><br>if current locale "en":
	 * <code>&lt;script src="locale-<b>rtf</b>-en.js" type="text/javascript"&gt;&lt;/script&gt;</code>
	 * 
	 *
	 * @access public
	 * @param locale String locale short name. (en, nl, ru, uk, etc)
	 * @type void
	 * @see currentLocale
	 * @see scriptPath
	 */
	function include( locale ) {
		var l = this.scriptPath + 'locale-' + locale + '-' + this.currentLocale + '.js';
		/**
		 * @access private
		 */
		this.fileName = l;
		if ( !this.isIncluded( l ) ) {
			this.includedLocales[this.includedLocales.length] = l;
			document.write('<script src="' + l + '"  type="text/javascript" language="javascript"><\/scr'+'ipt>');
		}
	}
	this.include = include;
	
	/**
	 * @access private
	 * @type void
	 */
	function throwException() {
		return alert( "Current locale: "+this.currentLocale+"\nFile " + this.scriptPath + "" + this.fileName + " not exists." );
	}
	/**
	 * @access private
	 */
	this.throwException = throwException;
	
	/**
	 * @access private
	 * @type boolean
	 * @param locale String locale short name. (en, nl, ru, uk)
	 */
	function isIncluded( locale ) {
		for ( var i = 0; i < this.includedLocales.length; i++ ) {
			if ( this.includedLocales[i] == locale ) {
				return true;
			}
		}
		return false;
	}
	/**
	 * @access private
	 */
	this.isIncluded = isIncluded;

	/**
	 * Gets locale code from cookie, if cookie is empty get it from browser properties.
	 *
	 * @access public
	 * @type String
	 */
	function getLocaleCode() {
		var /*:Locale:*/ l = ( this.currentLocale ) ? this.currentLocale : this.defaultLocale;
		var c = getCookieLocale();
		if ( c ) {
			l = c;
		} else	if ( navigator.browserLanguage ) {
			/* IE 4+ Win, IE 5 Mac */
			l = navigator.browserLanguage;
		} else if ( navigator.language ) {
			/* Gecko, Opera, Safari, Konqueror */
			l = navigator.language;
		}
		/* Returns 2 first letters (en-US = en) */
		return l.substring( 0, 2 );
	}
	this.getLocaleCode = getLocaleCode;
	
	/**
	 * @access private
	 */
	function /*:void:*/ setCookieLocale( /*:String:*/ locale ) {
		Cookies.set("locale", locale, 30 );
	}
	
	/**
	 * @access private
	 */
	function /*:String:*/ getCookieLocale() {
		return Cookies.get("locale");
	}

	if( this.autoDetect ) {
		/**
		 * @access private
		 */
		this.currentLocale = this.getLocaleCode();
	}
	this.include("common");
};


/**
 * Construct a locale
 * 
 * @access private
 * @deprecated
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
function JSLocale() {
	return new componence.util.Locale();
}

var Locale = new componence.util.Locale();
/**
 * <code>public class <b>NumberUtils</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.NumberUtils</code> class is used for common work with numbers<br>
 *
 * Defines static variable: <code>Object NumberUtils</code><br>
 * Available as <code>new componence.util.NumberUtils()</code><br>
 * Packege <b><code>componence.util</code></b>
 */
 
/**
 * <code>componence.util.NumberUtils</code> class is used for common work with numbers<br>
 *
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
componence.util.NumberUtils = function() {
	
	/**
	 * Current version of <code>componence.util.NumberUtils</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	/**
	 * Returns formated bytes
	 *
	 * @access public
	 * @param bytes int - value we are processiing
	 * @param toCase String - upper | lower, default - lower
	 * @return return formated bytes
	 * @type String
	 */
	function formatBytes(bytes, toCase) {
		var /*:bytes:*/ b = bytes;
		var /*:toCase:*/ c = toCase;
		var /*:unit:*/ u = " b";
		if ( b > 1024 ) {
			b = b / 1024;
			u = " kb";
		}
		if ( b > 1024 ) {
			b = b / 1024;
			u = " mb";
		}
		b = String( b );
		var /*:dot:*/ d = b.indexOf( "." );
		if ( d != -1 ) {
			d += 2;
			b = b.substring( 0, d );
		}
		if ( c && String( c ).toLowerCase() == "upper" ) 
				u = u.toUpperCase();
		return b + u;
	}
	this.formatBytes = formatBytes;
	
	/**
	 * Returns factorial of [n]
	 * @access public
	 * @param n int value we are processiing
	 * @return factorial of [n]
	 * @type int
	 */
	function factorial( n ) { 
	  if ( isNaN( n ) || ( n < 0 ) ) return NaN;
	  var v = n == 0 ? 1 : n * factorial( n - 1 );
	  if ( ( String( v ).indexOf('.') != -1 ) || ( v == Number.POSITIVE_INFINITY ) )
	  	return NaN;
	  return v;
	}
	this.factorial = factorial;
	
	/**
	 * Returns random number from range : 0 - [maxNumber - 1 ]
	 *
	 * @access public
	 * @param maxNumber int max diapazon number
	 * @return random number from range : 0 - [maxNumber - 1 ]
	 * @type int
	 */
	function random(maxNumber) {
		return Math.round( Math.abs( Math.sin( new Date().getTime() ) ) * ( maxNumber - 1 ) );
	}
	this.random = random;
	
	/**
	 * Returns value in DEC from HEX<br>( parseInt('ff',16) == 255 )
	 *
	 * @access public
	 * @param hexValue String value in HEX system
	 * @return value in DEC from HEX
	 * @type int
	 * 
	 * 
	 */
	function hexToDec(hexValue ) {
		return parseInt( hexValue, 16 );
	}
	this.hexToDec = hexToDec;
	
	/**
	 * Returns value in HEX from DEC
	 *
	 * @access public
	 * @param decValue String value in DEC system
	 * @return value in HEX from DEC
	 * @type String
	 */
	function decToHex( decValue ) {
		var /*:decValue:*/ d = decValue;
		var /*:hex:*/ h = "0123456789ABCDEF";
		var /*:mask:*/m = 0xf;
		var /*:returnStr:*/ r = "";
			while ( d != 0 ) {
				r = h.charAt( d & m ) + r;
				d >>>= 4;
			}
		 return r.length == 0 ? "0" : r;
	}
	this.decToHex = decToHex;
	
	/**
	 * Convert string to int
	 *
	 * @access public
	 * @param s String value we are processiing
	 * @type int
	 */
	function getValueOf( s ) {
		var i = parseInt( Number( s ) );
		if ( !isNaN( i ) ) return i;
		else return parseInt( s );
	}
	this.getValueOf = getValueOf;
	
	/**
	 * This function returns an expression formatted as a number
	 *
	 * @access public
	 * @param num intthe number to format
	 * @param decimalNum int the number of decimal places to format the number to
	 * @param bolLeadingZero boolean true / false - display a leading zero for numbers between -1 and 1
	 * @param bolParens boolean true / false - use parenthesis around negative numbers
	 * @param bolCommas boolean put commas as number separators.
	 * @type String
	 */
	function format( num, decimalNum, bolLeadingZero, bolParens, bolCommas ) {
		var /*:num:*/ n = num;
		var /*:decimalNum:*/ d = decimalNum;
		var /*:bolLeadingZero:*/ z = bolLeadingZero;
		var /*:bolParens:*/ p = bolParens;
		var /*:bolCommas:*/ c = bolCommas;
		if ( isNaN( parseInt( n ) ) ) return "NaN";

		d = d ? d : -1;
		var /*:Temporary:*/ t = n;
		/*Get sign of number*/
		var /*:iSign:*/ i = n < 0 ? -1 : 1;
		
		/* Adjust number so only the specified number of numbers after
		 * the decimal point are shown.
		 */
		t *= Math.pow( 10, d );
		t = Math.round( Math.abs(t));
		t /= Math.pow( 10, d );
		/*Readjust for sign*/
		t *= i;
		
		/*
		 * Create a string object to do our formatting on
		 */
		var /*:returnString:*/ r = new String(t);
		
		/* See if we need to strip out the leading zero or not.*/
		if (!z && n < 1 && n > -1 && n != 0) {
			if (n > 0) r = r.substring(1, r.length);
			else r = "-" + r.substring(2, r.length);
		}
		
		/* See if we need to put in the commas*/
		if (c && (n >= 1000 || n <= -1000)) {
			var /*iStart*/ s = r.indexOf(".");
			if (s < 0) s = r.length;
			s -= 3;
			while (s >= 1) {
				r = r.substring(0, s) + "," + r.substring(s, r.length);
				s -= 3;
			}
		}
		/* See if we need to use parenthesis*/
		if (p && n < 0) r = "(" + r.substring(1, r.length) + ")";
	
		return r;
	}
	Number.prototype.format = format;
	this.format = format;
};

/**
 * JSNumberUtils is the javascript class which contains common functions for string
 *
 * @access private
 * @deprecated
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
function JSNumber() {
	return new componence.util.NumberUtils();
}


//Number.prototype = new componence.util.NumberUtils();

/*
 * Create global NumberUtils object
 */
var NumberUtils = new componence.util.NumberUtils();
/**
 * <code>public class <b>Object</b></code><br><br>
 *
 * Class Object is the root of the class hierarchy. 
 * Every class has Object as a superclass. 
 * All objects, including arrays, implement the methods of this class.<br>
 *
 * Defines static variable: <code>none</code><br>
 * Available as <code>new componence.util.Object()</code><br>
 * Packege <b><code>componence.util</code></b>
 */

/**
 * Class Object is the root of the class hierarchy. 
 * Every class has Object as a superclass. 
 * All objects, including arrays, implement the methods of this class.
 *
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
componence.util.Object = function() {
	
	/**
	 * Current version of <code>componence.util.Object</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	if ( typeof Function.prototype.call == "undefined" ) {
		/**
		 * Allows you to call (execute) a method of another object in the context of a different object (the calling object).<br>
		 * Implemented in: JavaScript 1.3<br>
		 * Compatible with IE5.01.<br>
		 *
		 * @param obj Object Parameter for the calling object
		 * @param params Arguments for the object
		 * @type void
		 */
		Function.prototype.call=function(obj, a, b, c, d, e, f) {
			var v, p, o = obj;
			p = '__call';
			/* Searching free property */
			while(typeof o[p] != "undefined" ) p += p;
			
			/* Method of the function so - this - is the function:- */
			o[p] = this;
			v = o[p](a, b, c, d, e, f);
			delete o[p];
			return v;
		};
	}
	
	if( typeof Function.prototype.apply == "undefined" ) {
		/**
		 * Allows you to apply a method of another object in the context of a different object (the calling object).<br>
		 * Implemented in: JavaScript 1.3<br>
		 * Compatible with IE5.01.<br>
		 *
		 * @param obj Object Parameter for the calling object
		 * @param params Array An argument array for the object
		 * @type void
		 * @see Function.prototype.call
		 */
		Function.prototype.apply = function(obj, params) {
			var /*:object:*/ o = obj;
			var /*:params:*/ p = params;
			var /*:args:*/   a = [];
			if( o == null || typeof o == "undefined" ) 
				o = window;
			p = (p) ? p : [];
			for( var i = 0; i < p.length; i++ )
				a[a.length] = "p[" + i + "]";
			o.evalMethod = this;
			var /*:returnValue:*/ v = eval( "o.evalMethod(" + a.join( "," ) + ");" );
			o.evalMethod = null;
			return v;
		};
	}
	
	/**
	 * The extend() method is added to the builtin Object class, 
	 * providing attribute inheritance.
	 * @access private
	 * @param superClass JSClass
	 * @type void
	 * @see Function.prototype.call
	 */
	Object.prototype.extend = function(superClass, source){
        //fix for conflict with prototype.js 1.6.0.3
		if (arguments.length == 2) {
			for (var property in source) {
            	try {
					superClass[property] = source[property];
				} catch (e) {
				}
			}
		}
	
        if(Global.isDefined(superClass.call)){
            superClass.call(this);
            /**
             * @access private
             */
            this.superClass = new superClass();
            /*this.superClass = new this.constructor.prototype.constructor();*/
        } else {
            //return extend;
            //fix for conflict with rico
            //return Object.extend.apply(this, [this, superClass]);
            //fix for conflict with prototype.js 1.6.0.3
            for (var property in superClass) {
            	try {
					this[property] = superClass[property];
				} catch (e) {
				}
			}
        }
	};
	
	if( typeof Object.prototype.getSuperClass == "undefined" ) {
		/**
		 * Returns the runtime super class of an object
		 *
		 * @access public
		 * @type JSClass
		 */
		Object.prototype.getSuperClass = function() {
			return ( this.superClass ) ? this.superClass : null;
		};
	}
	
	if( typeof Object.prototype.instanceOf == "undefined" ) {
		/**
		 * Determines if the specified Object is assignment-compatible with the object represented by this Class.
		 *
		 * @access public
		 * @param c JSClass the object to check
		 * @return true if obj is an instance of this class
		 * @type boolean
		 */
		Object.prototype.instanceOf = function(c) {
			return( this.constructor == c );
		};
	}
	
	if( typeof Object.prototype.clone == "undefined" ) {
		/**
		 * Creates and returns a copy of this object
		 *
		 * @access public
		 * @param deep Object
		 * @type Object
		 */
		Object.prototype.clone=function(deep) {
			var obj = new this.constructor();
			for ( var p in this ) {
				if (deep && typeof(this[p]) == 'object') obj[p] = this[p].clone(deep);
				else obj[p] = this[p];
			}
			return obj;
		};
	}
	
	
	if( typeof Object.prototype.methods == "undefined" ) {
		/**
		 * Returns an array containing Method objects reflecting all the public member methods 
		 * of the class or interface represented by this Class object, including those declared 
		 * by the class or interface and those inherited from superclasses and superinterfaces.
		 *
		 * @access public
		 * @type Array
		 */
		Object.prototype.methods = function() {
			var m = [];
			for (var p in this)
				if (typeof(this[p]) == "function")
					m.push(p);
			return m;
		};
	}
};

/**
 * Class Object is the root of the class hierarchy. 
 * Every class has Object as a superclass. 
 * All objects, including arrays, implement the methods of this class.
 *
 * @access private
 * @deprecated
 * @constructor
 * @lastmodified
 */
function JSObject() {
	return new componence.util.Object();
}

//Object.prototype=new componence.util.Object();
/**
 * <code>public class <b>Request</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.Request</code> Defines an object to provide client request information.<br>
 *
 * Defines static variable: <code>Object Request</code><br>
 * Available as <code>new componence.util.Request()</code><br>
 * Packege <b><code>componence.util</code></b>
 *
 * @link http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletRequest.html
 */

/**
 * <code>componence.util.Request</code> Defines an object to provide client request information.<br>
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
componence.util.Request = function() {
	
	/**
	 * Current version of <code>componence.util.Request</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	/**
	 * Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request.
	 *
	 * @access public
	 * @return a String representing the single value of the parameter
	 * @param n String name String specifying the name of the parameter
	 * @param m String method Optional. get, rewrite. Default get.
	 * @type String
	 */
	function getParameter( n, m ) {
		m = ( m ) ? m : "get";
		if( m == "get" ) {
			var a = String(this.getQueryString()).split("&");
			for(var i=0; i<a.length; i++ ) {
				var b = String(a[i]).split("=");
				if(b[0] == n){
					return b[1];
				}
			}
		} else if(m == "rewrite") {
			var a = String(document.location).split("/");
			for( var i=0; i<a.length; i++ ) {
				if(a[i]==n){
					return a[i+1];
				}
			}
		}
		return null;
	}
	this.getParameter = getParameter;
	
	/**
	 * Returns the nameof the protocol
	 *
	 * @access public
	 * @return a String containing the protocol name
	 * @type String
	 */
	function getProtocol(){
		return document.location.protocol;
	}
	this.getProtocol = getProtocol;
	
	/**
	 * Returns the host name of the server that received the request.
	 *
	 * @access public
	 * @return a String containing the name of the server
	 * @type String
	 */
	function getServerName(){
		return document.location.hostname;
	}
	this.getServerName = getServerName;
	
	/**
	 * Returns the port number on which this request was received. 
	 *
	 * @access public
	 * @return an integer specifying the port number.
	 * @type int
	 */
	function getServerPort(){
		var p = document.location.port;
		return (p) ? p : 80;
	}
	this.getServerPort = getServerPort;
	
	/**
	 * Returns the query string that is contained in the request URL after the path. This method returns null  if the URL does not have a query string.
	 *
	 * @access public
	 * @return a String containing the query string or null if the URL contains no query string
	 * @type String
	 */
	function getQueryString() {
		var s = String( document.location.search );
		s = ( s.substring( 0, 1 ) == "?" ) ? s.substring( 1, s.length ) : s;
		return s;
	}
	this.getQueryString = getQueryString;
	
	/**
	 * Returns an array containing all of the Cookie  objects the client sent with this request. This method returns null if no cookies were sent.
	 *
	 * @access public
	 * @return an array of all the Cookies  included with this request, or null  if the request has no cookies
	 * @type Array
	 */
	function getCookies(){
		return String(document.cookie).split(";");
	}
	this.getCookies = getCookies;
};

/**
 * 
 * @access private
 * @deprecated
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
function JSRequest() {
	return new componence.util.Request();
}

var Request = new componence.util.Request();
/**
 * <code>public class <b>RuntimeException</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.RuntimeException</code> is the superclass of those exceptions that can be thrown during the normal operation.<br>
 *
 * Defines static variable: <code>none</code><br>
 * Available as <code>new componence.util.RuntimeException()</code><br>
 * Packege <b><code>componence.util</code></b>
 *
 * @link http://java.sun.com/j2se/1.4.2/docs/api/java/lang/RuntimeException.html
 */


/**
 * Constructs a new runtime exception with the specified detail message.
 * @version	2.1.19
 * @constructor
 * @lastmodified
 * @param e Object Exception Object
 */
componence.util.RuntimeException = function(e) {

	/**
	 * @access private
	 * @type Object
	 */
	this.e = e;
	
	/**
	 * Returns the detail message string of this Exception.
	 * @access public
	 * @type String
	 * @return the detail message string of this Exception instance (which may be null).
	 */
	function getMessage() {
		if(!this.message && this.e) this.message = (typeof this.e != "string") ? ((this.e.message) ? this.e.message : this.e.description) : this.e;
		return this.message;
	}
	this.getMessage = getMessage;
	
	/**
	 * @access private
	 * @type String
	 */
	this.type = "componence.util.RuntimeException";
	
	/**
	 * @access private
	 * @type String
	 */
	this.message = this.getMessage();
	
	/**
	 * @access private
	 * @type String
	 */
	this.url = document.location;
	
	/**
	 * @access private
	 * @type int
	 */
	this.number = 0;
	
	/*
	 * check inheritance
	 */
	if(e) return new Error(this.number, this.type + "\r\n" + this.getMessage());
};
/**
 * <code>public class <b>StringBuffer</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.StringUtils</code> A string buffer implements a mutable sequence of characters.<br>
 * <strong>Note:</strong> The latest versions of Firefox seem to have fixed the string concatenation problem.<br>
 * If you are using Firefox 1.0 or later, the string buffer may actually take longer than normal string concatenation.<br>
 *
 * Defines static variable: <code>Object StringBuffer</code><br>
 * Available as <code>new componence.util.StringBuffer()</code><br>
 * Packege <b><code>componence.util</code></b>
 * 
 * @link http://java.sun.com/j2se/1.3/docs/api/java/lang/StringBuffer.html
 */
 
/**
 * Constructs a string buffer so that it represents the same sequence of 
 * characters as the string argument; in other words, the initial contents 
 * of the string buffer is a copy of the argument string. The initial capacity 
 * of the string buffer is 16 plus the length of the string argument.<br>
 * 
 * @version	2.1.19
 * @constructor
 * @lastmodified
 * @param str String the initial contents of the buffer.
 */
componence.util.StringBuffer = function(str) {
	
	/**
	 * @access private
	 */
	this.strings = [];
	
	
	/**
	 * Appends the string to this string buffer.
	 *
	 * @access public
	 * @param str String a string.
	 * @type StringBuffer
	 * @return a reference to this <code>StringBuffer</code>.
	 */
	function append(str) {
    this.strings.push(str);
    return this;
	}
	this.append = append;
	
	/**
	 * The specified character of the sequence currently represented by the string buffer, 
	 * as indicated by the index argument, is returned. The first character of a string 
	 * buffer is at index 0, the next at index 1, and so on, for array indexing.<br>
	 * The index argument must be greater than or equal to 0, and less than the length of 
	 * this string buffer.
	 *
	 * @access public
	 * @param index int the index of the desired character..
	 * @type char
	 * @return the character at the specified index of this string buffer..
	 */
	function charAt(index) {
		return this.toString().charAt(index);
	}
	this.charAt = charAt;
	
	/**
	 * Returns the length (character count) of this string buffer.
	 *
	 * @access public
	 * @type int
	 * @return the length of the sequence of characters currently represented by this string buffer.
	 */
	function length() {
		return this.toString().length;
	}
	this.length = length;
	
	/**
	 * The character sequence contained in this string buffer is replaced by the 
	 * reverse of the sequence.
	 *
	 * @access public
	 * @type StringBuffer
	 * @return a reference to this  object.
	 * @see componence.util.StringUtils.reverse
	 */
	function reverse() {
		var str = this.toString().reverse();
		this.strings = [];
		this.append(str);
	}
	this.reverse = reverse;
	
	/**
	 * Converts to a string representing the data in this string buffer. 
	 * A new <code>String</code> object is allocated and initialized to 
	 * contain the character sequence currently represented by this string buffer. 
	 * This <code>String</code> is then returned. Subsequent changes to the string 
	 * buffer do not affect the contents of the String.
	 *
	 * @access public
	 * @type String
	 * @return a string representation of the string buffer
	 * @override toString in class Object
	 */
	function toString() {
    return this.strings.join("");
	}
	this.toString = toString;
	
	/**
	 * Returns a new <code>String</code> that contains a subsequence of characters 
	 * currently contained in this <code>StringBuffer</code>.
	 *
	 * @access public
	 * @type String
	 * @param start int The beginning index, inclusive.
	 * @param end int Optional. The ending index, exclusive.
	 */
	function substring(start, end) {
		return this.toString().substring(start, end);
	}
	this.substring = substring;
	
	/**
	 * @access private
	 */
	function main(str) {
		if(str) this.append(str);
	}
	this.main = main;
	
	this.main(str);
};

var StringBuffer = new componence.util.StringBuffer();
/**
 * <code>public class <b>StringUtils</b><br>
 * extends Object</code><br><br>
 *
 * <code>componence.util.StringUtils</code> This class is used for common work with strings.<br>
 *
 * Defines static variable: <code>Object StringUtils</code><br>
 * Available as <code>new componence.util.StringUtils()</code><br>
 * Packege <b><code>componence.util</code></b>
 */

/**
 * <code>componence.util.StringUtils</code> This class is used for common work with strings.<br>
 * 
 * @version	2.1.19
 * @constructor
 * @lastmodified
 */
componence.util.StringUtils = function() {
	
	/**
	 * Current version of <code>componence.util.StringUtils</code> Component.
	 *
	 * @access public
	 * @type String
	 */
	this.version = "2.1.19";
	
	/**
	 * @access public
	 * @type String
	 */
	this.doubleQuote = String.fromCharCode(34);
	
	/**
	 * @access public
	 * @type String
	 */
	this.singleQuote = String.fromCharCode(39);
	
	/**
	 * @access public
	 * @type String
	 */
	this.slash = String.fromCharCode(47);
	
	/**
	 * @access public
	 * @type String
	 */
	this.backSlash = String.fromCharCode(92);
	
	/**
	 * Reverses a string
	 *
	 * @access public
	 * @param s String
	 * @type String
	 */
	 
	String.prototype.reverse = function(s){
		s = Global.isDefined(s) ? String( s ) : this;
		var r = "";
		var i = s.length;
		while (i>0) {
			r += s.substring(i-1,i);
			i--;
		}
		return r;
	};
	/**
	 * @access private
	 */
	this.reverse = String.prototype.reverse;
	
	/**
	 * convert a string to ascii
	 * @access public
	 * @param s String
	 * @type String
	 */
	function  toAsciiString( s ){
		str = Global.isDefined(s) ? String( s ) : this;
		var /*:ascii:*/ a = "";
		for ( var i = 0; i < s.length; i++ )
			a += "&#" + s.charCodeAt(i) + ";";
		return a;
	}
	String.prototype.toAsciiString = toAsciiString;
	this.toAsciiString = toAsciiString;
	
	/**
	 * Compares this string to the specified object
	 * @access public
	 * @param s1 String
	 * @param s2 String
	 * @type boolean
	 */
	function equals( s1, s2 ) {
		s1 = Global.isDefined(s2) ? String( s1 ) : this;
		s2 = Global.isDefined(s2) ? String( s2 ) : s1;
		return( String( s1 ) == String( s2 ) );
	}
	String.prototype.equals = equals;
	this.equals = equals;
	
	/**
	 * Tests if this string starts with the specified prefix beginning
	 * a specified index.<br>
	 * Returns boolean result - true if [str] has prefix as [prefix]
	 * @param s String the string we are processiing
	 * @param	p String the string with prefix to compare
	 * @return true if [str] has prefix as [prefix]
	 * @type boolean
	 */
	function startsWith(s, p) {
		return(this.left( s, p.length ) == p );
	}
	this.startsWith = startsWith;
	
	/**
	 * Tests if this string ends with the specified suffix.
	 * Returns boolean result - true if [str] has suffix as [suffix]
	 * @param s String the string we are processiing
	 * @param	f String the string with suffix to compare
	 * @return true if [str] has suffix as [suffix]
	 * @type boolean
	 */
	function endsWith(s, f) {
		return(this.right( s, f.length ) == f );
	}
	this.endsWith = endsWith;
	
	/**
	 * Returns replaced string 
	 * @param original String the string we are processiing
	 * @param	pattern String the string which be replaced
	 * @param	replace String string for replacement
	 * @return replaced string with once replacement 
	 * @type String
	 */
	function replace(original, pattern, replace) {
		return internalReplace( original, pattern, replace );
	}
	this.replace = replace;
	
	/**
	 * Returns replaced string 
	 * @param original String the string we are processiing
	 * @param	pattern String the string which be replaced
	 * @param	replace String string for replacement 
	 * @return replaced string with global replacement 
	 * @type String
	 */
	function replaceAll( original,  pattern, replace ) {
		return internalReplace( original, pattern, replace, "g" );
	}
	this.replaceAll = replaceAll;
	
	/**
	 * Returns boolean result - true if <code>s</code> has prefix as <code>p</code>
	 *
	 * @param	p String the string with prefix to compare
	 * @param s String the string we are processiing
	 * @return true if <code>s</code> has prefix as </code>p</code>
	 * @type boolean
	 * @see startsWith
	 * @deprecated please use <code>startsWith</code>
	 */
	function hasPrefix( p, s ) {
		return( this.left( s, p.length ) == p );
	}
	this.hasPrefix = hasPrefix;
	
	/**
	 * Returns boolean result - true if <code>s</code> has suffix as <code>f</code>
	 *
	 * @param	f String the string with suffix to compare
	 * @param s String the string we are processiing
	 * @return true if <code>s</code> has suffix as </code>f</code>
	 * @type boolean
	 * @see endsWith
	 * @deprecated please use <code>endsWith</code>
	 */
	function hasSuffix(f, s) {
		return( this.right( s, f.length ) == f );
	}
	this.hasSuffix = hasSuffix;
	
	/**
	 * Returns first <code>c</code> of characters
	 * @param s String the string we are processiing
	 * @param	c int the number of characters we want to return
	 * @return first <code>c</code> of characters
	 * @type String
	 */
	function left( s, c ) {
		s = String(s);
		if (c <= 0 ) return "";
		else if ( c > s.length ) return s;
		else return s.substring( 0, c );
	}
	this.left = left;
	
	/**
	 * Returns last <code>c</code> of characters
	 * @param s String the string we are processiing
	 * @param	c int the number of characters we want to return
	 * @return last <code>c</code> of characters
	 * @type String
	 */
	function right( s, c ){
		s = String(s);
		if ( c <= 0 ) return "";
		else if ( c > s.length )return str;
		else {
			var /*:length:*/ l = s.length;
			return s.substring( l, l - c );
		}
	}
	this.right = right;
	
	/**
	 * Returns trimed string from left side
	 * @param s String string to trim
	 * @return trimed string
	 * @type String
	 */	
	function trimLeft( s ) {
		var s = Global.isDefined(s) ? String( s ) : this;
		return s.replace( /^\s+/, "" );
	}
	String.prototype.trimLeft = trimLeft;
	this.trimLeft = trimLeft;
	
	/**
	 * Returns trimed string from right side
	 * @param s String string to trim
	 * @return trimed string
	 * @type String
	 */	
	function trimRight( s ) {
		var s = Global.isDefined(s) ? String( s ) : this;
		return s.replace( /\s+$/, "" );
	}
	String.prototype.trimRight = trimRight;
	this.trimRight = trimRight;
	
	/**
	 * Returns trimed string from both side
	 * @param s String string to trim
	 * @return trimed string
	 * @type String
	 */	
	function trim( s ) {
		s = Global.isDefined(s) ? String( s ) : this;
		s = s.trimLeft();
		return s.trimRight();
	}
	String.prototype.trim = trim;
	this.trim = trim;
	
	/**
	 * @param url String the string we are processiing
	 * @type String
	 */
	function makeUncachebleURL( url ) {
		return( url + ( ( url.indexOf( "?" ) == -1 ) ? "?" : "&" ) + "nocache=" + ( new Date().getTime() ) );
	}
	this.makeUncachebleURL = makeUncachebleURL;
	
	/**
	 * @param link String the string we are processiing
	 * @type String
	 */
	function normalizeLink( link ) {
	  var /*:link:*/ l = this.trim( link );
	 /* if ( ( l.indexOf( 'http://' ) != 0 ) && ( l.indexOf( 'javascript:' ) != 0 ) && ( l.indexOf( '/' ) != 0 ) && l != "" )
	    l = 'http://' + l;
	  l = l.replace( /\x22/g, "%20" );*/
	  return l;
	}
	this.normalizeLink = normalizeLink;
	
	/**
	 * @param str String the string we are processiing
	 * @type String
	 */
	function uppercaseFirstLetter( str ) {
		var /*:str:*/ s = str.split( /\s+/g );
		for(var i = 0; i < s.length; i++ )
			s[i] = s[i].substring( 0, 1 ).toUpperCase() + s[i].substring( 1, s[i].length )+" ";
		return s.join(" ");
	}
	this.uppercaseFirstLetter = uppercaseFirstLetter;
	
	/**
	 * @access private
	 * Returns replaced string 
	 * @param original String the string we are processiing
	 * @param	pattern String the string which be replaced
	 * @param	replace String string for replacement
	 * @param	flag String must be "g" for global replacement or empty for once replacement
	 * @return replaced string 
	 * @type string
	 */
	function internalReplace( original, pattern, replace, flag ) {
		var f = flag || "i";
		var re = new RegExp( pattern, f );
		return original.replace( re, replace );
	}
};

/**
 * JSStringUtils is the javascript class which contains common functions for string
 * 
 * @access private
 * @deprecated use <code>componence.util.StringUtils</code>
 * @version	2.1.19
 * @constructor
 * @lastmodified
 * @see componence.util.StringUtils
 */
function JSString() {
	return new componence.util.StringUtils();
}

//String.prototype = new componence.util.StringUtils();

/*
 * Create global StringUtils object
 */
var StringUtils  = new componence.util.StringUtils();
//