﻿function toggle(id) {
    var itm = null;
    if (document.getElementById) {
        itm = document.getElementById(id);
    } else if (document.all) {
        itm = document.all[id];
    } else if (document.layers) {
        itm = document.layers[id];
    }
    if (!itm) {
        // do nothing
    } else if (itm.style) {
        if (itm.style.display == "none") { itm.style.display = ""; }
        else { itm.style.display = "none"; }
    } else { itm.visibility = "show"; }
}

function mShowDD(id, option) {
    var itm = null;
    if (document.getElementById) {
        itm = document.getElementById(id);
    } else if (document.all) {
        itm = document.all[id];
    } else if (document.layers) {
        itm = document.layers[id];
    }
        
    if (option == 1) {
       if (!itm) {
        // do nothing
       }
       else if (itm.style) {
         if (itm.style.display == "none") { itm.style.display = ""; }
       }
       else { itm.visibility = "show"; }
    } else {
        if (!itm) {
            // do nothing
        }
        else if (itm.style) {
            if (itm.style.display == "") { itm.style.display = "none"; }
        }
        else { itm.visibility = "show"; }
    }
}

function hide(id) {
    var itm = null;
    if (document.getElementById) {
        itm = document.getElementById(id);
    } else if (document.all) {
        itm = document.all[id];
    } else if (document.layers) {
        itm = document.layers[id];
    }

    if (!itm) {
        // do nothing
    }
    else if (itm.style) {
        itm.style.display = "none";
    }
    else { itm.visibility = ""; }
}

function mHover(obj, ent)
{
    if (ent == 'over')
    {
        if (obj.src.indexOf('-h.') == -1)
        {
            obj.src = obj.src.replace('.gif', '-h.gif');
            obj.src = obj.src.replace('.jpg', '-h.jpg');
        }
    }else{
        obj.src = obj.src.replace('-h.gif', '.gif');
        obj.src = obj.src.replace('-h.jpg', '.jpg');
    }
}
function clearText(formItem, defaultText) 
{
    if (formItem.value == defaultText)
    {
        formItem.value = "";
    }
}
function resetText(formItem, defaultText) 
{
    if(formItem.value == "")
    {
        formItem.value = defaultText;
    }
}
function setActiveButton(btnName)
{
    var btnObj = document.getElementById(btnName);
    btnObj.src = btnObj.src.replace('.gif', '-h.gif');
    btnObj.onmouseover = "";
    btnObj.onmouseout = "";
}
function printSelection(node) {

    var content = node.innerHTML
    var pwin = window.open('', 'print_content', 'width=1000,height=1000');

    pwin.document.open();
    pwin.document.write('<html><head><link rel="stylesheet" type="text/css" href="/design/css/stylesheet.css" /></head><body onload="window.print()">' + content + '</body></html>');
    pwin.document.close();

    setTimeout(function() { pwin.close(); }, 1000);

}
function inputInt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "This field accepts numbers only."
        return false
    }
    status = ""
    return true
}
