var selectVehicle = 'Select any of the vehicle !';
var selectAlarms = 'Select the alarm(s) that needs to be updated !';
var selectAlarmStatus = 'Select the status to be changed for the selected alarm(s) !';
var confirmAlarmAcknowledge = 'Are you sure you want to acknowledge the selected alarm(s)?';
var confirmAlarmClose = 'Are you sure you want to close the selected alarm(s)?';
var Alert_Alerts_AckConfirmation = 'Enter the comments to Acknowledge the selected alarm(s).';
var Alert_Select_Alarms = 'Please select the alarm(s) !';
var Alert_Alerts_CloseConfirmation = 'Enter the comments to Close the selected alarm(s).';
var Alert_AcknowledgedAlarms = 'Some of the alarm(s) selected were already acknowledged or closed. Please select unacknowledged alarm(s) !';
var Alert_AlreadyClosed = 'Some of the alarm(s) selected were closed already. Please select open alarm(s).';

function SetAlertMessages(selectVehicleAlert, selectAlarmsAlert, selectAlarmStatusAlert, confirmAlarmAcknowledgeMessage, confirmAlarmCloseMessage, Alert_Alerts_AckConfirmationMessage, Alert_Select_AlarmsMessage, Alert_Alerts_CloseConfirmationMessage, Alert_AcknowledgedAlarmsMessage, Alert_AlreadyClosedMessage) {
    selectVehicle = selectVehicleAlert;
    selectAlarms = selectAlarmsAlert;
    selectAlarmStatus = selectAlarmStatusAlert;
    confirmAlarmAcknowledge = confirmAlarmAcknowledgeMessage;
    confirmAlarmClose = confirmAlarmCloseMessage;
    Alert_Alerts_AckConfirmation = Alert_Alerts_AckConfirmationMessage;
    Alert_Select_Alarms = Alert_Select_AlarmsMessage;
    Alert_Alerts_CloseConfirmation = Alert_Alerts_CloseConfirmationMessage;
    Alert_AcknowledgedAlarms = Alert_AcknowledgedAlarmsMessage;
    Alert_AlreadyClosed = Alert_AlreadyClosedMessage;
}

function ValidateAlert() {
    if (document.getElementById("ddlVehicle").value == '- Select -') {
        TrinetraCustomAlerts(selectVehicleAlert);
        document.getElementById("ddlVehicle").focus();
        return false;
    }
    return true;
    //    return CheckStartAndEnd();
}

function OnGridSelectionChanged() {

    //            if (counter != null) setInnerText(counter, grid.GetSelectedRowCount().toString());
    gvData.GetSelectedFieldValues('AlarmId', OnGridSelectionComplete);
}

function OnGridSelectionComplete(values) {
    var counter = document.getElementById("hdnAlarmIDs");
    counter.value = '';
    for (var i = 0; i < values.length; i++) {
        counter.value = counter.value + values[i] + ',';
    }
}

function CheckSelection(enable) {
    var counter = document.getElementById("hdnAlarmIDs");
    var ack = gvData.GetColumn(9);
    var canProcess = true;
    if (enable == 0 && counter.value.length == 0 && gvData.GetSelectedRowCount() == 0) {
        //alert('Please select the alarm(s) !');
        TrinetraCustomAlerts(Alert_Select_Alarms);
        return false;
    } else if (enable == 0)
    { return true; }

    if (counter.value.length == 0 && gvData.GetSelectedRowCount() == 0 && (document.getElementById('ddlMassUpdateStatus').value == "0")) {
        TrinetraCustomAlerts(selectAlarmStatus + '<br>' +selectAlarms);
        canProcess = false;
    }
    else if (counter.value.length == 0 && gvData.GetSelectedRowCount() == 0) {     
        TrinetraCustomAlerts(selectAlarms);
        canProcess = false;
    }
    else if (document.getElementById('ddlMassUpdateStatus').value == "0") {      
        TrinetraCustomAlerts(selectAlarmStatus);
        canProcess = false;
    }
    else {
        canProcess = false;
        //        if (document.getElementById("hdnAlarmIDs") != null) {
        //            if (document.getElementById("hdnAlarmIDs").value != '') {
        //                ProcessFurther();
        //            } else {
        //                return canProcess;
        //            }
        //        }

        //        if (document.getElementById("hdnAlarmIDs") != null) {
        if (gvData.GetSelectedRowCount() != 0) {
            ShowPopUp();
            //ProcessFurther();
            document.getElementById("btnGetvalue").click();
        } else {
            return canProcess;
        }
        //}
    }
    return canProcess;
}


function OnGetSelectedFieldValues1(selectedValues) {
    document.getElementById("hdnAlarmIDs").value = '';
    document.getElementById("hdnValidGps").value = 'false';
    if (selectedValues.length == 0) return;
    for (i = 0; i < selectedValues.length; i++) {
        s = "";
        s += selectedValues[i] + ',';
        if (selectedValues[i] != 'N/A') { document.getElementById("hdnValidGps").value = 'true'; }
    }
    document.getElementById("hdnAlarmIDs").value = s;
}


function OnGetSelectedFieldValues(selectedValues) {
    document.getElementById("hdnAlarmIDs").value = '';
    document.getElementById("hdnValidGps").value = 'false';
    if (selectedValues.length == 0) return;
    for (i = 0; i < selectedValues.length; i++) {
        s = "";
        for (j = 0; j < selectedValues[i].length; j++) {
            if (j < selectedValues[i].length - 1) {
                s = s + selectedValues[i][j] + '%';
            } else { if (selectedValues[i][j] != 'N/A') { document.getElementById("hdnValidGps").value = 'true'; } }
        }
        document.getElementById("hdnAlarmIDs").value = document.getElementById("hdnAlarmIDs").value + s + ',';
    }
}

function ProcessFurther(value) {
    var confirmation;
    var isAckOrClosed = false;
    var selectedIds = '';
    if (value == '') {
        selectedIds = String(document.getElementById("hdnAlarmIDs").value).split(',');
    }
    else {
        selectedIds = value.split('#');
    }
    for (var i = 0; i < selectedIds.length - 1; i++) {
        var values = String(selectedIds[i]).split('%');
        if (document.getElementById('ddlMassUpdateStatus').value == "1") {
            if ((values[1] != "null") || (values[2] != "null")) {
                isAckOrClosed = true;
                break;
            }
        }
        else {
            if (values[2] != "null") {
                isAckOrClosed = true;
                break;
            }
        }
        if (isAckOrClosed)
            break;
    }
    if (isAckOrClosed) {
        if (document.getElementById('ddlMassUpdateStatus').value == "1") {
            //alert('Some of the alarm(s) selected were already acknowledged or closed. Please select unacknowledged alarm(s) !')
            TrinetraCustomAlerts(Alert_AcknowledgedAlarms);
            document.getElementById("hdnAlarmIDs").value = '';
        }
        else {
            //alert('Some of the alarm(s) selected were closed already. Please select open alarm(s).');
            TrinetraCustomAlerts(Alert_AlreadyClosed);
        }
        document.getElementById('btnClearGrid').click();
    }
    else {
        if (document.getElementById('ddlMassUpdateStatus').value == 1) {
            //confirmation = confirm(confirmAlarmAcknowledge);
            //confirmAlarmAcknowledge = 'Please enter a comments if you want to acknowledge the selected alarm(s)?';
            confirmation = prompt(Alert_Alerts_AckConfirmation, '');
        }
        else if (document.getElementById('ddlMassUpdateStatus').value == 2) {
            //confirmation = confirm(confirmAlarmClose);
            //confirmAlarmClose = 'Please enter a comments if you want to close the selected alarm(s)?'
            confirmAlarmClose = Alert_Alerts_CloseConfirmation;
            confirmation = prompt(confirmAlarmClose, '');
        }

        if (confirmation != null) {
            document.getElementById('hdnComments').value = confirmation;
            document.getElementById('btnProcessFurther').click();
            ShowPopUp();
        }
        else {
            document.getElementById('btnClearGrid').click();
            HidePopUp();
        }
    }
}

function ProcessFurther_Alert(value) {

    var confirmation;
    var isAckOrClosed = false;
    var selectedIds = '';
    if (value == '') {
        selectedIds = String(document.getElementById("hdnAlarmIDs").value).split(',');
    }
    else {
        selectedIds = value.split('#');
    }
    for (var i = 0; i < selectedIds.length - 1; i++) {
        var values = String(selectedIds[i]).split('%');
        if (document.getElementById('ddlMassUpdateStatus').value == "1") {
            if ((values[1] != "null") || (values[2] != "null")) {
                isAckOrClosed = true;
                break;
            }
        }
        else {
            if (values[2] != "null") {
                isAckOrClosed = true;
                break;
            }
        }
        if (isAckOrClosed)
            break;
    }
    if (isAckOrClosed) {
        if (document.getElementById('ddlMassUpdateStatus').value == "1") {
            //alert('Some of the alarm(s) selected were already acknowledged or closed. Please select unacknowledged alarm(s) !')
            TrinetraCustomAlerts(Alert_AcknowledgedAlarms);
            document.getElementById("hdnAlarmIDs").value = '';
        }
        else {
            //alert('Some of the alarm(s) selected were closed already. Please select open alarm(s).');
            TrinetraCustomAlerts(Alert_AlreadyClosed);
        }
        return false;
    }
    else {
        return true;
    }
}

//To openMap in Fullscreen Mode
var FullMapWindow;
function FullscreenMap() {
    if (document.getElementById('hdnValidGps') != null && document.getElementById('hdnValidGps').value == "true") {
        FullMapWindow = window.open("FullscreenMap.aspx?pMy9nEs9WLFPu5OGp76JWA==", 'FullscreenMapAlerts', 'scrollbars=yes,resizable=no,width=' +
            screen.width + ',height=' + screen.height, false);
        FullMapWindow.moveTo(0, 0);
        FullMapWindow.focus();
    }
}


function HideGrid() {
    var chk_AlarmSend = document.getElementById('chk_AlarmSend');
    if (chk_AlarmSend.checked) {
        document.getElementById('Gridgvuser').style.display = "block";
      //  document.getElementById('hdnChkLoadUser').value = "1";
        
    }
    else {
        document.getElementById('Gridgvuser').style.display = "none";
      //  document.getElementById('hdnChkLoadUser').value = "0";
    }

  
}
 
//// Legend Icons
//var VLegendHeader = "Legends";
//var VLegendToolTip = "click to show / hide legends";
//var VDirection = "ltr";
//var VNotify = 'Notify';
//var VWarning = 'Warning';
//var VCritical = 'Critical';
//var VNoAlarms = 'No Alarms';
//var VLegendHeader = "Legends";
//var VPending = 'Pending';
//var VAcknowledge = 'Acknowledged';
//var VClose = 'Closed';
//var VPendingCount = '0';
//var VAcknowledgedCount = '0';
//var VClosedCount = '0';
//var VAlarmStatistics = 'Alarms Statistics';
//function SetIconLegendText(Notify, Warning, VLegendAlignAlert, VDirectionMessage, VLegendHdrMessage, VLegendToolTipMessage, Critical, VarNoAlarms, VarPending, VarAcknowledge, VarClose, VarPendingCount, VarAcknowledgedCount, VarClosedCount, VarAlarmStatistics) {
//    VNotify = Notify;
//    VWarning = Warning;
//    VCritical = Critical;
//    VLegendAlign = VLegendAlignAlert;
//    VDirection = VDirectionMessage;
//    VLegendHeader = VLegendHdrMessage;
//    VLegendToolTip = VLegendToolTipMessage;
//    VNoAlarms = VarNoAlarms;
//    VAcknowledge = VarAcknowledge;
//    VClose = VarClose;
//    VPending = VarPending;
//    VPendingCount = VarPendingCount;
//    VAcknowledgedCount = VarAcknowledgedCount;
//    VClosedCount = VarClosedCount;
//    VAlarmStatistics = VarAlarmStatistics;
//    document.getElementById("Alarmlegend").innerHTML = iconLegendText();
//    document.getElementById("AlarmStatistics").innerHTML = iconLegendTextStatistics();
//}
//function iconLegendText() {
//    var height = '';
//    var VborderStyle = 'border-left: 1px dashed black';
//    if (VLegendAlign == 'right') {
//        VborderStyle = 'border-right: 1px dashed black';
//    }
//    else {
//        VborderStyle = 'border-left: 1px dashed black';
//    }
//    var legendText = "<div class='panel1' align='center' id='lnkLegend' style='opacity:1.0; background: url(../images/btn-Alarm_Stat.jpg) 100% 0 repeat-y;width:100px;height:20px;'> <h2 style='font:1px;'>" + VLegendHeader + "</h2><div class='panelcontent1' style='width:150px;'><table id='tblLegendAlarm' align='right'" + height + " style='direction:" + VDirection + ";width:90px'>" +
//                "<tr><td align='right' style='padding: 6px 0px 6px 6px;'>" +
//                 "<table cellpadding='2' cellspacing='2' align='right' width='140px' height='140px'>" +
//                "<tr>" +
//                 "  <td style='padding-left:2px;vertical-align:top'><img src='../images/Warning-alert.gif' alt='Warning' style='height:15px;width:15px' /></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spIgnitionOff' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VWarning + "</strong></span></td>" +
//                 "  <td >&nbsp;</td>" +
//                 "</tr>" +
//                 "<tr>" +
//                 "  <td style='padding-left:2px;vertical-align:top'><img src='../images/Critical-alert.gif' alt='Critical' style='height:15px;width:15px' /></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spAlarms' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VCritical + "</strong></span></td>" +
//                 "  <td >&nbsp;</td>" +
//                 "</tr> " +
//                 "<tr>" +
//                 "  <td style='padding-left:2px;vertical-align:top'><img src='../images/No alarm-alert.gif' alt='No Alarms' style='height:15px;width:15px' /></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spIgnitionOn' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VNoAlarms + "</strong></span></td>" +
//                 "  <td >&nbsp;</td>" +
//                 "</tr>" +
//                 "<tr>" +
//                 "  <td style='padding-left:2px;vertical-align:top;'><img src='../images/icn-pending-alarms.gif' alt='Critical' style='height:15px;width:15px' /></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spAlarms' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VPending + "</strong></span></td>" +
//                 "</tr>" +
//                 "<tr>" +
//                 "  <td style='padding-left:2px;vertical-align:top;'><img src='../images/icn-acknowledged-alarms.gif' alt='Critical' style='height:15px;width:15px' /></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spAlarms' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VAcknowledge + "</strong></span></td>" +
//                 "</tr>" +
//                 "<tr>" +
//                 "  <td style='padding-left:2px;vertical-align:top;'><img src='../images/icn-closed-alarms.gif' alt='No Alarms' style='height:15px;width:15px' /></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spIgnitionOn' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VClose + "</strong></span></td>" +
//                 "</tr>" +
//                 "</table></td></tr></table></div></div>";
//    return legendText;
//}
//function iconLegendTextStatistics() {
//    var height = '';
//    var VborderStyle = 'border-left: 1px dashed black';
//    if (VLegendAlign == 'right') {
//        VborderStyle = 'border-right: 1px dashed black';
//    }
//    else {
//        VborderStyle = 'border-left: 1px dashed black';
//    }
//    var legendText = "<div class='panel1' align='center' id='lnkLegend' style='opacity:1.0;background: url(../images/btn-Alarm_Legends.png) 100% 0 repeat-y;width:150px;height:20px;'> <h2 style='font:3px;'>" + VAlarmStatistics + "</h2><div class='panelcontent1' style='width:240px;'><table id='tblLegendAlarm' align='right'" + height + " style='direction:" + VDirection + ";width:200px'>" +
//                "<tr><td align='right' style='padding: 6px 0px 6px 6px;'>" +
//                 "<table cellpadding='2' cellspacing='2' align='right' width='200px' height='60px'>" +
//                "<tr>" +
//                 "  <td style='padding-left:2px;vertical-align:top;'><img src='../images/icn-pending-alarms.gif' alt='Critical' style='height:15px;width:15px' /></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spAlarms' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VPending + "</strong></span></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spAlarms' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VPendingCount + "</strong></span></td>" +
//                 "</tr>" +
//                 "<tr>" +
//                 "  <td style='padding-left:2px;vertical-align:top;'><img src='../images/icn-acknowledged-alarms.gif' alt='Critical' style='height:15px;width:15px' /></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spAlarms' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VAcknowledge + "</strong></span></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spAlarms' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VAcknowledgedCount + "</strong></span></td>" +
//                 "</tr> " +
//                 "<tr>" +
//                 "  <td style='padding-left:2px;vertical-align:top;'><img src='../images/icn-closed-alarms.gif' alt='No Alarms' style='height:15px;width:15px' /></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spIgnitionOn' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VClose + "</strong></span></td>" +
//                 "  <td align='" + VLegendAlign + "'><span class='txt' id='spAlarms' runat='server' style='font:11px arial;color:#333333;vertical-align:bottom'>&nbsp;&nbsp;&nbsp;&nbsp;<strong>" + VClosedCount + "</strong></span></td>" +
//                 "</tr>" +
//                 "</table></td></tr></table></div></div>";
//    return legendText;
//}
///********************Colapse panel JQuery foe Legends***************/
//var PANEL_NORMAL_CLASS = "panel1";
//var PANEL_COLLAPSED_CLASS = "panelcollapsed1";
//var PANEL_HEADING_TAG = "h2";
//var PANEL_CONTENT_CLASS = "panelcontent1";
//var PANEL_COOKIE_NAME = "panels";
//var PANEL_ANIMATION_DELAY = 15; /*ms*/
//var PANEL_ANIMATION_STEPS = 10;

//function setUpPanels() {
//    loadSettings();

//    // get all headings
//    var headingTags = document.getElementsByTagName(PANEL_HEADING_TAG);

//    // go through all tags
//    for (var i = 0; i < headingTags.length; i++) {
//        var el = headingTags[i];

//        // make sure it's the heading inside a panel
//        if (el.parentNode.className != PANEL_NORMAL_CLASS && el.parentNode.className != PANEL_COLLAPSED_CLASS)
//            continue;

//        // get the text value of the tag
//        var name = el.firstChild.nodeValue;
//        panelsStatus[name] = "false";
//        // look for the name in loaded settings, apply the normal/collapsed class
//        if (panelsStatus[name] == "false")
//            el.parentNode.className = PANEL_COLLAPSED_CLASS;
//        else
//            if (panelsStatus[name] == "true")
//            el.parentNode.className = PANEL_NORMAL_CLASS;
//        else {
//            // if no saved setting, see the initial setting
//            panelsStatus[name] = (el.parentNode.className == PANEL_NORMAL_CLASS) ? "true" : "false";
//        }

//        // add the click behavor to headings
//        el.onclick = function() {
//            var target = this.parentNode;
//            var name = this.firstChild.nodeValue;
//            var collapsed = (target.className == PANEL_COLLAPSED_CLASS);
//            saveSettings(name, collapsed ? "true" : "false");
//            animateTogglePanel(target, collapsed);
//        };
//    }
//}

//function animateTogglePanel(panel, expanding) {
//    // find the .panelcontent div
//    var elements = panel.getElementsByTagName("div");
//    var panelContent = null;
//    for (var i = 0; i < elements.length; i++) {
//        if (elements[i].className == PANEL_CONTENT_CLASS) {
//            panelContent = elements[i];
//            break;
//        }
//    }
//    // make sure the content is visible before getting its height
//    panelContent.style.display = "block";

//    // get the height of the content
//    var contentHeight = panelContent.offsetHeight;

//    // if panel is collapsed and expanding, we must start with 0 height
//    if (expanding)
//        panelContent.style.height = "0px";

//    var stepHeight = contentHeight / PANEL_ANIMATION_STEPS;
//    var direction = (!expanding ? -1 : 1);

//    setTimeout(function() { animateStep(panelContent, 1, stepHeight, direction) }, PANEL_ANIMATION_DELAY);
//}

//function animateStep(panelContent, iteration, stepHeight, direction) {
//    if (iteration < PANEL_ANIMATION_STEPS) {
//        panelContent.style.height = Math.round(((direction > 0) ? iteration : 10 - iteration) * stepHeight) + "px";
//        iteration++;
//        setTimeout(function() { animateStep(panelContent, iteration, stepHeight, direction) }, PANEL_ANIMATION_DELAY);
//    }
//    else {
//        // set class for the panel
//        panelContent.parentNode.className = (direction < 0) ? PANEL_COLLAPSED_CLASS : PANEL_NORMAL_CLASS;
//        // clear inline styles
//        panelContent.style.display = panelContent.style.height = "";
//    }
//}

//function loadSettings() {
//    // prepare the object that will keep the panel statuses
//    panelsStatus = {};

//    // find the cookie name
//    var start = document.cookie.indexOf(PANEL_COOKIE_NAME + "=");
//    if (start == -1) return;

//    // starting point of the value
//    start += PANEL_COOKIE_NAME.length + 1;

//    // find end point of the value
//    var end = document.cookie.indexOf(";", start);
//    if (end == -1) end = document.cookie.length;

//    // get the value, split into key:value pairs
//    var cookieValue = unescape(document.cookie.substring(start, end));
//    var panelsData = cookieValue.split("|");

//    // split each key:value pair and put in object
//    for (var i = 0; i < panelsData.length; i++) {
//        var pair = panelsData[i].split(":");
//        panelsStatus[pair[0]] = pair[1];
//    }
//}

//function expandAll() {
//    for (var key in panelsStatus)
//        saveSettings(key, "true");

//    setUpPanels();
//}

//function collapseAll() {
//    for (var key in panelsStatus)
//        saveSettings(key, "false");

//    setUpPanels();
//}

//function saveSettings(key, value) {
//    // put the new value in the object
//    panelsStatus[key] = value;

//    // create an array that will keep the key:value pairs
//    var panelsData = [];
//    for (var key in panelsStatus)
//        panelsData.push(key + ":" + panelsStatus[key]);

//    // set the cookie expiration date 1 year from now
//    var today = new Date();
//    var expirationDate = new Date(today.getTime() + 365 * 1000 * 60 * 60 * 24);
//    // write the cookie
//    document.cookie = PANEL_COOKIE_NAME + "=" + escape(panelsData.join("|")) + ";expires=" + expirationDate.toGMTString();
//}

//// Register setUpPanels to be executed on load
//if (window.addEventListener) {
//    // the "proper" way
//    window.addEventListener("load", setUpPanels, false);
//}
//else
//    if (window.attachEvent) {
//    // the IE way
//    window.attachEvent("onload", setUpPanels);
//}

////To set the Collapsable legends alive.
//Sys.Application.add_load(setUpPanels);
///********************End of Colapse panel JQuery foe Legends***************/