//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function GetObject(objID)
{
  if (document.getElementById)
    return document.getElementById(objID)
  else if (document.all)
    return document.all[objID];

  else if (document.layers)
  {
    this.obj = document.layers[objID];
    this.style = document.layers[objID];
  }
}



//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function safeSetClass(obj,classname)
{
	if (obj)
	{
		obj.setAttribute("class", classname);
		obj.setAttribute("className", classname);
	}
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function safeGetClass(obj)
{
	if (obj)
	{
		var tmp=obj.getAttribute("class");
		if (!tmp) var tmp=obj.getAttribute("className");
		return tmp;
	} else return false;
}



//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function GetXmlHttpObject()
{
	var xmlHttp=null;
  // Firefox, Opera 8.0+, Safari
	try
	{
    xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}




//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function processProductOperation(product,operation,pagelink,step2link)
{
	xmlHttp_operation=GetXmlHttpObject();
	if (xmlHttp_operation==null) return false;

	var thisValue=0;
	var obj=GetObject('product-value-'+product);
	if (obj) thisValue=obj.value;

	var url="fileadmin/eshop-ajax.php?ajaxmode&basket="+operation+"&product="+product+"&value="+thisValue+"&pagelink="+encodeURIComponent(pagelink)+"&step2link="+encodeURIComponent(step2link);

	xmlHttp_operation.onreadystatechange=stateChanged_operation;
	xmlHttp_operation.open("GET",url,true);
	xmlHttp_operation.send(null);
}


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function stateChanged_operation()
{
	if (xmlHttp_operation.readyState==4)
	{
		var ret = xmlHttp_operation.responseText;
//		document.write(ret);
		if (ret!='')
		{
			ret=ret.split('|*|*|');
			var sbobj=GetObject('sbuttonbox');
			if (sbobj)
			{
				if (ret[0]>0)
					safeSetClass(sbobj,'visible');
				else
					safeSetClass(sbobj,'hidden');
			}
			
			
			var obj=GetObject('product-'+ret[1]);
			if (obj)
			{
				obj.innerHTML=ret[2];
			}
			var obj2=GetObject('minibasket');
			if (obj2)
			{
				if (ret[3]!='')
				{
					obj2.innerHTML=ret[3];
					safeSetClass(obj2,'visible')
				} else
				{
					safeSetClass(obj2,'hidden')
				}
			}
			
		}
	}
}



