// true: Browser is IE / False: Browser is NOT IE
var IS_BROWSER_IE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
// true: Browser is Opera / False: Browser is NOT Opera
var IS_BROWSER_SAFARI = (navigator.userAgent.indexOf("Safari") != -1) ? true : false;
// This logic runs all of the pages to add the title of the smart navigation title for accessibility
if (document.getElementById('__hifSmartNav')) document.getElementById('__hifSmartNav').title = "Smart Navigation is on";

//--------------------------------------------------------------------------
// Function    : SetScrollBar()
// Description : (1)This function gets the following left and top from control postion
//             :    and set scroll position
//             : (2)This function is for Firefox. Use "window.navigate" for IE
//             : for example
//             : 
//             : node1----------------Left------------------|
//             :    |---node2                               |
//             :        |---node3                          top (pixels)
//             :             |---node4                      |
//             :                 |---node5                  |
//             :                     |---node6              |
//             :                         |---control--------|
//             :
//             : See http://developer.mozilla.org/en/docs/DOM:element.offsetLeft
//--------------------------------------------------------------------------
function SetScrollBar(control)
{
    //get as server control
    var node = document.getElementById(GetClientId(control));
    
    if (node == null || node == undefined)
    {
        // if control is not server control, get as html control
        node = document.getElementById(control);
    }

    var scrollLeft = node.offsetLeft;
    var scrollTop = 0;

    while (node)
    {
        scrollTop = scrollTop + node.offsetTop;
        node = node.offsetParent;
    }

    window.scrollBy(scrollLeft, scrollTop);
}

// Gets the Client ID of the control passed.
// Client ID is set in BasePage on attribute "clientId" of "bodyHome" of Home.Master
// get the value from the attribute, add "_" and control id which is passed.
function GetClientId(control) 
{
    var body = document.getElementsByTagName("body");

    var id = body[0].attributes["clientId"];

    var clientId = id.value + "_" + control;

    return clientId;
}

// Gets the Unique ID of the control passed.
// Unique ID can ben obtained by replacing "_" of clientId with "$"
function GetUniqueId(control) {
    var body = document.getElementsByTagName("body");

    var id = body[0].attributes["clientId"];

    var clientId = id.value + "_" + control;

    return clientId.replace(/_/gi, "$");
}
