
var g_VisibleMenu;

var d=document;
var agt=navigator.userAgent.toLowerCase();
var major = parseInt(navigator.appVersion);
var dom=(d.getElementById)?1:0;
var ns=(d.layers);
var ns4up=(this.ns && this.major >=4);
var ns6=(this.dom&&navigator.appName=="Netscape");
var op=(window.opera? 1:0);
var ie=(d.all);
var ie4=(d.all&&!this.dom)?1:0;
var ie4up=(this.ie && this.major >= 4);
var ie5=(d.all&&this.dom);
var win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
var mac=(this.agt.indexOf("mac")!=-1);

function openStars(){
	win = window.open("index.cfm?fuseaction=forums.stars","Stars","height=300,width=320");
}

function printableHelp(){
	win = window.open("index.cfm?fuseaction=order.printable","PrintableHelp","height=400,width=500,resizable=yes,scrollbars=yes");
}


function checkAll(theCheckAll, theCheckboxes){
	if (theCheckboxes){
		if (theCheckboxes.length){
			for (i=0; i<=theCheckboxes.length-1; i++){
				theCheckboxes[i].checked = theCheckAll.checked;
			}
		} else {
			theCheckboxes.checked = theCheckAll.checked;
		}
	}
}

function getY(obj){
	var y=0;
	if (ns){
		y=obj.pageY;
	} else {
		o=obj;
		while(eval(o)) { y+=o.offsetTop; o=o.offsetParent; }
	}
	
	return y;
}

function getX(obj){
	var x=0;
	if (ns){
		x=obj.pageX;
	} else {
		o=obj;
		while(eval(o)) { x+=o.offsetLeft; o=o.offsetParent; }
	}
	
	return x;
}

function Document_Click(){
	HideMenu();
}

function HideMenu(){
	
	if (g_VisibleMenu){
		g_VisibleMenu.style.visibility="hidden";
	}
}

function ShowMenu(theMenu, x, y){
	g_VisibleMenu = document.getElementById(theMenu);
	if (g_VisibleMenu){
		g_VisibleMenu.style.top=y;
		g_VisibleMenu.style.left=x;
		g_VisibleMenu.style.visibility="visible";
		
	} 
	else {
		return false;
	}
}

function hideItem(theObj){
	if (theObj.length){
		for (i=0; i<theObj.length; i++){
			theObj[i].className="hiddenItem";
		}
	} else {
		theObj.className="hiddenItem";
	}
}
function showItem(theObj){
	if (theObj.length){
		for (i=0; i<theObj.length; i++){
			theObj[i].className="visibleItem";
		}
	} else {
		theObj.className="visibleItem";
	}
}

function hideRow(theObj){
	if (theObj.length){
		for (i=0; i<theObj.length; i++){
			//theObj[i].style.top=0;
			//theObj[i].style.position="absolute";
			//theObj[i].style.visibility="hidden";
			theObj[i].className="hiddenRow";
		}
	} else {
		//theObj.style.top=0;
		//theObj.style.position="absolute";
		//theObj.style.visibility="hidden";
		//theObj.style.display="none";
		theObj.className="hiddenRow";
	}
}
function showRow(theObj){
	if (theObj.length){
		for (i=0; i<theObj.length; i++){
			//theObj[i].style.top=0;
			//theObj[i].style.position="relative";
			//theObj[i].style.visibility="visible";
			theObj[i].className="visibleRow";
		}
	} else {
		//theObj.style.top=0;
		//theObj.style.position="relative";
		//theObj.style.visibility="visible";
		//theObj.style.display="table-row";
		theObj.className="visibleRow";
	}
}

function swapImage(theImage, changeTo){
	document.getElementById(theImage).src=changeTo;
}
function openItemImageWindow(ItemID){
	var dlg = window.open("index.cfm?fuseaction=order.itemImages&item_id="+ItemID, "ItemImageWindow", "toolbar=no,menubar=no,personalbar=no,width=600,height=600,scrollbars=yes,resizable=no");
}
//document.onclick=Document_Click;

function checkItemOptions(theForm,theErrorMessage)
{
	if (theForm.Item_Type_List)
	{
		if (theForm.Item_Type_Group_List.length)
		{
			for (i=0; i<theForm.Item_Type_List.length; i++)
			{
				if (theForm.Item_Type_List[i].selectedIndex==0)
				{
					showItem(document.getElementById(theErrorMessage));
					return false;
				}
			}
		}
		else
		{
			if (theForm.Item_Type_List.selectedIndex==0)
			{
				showItem(document.getElementById(theErrorMessage));
				return false;
			}
		}
	}
	return true;
}

function openFormulaWindow() {
	var t=window.open('index.cfm?fuseaction=shippingtable.formulahelp','FormulaHelp','width=400,height=350');
}

function openItemNotifyWindow(item_id){
	var t=window.open('index.cfm?fuseaction=order.notify&item_id='+item_id,'ItemNotify','width=450,height=250');
}

function openWindow(url,windowName,options){
	var t=window.open(url,windowName,options);
}

function validUploadType(theField, UploadList)
{
	fileName = theField.value;
	
	if (fileName != "")
	{
		extension = fileName.substr(fileName.lastIndexOf(".") +1).toLowerCase();
		
		for (i=0; i < UploadList.length; i++ )
		{
			if (extension == UploadList[i])
			{
				return true;
			}
		}
		
		alert('The file you are uploading must be of the following types: ' + UploadList);
		return false;
	}
	return true;
}


