function clearForm(AForm)
{
    for (i = 0; i < AForm.elements.length; i++) {
        if (AForm.elements[i].type == "radio") {
            AForm.elements[i].checked = false;
        } else if (AForm.elements[i].type == "checkbox") {
            AForm.elements[i].checked = false;
        } else if (AForm.elements[i].type == "text") {
            AForm.elements[i].value = '';
        } else if (AForm.elements[i].type == "textarea") {
            AForm.elements[i].value = '';
        } else if (AForm.elements[i].type == "select-one") {
            AForm.elements[i].selectedIndex = 0;
        } else if (AForm.elements[i].type == "select-multiple") {
            AForm.elements[i].selectedIndex = -1;
        }
    }
    return true;
}

function validateForm(AForm)
{
    //1. login
    reg = /^[{1,2,3,4,5,6,7,8,9,0}a-zA-Z±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]{2,20}$/;
    wyn = AForm.login.value.match(reg);
    if (wyn == null) {
        alert("Type Your login correctly. " +
              "The lenght of login have to be from 2 to 20 letters. "
              );
        return false;
    }
    //2. password
    reg = /^[{1,2,3,4,5,6,7,8,9,0}a-zA-Z±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]{2,20}$/;
    wyn = AForm.haslo.value.match(reg);
    if (wyn == null) {
        alert("Type Your password correctly. " +
              "The lenght of password have to be from 2 to 20 letters. "
              );
        return false;
    }

    //4. name
    reg = /^[a-zA-Z±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]{2,20}$/;
    wyn = AForm.imie.value.match(reg);
    if (wyn == null) {
        alert("Type Your name correctly. " +
              "The lenght of name have to be from 2 to 20 letters. " +
              "You can type only letters"
              );
        return false;
    }
    //5. surmane
    reg = /^[a-zA-Z±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]{2,20}$/;
    wyn = AForm.nazwisko.value.match(reg);
    if (wyn == null) {
        alert("Type Your surname correctly. " +
              "The lenght of surname have to be from 2 to 20 letters. " +
              "You can type only letters"
              );
        return false;
    }
    //6. Email
    reg = /^[a-zA-Z0-9±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬.-]{1,30}@[a-zA-Z0-9±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]+(\.[a-zA-Z0-9±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]+)+$/;
    wyn = AForm.email.value.match(reg);
    if (wyn == null) {
        alert("Type correct e-mail adress.");
        return false;
    }
    //7. kraj
    reg = /^[a-zA-Z±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]{2,20}$/;
    wyn = AForm.panstwo.value.match(reg);
    if (wyn == null) {
        alert("Type Your Country correctly. "
              );
        return false;
    }    
    //8. P³eæ
    if (!(AForm.plec[0].checked || AForm.plec[1].checked )) {
        alert("Please choose your 'sex'.");
        return false;
    };
    //9. Opis
    reg = /^[{1,2,3,4,5,6,7,8,9,0}a-zA-Z±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]{2,20}$/;
    wyn = AForm.tekst.value.match(reg);
    if (wyn == null) {
        alert("Fill Why You want to take a part in workshops . "
              );
        return false;
    }

    return true;
}

function checkForm(AForm)
{

    //1. name
    reg = /^[a-zA-Z±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]{2,20}$/;
    wyn = AForm.imie.value.match(reg);
    if (wyn == null) {
        alert("Type Your name correctly. " +
              "The lenght of name have to be from 2 to 20 letters. " +
              "You can type only letters"
              );
        return false;
    }
    //2. surmane
    reg = /^[a-zA-Z±æê³ñó¶¿¼¡ÆÊ£ÑÓ¦¯¬]{2,20}$/;
    wyn = AForm.nazwisko.value.match(reg);
    if (wyn == null) {
        alert("Type Your surname correctly. " +
              "The lenght of surname have to be from 2 to 20 letters. " +
              "You can type only letters"
              );
        return false;
    }
  return true;
}

function pokazFotke(nazwa){
	window.open('show_photo.php?photo='+nazwa, '', 'fullscreen=yes');
}
function pokazFotkeSilesia(nazwa){
	window.open('show_photo_silesia.php?photo='+nazwa, '', 'fullscreen=yes');
}
function pokazFotkeWystawa04(nazwa){
	window.open('show_photo_exhibition04.php?photo='+nazwa, '', 'fullscreen=yes');
}
function ForSureDelete()
{
  return confirm("Are You sure to delete this photo? ");
}
function ForSureDeleteComment()
{
  return confirm("Are You sure to delete this comment? ");
}
function ForSure()
{
  return confirm("Are You sure to delete this? ");
}
