﻿// JScript File
function valDate(date)
{
    if (Date.parse(date))
        return true;
    else
        return false;
}

function Validate(idtxt, iderr)
{
    alert(idtxt);

    var obj = document.getElementById(idtxt);
    alert(obj.text);
    if (obj)
    {
        //set date to short date string
        //obj.value = formatDate(Date.parse(obj.value),"MM/dd/yyyy");
        //validate for date
        var val = (obj.value.length == 0)?true:valDate(date)
        var errspan = document.getElementById(iderr);
        if (errspan) errspan.style.display = (val==true)?"none":"inline";
    }

}

function Val(date, nul, id)
{
    var val = (date.length == 0)?true:valDate(date)
    var errspan = document.getElementById(id.replace("popCal","spnError"));
    if (errspan) errspan.style.display = (val==true)?"none":"inline";
}

//print a div contents
function printdiv(divname)
{
    var obj = document.getElementById(divname);
    if (obj)
    {
        //var printScript = frames['printit'];
        var win = window.open("","_print");
        win.document.open();
        win.document.write("<html><head></head><body>");
        win.document.write(obj.innerHTML);
        win.document.write("</body></html>");
        win.document.close();
        win.focus();
        win.print();
    }
}

//show delete confirmation box
function delete_confirm()
{
    return confirm('Are you sure you want to delete this record?');
}

//opens window with no menu / bars - for showing reports
function OpenWindow(lnk, win)
{
    window.open(lnk, win, "status=no,menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,fullscreen=no");
}

//opens window with no menu / bars - for showing reports
function OpenWindow(lnk)
{
    window.open(lnk, "_Helios", "status=no,menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,fullscreen=no");
}

function close_window()
{
    if (confirm('Are you sure you want to close this window and lose changes?') == true)
    {
        window.close();
    }
}

//to fix the Flash object's "click to activate this control" error
function flash_correct()
{
    objects = document.getElementsByTagName("object");
    for (var i = 0; i < objects.length; i++)
    {
        objects[i].outerHTML = objects[i].outerHTML;
    }
}

//flash_correct();
