var g_aoRealtimeBestandRequest = new Array();

function ClsRealtimeBestandRequest()
{
	var m_iTitelNr = 0;
	var m_sRealtimeBestandRequestLabel = '';
	var m_oHttpRequest = null;
		
	function ARTGetSpanContent()
	{
		var oSpan = document.getElementById('SpnRealtimeBestand_' + m_iTitelNr);
			
		if (oSpan)
		{
			return oSpan.innerHTML;
		}
		else
		{
			return '';
		}
	}
	
	function ARTSetSpanContent(sText)
	{
		var oSpan = document.getElementById('SpnRealtimeBestand_' + m_iTitelNr);
			
		if (oSpan)
		{
			oSpan.innerHTML = sText;					
			return true;
		}
		else
		{
			return false;
		}
	}
	
	this.ARTOnSuccess = function(sResponse)
	{	
		if (sResponse != '')
		{
			ARTSetSpanContent(sResponse);
		}
		else
		{
			ARTSetSpanContent(m_sRealtimeBestandRequestLabel);
		}
	}
	
	this.ARTOnError = function(iStatus)
	{
		ARTSetSpanContent(m_sRealtimeBestandRequestLabel);	
	}
	
	this.ARTExecute = function(iTitelNr, sLabel)
	{
		m_iTitelNr = iTitelNr;
		m_sRealtimeBestandRequestLabel = ARTGetSpanContent();
		m_oHttpRequest = new ClsHttpRequest();
				
		if (m_oHttpRequest)
		{					
			if (ARTSetSpanContent(sLabel))
			{	
				var sUrl = 'http://b2b.grosso-primeur.de/Bestand/request.asp?titelnr=' + m_iTitelNr + '&gpw=1';
				return m_oHttpRequest.ARTExecute(sUrl, this);
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
}

function ARTExecuteRealtimeBestandRequest(iTitelNr, sLabel)
{
	g_aoRealtimeBestandRequest[g_aoRealtimeBestandRequest.length] = new ClsRealtimeBestandRequest();
	g_aoRealtimeBestandRequest[g_aoRealtimeBestandRequest.length - 1].ARTExecute(iTitelNr, sLabel);
}

function ARTExecuteRealtimeBestandRequestImage(iTitelNr, sImageUrl)
{
	var sLabel = '<img src="' + sImageUrl + '" border="0" alt="">';
	ARTExecuteRealtimeBestandRequest(iTitelNr, sLabel);
}
