function hideSelects(yesno) {
	//this function hides the select boxes on the page, because they overlay the menu due to a browser bug.
	//it also shows text fields, which are used to keep the table cell from collapsing when the select is hidden.
	var selects = document.getElementsByTagName("select");
	var texts = document.getElementsByTagName("input");
	
	var x;

	if (yesno) {
		for (x = 0; x < selects.length; x++) {
			selects[x].style.display = "none";
		}
		for (x = 0; x < texts.length; x++) {
			if (texts[x].id != 'userID' && texts[x].id != 'userPass' && texts[x].type != 'submit' && texts[x].type != 'hidden') {
				texts[x].style.display = "";
			}
		}
	} else {
		for (x = 0; x < selects.length; x++) {
			selects[x].style.display = "";
		}
		for (x = 0; x < texts.length; x++) {
			if (texts[x].id != 'userID' && texts[x].id != 'userPass' && texts[x].type != 'submit' && texts[x].type != 'hidden') {
				texts[x].style.display = "none";
			}
		}
	}
}

//this function sizes the page to better match the user's screen resolution
function resizeDivs() {
	document.getElementById("header").style.left = ((screen.width - 770) / 2) + "px";
	document.getElementById("menu").style.left = ((screen.width - 770) / 2) + "px";
	document.getElementById("content").style.left = (((screen.width - 770) / 2) - 10) + "px";
	
	//if (screen.height > 768) {
		//document.getElementById("content").style.height = "800px";
		//document.getElementById("menu").style.height = "825px";
	//} else if (screen.height > 600) {
		//document.getElementById("content").style.height = "600px";
		//document.getElementById("menu").style.height = "625px";
	//} else if (screen.height <= 600) {
		//document.getElementById("content").style.height = "380px";
		//document.getElementById("menu").style.height = "405px";
	//}
}

function subItemChange(rownum) {
	try {
		document.getElementById('content').focus();
	} catch(ex) {}
	var listbox = document.getElementById('cartChoice' + rownum);
	var filename = new String(prods[rownum][listbox.selectedIndex]);
	var instruct = new String(instructions[rownum][listbox.selectedIndex]);
	var ebaylink = new String(ebaylinks[rownum][listbox.selectedIndex]);			
	
	//if there is no custom image for this sub-product, use main image for the product
	if (filename == '' || typeof(filename) == "undefined") {// || typeof(filename) == "object") { //typeof will be String normally //correction 11/14: typeof is object usually
		filename = new String(prods[rownum][0]);
	}
	
	//changed the button if this sub-product is an Ebay item
	if (ebaylink != '') {
		document.getElementById('cartbutton' + rownum).src = 'images/ebayCart.jpg';
		document.getElementById('buttonAction' + rownum).value = 'ebay';
	} else {
		document.getElementById('cartbutton' + rownum).src = 'images/addToCart.jpg';
		document.getElementById('buttonAction' + rownum).value = '';
	}
	
	//handle displaying and hiding the appropriate images/flash files
	if (filename != '') {
		if (filename.indexOf(".swf") != -1) {
			try {
				document.getElementById('object' + rownum).style.display = "";
			} catch (ex) {}
			try {
				document.getElementById('embed' + rownum).style.display = "";
				document.getElementById('embed' + rownum).src = 'productImages/' + filename;
			} catch (ex) {}
			document.getElementById('img' + rownum).style.display = "none";
			document.getElementById('movie' + rownum).value = 'productImages/' + filename;
		} else {
			try {
				document.getElementById('object' + rownum).style.display = "none";
			} catch (ex) {}
			try {
				document.getElementById('embed' + rownum).style.display = "none";
			} catch (ex) {}
			document.getElementById('img' + rownum).style.display = "";
			//alert(document.getElementById('img' + rownum).src);
			document.getElementById('img' + rownum).src = 'productImages/' + filename;
			//alert('productImages/' + filename);
		}
	}
	
	//display further instructions if needed
	if (instruct != '') {
		alert(instruct);
	}

	return true;
}

function DoButtonAction(row) {
	if (document.getElementById('buttonAction' + row).value == 'ebay') {
		var ebaylink = new String(ebaylinks[row][document.getElementById('cartChoice' + row).selectedIndex]);
		window.open(ebaylink, null, 'toolbar=no, resizable=yes,scrollbars=yes');
		return true;
	} else {
		return addToCart(row);
	}
}

function addToCart(row) {
	if (document.getElementById("cartChoice" + row)[document.getElementById("cartChoice" + row).selectedIndex].value == "----") {
		alert('Please select an item to add to your cart.');
		document.getElementById("cartChoice" + row).focus();
		return false;
	}
	document.getElementById("addedRow").value = row;
	document.getElementById("frmMain").submit();
	return false;
}

function WinOpen(url, h, w, l, t) {
	var disp;
	var poph;
	var popw;
	var content;
	var urlstr = new String(url);
	poph = + h + 30
	popw = + w
	//disp = window.open("","pop","height=" + poph + ",width=" + popw + ",left=" + l + ",top=" + t + "");
	disp = window.open("","pop","height=500,width=500,left=" + l + ",scrollbars=yes,resizable=yes,top=" + t + "");
	content = '<HTML>';
	content += '<TITLE>Product Image</TITLE>';
	content += '</HEAD>';
	content += '<BODY bgcolor="#000000" topmargin="0" leftmargin="0" rightmargin="0" onBlur="self.close()">';
	content += '<div align="center">';
	if (urlstr.indexOf('.swf') == -1) {
		content += '<img src="' + url + '">';
	} else {
		content += '<object border="0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" align="absmiddle">';
		content += '<param name="movie" value="productImages/' + url + '">';
		content += 'param name="quality" value="best">';
		content += '<param name="play" value="true"><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="productImages/' + url + '" type="application/x-shockwave-flash" quality="best" play="true">';
		content += '</object>';
	}
	content += '</div>';
	content += '<div align="center"><A HREF="#" onClick="self.close()"><strong>Close Window</strong></A></div>';
	content += '</BODY></HTML>';
	disp.document.write(content);
	disp.document.close();
}