function duplicateChar(chr,num)
{
	var tmpAr = new Array();

	for(var i=0; i<num; i++)
	{
		tmpAr.push(chr);
	}

	return tmpAr.join('');
}

function setPad(str)
{
	var decLength = 2;
	var padChar = '0';
	var endPad = true;

	if((arguments.length == 2) && testTypeOfObject(arguments[1],'number'))
	{
		decLength = arguments[1];
	}

	if((arguments.length == 3) && testTypeOfObject(arguments[2],'string'))
	{
		padChar = arguments[2];
	}

	if((arguments.length == 4) && testTypeOfObject(arguments[3],'boolean'))
	{
		endPad = arguments[3];
	}

	if(decLength > str.length)
	{
		if(endPad)
		{
			str += duplicateChar(padChar,decLength-str.length);
		}
		else
		{
			str = duplicateChar(padChar,decLength-str.length)+str;
		}
	}

	return str;
}

function setDecimal(num)
{
	var decLength = 2;
	var padChar = '0';

	var numStr = '';

	var decChar = '.';
	var dispDecChar = ',';

	if((arguments.length == 2) && ((typeof arguments[1]).toLowerCase() == 'number'))
	{
		decLength = arguments[1];
	}

	if((typeof num).toLowerCase() == 'number')
	{
		numStr = num.toString();
	}
	else if((typeof num).toLowerCase() == 'string')
	{
		numStr = num;
	}

	var numPart = numStr.split(decChar);

	if(numPart.length == 2)
	{
		if(decLength > numPart[1].length)
		{
			numPart[1] += duplicateChar(padChar,decLength-numPart[1].length);
		}
	}

	return numPart.join(dispDecChar);
}

function getNumberFromString(strVal)
{
	var retNum = null;

	if(testTypeOfObject(strVal,'string'))
	{
		var numVal = /^(-?[0-9]*(\.[0-9]+)?)(px)?$/;

		var res = numVal.exec(strVal);

		if(res)
		{
			retNum = parseFloat(res[1]);
		}
		else
		{
			retNum = 0;
		}
	}
	else if(testTypeOfObject(strVal,'number'))
	{
		retNum = strVal;
	}

	return retNum;
}


function testTypeOfObject(refObject,strType)
{
	var retBool = false;

	if((typeof strType).toLowerCase() == 'string')
	{
		if((typeof refObject).toLowerCase() == strType.toLowerCase())
		{
			retBool = true;
		}
	}
	else if((typeof strType).toLowerCase() == 'function')
	{
		if(refObject instanceof strType)
		{
			retBool = true;
		}
	}

	return retBool;
}

function isInitialized(objRef)
{
	var rtB = true;

	if((objRef == null) || testTypeOfObject(objRef,'undefined'))
	{
		rtB = false;
	}

	return rtB;
}

/*
Object.prototype.properties = new Array;

Object.prototype.setProperty = function(pN,pV)
{
	if(this.isObjectOfType(pN,'string'))
	{
		this.properties[pN] = pV;
	}
}

Object.prototype.getProperty = function(pN)
{
	var rtV = null;

	if(this.isObjectOfType(pN,'string'))
	{
		rtV = this.properties[pN];
	}

	return rtV;
}

Object.prototype.isObjectOfType = function(objRef,strType)
{
	var retBool = false;

	if((typeof strType).toLowerCase() == 'string')
	{
		if((typeof objRef).toLowerCase() == strType.toLowerCase())
		{
			retBool = true;
		}
	}
	else if((typeof strType).toLowerCase() == 'function')
	{
		if(objRef instanceof strType)
		{
			retBool = true;
		}
	}

	return retBool;
}

Object.prototype.isInitialized = function(objRef)
{
	var rtB = true;

	if((objRef == null) || this.isObjectOfType(objRef,'undefined'))
	{
		rtB = false;
	}

	return rtB;
}
*/
Array.prototype.getElement = function(ind)
{
	var retE = null;

	if((ind >= 0) && (ind < this.length))
	{
		retE = this[ind];
	}

	return retE;
}

function NamedEntry(k,sO)
{
	this.key = '';
	this.storedObject = sO;

	if(testTypeOfObject(k,'string'))
	{
		this.key = k;
	}

	this.getKey = function()
	{
		return this.key;
	}

	this.getStoredObject = function()
	{
		return this.storedObject;
	}
}

function NamedList()
{
	this.collection = new Array();

	this.addObject = function(o)
	{
		var sO = null;

		if(arguments.length == 1)
		{
			if(o instanceof NamedEntry)
			{
				if(this.getObject(o.getKey()) == null)
				{
					sO = o;
				}
			}
		}
		else if(arguments.length == 2)
		{
			if(testTypeOfObject(o,'string'))
			{
				if(this.getObject(o) == null)
				{
					sO = new NamedEntry(o,arguments[1]);
				}
			}
		}

		if(sO != null)
		{
			this.collection[this.collection.length] = sO;
		}
	}

	this.getObject = function(k)
	{
		var rtO = null;

		if(testTypeOfObject(k,'string'))
		{
			for(var i=0; i<this.collection.length; i++)
			{
				if(this.collection[i].getKey() == k)
				{
					rtO = this.collection[i].getStoredObject();
					break;
				}
			}
		}

		return rtO;
	}
	
	this.getCollection = function()
	{
		return this.collection;
	}
}

function Parameter(pN,pV)
{
	this._name = pN;
	this._value = pV;

	this.getName = function()
	{
		return this._name;
	}

	this.getValue = function()
	{
		return this._value;
	}
}

function RequestParam()
{
	this._param = new Array();
	this._xmlString = true;
	this._post = false;

	this.setXmlCompat = function(hB)
	{
		if((typeof hB).toLowerCase() == 'boolean')
		{
			this._xmlString = hB;
		}
	}

	this.isXmlCompat = function()
	{
		return this._xmlString;
	}

	this.addParam = function(pO)
	{
		if(testTypeOfObject(pO,Parameter))
		{
			if(pO.getName() != '' && pO.getValue != '')
			{
				this._param[this._param.length] = pO;
			}
		}
		else if(testTypeOfObject(pO,'string') && (arguments.length == 2))
		{
			if(pO != '' && testTypeOfObject(arguments[1],'string'))
			{
				this._param[this._param.length] = new Parameter(pO,arguments[1]);
			}
		}
	}

	this.getParamCount = function()
	{
		return this._param.length;
	}

	this.hasParam = function()
	{
		var rtB = false;

		if(this.getParamCount() > 0)
		{
			rtB = true;
		}

		return rtB;
	}

	this.setPost = function(pB)
	{
		if((typeof pB).toLowerCase() == 'boolean')
		{
			this._post = pB;
		}
	}

	this.methodIsPost = function()
	{
		return this._post;
	}

	this.createRequestString = function()
	{
		var rtStr = '';

		var pCount = this.getParamCount();

		for(var i=0; i<pCount; i++)
		{
			if((i == 0) && !this.methodIsPost())
			{
				rtStr += '?';
			}

			rtStr += this._param[i].getName()+'='+this._param[i].getValue();

			if(i != pCount-1)
			{
				if(this.isXmlCompat() && !this.methodIsPost())
				{
					rtStr += '&#38;';
				}
				else
				{
					rtStr += '&';
				}
			}
		}

		return rtStr;
	}
}