//RegExp for e-mail address validation
re1 = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})$/;

//RegExp for web address validation
re5 = /^[Ww]{3}\.\S+\.\S+$/;

//RegExp for simple address validation - no PO Box addresses
re4 = /^.*[Pp]{1}[\. ]*[Oo]{1}[\. ]*[Bb]{1}[Oo]{1}[Xx]{1}.*$/;

//RegExp for zip codes
re2 = /^\d{5}$/;

//RegExp for names
re3 = /^[a-zA-Z].*$/;

//RegExp for phone numbers (currently not in use)
//re3 = /^\(?\d{3}([-\. /]|(\)|\) ))?\d{3}[-\. ]?\d{4}$/;


function IsNumeric(val)
{
	//Uses a Regular Expression to determine if a string represents a numeric value

	reNum = /^\d+[\.]?\d*$/;

    if (reNum.test(val))
    	return true;
    else
		return false;
}

function writeDays()
{
	htmlText = "\n<select name='selDay' id='selDay' class='stdForm'>\n";
          htmlText += "\n<option value='0'>dd</option>";

    for(x = 1; x <= 31; x++)
    {
    	if (x < 10)
        	strVal = "0" + x;
    	else
        	strVal = x;

    	htmlText += "<option value='" + x + "'>" + strVal + "</option>\n";
    }

    htmlText += "</select>";

    return htmlText;
}

function writeMonths()
{
	htmlText = "\n<select name='selMonth' id='selMonth' class='stdForm'>\n";
          htmlText += "\n<option value='0'>mm</option>";

    for(x = 1; x <= 12; x++)
    {
    	if (x < 10)
        	strVal = "0" + x;
        else
        	strVal = x;

    	htmlText += "<option value='" + x + "'>" + strVal + "</option>\n";
    }

    htmlText += "</select>";

    return htmlText;
}

function writeYears()
{
	//Determine the range of years to include in the DDL (18 - 100)
	var d = new Date();
    var year = d.getFullYear();
    var minYear = year;
    var maxYear = year + 10;

	htmlText = "\n<select name='selYear' id='selYear' class='stdForm'>\n";
          htmlText += "\n<option value='0'>yyyy</option>";

    for(x = minYear; x <= maxYear; x++)
    {
    	htmlText += "<option value='" + x + "'>" + x + "</option>\n";
    }

    htmlText += "</select>";

    return htmlText;
}

function setBkgColor(objectID,strColor)
{
 	document.getElementById(objectID).style.backgroundColor = strColor;
}

function selectDDLOptionByValue(ddlName,selectValue)
{
	//Locates a DDL option by "value" and selects it

    if(document.getElementById(ddlName))
    {
    	ddlOptions = document.getElementById(ddlName);

        for (x = 0; x < ddlOptions.length; x++)
        {
        	if(ddlOptions.options[x].value == selectValue)
            {
            	ddlOptions.options[x].selected = true;
                break;
            }
        }
    }
}

function selectDDLOptionByText(ddlName,selectText)
{
	//Locates a DDL option by its "text" string and selects it
    if(document.getElementById(ddlName))
    {
        ddlOptions = document.getElementById(ddlName);

        for (x = 0; x < ddlOptions.length; x++)
        {
        	if(ddlOptions.options[x].text == selectText)
            {
            	ddlOptions.options[x].selected = true;
                break;
            }
        }
    }
}

function writeNumberedOptions(startVal, endVal, skipVal, textBefore, textAfter)
{
	//Writes <option> tags for lists that use a range of sequential numbers as values
    /*
    	startVal	- The starting number to include in the option list
        endVal 		- The last number to include in the option list
        skipVal     - Specified the increment amount between each number
        textBefore	- The displayable text to print before the number
        textAfter	- The displayable text to display after the number
    */
	var htmlText = "\n";

    for(x = startVal; x <= endVal; x += skipVal)
    {
    	if (x < 10)
        	strVal = "0" + x;
        else
        	strVal = x;

    	htmlText += "<option value='" + strVal + "'>" + textBefore + strVal + textAfter + "</option>\n";
    }

    return htmlText;
}
