function ClientWidth() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function ClientHeight() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}	

function ScrollLeft() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.scrollLeft:document.body.scrollLeft;
}

function ScrollTop() {
	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.scrollTop:document.body.scrollTop;
}	



function openWindow(id,width,height) {
	document.getElementById('hover').style.display='block';

	resLeft=((ClientWidth()-width)/2)+ScrollLeft();
	resTop=((ClientHeight()-height)/2)+ScrollTop();
	
	if (resLeft<0) resLeft=0;
	if (resTop<0) resTop=0;
	
	
	win=document.getElementById('window');
	win.style.left=resLeft+'px';
	win.style.top=resTop+'px';
	
	doLoad('','/ajax/catalog/'+id+'/','win_zone');
	
	win.style.display='block';
}

function closeWindow(res) {
	document.getElementById('win_zone').innerHTML='';
	document.getElementById('window').style.display='none';
	document.getElementById('hover').style.display='none';
}



function setImage(id,img) 
{
	doLoad('','/ajax/catalog_img/'+id+'/'+img+'/');
	
	list=document.getElementById('small_img').getElementsByTagName('img');
	for (var i=0; i < list.length; i++) {
	    image=list[i];
	    
	    if (i==img)
	    	image.className='select';
	    else
	    	image.className='';
	}
}

function deleteBasketItem(id)
{
	if (confirm('Вы действительно хотите удалить товар из корзины?')) 
	{	
		doLoad('','/ajax/basket_delete/'+id+'/');
		row = document.getElementById('item'+id);
		row.parentNode.removeChild(row);
	}
}
