function getClientWidthx()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getElementPositionx(elemId)
{
    var elem = document.getElementById(elemId);

    var w = elem.offsetWidth;
    var h = elem.offsetHeight;

    var l = 0;
    var t = 0;

    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}

function PU(obj_id, pop_id, tpoz, lpoz)
{
	try {
	popup = document.getElementById(pop_id);
	obj = document.getElementById(obj_id);
	tpoz = tpoz?tpoz:0;
	lpoz = lpoz?lpoz:0;

	pos = getElementPositionx(obj_id);
	if ((getClientWidthx()-pos.left)<325)
	{
		popup.style.right = 0+'px';
		popup.style.left = 'auto';
		popup.style.display = 'block';
	}
	else popup.style.left = (pos.left-lpoz)+'px';
	popup.style.top = (pos.top-tpoz)+'px';
	popup.style.display = 'block';
	}
	catch (e)
	{
		alert('Подождите немного, данные элементы еще не загрузились.');
	}
}


function pu$(id)
{
	return document.getElementById(id);
}


function PUT(title, obj_id, pop_id, tpoz, lpoz)
{
	try
	{

		popup = pu$('popupsTable');
		obj = pu$(obj_id);
		pu$('popupsTable_title').innerHTML = title;
		pu$('order-title').value = title;

		tpoz = tpoz?tpoz:0;
		lpoz = lpoz?lpoz:0;

		pos = getElementPositionx(obj_id);
		if ((getClientWidthx()-pos.left)<325)
		{
			popup.style.right = 0+'px';
			popup.style.left = 'auto';
			popup.style.display = 'block';
		}
		else
		{
			popup.style.left = (pos.left-lpoz)+'px';
		}

		popup.style.top = (pos.top-tpoz)+'px';

		pu$(pop_id).style.display = 'block';

		popup.style.display = 'block';

	}
	catch (e)
	{
		alert('Подождите немного, данные элементы еще не загрузились.');
	}
}






$(document).ready(function() {
			$('.liquid').liquidcarousel({height:200, duration:100, hidearrows:false});


			$('.tooltip').hover(
				function(){
					e = $('img', $(this));
					d = $('#tooltip');


					d.html($(this).attr('tooltip').split('[').join('<').split(']').join('>'));


					d.css({'top': e.position().top + e.height() + 'px', 'left' : e.position().left - parseInt(d.width()/2) + parseInt(e.width()/2) + 1 + 'px'});


					d.show();

				},

				function(){
					d = $('#tooltip');
					d.hide();
				}

			);






});


