/********************************************************
 *Common Utility Functions
 *===================================**/

function parseInt2(inVar)
{
	var iRet=parseInt(inVar);
	if(isNaN(iRet))
	{return 0;}
	else
	{return iRet;}
}

function parseFloat2(inVar)
{
	var iRet=parseFloat(inVar);
	if(isNaN(iRet))
	{return 0;}
	else
	{return iRet;}
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
function clickLinkTag(buttonObj,textObjId)
{
	 var meta_val=buttonObj.id;
	 var text_field=$(textObjId);
	 var selectColor="grey";
	
	if(text_field.value.indexOf(meta_val)!=-1)//if selected tag already in the list
	{
		buttonObj.style.color="";//turn button text color back to original color
		text_field.value=text_field.value.gsub(meta_val+", ","");//remove the tag from the list
	}
	else
	{
		//if no comma at end of the string, add a comma
		if(text_field.value.lastIndexOf(",")!=(text_field.value.trim().length-1))
		{
			text_field.value=text_field.value+", "+meta_val;
		}
		else
		{
			text_field.value=text_field.value+meta_val;
		}
		
		//text_field.focus();	
		text_field.value=text_field.value+", ";
		buttonObj.style.color=selectColor;
	}

}
