/*
 * funkce pro prolinani obrazku
 */
                    var obr=2;
                    var obr1=1;
                    var opacity=1;
                    var nopacity=0;
                    var files=["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg"];
                    

                    function readCookie(name) {
                        var nameEQ = name + "=";
                        var ca = document.cookie.split(';');
                        for(var i=0;i < ca.length;i++) {
                            var c = ca[i];
                            while (c.charAt(0)==' ') c = c.substring(1,c.length);
                            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
                        }
                        return null;
                    }

                    function setCookie(key, value, days, path, domain, secure) {
                        value = encodeURIComponent(value); // hodnota value by měla být minimálně escapována pomocí funkce escape()
                        //value+='; domain='+domain;
                        value+='; path='+path;
                        var date = new Date();
                        date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
                        value+='; expires=' + date.toGMTString();

                        if (secure) value+='; secure';
                        document.cookie = key + '=' + value;
                        //document.cookie ='ppkcookie1=testcookie; expires=Thu, 2 Aug 2010 20:47:11 UTC; path=/';
                    }

                    function obrazky(){
                        var cookie=readCookie("obrazek");

                        if(cookie==null){
                            if(document.obraz.style.display=="none"){ //nastavuju dalsi obrazek
                                document.obraz.src=filepath+files[obr];
                            }
                            if(document.obraz1.style.display=="none"){ //nastavuju dalsi obrazek
                                document.obraz1.src=filepath+files[obr];
                            }
                            if(obr==4)obr=0
                            else obr++;
                            obr1++;

                            if(obr1>5)idr="o5";
                            else idr="o"+(obr1-1);
                            elm_obraz=document.getElementById(idr);
                            elm_obraz.className="";

                            if(obr1>5)obr1=1;
                            idr="o"+obr1;
                            elm_obraz=document.getElementById(idr);
                            elm_obraz.className="active";
                        }
                        else{
                            idobr="o"+cookie;
                            elm_obraz=document.getElementById(idobr);
                            elm_obraz.className="active";

                            if(document.obraz.style.display!="none"){ //nastavuju obrazek, ktery se ma zobrazovat
                                document.obraz.src=filepath+cookie+".jpg";
                                document.obraz.style.opacity = 1;
                                document.obraz.style.MozOpacity = 1;
                                document.obraz.style.filter = "alpha(opacity=" + (100) + ")";
                            }
                            if(document.obraz1.style.display!="none"){ //nastavuju obrazek, ktery se ma zobrazovat
                                document.obraz1.src=filepath+cookie+".jpg";
                                document.obraz1.style.opacity = 1;
                                document.obraz1.style.MozOpacity = 1;
                                document.obraz1.style.filter = "alpha(opacity=" + (100) + ")";
                            }
                        }
                    }

                    function obrazekCookie(cislo){
                        var cookie=readCookie("obrazek");
                        if(cookie==cislo){
                            if(cookie==5)obr=0;
                            else obr=cookie;
                            obr1=cislo-1;
                            setCookie("obrazek","",0,"/","","");
                            idobr="o"+cislo;
                            elm_obraz=document.getElementById(idobr);
                            elm_obraz.className="";
                        }
                        else{
                            if(cookie){
                                idobr="o"+cookie;
                                elm_obraz=document.getElementById(idobr);
                                elm_obraz.className="";
                            }
                            setCookie("obrazek",cislo,1,"/","","");
                            idobr="o"+obr1;
                            elm_obraz=document.getElementById(idobr);
                            elm_obraz.className="";
                            idobr="o"+cislo;
                            elm_obraz=document.getElementById(idobr);
                            elm_obraz.className="active";
                        }
                        obrazky();
                    }

                    function opacitySet(opacity,nopacity){
                                document.obraz.style.opacity = opacity;
                                document.obraz.style.MozOpacity = opacity;
                                document.obraz.style.filter = "alpha(opacity=" + (opacity*100) + ")";

                                document.obraz1.style.opacity = nopacity;
                                document.obraz1.style.MozOpacity = nopacity;
                                document.obraz1.style.filter = "alpha(opacity=" + (nopacity*100) + ")";
                    }

                    function down(){
                            var cookie=readCookie("obrazek");
                            if(cookie){
                                idobr="o"+cookie;
                                elm_obraz=document.getElementById(idobr);
                                elm_obraz.className="active";
                            }

                            if(cookie==null){
                                opacity=opacity-0.05;
                                nopacity=nopacity+0.05;

                                opacitySet(opacity,nopacity);

                                document.obraz.style.display="block";
                                document.obraz1.style.display="block";

                             }
                             if(opacity>0.1){
                                setTimeout("down()",35);
                             }
                             else{
                               opacity=0;
                               nopacity=1;

                               opacitySet(opacity,nopacity);

                               document.obraz.style.display="none";
                               document.obraz1.style.display="block";
                               obrazky();
                               setTimeout("up()",4000);
                             }
                    }
                    function up(){
                            var cookie=readCookie("obrazek");
                            if(cookie){
                                idobr="o"+cookie;
                                elm_obraz=document.getElementById(idobr);
                                elm_obraz.className="active";
                            }
                            
                            if(cookie==null){
                                opacity=opacity+0.05;
                                nopacity=nopacity-0.05;

                                opacitySet(opacity,nopacity);

                                document.obraz.style.display="block";
                                document.obraz1.style.display="block";

                             }
                             if(nopacity>0.1){
                                setTimeout("up()",35);
                             }
                             else{
                               opacity=1;
                               nopacity=0;

                               opacitySet(opacity,nopacity);

                               document.obraz.style.display="block";
                               document.obraz1.style.display="none";
                               obrazky();
                               setTimeout("down()",4000);
                             }
                    }
