/************************************
    trim(string) - Trims a String
    @theElement = element ID
    @elementBody = data to put in element
************************************/
function trim(s){
       while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')) // remove leading spaces and carriage returns
        s = s.substring(1,s.length);
       
     while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')) // Remove trailing spaces and carriage returns
         s = s.substring(0,s.length-1);
     
       return s;
} // end trim
 
 
/************************************
    ih(theElement,elementBody) - Fills an element with information
    @theElement = element ID
    @elementBody = data to put in element
************************************/
function ih(theElement,elementBody){
    document.getElementById(theElement).innerHTML = elementBody; // fill element with specified content
} // end ih()


/************************************
    cv(theElement,elementValue) - Changes an elements value
    @theElement = element ID
    @elementValue = data to put in element
************************************/
function cv(theElement,elementValue){
    document.getElementById(theElement).value = elementValue; // fill element with specified content
} // end cv()


/************************************
    de(theElement) - Disables an element
    @theElement = element ID
************************************/
function de(theElement){
    document.getElementById(theElement).disabled = true; // disable the element
} // end de()


/************************************
    toggle(elementIDList) - Toggles visibility of an element
    @elementIDList = list of element ID's
************************************/
function toggle(elementIDList){
    
    toggleList = elementIDList.split(','); // get id's to loop thru
    for(var tgl = 0; tgl < toggleList.length; tgl++){
        elementToToggle = document.getElementById(toggleList[tgl]).style;
        if(elementToToggle.display=='none' || elementToToggle.visibility=='hidden'){
            elementToToggle.visibility='visible'; // show the element
            elementToToggle.display=''; // show the element
        } // end if
        else {
            elementToToggle.visibility='hidden'; // hide the element
            elementToToggle.display='none'; // hide the element **does not work in safari**
        } // end else
    } // end for
} // end toggle()


/************************************
    gebid(theElement) - Get the object type by id
    @theElement = element ID
************************************/
function gebid(theElement){
    return document.getElementById(theElement);
}


/************************************
    gebn(theElement) - Get the object type by name
    @theElement = element ID
************************************/
function gebn(theElement){
    return document.getElementsByName(theElement);
}


/************************************
    refresh(seconds) - Refreshes the page in specified amount of seconds
    @[seconds] = number of seconds to wait before refreshing
************************************/
function refresh(seconds){
    if(seconds == undefined) seconds = 0; // if no value is specified, refresh immediately
    setTimeout("window.location=location;",seconds*1000);
}



