var btnCart = new Image();
var btnCartOvr = new Image();
var lastMenu;

//var imagePath = "http://www.originalfrostcollection.com/images/";
var imagePath = "images/";

btnCart.src = imagePath + "cart_btn.jpg";
btnCartOvr.src = imagePath + "cart_btn_ovr.jpg";

function writeStateDDL(defaultState)
{
	var htmlText;
    var states = new Array("AK","AL","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY");
    var x = 0;
    var selState = defaultState || "";

    htmlText = "<option selected='selected' value='--'></option>\n";

    while (x < states.length)
    {
    	if(states[x] == selState)
	    	htmlText += "<option selected='selected' value='" + states[x] + "'>" + states[x] + "</option>\n";
        else
	    	htmlText += "<option value='" + states[x] + "'>" + states[x] + "</option>\n";

    	x++;
    }

	return htmlText;
}

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

function ShowSubMenu(menuID)
{
    if(document.getElementById(lastMenu) && (lastMenu != menuID))
        HideSubMenu(lastMenu);

    if(document.getElementById(menuID))
    {
        document.getElementById(menuID).style.visibility="visible";
        lastMenu = menuID;
    }
}

function HideSubMenu(menuID)
{
    if(document.getElementById(menuID))
        document.getElementById(menuID).style.visibility="hidden";
}

		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 - 100;
		    var maxYear = year - 5;

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

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

		    htmlText += "</select>";

		    return htmlText;
		}
        function selectDDLOptionByValue(ddlName,selectValue)
{
	//Locates a DDL option by "value" and selects it
	var 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
    var 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;
}
