// Fanshack item lookup application
// Purpose: add the proper values to the link
// Begin

function sendLink(itemDescription,manuf,modelLinkNum)
{
	//if a form doesn't have a the modellinknum field then is only form on page
	if (modelLinkNum == undefined)
	{
		if (itemDescription.length < "1")
		{
			alert("Please make a valid selection in the drop down box, then click the view model link.");
			return false;
		}
		else
		{
			var storeAppPath = sendToItemPage(itemDescription);		
			//var storeAppPath="../../store/index.cfm?fuseaction=getItemSpecs&itemDesc=" + itemDescription + "&manuf=" + manuf;
			document.getElementById('model_link').href = storeAppPath;
			return true;
		}
	}
	else
	{
		if (itemDescription.length < "1")
		{
			alert("Please make a valid selection in the drop down box, then click the view model link.");
			return false;
		}
		else
		{
			if (itemDescription.indexOf("Included") == "0")
			{
				alert('This is an Included item, please refer to the "Features" section on this page.');
				return false;
			}
			else
			{
			var storeAppPath = sendToItemPage(itemDescription);				
			//var storeAppPath="../../store/index.cfm?fuseaction=getItemSpecs&itemDesc=" + itemDescription + "&manuf=" + manuf;
			document.getElementById(modelLinkNum).href = storeAppPath;
			return true;
			}
		}
	}
}

function sendToItemPage(itemInfo)
{
	if (itemInfo.indexOf("*") == "0")
	{
		var iLen = itemInfo.length;
		var itemNo = itemInfo.substring(1,iLen-1);
	}
	else
	{
		var itemNo = itemInfo;
	}
	var itemIndex = itemNo.indexOf(" - ");
	var itemNo = itemNo.substring(0,itemIndex);
	
	var storeAppPath="../../store/index.cfm?fuseaction=getItem&item=" + itemNo;
	return storeAppPath;	
}
