//////////////////////////////////////////////////////////////////////////
function OpenWindow(strPage, strWindowName, intWidth, intHeight, intLeft, intTop, bolToolbar, bolMenubar, bolScrollbars, bolResizable, bolLocation, bolDirectories, bolStatus)
{
	if ((intTop == 9999) && (intLeft == 9999))
	{
		iTop = ((screen.availHeight - intHeight) / 2);
		iLeft = (screen.availWidth - intWidth) / 2;
	}
	else
	{
		iTop = intTop;
		iLeft = intLeft;
	}
	strFeatures = "height=" + intHeight + ",width=" + intWidth + ",top=" + iTop + ",left=" + iLeft
	strFeatures = strFeatures + ",toolbar=" + bolToolbar + ",menubar=" + bolMenubar + ",scrollbars=" + bolScrollbars + ",resizable=" + bolResizable + ",location=" + bolLocation + ",directories=" + bolDirectories + ",status=" + bolStatus
	window.open (strPage, strWindowName, strFeatures);
}

function FormatPhone(phonenum)
{
    if ((phonenum != "") && (phonenum != "###-###-####"))
    {
        if (phonenum.search(/^[0-9][0-9][0-9]\-[0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]$/) != -1)
        {
            return phonenum;
        }
        else
        {
            if ((isFinite(phonenum)) && (phonenum.length == 10))
            {
                var areacode = phonenum.substring(0, 3);
                var exchange = phonenum.substring(3, 6);
                var extension = phonenum.substring(6, 10);
                return areacode + "-" + exchange + "-" + extension;
            }
            else
            {
                return phonenum;
            }
        }
    }
    else
    {
        return phonenum;
    }
}

function isValidZipCode(sValue)
{
    if (sValue != "")
    {
        if (sValue.search(/^[0-9][0-9][0-9][0-9][0-9]$/) != -1)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return true;
    }
}

function isValidPhoneNumber(sValue)
{
    if (sValue != "")
    {
        if (sValue.search(/^[0-9][0-9][0-9]\-[0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]$/) != -1)
        {
            return true;
        } else if (sValue.search(/^\([0-9][0-9][0-9]\)[0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]$/) != -1)
        {
            return true;
        } else if (sValue.search(/^\([0-9][0-9][0-9]\)\ [0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]$/) != -1)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return true;
    }
}

function isValidEmail(email)
{
    var invalidChars = "/:,; ";
    if (email == "")
    {
        return false;
    }
    for (j = 0; j < invalidChars.length; j++)
    {
        var badChar = invalidChars.charAt(j);
        if (email.indexOf(badChar,0) != -1)
        {
            return false
        }
    }
    var atPos = email.indexOf("@", 1);
    if (atPos == -1)
    {
        return false;
    }
    if (email.indexOf("@",atPos+1) != -1)
    {
        return false;
    }
    var periodPos = email.indexOf(".",atPos)
    if (periodPos == -1)
    {
        return false;
    }
    if (periodPos+3 > email.length)
    {
        return false;
    }
    return true
}