function dim(m,y)
{
	var days = 32 - new Date(y,m,32).getDate();
	var obj = $$('date_day');
	obj.length = 0;
	for (var i=0; i<days; i++)
	{
		var day = i+1;
		obj.options[i]=new Option(day,day,i==0,false);
	}
}

function rejestruj() {
	advAJAX.assign($$('marginForm'), {
		onInitialization : function(obj) {
			$$('button').value = 'Rejestruję...';
		},
		
		onSuccess : function(obj) {
			var rs = obj.responseText;
			
			if (rs == '1')
			{
				$$('rejestruj').innerHTML = '';
				alert('Zarejestrowano! Odbierz e-mail.');
				content('login');
			}
			else if (rs == -1)
				alert('Wypełnij wszystkie pola!');
			else if (rs == -2)
				alert('Wpisane hasła są różne od siebie!');
			else if (rs == -8)
				alert('Hasło może się składać wyłącznie z liter, cyfer oraz znaku _\nMinimalnie 4 znaki, maksymalnie 12.');
			else if (rs == -3)
				alert('Podany login już istnieje. Spróbuj inny.');
			else if (rs == -4)
				alert('Podany e-mail już istnieje. Spróbuj inny');
			else if (rs == -5)
				alert('Podaj prawidłowy e-mail');
			else if (rs == -6)
				alert('Podaj prawidłową datę urodzenia');
			else if (rs == -7)
				alert('Login może się składać wyłącznie z liter, cyfer oraz znaku _\nMinimalnie 4 znaki, maksymalnie 12.');
			else if (rs == -10)
				alert('Wpisz poprawny kod z obrazka!');
			else if (rs == -11)
				alert('Musisz zaakceptować regulamin!');
			else if (rs == -12)
				alert('Taki login juz istnieje. Wybierz inny.');
			else if (rs == -13)
				alert('Ktoś się rejestrował kilka sekund temu z Twojego adresu - spróbuj za chwilę.');
			else alert('Błąd rejestracji. Spróbuj później');
		}
	});
}

function loguj(go_to_after) {

advAJAX.assign($$('marginForm'), {
	onSuccess : function(obj)
	{
		var response = obj.responseText;

		//alert(document.forms[0])
		
		if (response == -4) {
			alert ('Konto zablokowane... przykro nam, złamałeś regulamin!');
		} else if (response == -3) {
			alert ('Konto nieaktywne. Obierz mail aktywacyjny po rejestracji.');
		} else if (response == -2)
		{
			alert('Podano nieprawidłowe dane!\nSpróbuj jeszcze raz...');
		}
		else if (response == -1)
		{
			alert('Podaj login oraz hasło');
		}
		else if (response == 1)
		{
		
		    if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
			window.location = '/';
		    } else {
			if (typeof go_to_after == 'undefined')
				window.location.href = '/';
			else
				window.location.href = go_to_after;			
		    }
		    
		}
		else
		{
			//alert(response);
		}
	}
});

}