
        var dialogWindow = null;
        var theField = null;

        function ShowDialog(theInput,url) {
                var y2,m2,d2;
        theField = eval( "document.forms.rezervace." + theInput );
                if (theInput == "datum_vraceni") {
                    sep2 = document.forms.rezervace.datum_zapujceni.value.split(".");
                    d2 = sep2[0];
                    m2 = sep2[1]-1;
                    y2 = sep2[2];
            if (y2 == "")
                y2 = new Date().getFullYear();
                }
                sep = theField.value.split(".");
                if (sep[2] == "")
                    sep[2] = new Date().getFullYear();

        dialogWindow=window.open(url + "Y=" + sep[2] + "&M=" + (sep[1]-1) + "&Y2=" + y2 + "&M2=" + m2 + "&D2=" + d2,"MyDialog",
                    "dependent=yes, menubar=no, location=no, resizable=no, width=217, height=196, toolbar=no, scrollbars=no, left=100, top=100" );
        }

        function HideDialog() {
            if( dialogWindow != null ) {
                if (typeof(dialogWindow.document) == "object")
                    dialogWindow.close()
            }
        }

        function Transfer( theValue ) {
            if( theField != null )
                        theField.value = theValue;
                sepTo = document.forms.rezervace.datum_vraceni.value.split(".");
                sepValue = theValue.split(".");
                to = new Date(sepTo[2],sepTo[1]-1,sepTo[0]);
                from = new Date(sepValue[2],sepValue[1]-1,sepValue[0]);
                if (from.getTime() > to.getTime()) {
                        newTime = from.getTime() + (1000 * 60 * 60 * 24 * 7);
                        to.setTime(newTime);
                        document.forms.rezervace.datum_vraceni.value = getZero(to.getDate()) + "." + getMonth(to.getMonth()) + "." + to.getFullYear();
                }
        }


        function getZero( date ) {
                if (date < 10)
                        return "0" + date;
                else
                        return date;
        }

        function getMonth( month ) {
                month += 1;
                return getZero(month);
        }


 
        function open_window(URL , width, height) {
                var left = Math.round((screen.width - width) / 2);
                var top = Math.round((screen.height - height) / 2);
                window.open(URL,'','height=' + height + ',width=' + width + ',left=' + left + ',top=' + top);
        }
