var is_ie = /MSIE (5\.5|6).+Win/.test(navigator.userAgent);

/*************** для выплывающих меню ****************/

function findPos(Id)
{
	var x = 0;
	var y = 0;

	var el,temp;
	el = document.getElementById(Id);

	if ( el.offsetParent )
	{
		temp = el;
		while ( temp.offsetParent ) //Looping parent elements to get the offset of them as well
		{
			temp=temp.offsetParent;
			x+=temp.offsetLeft
			y+=temp.offsetTop;
		}
	}
	x+=el.offsetLeft
	y+=el.offsetTop

	return [x,y];
}


var menus = Array();

function sh(u)
{
	if ( !document.getElementById('box'+u) ) return;
	box = document.getElementById('box'+u).style;
	td = document.getElementById('td'+u).style;

	if( menus[u] == true )
	{
		box.visibility = "visible";
		//pos = findPos( 'td'+u );
		//box.left = pos[0]+'px';
		//box.top = pos[1] + 'px';
		//alert(pos[1]);
//alert( pos[1] + ' ' + box.top );
		//box.top = box.top + 'px';
	}
}

function shFirstLevel( u )
{
	//alert('sadf'); return;
	menus[u] = true;
}

function hd(u)
{
	if ( !document.getElementById('box'+u) ) return;
	box = document.getElementById('box'+u).style;
	box.visibility = "hidden";
}

function hd1(u)
{
	menus[u] = false;
}


/*
 *                         Для "выплывающих" меню
 ****************************************************************************/
 
function showHPblock( id )
{
	var blck = document.getElementById( id );
	if ( !blck ) return;

	if ( blck.style.display != 'block' )
	{
		blck.style.display = 'block';
		//syncColsHeight();
	}
	else
	{
		blck.style.display = 'none';
	}
	//setTimeout( "syncColsHeight()", 1000 );
}


/*****************************************************/



$(document).ready(function(){

	$("#login-form").dialog({
		autoOpen: false,
		bgiframe: true,
		position: 'center',
		show: 'highlight',
		hide: 'highlight',
		width: 450,
		modal: true,
		title: 'Вход с паролем'
	});
	$("#login-link").click(function() {
		$("#login-form").dialog('option', 'position', ['right','top']);
		$("#login-form").dialog('open');
		return false;
	});

	$.datepicker.setDefaults($.extend({showMonthAfterYear: false}, $.datepicker.regional['ru']));

	$('button, input:submit, input:reset, input:button, .button').button();

	$('a.shadow').click(function(){ return false; });

	$("a.history-tooltip").tooltip({ 
	    bodyHandler: function() { 
	        return $($(this).siblings('div.history-tooltip-box')).html(); 
	    },
	    track: true,
	    showURL: false,
	    fade: 250,
	    top: 10,
	    extraClass: 'fixedwidth',
	    positionLeft: true
	});

	$("a.cart-tooltip").tooltip({ 
	    bodyHandler: function() { 
	        return $($(this).siblings('div.cart-tooltip-box')).html(); 
	    },
	    track: true,
	    showURL: false,
	    fade: 250,
	    top: 10,
	    extraClass: 'fixedwidth',
	    positionLeft: true
	});

});
