// OCX Communicator - V 1.0
// Read Estimate Files
// Copyright(c) 2006 Infomedia Ltd. All rights reserved.

var m_path;
var from_Date;
var to_Date;
var manufacturers;
var APB_Integration_Object;

  	document.write ('<object id="APB_Estimates_Reader" width="0" height="0" classid="CLSID:6158155F-A946-4971-894B-BD0779BDAD49" codebase="http://www.autopartsbridge.com/APB_Estimate_Integration.cab#Version=1,2,5,0">'); 
	document.write ('<param name ="_Version" value = "65536">');
	document.write ('<param name ="_ExtentX" value = "2646">');
	document.write ('<param name ="_ExtentY" value = "1323">');
	document.write ('<param name ="_StockProps" value = "0"></object>');
	APB_Integration_Object = document.APB_Estimates_Reader;

	
/*function requestEstimates(path,fromDate,toDate){
	m_path = path;
	from_Date = fromDate;
	to_Date = toDate;
	try{	
		var partsListsXML = GetHeaders(path,from_Date,to_Date);
		return partsListsXML;
	}catch(e){
		alert(e.description +"\n stack:main.htm.OCX_COMS.requestEstimates");
	}
}*/

function filterEstimates(path,fromDate,toDate, manufacturers){
	m_path = path;
	from_Date = fromDate;
	to_Date = toDate;
	m_manufacturers = manufacturers;
	try{	
		var partsListsXML = GetHeaders(path,from_Date,to_Date, manufacturers);
		return partsListsXML;
	}catch(e){
		alert(e.description +"\n stack:main.htm.OCX_COMS.requestEstimates");
	}
}

function requestPartsList(id, path){
	try{  	
		m_path = path;
		var partsListXML = GetPartList(m_path, id);
		return partsListXML;
	}catch(e){
		alert(e.description +"\n\n stack:main.htm.OCX_COMS.requestPartsList \n\nPath=" + m_path + "\n\nid=" + id );
	}
}

/*function GetEstimateHeaderList(path,from_Date,to_Date){	 
	var outputvalue = APB_Integration_Object.GetEstimateHeaderList(path,from_Date,to_Date);
	return outputvalue;	
}*/

function locateEstimatePath(){
	try{  	
		var pathXML = APB_Integration_Object.SelectFolderDialog("Please select a folder for this estimating system");
		return pathXML;
	}catch(e){
		alert(e.description +"\n stack:main.htm.OCX_COMS.locateEstimatePath");
	}	
}

function GetValidatePath(path){	

	//alert("path"+path);
	try{ 
		var getvalue = APB_Integration_Object.FolderExists( path );
	//alert("GETVAL"+getvalue);
	}catch(e){
		getvalue = null;	
	}	
	return getvalue;	
}

function RefreshEstimateData(xmldata){
	try{
		bodyshop.RefreshEstimateData();
	}catch(e){
		alert(e.description +"\n Stack:OCX_COMS.RefreshEstimateData");
	}
}

function GetHeaders(path,from_Date,to_Date, manufacturers){
	//alert("sending: " + "Toyota,Buick,Scion,Hyundai");	
	var outputvalue = APB_Integration_Object.GetEstimateHeaders( path , manufacturers, from_Date , to_Date );
	//alert("returned: " + outputvalue);
	return outputvalue;	
}

function GetPartList(path, id){
	var outputvalue = APB_Integration_Object.GetEstimate(path, id);
	return outputvalue;
}

function GetVersion(){
	return( APB_Integration_Object.GetVersion());
}

