if (Browser.Name!="IE" || Browser.Version < 5.5) 
{
	
	document.close;
}
delete Browser;
window.status="          LOADING, PLEASE WAIT...";


//************************************************
//**********  Non-event driven functions **********
//************************************************

	
function AddToCart(basketID,itemID,description,quantity,retailPrice,dimensionA,dimensionB)
{
	var confirmAnswer;var message;var totalPrice;var ReturnedMessage;var PostXML="";
	var PostURL="http://" + document.domain + "/parts/PostToCart.asp?cn=" + Customer.Name + "&pw=" + Customer.Password + "&sid=" + SiteID + "&BasketID=" + BasketID;
	try
	{
		if (basketID==0 || basketID.length==0) return false;
		if (quantity.length==0 || isNaN(parseInt(quantity)) || parseInt(quantity)==0)
		{
			alert("You must specify a numeric Quantity greater than zero!\n\nTry again.");
			with (frmMain)
			{
				txtQuantity.focus();
				txtQuantity.select();
			}
			return false;
		}
		else if(!CheckNLAZeroPrice(description,retailPrice))
		    return false;
		else quantity=parseInt(quantity);
		if (retailPrice.indexOf("$")!=-1) retailPrice=parseFloat(retailPrice.substr(retailPrice.indexOf("$")+1));
		if (isNaN(retailPrice)) retailPrice=0;
		totalPrice=quantity * retailPrice;
		message="Item ID: " + itemID + "\nQuantity: " + quantity + "\nDescription: " + description + "\nDimension A: " + dimensionA + "\nDimension B: " + dimensionB + "\n\nPrice per Item: " + FormatCur(retailPrice) + "\nTotal Line Item Price: " + FormatCur(totalPrice);
		confirmAnswer=confirm("You have chosen to place the following line item into your cart...\n\n" + message + "\n\nClick OK if you are sure you want to do this, otherwise click Cancel.");
		if (confirmAnswer)
		{
			PostXML+="<Root>";
			PostXML+="<ItemID>" + itemID + "</ItemID>";
			PostXML+="<Quantity>" + quantity + "</Quantity>";
			PostXML+="<Price>" + retailPrice + "</Price>";
			PostXML+="<Description>" + description + "</Description>";
			PostXML+="<DimensionA>" + dimensionA + "</DimensionA>";
			PostXML+="<DimensionB>" + dimensionB + "</DimensionB>";
			PostXML+="<CartPostURL>" + CartPostURL + "</CartPostURL>";
			PostXML+="</Root>";
			//alert(PostXML);
			ReturnedMessage=PostForm(PostXML,PostURL,"GET");
			ReturnedMessage=ReturnedMessage.xml;
			var start=ReturnedMessage.indexOf("<message>");
			var end=ReturnedMessage.lastIndexOf("</message>");
			ReturnedMessage=ReturnedMessage.substring(start+9,end);
			if(ReturnedMessage.length > 0)
				alert(ReturnedMessage);
			else
				alert("Item successfully added to cart!");
		}
	}
	catch(e)
	{
		alert('An Error occurred: ' + e.message + '\nLocation: AddToCart');
	}	
	return true;	
}
function CheckNLAZeroPrice(description,retailPrice)
{
    try
    {
//return true;
        var returnVal=true;
        var temp=description.toUpperCase();
/*
        var v1; var v2; var v3; var v4;
        v1=temp.indexOf("NLA");
        v2=temp.indexOf('OBS');
        v3=parseFloat(retailPrice);
        v4=isNaN(parseFloat(retailPrice));
        alert(retailPrice);
        alert(v1);alert(v2);
        alert(v3);alert(v4);
  */      
        if(temp.indexOf('NLA')!=-1 || temp.indexOf('OBS')!=-1 || parseFloat(retailPrice)==0)// || isNaN(parseFloat(retailPrice)))
        {
            alert('STOP!\n\nThis item is not available.\nPlease refer to the item\’s description\nfor replacement information.\nIf you wish to order the replacement item\nplease enter the new item number in the box\nnext to \“try it here:\”');
            returnVal=false;
        }
        return returnVal;
        
    }
    catch(e)
	{
		alert('An Error occurred: ' + e.message + '\nLocation: AddToCart');
	}
}
Category.PicDiv=divCategoryPic;
Category.Select=frmMain.cboCategory;
PartType.PicDiv=divPartTypePic;
PartType.Select=frmMain.cboPartType;
Brand.Select=frmMain.cboBrand;
Model.PicDiv=divModelPic;
Model.Select=frmMain.cboModel;
UI.PartNumber=frmMain.txtPartNumber;
function Config(){}
Config.SiteID;
Config.SiteTitle=null;
Config.CartEnabled=false;
Config.GraphicPathPrefix="http://www.OptimusParts.com/Graphics/Catalog/";
Config.RelatedItemsPathPrefix=Config.GraphicPathPrefix + "PDF/";
Config.RelatedItemsGraphic="http://www.optimusFAP.com/parts/images/btnModelpartsdrawing.gif";
Config.SortType="itemid";
Config.SortDirection="asc";
function InitBody() 
{
	try
	{	
//		if (Alert.length>0)
//			alert(Alert);
		Category.Fill();
		window.status="Page Load complete, please proceed.";
		window.defaultStatus=SiteTitle;
		Category.Select.focus();
	}
	catch(e)
	{
		alert('An Error occurred: ' + e.message + '\nLocation: InitBody');
	}
	return true;
}
