var prodid;

function toggleproduct(href, id) {
	if (document.getElementById) {
		var container = document.getElementById("prodcont" + id);
		if (container != null) {
			if (container.innerHTML.length == 0)
				return showproduct(href, id);
			else
				return hideproduct(href, id);
		}
	}
	return true;
}
function showproduct(href, id) {
	if (document.getElementById) {
		var container = document.getElementById("prodcont" + id);
		if (container != null) {
			prodid = id;
			var ret = http_request("ajax/prodaction_ajax.aspx?pid=" + id, prodchange_complete);
			if (!ret)
				href.childNodes[0].src = "gfx/ArrowOpen.gif";
			return ret;
		}
	}
	return true;
}
function hideproduct(href, id) {
	if (document.getElementById) {
		var container = document.getElementById("prodcont" + id);
		if (container != null) {
			container.style.display = "none";
			container.innerHTML = "";

			href.childNodes[0].src = "gfx/ArrowClosed.gif";
			return false;
		}
	}
	return true;
}
function prodchange_complete(http) {
	var container = document.getElementById("prodcont" + prodid);
	if (container != null) {
		var content = http.responseText;
		
		container.style.display = "block";
		container.innerHTML = content;
	}
}

function generateproductsheet(href, id) {
	var ret = http_request("ajax/productsheetaction_ajax.aspx?pid=" + id, generateproductsheet_complete);
	
	return ret;
}

function generateproductsheet_complete(http) {
	var strUrl = http.responseText;
	
	if(strUrl != "")
	{
		window.open(strUrl,"file","toolbar=no,width=790,height=521,scrollbars=yes,resizable=yes");
	}
}

top.hideAddToPopup = false;
top.currentPopupMenuAddTo = null;
top.currentTimeout = null;

function AddToMouseOver()
{
	top.hideAddToPopup = false;
}

function AddToMouseOut()
{
	top.hideAddToPopup = true;
	
	top.currentTimeout = setTimeout("if(top.hideAddToPopup) top.currentPopupMenuAddTo.style.display = 'none';", 4000)
}

function AddToClicked(e, imgAddTo, divPopupMenuAddTo)
{
	if (!e) 
		var e = window.event;
	
	top.hideAddToPopup = false;
	
	if(top.currentTimeout)
		top.currentTimeout = null;
		
	if(top.currentPopupMenuAddTo)
		top.currentPopupMenuAddTo.style.display = 'none';
	
	top.currentPopupMenuAddTo = divPopupMenuAddTo;
	
	divPopupMenuAddTo.style.left = 550;
	divPopupMenuAddTo.style.top = -30;
	
	divPopupMenuAddTo.style.display = '';
	
	AddToMouseOut();		
}