function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

 function ShowHideByOther(v,txtbox)
    { 
       if( v.toLowerCase() == "other")
       { 
            document.getElementById(txtbox).style.display = '';
       }
       else
       {
            document.getElementById(txtbox).style.display = 'none';
       }
    }
    
function ShowHideTxtByDdlst(ddlst,txtbox)
    { 
        ShowHideByOther(ddlst.options[ddlst.selectedIndex].text,txtbox);
    }
function ClearTxt(txtbox)
{
    document.getElementById(txtbox).value = '';
}
function ShowHideByOtherSuffix(ddlst,txtbox)
  { 
    ClearTxt(txtbox);
    var t = ddlst.options[ddlst.selectedIndex].text;
    if( t.substr(t.length - 7 ))
        ShowHideByOther(t.substr(t.length - 5 ),txtbox);
  }


function ShowHideControl(chk,cntrl)
{
    ShowHideControlByBool(cntrl,chk.checked)
}
function ShowHideControlByBool(cntrl,boolv)
{
   if(boolv)
       { 
            document.getElementById(cntrl).style.display = '';
       }
       else
       {
            document.getElementById(cntrl).style.display = 'none';
       }
}
function Disable(cntrl)
	{
		document.getElementById(cntrl).setAttribute('disabled','disabled');
	}
function Enable(cntrl)
	{
		document.getElementById(cntrl).setAttribute('disabled','');
	}
	
function addSpace(argvalue, numlength)
{
    return addSpace(argvalue,' ',numlength);
}	
function addZero(argvalue, numlength)
{
    return addTrialingChar(argvalue,'0',numlength);
}

function addTrialingChar(argvalue,charValue  , numlength)
 {

        argvalue = argvalue +'';
      if (! numlength > 0)
        numlength = 10;

      if (argvalue.length < numlength) 
      {
        for(var i = argvalue.length; i < numlength; i++)
          argvalue = charValue + argvalue;
      }

     return argvalue;
  }
 function ToggleChkbox(chkbox)
    {
       var fmobj = document.forms[0];
       
       for (var i=0;i<fmobj.elements.length;i++) 
       {
            var e = fmobj.elements[i];
            if ( (e.name != chkbox.name) && (e.type=='checkbox') && (!e.disabled) ) 
                e.checked =chkbox.checked;
        }
    }	
function ArrSearch(arr,v)
{
    for(i = 0 ; i < arr.length; i++)
    {
       if(arr[i] == v)
        {
            return true;
        }
    }
    return false;
}
 function AddItem(dropdown,Text,Value)
    {
        // Create an Option object               
         var opt = document.createElement("option");
        opt.text = Text;
        opt.value = Value;
        // Add an Option object to Drop Down/List Box
        dropdown.options.add(opt);        // Assign text and value to Option object
    }