function Util()
{
	this.getValue = function (pElement)
	{
		var lValue;
		var lText;
		var lCount;
		var lType;
		lText = "";
		lValue = "";
		try{
				if (pElement.length)
				{
					lType = pElement[0].type;
					if (!lType)
					{
						lType = pElement.type;
					}
				}
		
			else
			{
				lType = pElement.type;
			}
		}
		catch(Exception)
		{
			lType = pElement.type;
		}
		if (lType == "text" || lType == "hidden" || lType == "password" || lType == "textarea")
		{
			lValue = pElement.value;
		}
		else if(lType == "select-multiple" || lType == "select-one")
		{
			lValue = this.getSelectedOption(pElement)
			lText = this.getSelectedText(pElement)
		}
		else if(lType == "checkbox" || lType == "radio-button" || lType == "radio")
		{
			if (pElement.length)
			{
				for (lCount = 0; lCount < pElement.length; lCount++)
				{
					if (pElement[lCount].checked)
					{
						lValue = pElement[lCount].value;
						break;
					}
				}
			}
			else
			{
				if (pElement.checked)
				{
					lValue = pElement.value;
				}
				else
				{
					lValue = "";
				}
			}
		}
		return [lValue, lText];
	}
	this.getSelectedOption = function (pElement)
	{
		var lSelectedValue;
		if (pElement.selectedIndex >= 0)
		{
			lSelectedValue = pElement.options[pElement.selectedIndex].value;
			if (lSelectedValue.length == 0)
			{
				lSelectedValue = pElement.options[pElement.selectedIndex].text;
			}
		}
		else
		{
			lSelectedValue = "";
		}
		return lSelectedValue;
	}
	this.getSelectedText = function (pElement)
	{
		var lSelectedText;
		if (pElement.selectedIndex >= 0)
		{
			lSelectedText = pElement.options[pElement.selectedIndex].text;
		}
		else
		{
			lSelectedText = "";
		}
		return lSelectedText;
	}
	this.setValue = function (pElement, pValue)
	{
		var lType;
		var lCount;
		var lText;
		lText = "";
		pValue = Url.decode(pValue);
		if (pElement.length)
		{
			try{
			lType = pElement[0].type;
			if(pElement[0].type == undefined)
			{
				lType = pElement.type;				
			}
			if (!lType)
			{
				lType = pElement.type;
			}
			}catch(Exception)
			{
				lType = pElement.type;
			}
		}
		else
		{
			lType = pElement.type;
		}
		if (lType == "text" || lType == "password" || lType == "hidden")
		{
			pElement.value = pValue;
		}
		else if (lType == "textarea")
		{
			pElement.value = pValue;
		}
		else if(lType == "select-multiple" || lType == "select-one")
		{
			this.selectOption(pElement, pValue)
		}
		else if(lType == "checkbox" || lType == "radio-button" || lType == "radio")
		{
			if (!pElement.length)
			{
				if (pValue == "1" || pValue.toUpperCase == "ON" || pValue.toUpperCase == "T" ||
				    pValue.toUpperCase == "TRUE" || pValue.toUpperCase == "YES" || pValue.toUpperCase == "Y")
				{
					pElement.checked = true;
				}
				else
				{
					pElement.checked = false;
				}
			}
			else
			{
				for (lCount = 0; lCount < pElement.length; lCount++)
				{
					if (pElement[lCount].value == pValue)
					{
						pElement[lCount].checked = true;
						break;
					}
				}
			}
		}
	}
	this.selectOption = function (pOptionBox, pValue, pMultiple)
	{
		var lCount;
		for (lCount = 0; lCount < pOptionBox.options.length; lCount++)
		{
			if (pOptionBox.options[lCount].value.length > 0)
			{
				if (pOptionBox.options[lCount].value == pValue)
				{
					pOptionBox.options[lCount].selected = true;
				}
			}
			else
			{
				if (pOptionBox.options[lCount].text == pValue)
				{
					pOptionBox.options[lCount].selected = true;
				}
			}
		}
	}
	this.getEvent = function(pEvent)
	{
		var lEvent;
		if (window.event)
		{
			lEvent = window.event;
		}
		else
		{
			lEvent = pEvent;
		}
		return lEvent;
	}
	this.getTargetElement = function(pEvent)
	{
		var lTargetElement;
		if (pEvent.srcElement)
		{
			lTargetElement = pEvent.srcElement;
		}
		else
		{
			lTargetElement = pEvent.target;
		}
		return lTargetElement;
	}
	this.trim = function (pValue)
	{
		pValue = pValue.replace(/^\s+/,""); // Left trim
		pValue = pValue.replace(/\s+$/,""); // Right trim
		return pValue;
	}
	this.isTimeValid = function (pTime)
	{
		var lFoundAt;
		var lHours;
		var lMinutes;
		var lValid = true;
		lFoundAt = pTime.indexOf(":");
		if (lFoundAt >= 0)
		{
			lHours = pTime.substr(0, lFoundAt);
			lMinutes = pTime.substr(lFoundAt + 1);
		}
		else
		{
			lMinutes = pTime.substr(pTime.length - 2);
			lHours = pTime.substr(0, pTime.length - 2);
		}
		if (parseInt(lHours) < 0 || parseInt(lHours) > 24)
		{
			lValid = false;
		}
		//For any Hour between 0 and 23
		if (lValid && lHours < 24)
		{
			if (parseInt(lMinutes) < 0 || parseInt(lMinutes) > 59)
			{
				lValid = false;
			}
		}
		//If it is a valid hour and value is equal to 24
		else if (lValid)
		{
			if (parseInt(lMinutes) != 0)
			{
				lValid = false;
			}
		}
		return lValid;
	}
	this.isHoursMinutesValid = function(pTime)
	{
		var lFoundAt;
		var lHours;
		var lMinutes;
		var lValid = true;
		lFoundAt = pTime.indexOf(":");
		if (lFoundAt >= 0)
		{
			lHours = pTime.substr(0, lFoundAt);
			lMinutes = pTime.substr(lFoundAt + 1);
		}
		else
		{
			lMinutes = pTime.substr(pTime.length - 2);
			lHours = pTime.substr(0, pTime.length - 2);
		}
		//Hours can be any value on the higher side.
		if (parseInt(lHours) < 0)
		{
			lValid = false;
		}
		if (parseInt(lMinutes) < 0 || parseInt(lMinutes) > 59)
		{
			lValid = false;
		}
		return lValid;
	}
}