/**
 * Chenaged from open to _open because open is a system function and cannot be redeclared
 */
var _open = false;
var last_open = false;

$('#you').live('click', function(ev) {
	var o = 'you';
	if($('#h_bar_' + o + '_popup').hasClass('open')) {
		h_bar('close', o);
	} else {
		h_bar('open', o);
	}
});

$('#h_bar_you').live('click', function(ev) {
	var o = 'you';
	if($('#h_bar_' + o + '_popup').hasClass('open')) {
		h_bar('close', o);
	} else {
		h_bar('open', o);
	}
});

if ( !POLISH_VER_ONLY ) {
	$('#h_bar_language').live('click', function(ev) {
		var o = 'language';
		if($('#h_bar_' + o + '_popup').hasClass('open')) {
			h_bar('close', o);
		} else {
			h_bar('open', o);
		}
	});
}

/***/

function h_bar(a, o) {
	if(a == 'open') {
	
		if(_open == true) h_bar('close', last_open);
	
		$('#h_bar_' + o + '_popup').removeClass('closed');
		$('#h_bar_' + o + '_popup').addClass('open');
		$('#h_bar_' + o).addClass('active_popup');
		if(o == 'you') $('#you').addClass('active_popup');
		
		_open = true;
		last_open = o;
		
	} else if(a == 'close') {
	
		$('#h_bar_' + o + '_popup').removeClass('open');
		$('#h_bar_' + o + '_popup').addClass('closed');
		$('#h_bar_' + o).removeClass('active_popup');
		if(o == 'you') $('#you').removeClass('active_popup');
		
		_open = false;
		last_open = o;
		
	}
}

/***/

$('.item').live('mouseover mouseout', function(ev) {
	if(ev.type == 'mouseover') {
		$(this).find('.object_remove').css('display', 'inline-block');
		$(this).find('.spam_link').css('display', 'inline-block');
                $(this).find('.edit_comment').css('display', 'inline-block');
	} else {
		$(this).find('.object_remove').css('display', 'none');
                $(this).find('.edit_comment').css('display', 'none');
		$(this).find('.spam_link').css('display', 'none');
	}
});

/***/

$('.button_box').live('mousedown mouseup', function(ev) {
	if(ev.type == 'mousedown') {
		$(this).addClass('clicked');
	} else {
		$(this).removeClass('clicked');
	}
});
