function SprDodKom(){
    Imie = document.getElementById("Imie").value;
    if (Imie == "" ){
        alert ('Imię musi być podane');        
        return false;
    }    
    if (Imie.indexOf("http://")!=-1) {
        alert("Nie można wklejać linków do innych stron");
        return false;
    }
    Tresc = document.getElementById("Tresc").value;
    if (Tresc.indexOf("http://")!=-1) {
        alert("Nie można wklejać linków do innych stron");
        return false;
    }

    return true;
}

function SprKontakt(){    
    mail = document.getElementById("mail").value;
    
    if (mail == "" ){
        alert ('E-mail musi być podany');        
        return false;
    }    
    return true;
}
//********************************************************************************
var CAlbumy = function (id, ilosc_zdj){        
    Album_obj = this;
    this.location_album = "";
    this.katalog = "";
    this.active_id = id;
    this.next_id = id+1;
    this.prev_id = id-1;
    this.max_zdjec = ilosc_zdj;    
    this.koniec = 0;
    this.RunSlide = 0;
    this.tab_zdjecia = [];
    if (id == 0 || id == ilosc_zdj-1)
        this.koniec = 1;    
    if (id == 0)    
        document.getElementById("lewyButton_menu").style.visibility = "hidden";
    if (id == ilosc_zdj-1)
        document.getElementById("prawyButton_menu").style.visibility = "hidden";
}

CAlbumy.prototype.wysunPrzycisk = function(obj){    
    button = document.getElementById(obj);    
    if ( (obj == "lewyButton" && this.active_id != 0) || (obj == "prawyButton" && this.active_id != this.max_zdjec -1) )
    {            
        button.style.filter = "alpha(opacity = 50)";
        button.style.opacity = 0.5;
        button.style.cursor = "pointer";
    }
    else
    {
        button.style.cursor = "default";
    }
}

CAlbumy.prototype.schowajPrzycisk = function(obj){
    button = document.getElementById(obj);
    button.style.filter = "alpha(opacity = 0)";
    button.style.opacity = 0;
    button.style.cursor = "default";
}

CAlbumy.prototype.podmienZdjecie = function (zdj_id){
    album = document.getElementById("main_photo_img");
    album.src = zdj_id;
    if ( document.form_wybor )
    {
        document.form_wybor.zdjecie_id.value = zdj_id;
        ajaxFunction("sprawdzWybor");
        wyczysc_opis();
    }
}

CAlbumy.prototype.WyswietlZdjecie = function (id){
    this.active_id = id;
    this.next_id = id+1;
    this.prev_id = id-1;

    if (id == 0 || id == this.max_zdjec-1)
        this.koniec = 1;
    if (id == 0)
        document.getElementById("lewyButton_menu").style.visibility = "hidden";
    if (id == this.max_zdjec-1)
        document.getElementById("prawyButton_menu").style.visibility = "hidden";

    this.podmienZdjecie(this.location_album + "/" + this.tab_zdjecia[this.active_id]);
}

CAlbumy.prototype.NastepneZdjecie = function (){    
    if (this.active_id != this.max_zdjec - 1){ 
        this.prev_id = this.active_id;
        this.active_id = this.next_id;    
        this.next_id++;
        this.podmienZdjecie(this.location_album + "/" + this.tab_zdjecia[this.active_id]);
        //album = document.getElementById("main_photo_img");
        //album.src = this.location_album + "/" + this.tab_zdjecia[this.active_id];
        
        document.getElementById("prawyButton_menu").style.visibility = "visible";
        document.getElementById("lewyButton_menu").style.visibility = "visible";
        if (this.active_id == this.max_zdjec - 1){
            this.schowajPrzycisk("prawyButton");
            document.getElementById("prawyButton_menu").style.visibility = "hidden";
        }        
    }
    else{        
        this.koniec = 1;
        this.schowajPrzycisk("prawyButton");
        document.getElementById("prawyButton_menu").style.visibility = "hidden";        
        if (this.RunSlide == 1)
            this.SlideShow();
    }    
}
CAlbumy.prototype.PoprzednieZdjecie = function (){    
    if (this.active_id != 0){
        document.getElementById("lewyButton_menu").style.visibility = "visible";
        document.getElementById("prawyButton_menu").style.visibility = "visible";
        this.next_id = this.active_id;
        this.active_id = this.prev_id;            
        this.prev_id--;
//        album = document.getElementById("main_photo_img");
//        album.src =this.location_album + "/" + this.tab_zdjecia[this.active_id];
        this.podmienZdjecie(this.location_album + "/" + this.tab_zdjecia[this.active_id]);
        if (this.active_id == 0){
            this.schowajPrzycisk("lewyButton");
            document.getElementById("lewyButton_menu").style.visibility = "hidden";
        }
    }
    else{        
        this.koniec = 1;
        this.schowajPrzycisk("lewyButton");
        document.getElementById("lewyButton_menu").style.visibility = "hidden";
    }     
}

CAlbumy.prototype.SlideShow = function(){
    if (this.RunSlide == 0){
        this.RunSlide = 1;    
        interval_slide_show = setInterval("Album_obj.NastepneZdjecie()",3000);
        document.getElementById("SlideShow_img").src = "images/pause.gif";
    }
    else{
        this.RunSlide = 0;
        clearInterval(interval_slide_show);
        document.getElementById("SlideShow_img").src = "images/play.gif";
    }
}
CAlbumy.prototype.ToURL = function(){
    tmp = "albumy.php?album=" + this.katalog + "&nr="+this.active_id;
    document.location = tmp;
}
CAlbumy.prototype.ActiveButton = function(nr, nazwa){
    stary = "_a.gif";
    nowy = ".gif";
    if (nr == 1){
        tmp = stary;
        stary = nowy;
        nowy = tmp;
    }
        
    pozycja = document.getElementById(nazwa);    
    pozycja.src = pozycja.src.replace(stary,nowy);
    
}

