﻿function FlipDiv(img, divname) {
    //alert(img.src);
    if (img.src.endsWith('SingleMinus.gif')) {
        img.src = '/images/icons/SinglePlus.gif';
        HideContent(divname);
    }
    else {
        img.src = '/images/icons/SingleMinus.gif';
        ShowContent(divname);
    }
}
function HideContent(d) {
    if (d.length < 1) { return; }
    document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
    if (d.length < 1) { return; }
    document.getElementById(d).style.display = "block";
}
function toggleAll(isChecked, control) {
    i = 0;
    var thisControl = document.getElementById(control + '_' + i);
    while (thisControl != null) {
        thisControl = document.getElementById(control + '_' + i);

        if (thisControl != null) {
            thisControl.checked = isChecked;
            i++;
        }
    }
}
function Select(Select, Search) {
    for (var n = 0; n < document.forms[0].length; n++) {
        if (document.forms[0].elements[n].type == 'checkbox') {
            if (document.forms[0].elements[n].id) {
                if (Search == '') {
                    document.forms[0].elements[n].checked = Select;
                } else if (document.forms[0].elements[n].id.indexOf(Search) > 0) {
                    document.forms[0].elements[n].checked = Select;
                }
            }
        }
    }
    return false;
}
function ConfirmSubmit() {
    if (confirm("Are you sure you want to continue?"))
        return true;
    else
        return false;
}
function hideLayer(whichLayer) {
    if (document.getElementById) {
        // this is the way the standards work
        document.getElementById(whichLayer).style.visibility = "hidden";
    }
    else if (document.all) {
        // this is the way old msie versions work
        document.all[whichlayer].style.visibility = "hidden";
    }
    else if (document.layers) {
        // this is the way nn4 works
        document.layers[whichLayer].visibility = "hidden";
    }
}

function showLayer(whichLayer) {
    if (document.getElementById) {
        // this is the way the standards work
        //alert('ie');
        document.getElementById(whichLayer).style.visibility = "visible";
    }
    else if (document.all) {
        // this is the way old msie versions work
        //alert('all');
        document.all[whichlayer].style.visibility = "visible";
    }
    else if (document.layers) {
        // this is the way nn4 works
        //alert('layers');
        document.layers[whichLayer].visibility = "visible";
    }
}
var emptyString = /^\s*$/;
function OnFocusRowAll(valfield, infofield, msgContent) {
    document.getElementById(valfield).className = 'rowbgcolor';
    msg(infofield, "normaltextgrey", msgContent);
    return true;
}
function OnBlurrRowAll(valfield, infofield, msgContent) {
    document.getElementById(valfield).className = 'norowbgcolor';
    msg(infofield, "normaltextgrey", msgContent);
    return true;
}
// --------------------------------------------
//                  msg
// Display warn/error message in HTML element.
// commonCheck routine must have previously been called
// --------------------------------------------
//fld id of element to display message in
//msgtype class to give element ("warn" or "error")
//message string to display
function msg(fld, msgtype, message) {
    // setting an empty string can give problems if later set to a 
    // non-empty string, so ensure a space present. (For Mozilla and Opera one could 
    // simply use a space, but IE demands something more, like a non-breaking space.)
    var dispmessage = "";
    if (emptyString.test(message))
        dispmessage = " "; //String.fromCharCode(nbsp);
    else
        dispmessage = message;

    var elem11 = document.getElementById(fld);
    if (elem11.firstChild != null && elem11.firstChild != undefined) {
        elem11.firstChild.nodeValue = dispmessage;
    }
    else {
        elem11.value = dispmessage;
    }
    elem11.className = msgtype;   // set the CSS class to adjust appearance of message
}
