﻿// JScript File
function Toggle(ID,Display)
{
    document.getElementById(ID).style.display=Display;
    if (Display == 'none' && document.getElementById('TransparentBackground') != null){document.getElementById('TransparentBackground').style.display=Display;}
}

function ToggleBackgroundColor(ID,Color)
{
    document.getElementById(ID).style.backgroundColor=Color;
}

function ToggleBackgroundImage(ID,ImageURL)
{
    document.getElementById(ID).style.backgroundImage="url(" + ImageURL + ")";
}

function ToggleTextColor(ID,Color)
{
    document.getElementById(ID).style.color=Color;
}

function OpenPage(URL,Target)
{
    if (Target == null) {window.open(URL,'_self');}
    else {window.open(URL,Target);}
}

function Fade(ID,Percent)
{
    if (document.getElementById)
    {
        var object = document.getElementById(ID).style;
        if (document.all)
        {
            object.filter = "alpha(opacity=" + Percent + ")";
        }
        else
        {
            object.opacity = (Percent / 100);
        }
    }
}

function scrollTop(pos)
{
    window.document.body.scrollTop = pos;
    window.document.documentElement.scrollTop = pos;
}


function ToggleImageSrc(ID, ImgPath)
{
    document.getElementById(ID).src = ImgPath;
}

function ToggleGroup(ID, IDArray)
{
    for (i = 0; i < IDArray.length; i++)
    {
        if (IDArray[i] == ID)
        {
            document.getElementById(IDArray[i]).style.display='block';
        }
        else
        {
            document.getElementById(IDArray[i]).style.display='none';
        }
    }
}

function ToggleRadDatePickerPopup(rdp)
{
    eval(rdp).ShowPopup();
}

function ShowMPE(id)
{
    var extender = $find(id); 
    extender.show();
}

function ShowModal(id)
{
    var extender = $find(id); 
    extender.show();
}

function HideModal(id)
{
    var extender = $find(id); 
    extender.hide();
}
        
function HideMPE(id)
{
    var extender = $find(id); 
    extender.hide();
}

function ShowSelect()
{
    tagElements = document.getElementsByTagName('SELECT');
    for (var k = 0 ; k < tagElements.length; k++) 
    {
        tagElements[k].style.visibility = 'inherit';
        i++;
    }
}

function NoSubmit(sObjectID) {
    try {
        if (!document.all) {
            var oObject = document.getElementById(sObjectID);
           
            if (oObject.addEventListener) { 
                oObject.parentNode.addEventListener("keypress",
                    function(e) {
                        if (e && e.keyCode && e.keyCode==13) {
                            e.stopPropagation();
                        }
                    }, false); 
            } 
        }
    } catch (e) {}
}

function ShowLoad()
{
    document.body.style.cursor = 'wait';
    obj = $find('LoadingPanel');
    obj.show();
}

function HideLoad()
{
    document.body.style.cursor = 'default';
    obj = $find('LoadingPanel');
    obj.hide();
}

function ismaxlength(obj, max)
{
    if (obj.value.length>max)
        obj.value=obj.value.substring(0,max);
}