//------------------------------------------------------------------------------
//This function handles the mouseover "effect" of the main links

function hdlMouseOver(strID, strAction)
{
	if (strAction == 'in')
	{
		document.all[strID].style.backgroundColor = '#E4490C';
		
		/* 
		<td width="55"></td>
		<td width="75"></td>
		<td width="75">ff</td>
		<td width="120"></td>
		<td width="65"></td>
		<td width="90"></td>
		<td width="52"></td>
		<td width="100%"></td>
		*/
		
	}
	else if (strAction == 'out')
	{
		document.all[strID].style.backgroundColor = '#ffffff';
	}
	
}
		
		
//------------------------------------------------------------------------------
// This function opens a new quote window
function openNewChallenge(strQuoteNo)
{
	popUp = window.open('/AGP/opStep-1.asp?QuoteNo=' + strQuoteNo + '','newChallenge','width=750,height=600,menubar,scrolling=auto');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new quote window
function openNewQuote(strQuoteNo)
{
	popUp = window.open('/AGP/quoteStep-1.asp?QuoteNo=' + strQuoteNo + '','newQuote','width=750,height=600,menubar,scrolling=auto');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new quote window 
function openNewOrder(strOrderId) 
{ 
	popUp = window.open('/AGP/ProdOrderForm.asp?OrderId=' + strOrderId + '','newOrder','width=770,height=650,menubar,scrollbars=1'); 
	popUp.focus(); 
} 
function openNewOrder2(strOrderId) 
{ 
	popUp = window.open('/AGP/ProdOrderForm3.asp?OrderId=' + strOrderId + '','newOrder','width=770,height=650,menubar,scrollbars=1'); 
	popUp.focus(); 
} 

//------------------------------------------------------------------------------
// This function opens a new quote window
function openNewStockQuote(strSerialNo, strJDSCode)
{
	// quoteStockStep-1.asp
	popUp = window.open('/AGP/quoteStep-1.asp?serialNo=' + strSerialNo + '&JDSCode='+ strJDSCode +'','newQuote','width=750,height=600,menubar,scrolling=auto');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new message window
function openNewMessage(intMessageID)
{
	popUp = window.open('/AGP/messageNew.asp?messageID=' + intMessageID + '','message','width=750,height=600,menubar,scrolling=auto');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a quote to view
function viewQuote(strQuoteNo)
{
	popUp = window.open('/AGP/viewQuote-1.asp?QuoteNo=' + strQuoteNo + '','viewQuote','width=750,height=600,menubar,scrolling=auto,resizable=1');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a message to view
function viewMessage(strMessageID)
{
	popUp = window.open('/AGP/messageView.asp?messageCharID=' + strMessageID + '','viewMessage','width=750,height=600,menubar,scrolling=auto');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new upload window
function uploadFile(strAction,strID)
{
	popUp = window.open('/AGP/uploadFile.asp?actionID=' + strID + '&action=' + strAction,'uploadFile','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new upload window and lists existing images...
function useExistingFile(strAction,strID)
{
	popUp = window.open('/AGP/viewExistingFile.asp?actionID=' + strID + '&action=' + strAction,'uploadFile','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new customers window
function browseCustomers(strAction)
{
	popUp = window.open('/AGP/browseCustomers.asp?action=' + strAction,'browseCust','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new challenge Quotes window
function viewChallengeQuotes(strQuoteNo)
{
	popUp = window.open('/AGP/viewChallengeQuotes.asp?QuoteNo=' + strQuoteNo,'challengeQuotes','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new user window
function viewUser(intUserID)
{
	popUp = window.open('/AGP/userDetails.asp?userID=' + intUserID,'viewUser','width=516,height=470,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a manage user branches window
function manageuserbranchs(intUserID)
{
	popUp = window.open('/AGP/userBranches.asp?userID=' + intUserID,'manageBranch','width=516,height=470,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new news window
function newArticle(intNewsID)
{
	popUp = window.open('/AGP/newsDetails2.asp?newsID=' + intNewsID,'viewNews','width=516,height=470,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new news window that is rendered
function viewArticle(intNewsID)
{
	popUp = window.open('/AGP/newsViewDetails.asp?newsID=' + intNewsID,'viewNewsRendered','width=516,height=470,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new news window that is rendered
function viewNews(intNewsID)
{
	popUp = window.open('/AGP/newsView_list.asp','viewNewsRendered','width=516,height=470,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new branch window
function viewBranch(intBranchID)
{
	popUp = window.open('/AGP/branchDetails.asp?branchID=' + intBranchID,'viewBranch','width=516,height=470,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new suburbs window
function browseSuburbs(strAction)
{
	popUp = window.open('/AGP/browseSuburbs.asp?action=' + strAction,'browseSub','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new suburbs window
function openMachineConfig(strConfigID)
{
	popUp = window.open('/AGP/viewMachineConfig.asp?configID=' + strConfigID,'machineConfig','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new parts details window
function openPartsDatail(strRecID, StoreID)
{
	popUp = window.open('/AGP/viewPartsDetail.asp?ProdKey=' + strRecID + '&StoreId=' + StoreID,'partDetails','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//This function to replace current parts detail window. 091008
function openPartsDetail(strRecID, StoreID)
{
	popUp = window.open('/AGP/partdetails/viewPartsDetail.asp?ProdKey=' + strRecID + '&StoreId=' + StoreID,'partDetails','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}


function openPartsDetailNew(strRecID)
{
	popUp = window.open('/AGP/newPartsDetailNew.asp?recID=' + strRecID,'partDetailNew','width=516,height=450,menubar,scrollbars=yes');
	popUp.focus();
}

function sellPart(strRecID, strPartNo, strLocation)
{
	popUp = window.open('/AGP/sellPart.asp?recID=' + strRecID + '&part_no=' + strPartNo + '&location=' + strLocation,'sellPart','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

function orderPart(strPartNo, strState, StoreID, strList, strMake, strDesc, strPartKey)		//strRecID, strPartNo, strLocation
{
	//popUp = window.open('/AGP/orderPart.asp?recID=' + strRecID + '&part_no=' + strPartNo + '&location=' + strLocation,'orderPart','width=516,height=550,menubar,scrollbars=yes');
	//changed to unify all ordering processes to the one page 28/0/06
	strRecID = ''
	popUp = window.open('/AGP/orderPartBulk.asp?recID=' + strRecID + '&part_no=' + strPartNo + '&prodMasterUDfStore=' + strState + '&StoreID=' + StoreID + '&ProdMasterEsclList=' + strList + '&ProdMasterMake=' + strMake + '&ProdMasterDesc=' + strDesc + '&PARTS_MASTER_KEY=' +  strPartKey,'orderPart','width=775,height=600,menubar,scrollbars=yes');
	popUp.focus();
}

function orderPart2(strPartNo, strState, StoreID, strList, strMake, strDesc, strPartKey)		//strRecID, strPartNo, strLocation
{
	//popUp = window.open('/AGP/orderPart.asp?recID=' + strRecID + '&part_no=' + strPartNo + '&location=' + strLocation,'orderPart','width=516,height=550,menubar,scrollbars=yes');
	//changed to unify all ordering processes to the one page 28/0/06
	strRecID = ''
	popUp = window.open('/AGP/partOrder/orderPartBulk.asp?recID=' + strRecID + '&part_no=' + strPartNo + '&prodMasterUDfStore=' + strState + '&StoreID=' + StoreID + '&ProdMasterEsclList=' + strList + '&ProdMasterMake=' + strMake + '&ProdMasterDesc=' + strDesc + '&PARTS_MASTER_KEY=' +  strPartKey,'orderPart','width=775,height=600,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new sizable window containing the URL pass to it
function openSizableWindow(strURL,strName)
{
	popUp = window.open(strURL,strName,'menubar,scrollbars=yes,resizable=1');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new sizable window containing the URL pass to it
function openQuoteEmailer(strURL,strName)
{
	popUp = window.open(strURL,strName,'height=380,width=480,menubar,scrollbars=no,resizable=0');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new window to view/modify Option Details

function openOption(intOptionID,bModify,strQuoteNo,intCustom,intExtra)
{
	popUp = window.open('/AGP/viewOption.asp?intExtra=' + intExtra + '&custom=' + intCustom + '&QuoteNo=' + strQuoteNo + '&optionID=' + intOptionID + '&bMod=' + bModify ,'viewOption','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new window to view/modify Option Details for sales challenge

function openOptionOP(intOptionID,bModify,strQuoteNo,intCustom,intExtra)
{
	popUp = window.open('/AGP/viewOptionOP.asp?intExtra=' + intExtra + '&custom=' + intCustom + '&QuoteNo=' + strQuoteNo + '&optionID=' + intOptionID + '&bMod=' + bModify ,'viewOption','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new window to view/modify Option Details for sales challenge

function openOptionOb(intOptionID,bModify,strQuoteNo,intCustom,intExtra)
{
	popUp = window.open('/AGP/viewOptionOb.asp?intExtra=' + intExtra + '&custom=' + intCustom + '&QuoteNo=' + strQuoteNo + '&optionID=' + intOptionID + '&bMod=' + bModify ,'viewOption','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new window to view/modify TradeIn details

function openTradeIn(strTradeInID,strQuoteNo)
{
	popUp = window.open('/AGP/viewTradeIn.asp?tradeinIN=' + strTradeInID + '&QuoteNo=' + strQuoteNo,'viewTrade','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new window to view/modify TradeIn details
function openTradeInMod(strTradeInID,strQuoteNo)
{
	popUp = window.open('/AGP/viewTradeIn.asp?tradeinID=' + strTradeInID + '&QuoteNo=' + strQuoteNo,'viewTrade','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new window to view aea tradein owners already used

function browseOwners(strExisting)
{
	popUp = window.open('/AGP/viewOwners.asp?action=' + strExisting,'viewOwners','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new window to view a customers details based on COMPANYID

function viewCustDetails(strCustID)
{
	popUp = window.open('/AGP/custDetails.asp?CompanyID=' + strCustID,'viewCustDetails','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new window to view the details of a customer contact

function viewContactDetails(strContactID)
{
	popUp = window.open('/AGP/contactDetails.asp?contactID=' + strContactID,'viewContactDetails','width=516,height=400,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens Stock window
function openStocklist(stockfilter)
{
	popUp = window.open('/AGP/dealers/stocklist2.asp?filter=' + stockfilter + '','Stocklist','width=800,height=600,menubar,scrollbars=yes');
	popUp.focus();
}

//------------------------------------------------------------------------------
// This function opens a new window for Reynolds Part Order insertion 
function openReynoldsOrder(storeID, orderID) 
{ 
	popUp = window.open('/AGP/reynolds/default.aspx?storeid=' + storeID + '&orderid=' + orderID,'Reynolds','width=800,height=600,menubar,scrollbars=yes'); 
	popUp.focus(); 
} 


//This function queries a webpage that produces an XML response...
function getXMLResponse(url)
{
		
	var xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	var strURL = url + "&rnd=" + Math.round(100*Math.random());	
	var strHttpMethod = "POST";
	
	xmlHTTP.Open(strHttpMethod, strURL, false);
	xmlHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHTTP.Send();

	var strReply = xmlHTTP.ResponseText;
	//alert(xmlHTTP.ResponseText);
	
	if (xmlHTTP.status != 200)
	{
		//failure		
		strReply = "";
	}
	return strReply;	

}

//------------------------------------------------------------------------------
// This function takes a CompanyID and returns the company and all its contact details into a hidden div box on the page calling it
function getFullCompanyDetails(strCompanyID)
{
	
	var strRequest = "<RequestCompanyDetails CompanyID='";
	strRequest += strCompanyID;
	strRequest += "'></RequestCompanyDetails>";
	
	var xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	var strURL = "/AGP/webUtils/xml_getContactDetails.asp?rnd=" + Math.round(100*Math.random());	
	var strHttpMethod = "POST";
	
	xmlHTTP.Open(strHttpMethod, strURL, false);
	xmlHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHTTP.Send(strRequest);

	var strReply = xmlHTTP.ResponseText;
	//alert(xmlHTTP.ResponseText);
	
	if (xmlHTTP.status != 200)
	{
		//failure
		strReply = "";
	}
	return strReply;
	
	/*
	var xmlhttp = false;  
  	xmlhttp = new ActiveXObject("msxml2.XMLHTTP");  
	
	xmlhttp.open("GET",'/AGP/webUtils/xml_getContactDetails.asp?rnd=' + Math.round(100*Math.random()) + '&companyID=' + strCompanyID,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readystate == 4)
		{
			document.all.test.innerHTML = xmlhttp.responseText;			
		}
	}
	
	xmlhttp.send(null);
  	*/

}

//------------------------------------------------------------------------------
// This function takes a EmplyeeID and returns the contact details into a hidden div box on the page calling it
function getFullDealerDetails(strCompanyID)
{
	//alert("extrapulating details now")
	var strRequest = "<RequestCompanyDetails CompanyID='";
	strRequest += strCompanyID;
	strRequest += "'></RequestCompanyDetails>";
	
	var xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	//var strURL = "/AGP/webUtils/xml_getContactDetails.asp?rnd=" + Math.round(100*Math.random());	//
	var strURL = "/AGP/webUtils/xml_getDealerDetails.asp?rnd=" + Math.round(100*Math.random());
	var strHttpMethod = "POST";
	
	xmlHTTP.Open(strHttpMethod, strURL, false);
	xmlHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHTTP.Send(strRequest);

	var strReply = xmlHTTP.ResponseText;
	//alert(xmlHTTP.ResponseText);
	
	if (xmlHTTP.status != 200)
	{
		//failure
		strReply = "";
	}
	//alert("details extrapulated - " + strReply)
	
	return strReply;
	
	/*
	var xmlhttp = false;  
  	xmlhttp = new ActiveXObject("msxml2.XMLHTTP");  
	
	xmlhttp.open("GET",'/AGP/webUtils/xml_getContactDetails.asp?rnd=' + Math.round(100*Math.random()) + '&companyID=' + strCompanyID,true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readystate == 4)
		{
			document.all.test.innerHTML = xmlhttp.responseText;			
		}
	}
	
	xmlhttp.send(null);
  	*/

}

//------------------------------------------------------------------------------
// This function grabs a place name and tries to find the weather forecase for it. It calls an asp page which in turn uses the yahoo weather service:
//http://xml.weather.yahoo.com/forecastrss?p=USCA1116 for its data

function getWeather(strPlace,bShowForecast)
{
	var xmlhttp = false;
	var pageResponse;
	var placeCode;
	
	//first make sure that we have entered a place...
	if (strPlace == '')
	{
		alert('Please enter a location');
	}
	else
	{
	
		xmlhttp = new ActiveXObject("msxml2.XMLHTTP");
			
			//alert(checkPath + ':' + document.all.myForm.file_path.value);
		//first, we need to get the code for the place we are searching for...
		
		xmlhttp.open("POST","/AGP/webUtils/getPlaceCode.asp?strPlace=" + strPlace + "&showForecast=" + bShowForecast + "&rnd=" + Math.round(100*Math.random()),true);
		xmlhttp.onreadystatechange=function()
		{
		
			if (xmlhttp.readystate == 4)
			{
				placeCode = xmlhttp.responseText;
				
				if (placeCode == 'NOT FOUND')
				{
					alert('Location not found!');
				}
				else
				{
					//because it is a valid place, save this in a cookie for use next time:
					document.cookie = "AEA-weatherLocation=" + strPlace + ";expires=2015-12-31";
					//now query the yahoo service to get the weather for this place code..
					//alert('getWeatherDetails'+ placeCode +','+ bShowForecast)
					getWeatherDetails(placeCode,bShowForecast);
					
				}
				
			}
			
		}
		
		xmlhttp.send(null);	
		
	}	
	
}

function getWeatherDetails(strCode, bShowForecast)
{
	var xmlhttp = false;
	var pageResponse;
	var placeCode;
	var i;
	
	xmlhttp = new ActiveXObject("msxml2.XMLHTTP");
	
	//alert(checkPath + ':' + document.all.myForm.file_path.value);
	//first, we need to get the code for the place we are searching for...
	//http://xml.weather.yahoo.com/forecastrss?p=USCA1116 	
	
	xmlhttp.open("POST","/AGP/webUtils/getWeatherDetails.asp?strCode=" + strCode + "&showForecast=" + bShowForecast + "&rnd=" + Math.round(100*Math.random()),true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readystate == 4)
		{
			pageResponse = xmlhttp.responseText;
			
			if (pageResponse == 'NOT FOUND')
			{
				alert('Place not found!');
			}
			else
			{
				//now try and load the resopnse in a xml object...
				var objXmlDom = new ActiveXObject("Microsoft.XMLDOM");
				var currentDay;
				
				if (!objXmlDom.loadXML(pageResponse))
				{
				    var sErr = "Error in Response XML String\n" + pageResponse;
					alert(sErr);
				}
				else
				{
					//get the current temp...
					var objRoot = objXmlDom.selectSingleNode("/rss/channel/item/yweather:condition")		
					document.all.dayCurrent.innerHTML = objRoot.getAttribute("temp");
					
					//get the low and high for today...													
					objRoot = objXmlDom.selectNodes("/rss/channel/item/yweather:forecast")							
					document.all.dayLow.innerHTML = objRoot[0].getAttribute("low");
					document.all.dayHigh.innerHTML = objRoot[0].getAttribute("high");
					
					//now get the forecast for the next two days...
					document.all.day2Name.innerHTML = objRoot[1].getAttribute("day");
					document.all.day2Status.innerHTML = objRoot[1].getAttribute("text");
					document.all.day2Low.innerHTML = objRoot[1].getAttribute("low");
					document.all.day2High.innerHTML = objRoot[1].getAttribute("high");
					
					//alert(objRoot[2].getAttribute("day");)
					//document.all.day3Name.innerHTML = objRoot[2].getAttribute("day");
					//document.all.day3Status.innerHTML = objRoot[2].getAttribute("text");
					//document.all.day3Low.innerHTML = objRoot[2].getAttribute("low");
					//document.all.day3High.innerHTML = objRoot[2].getAttribute("high");
					
					document.all.day3Name.innerHTML = 'na';
					document.all.day3Status.innerHTML = 'na';
					document.all.day3Low.innerHTML = 'na';
					document.all.day3High.innerHTML = 'na';
					
					objRoot = objXmlDom.selectSingleNode("/rss/channel/item/title")		
					document.all.strConditions.innerHTML = objRoot.text;
					
					//we need to find the image node so load it up in another XMLDOM object
					objRoot = objXmlDom.selectSingleNode("/rss/channel/item/description")		
					
					var objXmlDom2 = new ActiveXObject("Microsoft.XMLDOM");
					if (!objXmlDom2.loadXML("<xml>" + objRoot.text + "</xml>"))
					{
					    var sErr = "Error in Response XML String\n" + test;
						alert(sErr);
					}
					else
					{
						//now find the first image...
						objRoot = objXmlDom2.getElementsByTagName("img")	
						
						//document.all.test.innerHTML = objRoot[0].getAttribute("src")
						document.all.weatherIcon.innerHTML = "<img src=\"" + objRoot[0].getAttribute("src") + "\" />";		
					}
				
				}
			
			}
		
		}
	
	}
	
	xmlhttp.send(null);		
}


/*
FormatNumber(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit,
             UseParensForNegativeNumbers, GroupDigits)
======================================================================
http://www.4guysfromrolla.com/webtech/code/FormatNumber.shtml
*/

function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
    if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.$,-";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}


function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

// -- SABS PARTS FUNCTIONS... ALL OTHER FUNCTIONS, PLEASE ENTER BEFORE THIS SECTION...

function viewOrderDetails_rey(intOrderID, storeID)
{
	popUp = window.open('/AGP/orderDetails_rey.asp?orderID=' + intOrderID+'&storeid=' + storeID,'viewOrderDetails','width=700,height=470,menubar,scrollbars=yes');
}

function viewOrderDetails(intOrderID, storeID)
{
	popUp = window.open('/AGP/orderDetails.asp?orderID=' + intOrderID+'&storeid=' + storeID,'viewOrderDetails','width=700,height=470,menubar,scrollbars=yes');
}

function viewSuperceededParts()
{
	popUp = window.open('/AGP/PartsSuperseded.asp','viewSupersededParts','width=600,height=550,menubar,scrollbars=yes');
}

function modifyOrder(intOrderID)
{
	popUp = window.open('/AGP/modifyOrder.asp?orderID=' + intOrderID,'modifyOrderDetails','width=516,height=470,menubar,scrollbars=yes');
	
}

function updateOrder(intOrderID,intQtyOrdered)
{
	popUp = window.open('/AGP/updateOrder.asp?qtyOrdered=' + intQtyOrdered + '&orderID=' + intOrderID,'updateOrder','width=516,height=470,menubar,scrollbars=yes');
	
}

function browseContacts(strAction)
{
	popUp = window.open('/AGP/browseContacts.asp?action=' + strAction,'browseContacts','width=516,height=400,menubar,scrollbars=yes');
}

function openBulk(intBulkOrderID)
{
	popUp = window.open('/AGP/orderPartBulk.asp?bulkOderID=' + intBulkOrderID + '','bulkOrder','width=775,height=600,menubar,scrollbars=yes');
}

function openBulk2(intBulkOrderID)
{
	popUp = window.open('/AGP/partOrder/orderPartBulk.asp?bulkOderID=' + intBulkOrderID + '','bulkOrder','width=775,height=600,menubar,scrollbars=yes');
}

function openBulk_oos(intBulkOrderID)
{
	popUp = window.open('/AGP/orderPartBulk.asp?bulkOderID=' + intBulkOrderID + '&outofstock=y','bulkOrder','width=775,height=600,menubar,scrollbars=yes');
}

function openBulk_oos2(intBulkOrderID)
{
	popUp = window.open('/AGP/partOrder/orderPartBulk.asp?bulkOderID=' + intBulkOrderID + '&outofstock=y','bulkOrder','width=775,height=600,menubar,scrollbars=yes');
}

//------------------------------------------------------------------------------
// This function opens a new suburbs window
function browseParts()
{
	popUp = window.open('/AGP/browseParts.asp','browseParts','width=516,height=400,menubar,scrollbars=yes');
}

// This function opens a parts browsing window to replace current popup function 091008
function browseParts2()
{
	popUp = window.open('/AGP/partBrowse/browseParts.asp','browseParts','width=516,height=400,menubar,scrollbars=yes');
}
