// JavaScript Document
// Flyout menu stuff

function showSubMenu(id)
{
	getObjectStyle(id).display = 'block';
}
function hideSubMenu(id)
{
	var obj = getObjectStyle(id);	
	obj.display = 'none';
}
function setHotItem(obj)
{	
	var zindex = obj.style.zIndex;
	obj.style.zIndex = 10000;	
	obj.style.color = "#ff0033";
	obj.style.backgroundColor = "#ccffff";
	return zindex;
}
function resetItem(obj, zindex)
{		
	obj.style.zIndex = zindex;
	obj.style.color = "#333333";
	obj.style.backgroundColor = "#ffffff";
}
function checkCart(url)
{			
	if(isCartEmpty())
	{
		alert("Your shopping basket is empty");
		return;
	}
			
	self.location = url;
}
function buyThis(pID, manufacturer, serialNo, name, price)
{
	addToCart(pID);
	
	var msg = manufacturer + " " + name;
	msg += "\n\nPart number " + serialNo + " - " + String.fromCharCode(163) + price + "\n\n";
	msg += "This item has been added to youy shopping basket";
	msg += "\n============================================";
	msg += "\nClick the \"View Basket\" button to check your order and make any changes.";
	
	alert(msg);
}
function cleanUp(str)
{
	str = str.replace("<","");
	str = str.replace(">","");
		
	document.forms[0]['search'].value = str;
	document.forms[0]['search'].focus();
}
function doSearch()
{
	var str = document.forms[0]['search'].value;

	if(str.indexOf("<") != -1)
	{
		alert("Illegal character (<)");
		cleanUp(str);
		return;
	}
		
	if(str.indexOf(">") != -1)
	{		
		alert("Illegal character (>)");
		cleanUp(str);
		return;
	}

	else if(str.length)
		relocate(str);
}
function relocate(str)
{
	var fields = new Array("Name", "Description", "SerialNo", "Keywords", "CatLabel", "CatDescription", "SubCatLabel", "SubCatDescription");
//	var fields = new Array("Description");
	var query = "(";
	var words = str.split(",");
	for(var i = 0; i < words.length; i++)
	{
		for(var j = 0; j < fields.length; j++)
		{
			if( i > 0 || j > 0)
				query += "OR " + fields[j] + " LIKE ^%25";
			
			else 
				query += fields[j] + " LIKE ^%25";
			
			query += words[i] + "%25^ ";
		}
	}
	
	query += ")";
			
	self.location = "Search.aspx?" + query;
}
function doEnlarge(pID)
{
	doLink("Detail.htm?pID=" + pID);
}
