function logout(logout_link) {
	var is_confirmed = confirm('Czy na pewno chcesz się wylogować ?');
	if (is_confirmed) { logout_link.href; }
	return is_confirmed; }

function menu_show(option) {
	if (option == 'user') option = 'users';
	else if (option == 'car') option = 'cars';
	else if (option == 'club') option = 'clubs';
	else if (option == 'ad') option = 'ads';
	else if (option != 'races' && option != 'fotos' && option != 'users' && option != 'user' && option != 'cars' && option != 'clubs' && option != 'ads' && option != 'messages' && option != 'account') {
		option = 'main'; }
	if (document.getElementById('item_' + option).className != "menu_item_selected") {
		document.getElementById('item_' + option).className = 'menu_item_active'; }
	if (option == 'main') { document.getElementById('menu_main').style.display = ''; }
	else { document.getElementById('menu_main').style.display = 'none'; }
	if (option == 'races') { document.getElementById('menu_races').style.display = ''; }
	else { document.getElementById('menu_races').style.display = 'none'; }	
	if (option == 'fotos') { document.getElementById('menu_fotos').style.display = ''; }
	else { document.getElementById('menu_fotos').style.display = 'none'; }	
	if (option == 'users') { document.getElementById('menu_users').style.display = ''; }
	else { document.getElementById('menu_users').style.display = 'none'; }	
	if (option == 'cars') { document.getElementById('menu_cars').style.display = ''; }
	else { document.getElementById('menu_cars').style.display = 'none'; }
	if (option == 'clubs') { document.getElementById('menu_clubs').style.display = ''; }
	else { document.getElementById('menu_clubs').style.display = 'none'; }
	if (option == 'ads') { document.getElementById('menu_ads').style.display = ''; }
	else { document.getElementById('menu_ads').style.display = 'none'; }	
	if (option == 'messages') { document.getElementById('menu_messages').style.display = ''; }
	else { document.getElementById('menu_messages').style.display = 'none'; }
	if (option == 'account') { document.getElementById('menu_account').style.display = ''; }
	else { document.getElementById('menu_account').style.display = 'none'; } }

function menu_hide(option) {
	if (document.getElementById('item_' + option).className != "menu_item_selected") {
		document.getElementById('item_' + option).className = 'menu_item'; } }

function menu_start(option) {
	if (option == '') {
		var option = 'main'; }
	document.getElementById('menu_' + option).style.display = ''; }

function car_delete(car) {
	var is_confirmed = confirm('Czy na pewno chcesz usunąć auto ?');
	if (is_confirmed) { location.href = 'index.php?action=car_delete&car=' + car; }
	return is_confirmed; }

function car_picture_delete(link) {
	var is_confirmed = confirm('Czy na pewno chcesz usunąć zdjęcie ?');
	if (is_confirmed) { link.href; }
	return is_confirmed; }

function ads_delete(ads) {
	var is_confirmed = confirm('Czy na pewno chcesz usunąć ogłoszenie ?');
	if (is_confirmed) { location.href = 'index.php?action=ads_delete&ads=' + ads; }
	return is_confirmed; }

function invite_reject(link) {
	var is_confirmed = confirm('Czy na pewno chcesz odrzucic zaproszenie ?');
	if (is_confirmed) { link.href; }
	return is_confirmed; }

function invite_cancel(link) {
	var is_confirmed = confirm('Czy na pewno chcesz anulować zaproszenie ?');
	if (is_confirmed) { link.href; }
	return is_confirmed; }

function invite_delete(link) {
	var is_confirmed = confirm('Czy na pewno chcesz usunąć użytkownika z listy znajomych ?');
	if (is_confirmed) { link.href; }
	return is_confirmed; }

function race_picture_delete(link) {
	var is_confirmed = confirm('Czy na pewno chcesz usunąć zdjęcie ?');
	if (is_confirmed) { link.href; }
	return is_confirmed; }

function message_trash(id,option) {
	var is_confirmed = confirm('Czy na pewno chcesz przenieść wiadomość do kosza ?');
	if (option != '') option_string = '&option=' + option;
	else option_string = '';
	if (is_confirmed) { location.href = 'index.php?action=message_trash' + option_string + '&message=' + id; }
	return is_confirmed; }

function message_delete(id) {
	var is_confirmed = confirm('Czy na pewno chcesz usunąć wiadomość ?');
	if (is_confirmed) { location.href = 'index.php?action=message_delete&message=' + id; }
	return is_confirmed; }

function message_all_delete() {
	var is_confirmed = confirm('Czy na pewno chcesz usunąć wszystkie wiadomości z kosza ?');
	if (is_confirmed) { location.href = 'index.php?action=message_all_delete'; }
	return is_confirmed; }

function club_reject(link) {
	var is_confirmed = confirm('Czy na pewno nie chcesz przyjąć użytkownika do klubu ?');
	if (is_confirmed) { link.href; }
	return is_confirmed; }

function club_delete(link) {
	var is_confirmed = confirm('Czy na pewno chcesz usunąć użytkownika z klubu ?');
	if (is_confirmed) { link.href; }
	return is_confirmed; }

function form_select(form,field) {
	if (document.getElementById(field).value != '') {
		document.getElementById(form).submit(); } }

function form_car_brand() {
	if (document.getElementById('car_brand').value == 'Inna') { 
		document.getElementById('car_brand_other').style.display = ''; }
	else {
		document.getElementById('car_brand_other').style.display = 'none'; } }

function form_submit(form,field) {
	document.getElementById(field).disabled = true;	
	document.getElementById(field).value = "Proszę czekać...";	
	document.getElementById(form).submit();	}

function show_colors() {
	if (document.getElementById('editor_colors').style.display == "none") {
		document.getElementById('color_button').value = 'ukryj kolor czcionki';
		document.getElementById('editor_colors').style.display = ''; }
	else {
		document.getElementById('color_button').value = 'kolor czcionki';
		document.getElementById('editor_colors').style.display = 'none'; } }

var vote_urls = new Array('images/vote_0.gif','images/vote_1.gif','images/vote_2.gif','images/vote_3.gif','images/vote_4.gif','images/vote_5.gif');
var vote_images = new Array();
for (var i = 0; i<vote_urls.length; ++i) {
	vote_images[i] = new Image();
	vote_images[i].src = vote_urls[i]; }

function set_vote(vote) {
	for (var i = 1; i<=5; i++) {
		if (vote >= i) { nr = i; }
		else { nr = 0; }
		var image = document.images['vote_' + i];
		if (image) { image.src = vote_images[nr].src; } } }

function show_search() {
	if (document.getElementById('search_show').style.display == "none") {
		document.getElementById('search_show').style.display = '';
		document.getElementById('search_basic_show').style.display = '';
		document.getElementById('search_advanced_show').style.display = 'none'; }
	else {
		document.getElementById('search_show').style.display = 'none';
		document.getElementById('search_basic_show').style.display = 'none';
		document.getElementById('search_advanced_show').style.display = ''; } }

function show_report() {
	if (document.getElementById('report_show').style.display == "none") {
		document.getElementById('report_show').style.display = ''; }
	else {
		document.getElementById('report_show').style.display = 'none'; } }

function put_emoticon(emoticon) {
	document.getElementById('message_form').message_text.value  += ' ' + emoticon + ' ';
	document.getElementById('message_form').message_text.focus(); }

function put_editor(tab_open, tag_close) {
	theSelection = '';
	var textarea = document.getElementById('editor_area');
	var new_position;
	textarea.focus();
	if (textarea.selectionStart || textarea.selectionStart == 0) {
		new_position = textarea.selectionStart + tab_open.length; }
	else if (document.selection) {
		var range = document.selection.createRange();
		var range_all = document.body.createTextRange();
		range_all.moveToElementText(textarea);
		var sel_start;
		for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) {		
			range_all.moveStart('character', 1); }
		new_position = sel_start + tab_open.length; }
	if (document.selection) {
		textarea.focus();
		sel = document.selection.createRange();
		sel.text = tab_open + tag_close; }
	else if (textarea.selectionStart || textarea.selectionStart == '0') {
		var startPos = textarea.selectionStart;
		var endPos = textarea.selectionEnd;
		textarea.value = textarea.value.substring(0, startPos) + tab_open + tag_close + textarea.value.substring(endPos, textarea.value.length); }
	else {
		textarea.value += tab_open + tag_close; }
	if (!isNaN(textarea.selectionStart)) {
		textarea.selectionStart = new_position;
		textarea.selectionEnd = new_position; }	
	else if (document.selection) {
		var range = textarea.createTextRange(); 
		range.move("character", new_position); 
		range.select();	}
	textarea.focus(); }