function gid(o){return document.getElementById(o);}

//funkcja deszyfrujaca email i otwierajaca domyslnego klienta poczty

function wyslijEmail(email)
{
	email2 = decode64(email);


	document.location = 'mailto:'+email2;
}

function pokazEmail(email)
{
	email2 = decode64(email);

	document.write(email2);
}

//funkcja pobierajaca kanal RSS

function pobierzRSS(url)
{
	advAJAX.get({
		url: "/rss/rss.php?url="+escape(url),
		unique: false,
		onSuccess : function(obj)
		{

			gid('content').innerHTML = obj.responseText;

		},
		onError : function(obj) {
			alert("blad");
		}
	});


}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function dodajElement(formName, elementName)
{
	currentElement = document.createElement("input");
	currentElement.setAttribute("type", "hidden");
	currentElement.setAttribute("name", elementName);
	currentElement.setAttribute("id", "id_"+elementName);
	currentElement.setAttribute("value", "lararara");

	document.forms[formName].appendChild(currentElement);
}

function sprawdz_rejestracja()
{
	EMAILre = /^([a-zA-Z0-9][\w\.-]*[a-zA-Z0-9])/;

	if (gid('id_imie').value.length == 0)
	{
		alert("Musisz wpisać Imię!");
		gid('id_imie').focus();

		return false;
	}
	
	if (gid('id_login').value.length == 0)
	{
		alert("Musisz wpisać Login!");
		gid('id_login').focus();

		return false;
	}

	if (gid('id_login').value.length > 0 && !EMAILre.test(gid('id_login').value))
	{
		alert("Niepoprawny login, dozwolone litery, cyfry i - !");
		gid('id_login').focus();

		return false;
	}

	if (gid('id_haslo').value.length == 0)
	{
		alert("Musisz wpisać hasło!");
		gid('id_haslo').focus();

		return false;
	}
	
	if (gid('id_haslo').value.length < 6)
	{
		alert("Hasło musi mieć co najmniej 6 znaków!");
		gid('id_haslo').focus();

		return false;
	}

	if (gid('id_haslo_2').value.length == 0)
	{
		alert("Musisz powtórzyć hasło!");
		gid('id_haslo_2').focus();

		return false;
	}
	
	if (gid('id_haslo').value != gid('id_haslo_2').value)
	{
		alert("Hasła nie są takie same!");

		return false;
	}
}