$(document).ready( function() {
		$('.button').hover(function(){
				$(".tooltip", this).show();
			},
			function(){
				$(".tooltip", this).hide();
			}
		);

		$('#head_main b.tr').click(function(){
			$.cookie('toggled','true',{ expires: 500 });
			$('#head_main').slideUp("fast", function(){$('#head_main_toggled').slideDown("fast");});
		});
		$('#head_main_toggled b.tr').click(function(){
			$.cookie('toggled','false',{ expires: 500 });
			$('#head_main_toggled').slideUp("fast", function(){$('#head_main').slideDown("fast");});
		});

		$('.bottom-block-title').css({'cursor':'pointer'});
		$('.bottom-block-title').click(function(){
			var a_element = $('.bottom-block-content a', this.parentNode);
			if(a_element[0])
				window.location = a_element[0].href;
		});
		$('.bottom-block-content').css({'cursor':'pointer'});
		$('.bottom-block-content').click(function(){
			var a_element = $("a", this);
			if(a_element[0])
				window.location = a_element[0].href;
		});

		/*var required_labels = $('.required .form_label label');
		required_labels.each(function(i, element){
			//element.text(this.text()+"*");
			this.text(element.textContent+"*");
		});
		text += "*";*/

		$('.hidder').click(function(){
			$('.hidden_info', this).toggle();
		});

		$('a','.langselector').bind('click',function(){
			var lang = this.id.split('_')[1];
			var site_language = $.cookie('user_language');
			if(lang != site_language){
				$.cookie('user_language',lang,{ expires: 500 });
				document.location = '/';
			}
			return false;
		});
	});

function showLogin(id)
{
	var check_other;
	var check_curr;
	switch(id)
	{
		case "login-form-wrapper":
			check_other = "feedback";
			check_curr = "login";
			break;
		case "feedback-form-wrapper":
			check_curr = "feedback";
			check_other = "login"; break;
	}
	var other_element = $("#"+check_other+"-form-wrapper");
	if(other_element.css("display") == 'block')
	{
		$("#"+check_other+"-li").removeClass("active");
		$("#"+check_curr+"-li").addClass("active");
		other_element.hide();
		$("#"+id).show();

	} else {
		var curr_element = $("#"+check_curr+"-form-wrapper");
		if(curr_element.css("display") == 'none')
			$("#"+check_curr+"-li").addClass("active");
		$("#"+id).slideToggle("slow", function()
			{
				if(curr_element.css("display") == 'block')
					$("#"+check_curr+"-li").addClass("active");
				else
					$("#"+check_curr+"-li").removeClass("active");
			}
		);
	}
}

function showEditable()
{
	$(".current").toggle();
	$("#main-content .editable").toggle();
}

function addComment(id)
{
	if(id > 0) {
		var title = $("#comment_"+id+"_title").text();
		if(title.length > 0)
			title = "RE: "+title;
		$("#comment_title").val(title);
		$("#parent_id").val(id);
	} else
		$("#comment_title").val("");
	$(".commentform").show();
}
