/* common function */
function toggleBlock(id, link, animate, t_class, animate_param, opened_text, closed_text){
	if(!animate_param){
		animate_param = 'height';
	}
	
	var el = typeof(id) == 'object' ? id : $('#' + id);
	
	var res = 1;
	if(t_class){
		$(link).toggleClass(t_class);
	}
	if($(el).css('display') == 'none'){

		if(animate){
			if(animate_param == 'height')
				$(el).animate({'height': 'show'}, 'fast');
			else
				$(el).animate({'width': 'show'}, 'fast');
		}else
			$(el).show();
		
		if(opened_text && link){
			link.innerHTML = opened_text;
		}
			
	}else{
		if(animate){
			if(animate_param == 'height')
				$(el).animate({'height': 'hide'}, 'fast');
			else
				$(el).animate({'width': 'hide'}, 'fast');
		}else
			$(el).hide();
			
		if(closed_text && link){
			link.innerHTML = closed_text;
		}
	}
	if(link)
		link.blur();
	return false;
}


function ajaxLoadContent(url, content_id, params){
	$('#' + content_id).html('<div class="ajax_loader"><img src="/img/ajax-loader.gif"/></div>');
	$.get(url, params, 
		function(response){
			onAjaxContentLoaded(response, content_id);
		}
	);
}

function onAjaxContentLoaded(text, content_id){
	$('#' + content_id).html(text);
}

/* submenu */
function showSubmenu(pid){
	var par_pos = $('#par' + pid).position();
	var par_height = document.getElementById('par' + pid).offsetHeight;
	$('#ch' + pid).show().css({'left' : par_pos.left, 'top': par_pos.top + par_height});
}

function hideSubmenu(pid){
	$('#ch' + pid).hide();
}
