﻿// JavaScript Document
function PokazGradacje()
{
var akapit = document.getElementById('gradacja');
var view = akapit.style.display;
	if (view == "block")
	{
	akapit.style.display = "none";
	}
	if (view == "none")
	{
	akapit.style.display = "block";
	}
}
function confirm_delete(url)
{
	if(confirm('Czy na pewno usunąć ???')) window.location = url;

}
function goto_link(url)
{
	window.location = url;

}
function showhide(nazwa)
{
	var nazwa2 = nazwa+'_img';

	if(document.getElementById(nazwa).style.display=='block')
	 {
		 document.getElementById(nazwa).style.display='none';
	 } else {

		 document.getElementById('mail_inbox').style.display='none';
		 document.getElementById('mail_outbox').style.display='none';
		 document.getElementById('mail_new').style.display='none';
		 document.getElementById(nazwa).style.display='block';
	 }
}
function showhide_avatars()
{
	var nazwa = 'avatars_gallery';

	if(document.getElementById(nazwa).style.display=='block')
	 {
		 document.getElementById(nazwa).style.display='none';
	 } else {

		 document.getElementById(nazwa).style.display='block';
	 }
}


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=480,height=340,left = 600,top = 375');");
}

function sh_cat(id)
{
	var nazwa = 's'+id;
	if(document.getElementById(nazwa).style.display == 'block')
	{
		document.getElementById(nazwa).style.display = 'none';
	} else {
		document.getElementById(nazwa).style.display = 'block';
	}
}
function mail(user, domain){window.location = 'mailto:'+user+'@'+domain;}

function ValidEmail(src)
{
var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
return regex.test(src);
}


function checkcontact() {

var form = document.getElementById('contact');

if(form.imie.value=='' || form.imie.value==null || form.nazwisko.value=='' || form.nazwisko.value==null || form.email.value=='' ||  form.email.value==null || form.temat.value=='' || form.temat.value==null || form.msg.value==null || form.msg.value=='') {

alert('Wymagane jest wypełnienie wszystkich pól !');
return false;

} else {



if(ValidEmail(form.email.value)) {

return true;

} else {

alert('Nieprawidłowy format adresu email !');
return false;

}


}


}

function step1()
{
form = document.getElementById('step1');

if(form.new_tytul.value=='' || form.new_tytul.value==null || form.new_main.value=='' || form.new_main.value==null)
{
alert('Wypełnij wszystkie pola/dodaj zdjęcie !');
return false;
} else {
return true;
}

}

function polec(adres) {
wspolrzednax = (screen.width-480)/2;
wspolrzednay = (screen.height-300)/2;
noweOkno = window.open(adres, 'rafiner','menubar=no, toolbar=no, scrollbars=no, resizable=no,location=no, status=no, width=480, height=300, left='+wspolrzednax+', top='+wspolrzednay+'')
noweOkno.focus()
};


function submit_item()
{
form = document.getElementById("edititem");
if(checkedit()) form.submit();

}

function checkedit()
{
var form = document.getElementById("edititem");
if(form.edit_tytul.value=="" || form.edit_tytul.value==null)
{
alert("Podaj tytul !");
return false;

} else {

if(form.edit_cat.selectedIndex!=0)
{
form.submit();
return true;
} else {
alert("Wybierz kategorie!");
return false;

}

}

}

function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}

function delete_konto(link) {

if(confirm('Czy na pewno chcesz usunąć to konto ?')) window.location = link;

}


function check_polec() {

var form = document.getElementById('polec');

if(form.imie.value=='' || form.imie.value==null || form.odbiorca_email.value=='' || form.odbiorca_email.value==null || form.email.value=='' ||  form.email.value==null || form.koment.value=='' || form.koment.value==null) {

alert('Wypełnij wszystkie pola !');
return false;

} else {

if(ValidEmail(form.odbiorca_email.value)) {

if(ValidEmail(form.email.value)) {

return true;

} else {

alert('Nieprawidłowy format Twojego adresu email !');
return false;

}


} else {

alert('Nieprawidłowy format adresu email odbiorcy!');
return false;

}


}


}


