
//This method will hide the panel.
function HidePanel(Panel) {
    try {
        var ChosenPanel = document.all(Panel);
        if (ChosenPanel != null) {
            document.all(Panel).style.display = "none";
        }
    }
    catch (e) {
        alert("Error in HidePanel Method: " + e);
    }
}

//This method will show the panel.	
function ShowPanel(Panel) {
    try {
        var ChosenPanel = document.all(Panel);
        if (ChosenPanel != null) {
            document.all(Panel).style.display = "block";
        }
    }
    catch (e) {
        alert("Error in ShowPanel Method: " + e);
    }
}

function ShowAllPanel() {
    var tag;
    var myRegExp = "_gvServiceList";
    var matchPos;

    for (i = 0; i < document.all.length; i++) {
        tag = document.all(i).id;
        matchPos = tag.search(myRegExp);

        if (matchPos != -1)
            document.all(document.all(i).id).style.display = "";
    }
}

function HideAllPanel() {
    var tag;
    var myRegExp = "_gvServiceList";
    var matchPos;

    for (i = 0; i < document.all.length; i++) {
        tag = document.all(i).id;
        matchPos = tag.search(myRegExp);

        if (matchPos != -1)
            document.all(document.all(i).id).style.display = "none";
    }
}

//This method will hide and show the panel.	
function HideShowPanel(Panel) {
    try {
        var ChosenPanel = document.all(Panel);
        if (ChosenPanel != null) {
            var currentdisplay = document.all(Panel).style.display;
            if (currentdisplay == "none") {
                document.all(Panel).style.display = "";
            }
            else {
                document.all(Panel).style.display = "none";
            }
        }
    }
    catch (e) {
        alert("Error in HideShowPanel Method: " + e);
    }
}

//This method will get the object using partial id match.
function getItem(IDSearchCriteria, DataGridID) {
    try {
        if (IDSearchCriteria == null || IDSearchCriteria.length <= 0) {
            return null;
        }
        else if (DataGridID == null || DataGridID.length <= 0) {
            return null;
        }

        if (document.getElementsByTagName) {
            var table = document.getElementById(DataGridID);
            if (table != null) {
                var rows = table.getElementsByTagName("tr");
                for (var i = 0; i < rows.length; i++) {
                    var Identity = rows[i].id;

                    if (Identity != null && Identity.length > 0) {

                        var cellid = IDSearchCriteria.substring(IDSearchCriteria.lastIndexOf("_") + 1);
                        if (Identity.match(cellid)) {
                            //alert("Found: " + Identity);
                            return Identity;
                        }

                    }
                }
            }
            return null;
        }
        else {
            return null;
        }
    }
    catch (e) {
        alert("Error in getItem Method: " + e);
        return null;
    }
}