check = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
$(function(){if ('#confirmation-form'){$('.conf').click(function(){var clicked = parseInt($(this).val());switch (clicked){case 1:$('#mode-1-extended').show('fast');$('#mode-2-extended').hide('slow');break;case 2:$('#mode-1-extended').hide('fast');$('#mode-2-extended').show('slow');break;case 3:$('#mode-1-extended').hide('fast');$('#mode-2-extended').hide('slow');break;}});}
$('.delete').css('color','red').click(function(){if(confirm('Czy napewno usunąć element ?')){return true;}return false;});
$('.new-post').click(function(){$('.forum').hide('fast');$('#new-thread-form').show('slow');return false;});
$('#new-thread').click(function(){$('.forum').hide('fast');$('#threads-pagination').hide('fast');$('#new-thread-form').show('slow');return false;});
$('#new-thread-cancel').click(function(){$('#new-thread-form').hide('fast');$('#threads-pagination').show('slow');$('.forum').show('slow');return false;});
$('#messagesCheckAll').click(function(){$("input[name$='messageIds[]']").each(function(n){$(this).attr('checked',true);});return false;});
$('#messagesUncheckAll').click(function(){$("input[name$='messageIds[]']").each(function(n){$(this).attr('checked',false);});return false;});
$('#checkAllCheckboxes').click(function(){$("input[type$='checkbox']").each(function(n){$(this).attr('checked',true);});});
$('#uncheckAllCheckboxes').click(function(){$("input[type$='checkbox']").each(function(n){$(this).attr('checked',false);});});
$('.button-add-to-friends').click(function(){var friendId = $(this).attr('id').replace(/f-/,'');$.ajax({type:"POST",url:"/inc/ajax.php",data:"function=addToFriends&friendId="+friendId,success:function(msg){alert( msg );}});});
$('.button-delete-from-friends').click(function(){var friendId=$(this).attr('id').replace(/f-/,'');$.ajax({type:"POST",url:"/inc/ajax.php",data:"function=deleteFromFriends&friendId=" + friendId,success: deleteFriend});});
$('.focusToLogin').click(function(){$('#topUserLogin').focus();});
$('#system-message').dialog({resizable:false,draggable:false,title:'Wiadomość systemowa',show:'drop',height:100});
$('#i_question_submit').click(function(){if ($('#i_question_name').val()==''){alert('Podaj swoje imię.');return false;}if ($('#i_question_email').val()==''){alert('Proszę podać adres email.');return false;}else if (!check.test($('#i_question_email').val())){alert('Proszę podać prawidłowy adres email.');return false;}if($('#i_question_name').val()==''){alert('Wpisz treść pytania');return false;}return true;});
$('#i_question_reset').click(function(){$('#i_question_name').val('');$('#i_question_email').val('');$('#i_question_text').val('');return false;});
$('#i_user_submit').click(function(){if($('#i_user_login').val()==''){alert('Podaj login');return false;}if ($('#i_user_password').val()==''){alert('Podaj hasło');return false;}return true;});
$('.movie-title').toggle(function(){$(this).next().show('slow')},function(){$(this).next().hide('slow')});
$('#i_msg_to').autocomplete('/inc/ajax.php?function=getUsersAutocomplete',{minChars:2,mustMatch: true});
$('#new-threa2d-submit').click(function(){if ($('#i-thread-title').val()==''){alert('Musisz podać tytuł wątku.');return false;}if ($('#i-thread-body').val()==''){alert('Musisz podać treść wątku.');return false;}return true;});


	$('.sendcard').click(function(){
		
		var cardId=$(this).attr('id').replace(/k-/,'');
		
		$('#kartki-container').hide('fast');
		$('#kartki-form-container').css('display','block');
		$('#i_card_id').val(cardId);
		
		return false;
	});

	
	$('.cancel').click(function(){
		if (confirm('Czy napewno chcesz się wypisać z tego warsztatu?'))
		{
			return true;
		}
		
		return false;
	});

});

function deleteFriend(msg){$('#fr-' + msg).hide('puff');alert('Użytkownik został usunięty z Twojej listy znajomych');}


function postcardCheck()
{
	var msg = '';
	
	
	if ($('#i_friend_email').val()=='')
	{
		msg += "Uzupełnij email znajomego\n";
	}
	
	if ($('#i_friend_name').val()=='')
	{
		msg += "Uzupełnij imię znajomego\n";
	}
	
	if ($('#i_your_email').val()=='')
	{
		msg += "Uzupełnij swój email\n";
	}
	
	if ($('#i_your_name').val()=='')
	{
		msg += "Uzupełnij swoje imię\n";
	}
	
	if (msg)
	{
		alert(msg);
		return false;
	}
	
	return true;
}