/*Copyright Bridgeline Software, Inc. An unpublished work created in 2009. All rights reserved. 
This software contains the confidential and trade secret information of Bridgeline Software, Inc. 
("Bridgeline").  Copying, distribution or disclosure without Bridgeline's express written permission is prohibited.*/


/* Function to Clear the Text in a TextBox */ 

function clearText(ElemID)
{
     var tempElem = document.getElementById(ElemID);
     if (tempElem) 
        {
           tempElem.value="";
        }
}

function Delete_Cookie( name, path, domain ) {
if ( ReadCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function ReplaceAll(str, pcFrom, pcTo)
{
    var i = str.indexOf(pcFrom);    
    var c = str; 
    while (i > -1)
    {
        c = c.replace(pcFrom, pcTo);            
        i = c.indexOf(pcFrom);      
    }    
    return c;
}

function ReadCookie(cookieName) 
{
     var theCookie = "" + document.cookie;
     var ind = theCookie.indexOf(cookieName);
     if (ind == -1 || cookieName == "") 
        return null;        

     var ind1 = theCookie.indexOf(';', ind);
     if (ind1 == -1) 
        ind1 = theCookie.length;         

     var val = unescape(theCookie.substring(ind+cookieName.length+1,ind1));
     val = ReplaceAll(val, cookieName + "=" , "");
     val = ReplaceAll(val, ";" , "");
     return val;
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function controlCenter (btnId, evt) 
{   
    btn = document.getElementById(btnId);
    if (btn)
    {
        if (evt.keyCode == 13)
        {
            evt.returnValue = false;
            evt.cancel = true;
            btn.click();
            return false;
        } 
    } 
}
