var site = "http://www.heavenlywood.com/"; // used to direct pages to the approriate site
var rand1 = 0;
var rand2 = 0;
var rand3 = 0;

function checkExtOps(frmname)
{
	var confirmval = "";
	var tcnt = 0;
	
	if (frmname.custom3 != null && frmname.custom3.value == "")
	{
		confirmval = "wood stain color";
		tcnt = 1;
	}
	
	if (frmname.custom4 != null && frmname.custom4.value == "")
	{
		if (confirmval != "")
		{
			confirmval += " or upholstery fabric";	
		} else {
			confirmval = "upholstery fabric";
			tcnt = 2;	
		}
	
	}
	
	if (tcnt > 0)
	{
		var blah = "";
		if (tcnt == 1)
		{
			blah = "a ";
		} else {
			blah = "an ";
		}
		
		return confirm("You have not selected " + blah + confirmval + " for your item.\nSelecting these colors now will expedite the order process.\n\nClick 'OK' to add the item to your shopping cart as is.\nClick 'Cancel' if you want to select " + blah + confirmval + " now.");  	
	}
	//go through each element to see if any are dropdowns, check to see if something is selected.
	for(i=0; i < frmname.length; i++)
	{		
		if(frmname.elements[i].type == 'select-one' || frmname.elements[i].type == 'select-multiple')
		{
			if(frmname.elements[i].selectedIndex==0)
			{
				alert("Please select an option.");
				frmname.elements[i].focus();
				return false;
			}
		}
	}	
	return true;
}

function sstat(d)
{
	window.status = d;
	return true;	
}

function clstat()
{
	window.status = '';	
}

function createrandom(listlength) {

	rand1 = Math.round(Math.random() * (listlength -1));
	do {
		rand2 = Math.round(Math.random() * (listlength -1));
	} while (rand2 == rand1);
	do {
		rand3 = Math.round(Math.random() * (listlength -1));
	} while (rand3 == rand1 || rand3 == rand2);
}

function addspecials() {
	images = ["specials1.gif", "specials2.gif", "specials3.gif", "specials4.gif", "specials5.gif", "specials6.gif", "specials7.gif", "specials8.gif", "specials9.gif", "specials10.gif", "specials11.gif", "specials12.gif", "specials13.gif", "specials14.gif", "specials15.gif", "specials16.gif", "specials17.gif", "specials18.gif", "specials19.gif", "specials20.gif", "specials21.gif", "specials22.gif", "specials23.gif", "specials24.gif", "specials25.gif", "specials26.gif", "specials27.gif", "specials28.gif", "specials29.gif" , "specials30.gif", "specials31.gif", "specials32.gif", "specials33.gif"];
	links =  ["466-communion-table.htm", "as319-altar-set.htm", "1072-altar.htm", "pss243-speaker-stand.htm", "1180-brass-lamp.htm", "320-lectern.htm", "327-adjustable-ambro.htm", "510-adjustable-lectern.htm", "368-pulpit.htm", "93c-chair.htm",   "373-portable-pew.htm", "540-arm-chair.htm", "341-credence-table.htm", "346-credence-table.htm", "418-offeratory-table.htm", "57-prie-dieu.htm", "262-wedding-prie-dieu.htm", "65-side-chair.htm", "573-side-chair.htm", "684s-side-chair.htm", "875-registration-stand.htm", "176-confessional-screen.htm", "401-offering-box.htm", "237b-hymn-board.htm", "239-hymn-board.htm", "dbcb20.htm", "wilwml8.htm", "wilwma9.htm", "wilwml10f.htm", "gould34281.htm", "gould10112.htm", "gould34184.htm", "gould3620x.htm"];
	createrandom(images.length);
	document.write("<table width=\"100%\"><tr align=\"center\"><td width=\"33%\">");

	PrintSpecialImageAndLink(links[rand1], images[rand1]);
	document.write("</td>");
	document.write("<td width=\"33%\">");
	PrintSpecialImageAndLink(links[rand2], images[rand2]);
	document.write("</td>");
	document.write("<td width=\"33%\">");
	PrintSpecialImageAndLink(links[rand3], images[rand3]);
	document.write("</td></tr></table>");
}

//Prints the special link information and image
function PrintSpecialImageAndLink(strlink, strimage)
{
	document.write("<a href=\""+site+strlink+"\" onMouseOver=\"window.status='"+site+strlink+"';return true;\" onMouseOut=\"scls();\"><img src=\"images/"+strimage+"\" width=\"100\" height=\"100\" border=\"1\" alt=\"Veiw This Featured Product\"></a>");
}

// this function is used for the holiday popup from the home page.
function PopUp()
{
	if(document.cookie==null || document.cookie=="")
		{
		var myDate = new Date();
		// Y2K Fix
		if (myDate.getYear() <= 1000) var myYear= myDate.getYear() + 1900;
		else  myYear= myDate.getYear(); 
		var myMonth = myDate.getMonth() +1; // this line gets the Month variable to correspond with the 		calendar month.
		var dayOfMonth = myDate.getDate();  // this line gets the current date (day of the month).
		var holiday = (myMonth + "/" + dayOfMonth + "/" + myYear);
		//document.write(holiday);
		var dateArray = new Array();
		dateArray["11/20/2006"] = "thanksgiving";
		dateArray["11/21/2006"] = "thanksgiving";
		dateArray["11/22/2006"] = "thanksgiving";
		dateArray["11/23/2006"] = "thanksgiving";
	
		dateArray["12/21/2006"] = "christmas";
		dateArray["12/22/2006"] = "christmas";
		dateArray["12/23/2006"] = "christmas";
		dateArray["12/24/2006"] = "christmas";
		dateArray["12/25/2005"] = "christmas";

		dateArray["12/28/2006"] = "newyear";
		dateArray["12/29/2006"] = "newyear";
		dateArray["12/30/2006"] = "newyear";
		dateArray["12/31/2006"] = "newyear";
		dateArray["1/1/2007"] = "newyear";

		dateArray["5/24/2007"] = "memorial";
		dateArray["5/25/2007"] = "memorial";
		dateArray["5/26/2007"] = "memorial";
		dateArray["5/27/2007"] = "memorial";
		dateArray["5/28/2007"] = "memorial";

		dateArray["7/1/2007"] = "independence";
		dateArray["7/2/2007"] = "independence";
		dateArray["7/3/2007"] = "independence";
		dateArray["7/4/2007"] = "independence";

		dateArray["8/30/2007"] = "labor";
		dateArray["8/31/2007"] = "labor";
		dateArray["9/1/2007"] = "labor";
		dateArray["9/2/2007"] = "labor";
		dateArray["9/3/2007"] = "labor";

		if (dateArray[holiday])
			{
			window.open('holidays.htm', dateArray[holiday], 'scrollbars=no,toolbar=no,width=435,height=400');
			}
		}
	document.cookie="Visited=Yes;";
}

function showPromoInfo()
{
	if (document.getElementById('promo_link').style.height == '170px')
	{
		clearTimeout(timeoutid);	
		document.getElementById('promo_link').style.height = '22px';
	} else {

		document.getElementById('promo_link').style.height = '170px';
		timeoutid = setTimeout("document.getElementById('promo_link').style.height = '22px'", 4500);
	}
}