function fixpng(a){if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){var b;if(a.tagName=='IMG'){if(/\.png$/.test(a.src)){b=a.src;a.src="/img/blank.gif"}}else{b=a.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);if(b){b=b[1];a.runtimeStyle.backgroundImage="none"}}if(b)a.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"',sizingMethod='scale')"}}

var busy = 0

var AjaxResult = function(response){
// 	alert(response)
	eval(response)
}

var del = function(Id, El){
	if(confirm("Удалить?"))
	$.post(
		'/req/delete.php',
		{id:Id,el:El},
		AjaxResult
	)
}

var move = function(Id, Dir, El){
	if(busy) return
	busy = 1
	$.post(
		'/req/move.php',
		{id:Id,dir:Dir,el:El},
		function(response){
			busy = 0
			eval(response)
		}
	)
}

var get_options = function(Id, El){
	$.post(
		'/req/get_options.php',
		{
			el:El,
			id:Id
		},
		AjaxResult
	)
}

function mousePos(evt){

	if(window.event){
		var X = window.event.x
		var Y = window.event.y
	}
	else{
		var X = evt.clientX
		var Y = evt.clientY
	}

	return {'top':Y,'left':X}

}

function show_menu(evt, id){
	$('.menu:visible').each(function(){
		if($(this).attr('id') == 'menu'+id) return
		$(this).hide(200)
	})
	var coords = mousePos(evt)
	var marginTop = $('div', '#menu'+id).size()*33
	$('#menu'+id+':hidden').css({top:coords.top-marginTop-20, left:coords.left}).show(300).mouseleave(function(){$('#menu'+id).hide(300)})
}
