        var cii         = new Array()
    
        function cacheImg(name) {
            var newElem=new Image();
            newElem.src=name;
            cii[name]=newElem;
        }

        function precacheImg(name, film) {
            cacheImg(_rootdir_+"img/menu/" + name + "_normal.gif");
            cacheImg(_rootdir_+"img/menu/" + name + "_mouseOver.gif");
            cacheImg(_rootdir_+"img/menu/" + name + "_selected.gif");
        }

        function setImg(name, mode) {
            imgSrc = _rootdir_+"img/menu/" + name + "_" + mode + ".gif";
            document.images[name].src = imgSrc;
        }


        function setSelected(name) {
            if (document.selected!=null) {
                selected          = document.selected;
                document.selected = null;
 
                setNormal(selected);
            }

            setImg(name, "selected");
 
            document.selected = name;

            return true;
        }

        function setMouseOver(name) {
            if (document.selected!=name) {
                setImg(name, "mouseOver");
            }
        }
        
        function setNormal(name) {
            if (document.selected!=name) {
                setImg(name, "normal");
            }
        }

        function resetAll() {
            selected = document.selected;
            document.selected=null;

            setNormal(selected);
        }

        function getDocument(url) {
            idx = url.lastIndexOf(".");

            if (0<idx) {
 
                pgIDX = url.substr(idx-1, 1);
                
                if ( ("2"<=pgIDX) && ("9">=pgIDX) ) {
                    ret = url.substr(url, idx-1) + "1";
                } else {
                    ret = url.substr(url, idx);
                }
            } else {
                ret = url;
            }

            return ret;
        }

        function getSuffix(url) {
            idx = url.lastIndexOf(".");

            if (0<idx) {
                ret = url.substr(idx+1);
            } else {
                ret = "";
            }

            return ret;
        }

        function dirname(path) {
            idx = path.lastIndexOf("/");

            if (0<idx) {
                ret = path.substr(0, idx+1);
            } else {
                ret = "";
            }

            return ret;
        }
        
        function openLinkWithSuffix(name, page, suffix, frames) {
            // frames:
            // 1: just content
            // 2: content + menuRight
            // 3: allFrames

            if (("none"!=name) && ("filminfo"!=name)) {
                setSelected(name);
                setImg(name, "selected");
            }

            if ((2==frames) || (3==frames) ) {
                doc = getDocument(page);
                parent.frames['content'].location=page;
                parent.frames['submenuright'].location=doc+"MenuRight."+suffix;

                if (3==frames) {
                    if ("filminfo"==name) {
                        dname=dirname(doc);
                        parent.frames['title'].location=dname+"title."+suffix
                        parent.frames['submenuleft'].location=dname+"menuLeft."+suffix;
                    } else if ("DocumentaryCinema"==name) {
                        dname=dirname(doc);
                        parent.frames['title'].location=dname+"title."+suffix;
                        parent.frames['submenuleft'].location=dname+"menuLeft."+suffix;
                    } else {
                        parent.frames['title'].location=doc+"Title."+suffix;
                        parent.frames['submenuleft'].location=doc+"MenuLeft."+suffix;
                    }
                }
            } else {
                parent.frames['content'].location=page;
            }
        }

        function openLink(name, page, frames) {
            // frames:
            // 1: just content
            // 2: content + menuRight
            // 3: allFrames

            openLinkWithSuffix(name, page, getSuffix(page), frames);
        }
        
        function justOpenPage(src) {
            parent.frames['title'].location=_rootdir_+"/empty/emptyWhite.html";
            parent.frames['submenuleft'].location=_rootdir_+"/empty/emptyWhite.html";
            parent.frames['submenuright'].location=_rootdir_+"/empty/emptyWhite.html";
            parent.frames['content'].location=src;
        }
