function checkOldPassword()
{
	bBool = false;
	if ($('#oldPassForm')[0].value.match(/^.{6,18}$/i))
	{
		if (bBool==true)
			return true;
		$('#oldPassType').css('background-image','url(images/bg_form_ok.gif)');
	}
	else
	{
		if (bBool==true)
			return false;
		$('#oldPassType').css('background-image','url(images/bg_form_error.gif)');
	}
}

function checkPassword()
{
	bBool = false;
	if ((arguments.length>0)&&(arguments[0]==true))
		bBool = true;

	if ($('#passForm')[0].value=='')
	{
		if (bBool==true)
			return false;
		$('#passType').css('background-image','');
		if ($('#pass2Form')[0].value!='')
		{
			if (bBool==true)
				return false;
			$('#pass2Type').css('background-image','url(images/bg_form_error.gif)');
		}

		return 0;
	} else {
		if ($('#pass2Form')[0].value=='')
		{
			if (bBool==true)
				return false;
			$('#pass2Type').css('background-image','');
		} 
		{
			if ($('#passForm')[0].value.match(/^.{6,18}$/i))
			{
				if (bBool==true)
					return true;
				$('#passType').css('background-image','url(images/bg_form_ok.gif)');
			} else {
				if (bBool==true)
					return false;
				$('#passType').css('background-image','url(images/bg_form_error.gif)');
			}


			if (($('#passForm')[0].value==$('#pass2Form')[0].value))
			{	
				if (bBool==true)
					return true;
				$('#pass2Type').css('background-image','url(images/bg_form_ok.gif)');
			}
			else
			{
				if (bBool==true)
					return false;
				$('#pass2Type').css('background-image','url(images/bg_form_error.gif)');
			}
		}
	}
}

function checkPseudo()
{
	/*bBool = false;
	if ((arguments.length>0)&&(arguments[0]==true))
		bBool = true;

	if ($('#pseudo')[0].value=='')
	{
		if (bBool==true)
			return false;
		$('#pseudoType').css('background-image','');
		return 0;
	}

	if ($('#pseudo')[0].value.match(/^[A-Z0-9]{3,10}$/i))
	{
		if (bBool==true)
			return true;
		$('#pseudoType').css('background-image','url(images/bg_form_ok.gif)');
	}
	else
	{
		if (bBool==true)
			return false;
		$('#pseudoType').css('background-image','url(images/bg_form_error.gif)');
	}*/
	return true;
}

function checkLogin()
{
	bBool = false;
	if ((arguments.length>0)&&(arguments[0]==true))
		bBool = true;

	if ($('#loginForm')[0].value=='')
	{
		if (bBool==true)
			return false;
		$('#loginType').css('background-image','');
		return 0;
	}

	if ($('#loginForm')[0].value.match(/^[a-zA-ZęóąśłżźćńĘÓĄŚŁŻŹĆŃ0-9_\-]{3,10}$/i))
	{
		if (bBool==true)
			return true;
		$('#loginType').css('background-image','url(images/bg_form_ok.gif)');
	}
	else
	{
		if (bBool==true)
			return false;
		$('#loginType').css('background-image','url(images/bg_form_error.gif)');
	}
}


function checkEmail()
{
	bBool = false;
	if ((arguments.length>0)&&(arguments[0]==true))
		bBool = true;

	if ($('#email')[0].value=='')
	{
		if (bBool==true)
			return false;
		$('#emailType').css('background-image','');
		return 0;
	}

	if ($('#email')[0].value.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i))
	{
		if (bBool==true)
			return true;
		$('#emailType').css('background-image','url(images/bg_form_ok.gif)');
	}
	else
	{
		if (bBool==true)
			return false;
		$('#emailType').css('background-image','url(images/bg_form_error.gif)');
	}
}

function updateUser() {
	if (checkEmail(true))
	{
		$('#formProfil').submit();
	}
}

function newUser() {
	if (checkLogin(true)&&checkEmail(true)&&checkPassword(true)&&checkPseudo(true))
	{
		$('#formProfil').submit();
	}
}


function getAllArticles() {
	if (iStartAll == undefined)
	{
		return false;
	}
	$('#showAllArt').html('wczytywanie ...');
	$.ajax({
		  type: "POST",
		  url: "ajax-getart.html",
		  data: "iStart="+iStartAll,
		  dataType: "xml",
		  success: function(xml){
			$('ul#listArt li.last').removeClass('last');
			$('#liArt').after($(xml).find('dane').text());
			$('#liArt').remove();
		  },
		  error: function () {$('#showAllArt').html('błąd w połączeniu');}
	});
}
