function addToCart(id)
{
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("get", '/ajax.php?s=buy&id='+id, true);
	oXmlHttp.onreadystatechange = function ()
   		{
    		if (oXmlHttp.readyState == 4)
      		{
       			if (oXmlHttp.status == 200)
         		{
	  				addToCartR( oXmlHttp.responseText);
	 			} 
     		}
  		}
	oXmlHttp.send(null);
}
function addToCartR(txt)
{
	p1=txt.indexOf('OK::::::');
	if(p1!=-1)
	{
		var e = document.getElementById('cart');
		e.innerHTML=txt.substring(p1+8, txt.length);
	}
}
function showInfo(id)
{
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("get", '/ajax.php?s=info&id='+id, true);
	oXmlHttp.onreadystatechange = function ()
   		{
    		if (oXmlHttp.readyState == 4)
      		{
       			if (oXmlHttp.status == 200)
         		{
	  				showInfoR( oXmlHttp.responseText);
	 			} 
     		}
  		}
	oXmlHttp.send(null);
}
function  getPageSize()
{
	var xScroll, yScroll;
	if(window.innerHeight && window.scrollMaxY) 
	{
	    xScroll = document.body.scrollWidth;
	    yScroll = window.innerHeight + window.scrollMaxY;
	}else if (document.body.scrollHeight > document.body.offsetHeight)// all but Explorer Mac
	{ 
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
	}else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight)// Explorer 6 strict mode
	{ 
        xScroll = document.documentElement.scrollWidth;
        yScroll = document.documentElement.scrollHeight;
	}else // Explorer Mac...would also work in Mozilla and Safari
	{ 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if(self.innerHeight) // all except Explorer
	{ 
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
	}else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
	{ 
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
	}else if (document.body) // other Explorers
	{ 
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
	}
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
        pageHeight = windowHeight;
	}else 
	{
        pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth)
	{
        pageWidth = windowWidth;
	}else
	{
        pageWidth = xScroll;
	}
	xScroll=self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
	yScroll=self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
	return {pw:pageWidth, ph:pageHeight, ww:windowWidth, wh:windowHeight,sx:xScroll ,sy:yScroll};
}
function GetCartDialod()
{
	var dfon=document.getElementById('cartdlg_fon');
	if(dfon!=null)return dfon;
	dfon=document.createElement('div');
	dfon.id='cartdlg_fon';
	var dcont=document.createElement('div');
	dcont.id='cartdlg_content';
	dfon.style.display='none';
	dfon.content=dcont;
	dfon.Show = function(){document.getElementById('cartdlg_fon').style.display='';this.content.style.display='';};
	dfon.Hide = function(){document.getElementById('cartdlg_fon').style.display='none';this.content.style.display='none';};
	dfon.Loading = function(){document.getElementById('cartdlg_content').innerHTML='<img src="/template/images/loading.gif" width="20" height="20"';};
	dfon.SetInner = function(txt){document.getElementById('cartdlg_content').innerHTML=txt;};
	dfon.Centrate = function()
	{
		var ell=document.getElementById('cartdlg_content');
		var cw=ell.offsetWidth;
		var ch=ell.offsetHeight;
		var ps=getPageSize();
		this.style.width=ps.pw+'px';
		this.style.height=ps.ph+'px';
		ell.style.top=(ps.sy+(ps.wh-ch)/2)+'px';
		ell.style.left=(ps.sx+(ps.ww-cw)/2)+'px';
	}
	document.body.appendChild(dfon);
	document.body.appendChild(dcont);
	return dfon;
}



var box=null;
function showInfoR(txt)
{
	if(box==null)
	{
		box = document.createElement('div');
		box.style.display='none';
		box.className='box';
		box.innerHTML='<div class="bg" onclick="box.style.display=\'none\';">&nbsp;</div><div class="cont"></div>';
		document.body.appendChild(box);
	}
	var divs = box.getElementsByTagName('div');
	var bg=divs[0];
	var div=divs[1];
	div.innerHTML = "<b class=\"close\" onclick=\"box.style.display='none';\">&nbsp;</b>"+txt;
	box.style.display='';
	var ps=getPageSize();
	bg.style.height = ps[1]+'px';
	div.style.top= (ps[5]+20)+'px';
	div.style.left= '250px';
	div.style.width= (ps[0]-500)+'px';
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	yScroll = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop)||(document.body && document.body.scrollTop);
	xScroll = self.pageYOffset || (document.documentElement && document.documentElement.scrollLeft)||(document.body && document.body.scrollLeft);

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,xScroll,yScroll)
	return arrayPageSize;
}
function freeCart()
{
	document.getElementById('cart_action').value='free';
	document.getElementById('cart_form').submit();
}
function updateCart()
{
	document.getElementById('cart_action').value='refresh';
	document.getElementById('cart_form').submit();
}
function rmFromCart(id)
{
	document.getElementById('cart_action').value='del';
	document.getElementById('cart_id').value=id;
	document.getElementById('cart_form').submit();
}

