
// Scripts Added / Updated by Gnana Prakasham  - 12/APR/2013 - Starts
cssPrimaryBtnOnMouseOver = function (btnId) {
    if (typeof (btnId) != 'undefined' && btnId != null) {
        btnId.style.background = "#006699";
    }
}

cssPrimaryBtnOnMouseOut = function (btnId) {
    if (typeof (btnId) != 'undefined' && btnId != null) {
        btnId.style.background = "#0096d6";
    }
}

cssSecondaryBtnOnMouseOver = function (btnId) {
    if (typeof (btnId) != 'undefined' && btnId != null) {
        btnId.style.background = "#5A5A5A";
    }
}

cssSecondaryBtnOnMouseOut = function (btnId) {
    if (typeof (btnId) != 'undefined' && btnId != null) {
        btnId.style.background = "#767676";
    }
}

cssFormInputFocus = function (inputId) {
    if (typeof (inputId) != 'undefined' && inputId != null) {
        inputId.style.color = "#000";
        inputId.style.border = "2px solid #5A5A5A";
    }
}

cssFormInputBlur = function (inputId) {
    if (typeof (inputId) != 'undefined' && inputId != null) {
        inputId.style.color = "#767676";
        inputId.style.border = "2px solid #CCCCCC";
    }
}

cssFormInputMouseOver = function (inputId) {
    if (typeof (inputId) != 'undefined' && inputId != null) {
        inputId.style.color = "#000";
        inputId.style.border = "2px solid #5A5A5A";
    }
}

cssFormInputMouseOut = function (inputId) {
    if (typeof (inputId) != 'undefined' && inputId != null) {
        if (typeof (document.activeElement) != 'undefined' && document.activeElement != null) {
            if (document.activeElement.id != inputId.id) {
                inputId.style.color = "#767676";
                inputId.style.border = "2px solid #CCCCCC";
            }
        }
    }
}

cssAjaxComboBoxItemListMouseOver = function (inputId) {
    if (typeof (inputId) != 'undefined' && inputId != null) {
        inputId.style.color = "#000";
        inputId.style.border = "2px solid #5A5A5A";
    }
}

cssAjaxComboBoxItemListMouseOut = function (inputId) {
    if (typeof (inputId) != 'undefined' && inputId != null) {
        if (typeof (document.activeElement) != 'undefined' && document.activeElement != null) {
            if (document.activeElement.id != inputId.id) {
                inputId.style.color = "#767676";
                inputId.style.border = "2px solid #CCCCCC";
            }
        }
    }
}
// Scripts Added / Updated by Gnana Prakasham  - 12/APR/2013 - End

//Scripts Added By Manjula - 19/MAR/2013 --STARTS

// Script for Text Decoration onmouseover/onmouseleave -- STARTS
function textDecorationOnMouseOver(control) {
    if (typeof (control) != 'undefined' && control != null) {
        if (control.className == "htab htabOn" || control.className == "lbItem lbOn") {
            control.style.textDecoration = 'none';
            control.style.cursor = 'default';
        }
        else {
            control.style.textDecoration = 'underline';
            control.style.cursor = 'pointer';
        }
    }
}
function textDecorationOnMouseOut(control) {
    if (typeof (control) != 'undefined' && control != null) {
        control.style.textDecoration = 'none';
        control.style.cursor = 'default';
    }
}
// Script for Text Decoration onmouseover/onmouseleave -- ENDS

// Script for Buttons onmouseover/onmouseleave -- STARTS

function criticalHPButtonsOnMouseOver(obj) {
    if (typeof (obj) != 'undefined' && obj != null) {
        if (obj.parentElement.disabled == false) {
            obj.style.backgroundColor = "#C1401A";
            return true;
        }
        else {
            return false;
        }
    }
}

function criticalHPButtonsOnMouseOut(obj) {
    if (typeof (obj) != 'undefined' && obj != null) {
        if (obj.parentElement.disabled == false) {
            obj.style.backgroundColor = "#D7410B";
            return true;
        }
        else {
            return false;
        }
    }
}
function primaryHPButtonsOnMouseOver(obj) {
    if (typeof (obj) != 'undefined' && obj != null) {
        if (obj.parentElement.disabled == false) {
            obj.style.backgroundColor = "#006699";
            return true;
        }
        else {
            return false;
        }
    }
}

function primaryHPButtonsOnMouseOut(obj) {
    if (typeof (obj) != 'undefined' && obj != null) {
        if (obj.parentElement.disabled == false) {
            obj.style.backgroundColor = "#0096d6";
            return true;
        }
        else {
            return false;
        }
    }
}

function secondaryHPButtonsOnMouseOver(obj) {
    if (typeof (obj) != 'undefined' && obj != null) {
        if (obj.parentElement.disabled == false) {
            obj.style.backgroundColor = "#5a5a5a";
            return true;
        }
        else {
            return false;
        }
    }
}

function secondaryHPButtonsOnMouseOut(obj) {
    if (typeof (obj) != 'undefined' && obj != null) {
        if (obj.parentElement.disabled == false) {
            obj.style.backgroundColor = "#767676";
            return true;
        }
        else {
            return false;
        }
    }
}

// Script for Buttons onmouseover/onmouseleave -- ENDS

// Script for Textboxes onmouseover/onmouseleave -- STARTS 
function textboxOnFocusAndMouseOver(obj) {
    if (typeof (obj) != 'undefined' && obj != null) {
        obj.style.borderColor = "#5a5a5a";
        return true;
    }
}

function textboxOnMouseOut(obj) {
    if (typeof (obj) != 'undefined' && obj != null) {
        obj.style.borderColor = "#cccccc";
        return true;
    }
}

// Script for Textboxes onmouseover/onmouseleave -- ENDS
function changeExpandCtrlPosition(expandCtrl, ishover) {
    if (typeof (expandCtrl) != 'undefined' && expandCtrl != null) {
        if (expandCtrl.className == 'icn_mns_drk') {
            if (ishover) {
                expandCtrl.style.backgroundPosition = 'left -2085px';
            } else {
                expandCtrl.style.backgroundPosition = 'left -1815px';
            }
        } else {
            if (ishover) {
                expandCtrl.style.backgroundPosition = 'left -1950px';
            } else {
                expandCtrl.style.backgroundPosition = 'left -1680px';
            }
        }
    }
}

// Script for HP Dropdown list onmouseover/onmouseleave -- STARTS
function changeHPSelectBoxBorderOnMouseOver(selectBoxTR) {
    if (typeof (selectBoxTR) != 'undefined' && selectBoxTR != null) {
        //Condition added by sravan HPE Changes
        if (!selectBoxTR.children[0].all[0].disabled) {
            if (selectBoxTR.children[0] != 'undefined' && selectBoxTR.children[0] != null)
                selectBoxTR.children[0].style.border = '2px solid #5A5A5A';
            if (selectBoxTR.children[1] != 'undefined' && selectBoxTR.children[1] != null)//Changed Children[0] to Children[1] HPE Changes Sravan
                selectBoxTR.children[1].style.border = '2px solid #5A5A5A';
        }
    }
}
function changeHPSelectBoxBorderOnMouseOut(selectBoxTR) {
    if (typeof (selectBoxTR) != 'undefined' && selectBoxTR != null) {
        if (selectBoxTR.children[0] != 'undefined' && selectBoxTR.children[0] != null)
            selectBoxTR.children[0].style.border = '2px solid #CCCCCC';
        if (selectBoxTR.children[1] != 'undefined' && selectBoxTR.children[1] != null)//Changed Children[0] to Children[1] HPE Changes Sravan
            selectBoxTR.children[1].style.border = '2px solid #CCCCCC';
    }
}
// Script for HP Dropdown list onmouseover/onmouseleave -- ENDS

//Scripts Added By Manjula - 19/MAR/2013 --ENDS 

//Scripts Added by Shashibala - 16/Apr/2013. This function is to make by default the selected item in blue color as per HPE standard- start
//Scripts Added by Shashibala - 16/Apr/2013. This function is calling onchange of selected item: start

//Modified by Shashibala on 17/Jan/2014 for 14.3 release
function OnChange(event) {
    if (typeof (event) == 'undefined' || event == null)
        return; // FF dont define event
    var obj = event.srcElement || event.target;
    SetDropDownColor(obj);
}

//Scripts Added by Shashibala - 16/Apr/2013. This function is calling onchange of selected item: end


//Modified by Shashibala on 17/Jan/2014 for 14.3 release
function SetDropDownColor(SourceObject) {


    if (typeof (SourceObject) != 'undefined')
    {
        for (var i = 0; i < SourceObject.options.length; i++)
        {
            SourceObject[i].style.color = "#000000";
        }
        if (SourceObject.id != null && SourceObject.id != "") {
            var objElement = document.getElementById(SourceObject.id);
            if (typeof (objElement) != 'undefined' && objElement != null) {
                objElement.style.color = '#000000';
            }
        }
        else {
            SourceObject.style.color = '#000000';
        }
    }
}
//Scripts Added by Shashibala - 16/Apr/2013. This function is to make the selected item in blue color as per HPE standard- start

//function SetDropDownColor(SourceObject) {
//    if (typeof (SourceObject) != 'undefined' && SourceObject != null) {
//        var obj = SourceObject;
//        for (var i = 0; i < obj.options.length; i++) {
//            // HPE Changes :- Added By Manjula on 06-May-2013*/
//            obj.options[i].style.color = "#000000";
//        }
//    }
//}

//Scripts Added by Shashibala - 16/Apr/2013. This function is to make the selected item in blue color as per HPE standard- end

function SetDefaultColor() {
    var elements = document.getElementsByTagName('select');
    for (var i = 0; i < elements.length; i++) {
        var dropdown = elements[i];
        if ((dropdown.selectedIndex) != -1) {
            dropdown.style.color = '#0096d6';
            for (var j = 0; j < dropdown.options.length; j++) {
                if (j == dropdown.selectedIndex)
                    dropdown.options[j].style.color = '#0096d6';
                else
                    dropdown.options[j].style.color = '#000000';
            }
        }
    }
}

//Styles Added by Navaneethakrishnan - 30/Apr/2013. This function is used to change the color of mouseover & mouseout for critical buttons
cssCriticalBtnOnMouseOver = function (btnId) {
    if (typeof (btnId) != 'undefined' && btnId != null) {
        btnId.style.background = "#C1401A";
    }
}

cssCriticalBtnOnMouseOut = function (btnId) {
    if (typeof (btnId) != 'undefined' && btnId != null) {
        btnId.style.background = "#D7410B";
    }
}

cssCriticaltextboxOnFocusAndMouseOver = function (obj) {
    if (typeof (btnId) != 'undefined' && btnId != null) {
        obj.style.borderColor = "#C1401A";
        return true;
    }
}

//Script added by Masoom 06 May 2013 for autowiring of mouse events

function AttachMouseEvents() {

    var inputelementsOnPage = document.getElementsByTagName('input');
    if (inputelementsOnPage.length == 0)
        return;

    for (var i = 0; i < elements.length; i++) {
        MouseEvents(elements[i]);
    }
}

function MouseEvents(element) {

    if (element.type == 'text') {
        element.className = 'textbox';

        element.onmouseover = function () {
            textboxOnFocusAndMouseOver(this);
        }
        element.onmouseout = function () {
            textboxOnMouseOut(this);
        }
    }

    if (element.type == 'button' || element.type == 'submit') {
        element.className = 'button default primary btn_label';

        element.onmouseover = function () {
            primaryHPButtonsOnMouseOver(this);
        }
        element.onmouseout = function () {
            primaryHPButtonsOnMouseOut(this);
        }
    }
}

//Added for HPE Changes -- Sravan
function changeAst(text, id) {
    var str = text.replace("*", "<a class=\"required_asterisk\">*</a>");
    document.getElementById(id).innerHTML = str;
}

function setDateValue(objTextBox, value) {
    objTextBox.attr('returnValue', FormatUtcDate(value));
}

function FormatUtcDate(D) {
    var dateObj = new Date(D);
    return String(dateObj.getFullYear()) + "-" + PadNumber(String(dateObj.getMonth() + 1)) + "-" + PadNumber(String(dateObj.getDate())) + "T";
}

function PadNumber(s) {
    if (String(s).length == 1) {
        return "0" + s;
    }
    return s;
}

/*added the code to make jquery calendar icon disabled on page referesh or page load*/
function disableDateIcon()
{
    var itemsLength = $(".ui-datepicker-trigger").length;

    for (index = 0; index < itemsLength; index++)
    {
        var disabled = $($(".ui-datepicker-trigger")[index]).prev()[0].disabled;
        if (disabled == true || disabled == 'disabled') {

            $($(".ui-datepicker-trigger")[index]).css({ opacity: '0.5', cursor: 'default' }).unbind('click');
        }
        else {
            $($(".ui-datepicker-trigger")[index]).bind('click');
        }
    }
}
//Added By Manjula on 16-JAN-2014
/*************FIXED GRID HEADER - START**************/
function ScrollHeader(GridId, ScrollHeight) {
    var grid = document.getElementById(GridId);
    if (typeof (grid) != 'undefined' && grid != null) {
    var gridWidth = grid.offsetWidth;
    var gridHeight = grid.offsetHeight;
    var headerCellWidths = new Array();
    var tableHeaderTrChild; var headerItemLen;
        //    if (grid.children[0].tagName == "THEAD") {
        //       if(grid.children[0].children[0])//Added By sravan for Javascript error
        //        tableHeaderTrChild = grid.children[0].children[0].children;
        //    }
        //    else if (grid.children[0].tagName == "TR" && grid.children[0].children[0].tagName == "TH") {
        //        tableHeaderTrChild = grid.children[0].children;
        //    }
        if (grid.children.length > 0) {
            if (grid.children[0].tagName == "THEAD") {
                tableHeaderTrChild = grid.children[0].children[0].children;
                if (tableHeaderTrChild != null) {
                    for (var i = 0; i < tableHeaderTrChild.length; i++) {
                        headerCellWidths[i] = tableHeaderTrChild[i].offsetWidth;
                    }
                }
            }
            else if (grid.children[0].tagName == "TR" && grid.children[0].children[0].tagName == "TH" || grid.children[0].children[0].tagName == "TD") {
                tableHeaderTrChild = grid.children[0].children;
                if (tableHeaderTrChild != null) {
                    for (var i = 0; i < tableHeaderTrChild.length; i++) {
                        headerCellWidths[i] = tableHeaderTrChild[i].offsetWidth;
                    }
                }
            }
            else if (grid.children[0].children[0].tagName == "TR" && grid.children[0].children[0].children[0].tagName == "TD" || grid.children[0].children[0].children[0].tagName == "TH") {
                tableHeaderTrChild = grid.children[0].children[0].children;
                if (tableHeaderTrChild != null) {
                    for (var i = 0; i < tableHeaderTrChild.length; i++) {
                        headerCellWidths[i] = grid.children[0].children[0].children[i].style.posWidth;//tableHeaderTrChild[i].offsetWidth;
                    }
                }
            }

            //if (grid.children[0].children[0])//Added By sravan for Javascript error
            //{
            //    for (var i = 0; i < tableHeaderTrChild.length; i++) {
            //        headerCellWidths[i] = tableHeaderTrChild[i].offsetWidth;
            //    }
            //}
            headerItemLen = tableHeaderTrChild.length;
            grid.parentNode.appendChild(document.createElement("div"));
            var parentDiv = grid.parentNode;
            var table = document.createElement("table");

            for (i = 0; i < grid.attributes.length; i++) {
                if (grid.attributes[i].specified && grid.attributes[i].name != "id") {
                    table.setAttribute(grid.attributes[i].name, grid.attributes[i].value);
                }
            }

            table.style.cssText = grid.style.cssText;
            table.style.verticalAlign = "top";
            table.style.width = gridWidth + "px";
            table.appendChild(document.createElement("tbody"));
            table.getElementsByTagName("tbody")[0].appendChild(grid.getElementsByTagName("TR")[0]);

            var gridRow = grid.getElementsByTagName("TR")[0];
            //if (grid.children[0].children[0])//Added By sravan for Javascript error
            //{
            for (var i = 0; i < headerItemLen.length; i++) {
                    var width;
                    if (headerCellWidths[i] > gridRow.getElementsByTagName("TD")[i].offsetWidth) {
                        width = headerCellWidths[i];
                    }
                    else {
                        width = gridRow.getElementsByTagName("TD")[i].offsetWidth;
                    }
                    tableHeaderTrChild[i].style.width = parseInt(width - 3) + "px";
                    gridRow.getElementsByTagName("TD")[i].style.width = parseInt(width - 3) + "px";
                }
            //}
            parentDiv.removeChild(grid);
            grid.style.verticalAlign = "bottom";
            var dummyHeader = document.createElement("div");
            parentDiv.appendChild(table);
            if (parseInt(gridHeight) > ScrollHeight) {
                gridWidth = parseInt(gridWidth) + 17;
            }
            dummyHeader.style.cssText = "float:left;overflow:auto;height:" + ScrollHeight + "px;width:" + gridWidth + "px";
            dummyHeader.appendChild(grid);
            parentDiv.appendChild(dummyHeader);
        }
    }
}
/*************FIXED GRID HEADER - END**************/