function addbookmark()
{
	bookmarkurl="http://www.digitron.com"
	bookmarktitle="DIGITRON PART SEARCH"
	if (document.all)
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function formatMoney(value) 
{
	result = "$"+Math.floor(value)+".";
	var cents = 100*(value-Math.floor(value))+0.5;
	result += Math.floor(cents/10);
	result += Math.floor(cents%10);
	return result;
}

function AddOther0(SelectBox)
{
	var OtherText;
	OtherText = prompt("Describe the OTHER option.","")
	if ((OtherText != "") && (OtherText != null))
	{
		SelectBox.options[SelectBox.options.length]=new Option(OtherText, "0");
		SelectBox.selectedIndex = SelectBox.options.length-1;
	}
	return true;
}

function AddOther(SelectBox)
{
	var OtherText;
	OtherText = prompt("Describe the OTHER option.","")
	if ((OtherText != "") && (OtherText != null))
	{
		SelectBox.options[SelectBox.options.length]=new Option(OtherText, OtherText);
		SelectBox.selectedIndex = SelectBox.options.length-1;
	}
	return true;
}

function newScrollWindow(URL, width, height)
{
	window.open(URL, "Sub", "scrollbars=yes,width=" + width + ",height=" + height + ",menubar=no,toolbar=no,titlebar=no,status=no");
}


function newWindow(URL, width, height)
{
	window.open(URL, "Sub", "scrollbars=no,width=" + width + ",height=" + height + ",menubar=no,toolbar=no,titlebar=no,status=no");
	return true;
}

function newScrollWindow(URL, width, height)
{
	
	var d;
	d = new Date();
	window.open(URL, "Sub" + d.getSeconds(), "scrollbars=yes,width=" + width + ",height=" + height + ",menubar=no,toolbar=no,titlebar=no,status=no");
	return true;
}

function toggle_display(img, block)
{
	var imgSrc = String(img.src);
	if (imgSrc.indexOf("/media/icons/plus.gif") != -1)
	{
		block.style.display = "block";
		img.src = "/media/icons/minus.gif";
	}
	else
	{
		block.style.display = "none";
		img.src = "/media/icons/plus.gif";
	}
}
function addPartCookie(PartID, bState)
{
	var sParts				= "";
	
	sParts					= getCookie("RFQ_Parts");

	if (sParts == null)		sParts = "";
	
	if (bState)
	{
		sParts				= sParts + "," + PartID + ",";
	}
	else
	{
		sParts				= sParts.replace("," + PartID + ",", "");	
	}
	
	if (sParts == ",")		sParts = "";
	
	//Count Parts
	var aryParts;
	var rfq_count			= 0;
	
	aryParts				= sParts.split(",,");

	//document.all.rfqcart_count.innerHTML = aryParts.length;
	
	setCookie("RFQ_Parts", sParts);

	//alert(sParts + ":" + bState);
}
function checkParts()
{
	var i;
	var sParts				= "";
	
	sParts					= getCookie("RFQ_Parts");
	
	if (sParts == null)		sParts = "";

	for (i = 0; i < document.all.tags("input").length; i++)
	{
		obj = document.all.tags("input")[i];
		if (obj.type == "checkbox" && obj.name == "partnums")
		{
			if (sParts.indexOf("," + obj.value + ",") != -1)
			{
				obj.checked	= true;
			}
		}
	}
}
var curMenu = null;
var mouseX;
var mouseY;

if (!document.all) 
{
    window.captureEvents(Event.MOUSEMOVE);
    window.onmousemove=mouse_move;
}

function MouseOverChangeClass(elem,strColor) 
{
	if (elem.className != strColor + "_click") 
	{
		elem.className = strColor + "_over";
	}

}

function MouseOutChangeClass(elem, strColor) 
{

	if (elem.className != strColor + "_click") 
	{
		elem.className = strColor + "_off";
	}
}

function drop_menu(oMenu)
{
	var IE = document.all?true:false
	
	if (curMenu != null)
		curMenu.style.display = "none";
		
	oMenu.style.display = "block";
	curMenu = oMenu;
}

function mouse_move(e)
{
	mouseX = e.pageX;
	mouseY = e.pageY;
}

function change_class(oElm, tClass, fClass)
{

	var iX = 0;
	var iY = 0;
	var ibX1, ibX2, ibY1, ibY2;
	var IE = document.all?true:false
	
	if (IE) 
	{
		iX = event.clientX + document.body.scrollLeft
		iY = event.clientY + document.body.scrollTop
	}
	else 
	{
		iX = mouseX;
		iY = mouseY;
	}  
	
	if (oElm != null)
	{
		ibX1 = parseInt(oElm.style.left);
		ibX2 = ibX1 + parseInt(oElm.style.width);
		ibY1 = parseInt(oElm.style.top);
		ibY2 = ibY1 + parseInt(oElm.style.height);
		
		if (((iX < ibX1 + 3 || iX > ibX2 - 3) || (iY < ibY1 + 3  || iY > ibY2 - 5)) || (isNaN(ibX1) || isNaN(ibY1)))
		{
			//window.status = iX + ":" + iY + "-" + ibX1 + "," + ibY1 + ":" + ibX2 + "," + ibY2;
			oElm.className = tClass;
		}
		else
		{
			oElm.className = fClass;
		}
	}
}

function hide_menu(oMenu)
{	

	var iX = 0;
	var iY = 0;
	var ibX1, ibX2, ibY1, ibY2;
	var IE = document.all?true:false
	
	if (IE) 
	{
		iX = event.clientX + document.body.scrollLeft
		iY = event.clientY + document.body.scrollTop
	}
	else 
	{
		iX = mouseX;
		iY = mouseY;
	}  
	
	if (oMenu != null)
	{
		ibX1 = parseInt(oMenu.style.left);
		ibX2 = ibX1 + parseInt(oMenu.style.width);
		ibY1 = parseInt(oMenu.style.top);
		ibY2 = ibY1 + parseInt(oMenu.style.height);

		//alert(iX + ":" + iY);
		//alert(ibX1 + "," + ibY1 + ":" + ibX2 + "," + ibY2);
		window.status = iX + ":" + iY + "-" + ibX1 + "," + ibY1 + ":" + ibX2 + "," + ibY2;
		if ((iX < ibX1 + 3 || iX > ibX2 - 3) || (iY < ibY1 - 5  || iY > ibY2 - 3))
		{
			oMenu.style.display = "none";
		}
	}	
}

function hide_cur_menu()
{
	if (curMenu != null)
		curMenu.style.display = "none";
}


function setCookie(name, value) 
{
  var curCookie = name + "=" + escape(value) + "; path=/";
  document.cookie = curCookie;
}

function getCookie(name) 
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	
	if (begin == -1) 
	{
		begin = dc.indexOf(prefix);
	
		if (begin != 0) return null;
	} 
	else
		begin += 2;
		
	var end = document.cookie.indexOf(";", begin);
	
	if (end == -1)
		end = dc.length;
		
	return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name) 
{
	if (getCookie(name)) 
	{
		document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
