
var Search = {

    resultList: "search-result",

    imgElm: "target-image",
    imgHeader: "image-header",
    textHeader: "text-header",
    textContent: "image-content-text",
    textFacts: "image-facts",
    imgHighRes: "high-res-image",

    movieElm: "movie",
    movieHeader: "movie-header",
    movieText: "movie-maintext",
    movieFacts: "movie-facts",

    Init: function () {
        if ($("search-result")) {
            alert("test");
            var rows = $(Search.resultList).getElementsByTagName("tr");
            if (rows) {
                for (var i = 0; i < rows.length; i++) {
                    if (rows[i]) {
                        elm = rows[i];
                        elm.onmouseover = Search.ToggleRows;
                        elm.onmouseout = Search.ToggleRows;
                    }
                }
            }
        }
    },

    ToggleRows: function () {
        if (!/result-over/i.test(this.className)) {
            General.addClassName(this, "result-over");
        } else {
            General.removeClassName(this, "result-over");
        }
    },

    OpenZoom: function () {
        Search.OpenWindow("/Templates/Public/Pages/ImageZoom.aspx?motivid=" + $("motivid").value, "zoom");
    },

    OpenWindow: function (aURL, aWinName) {
        var wOpen;
        var sOptions;

        sOptions = 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
        sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
        sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString();
        sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

        wOpen = window.open('', aWinName, sOptions);
        wOpen.location = aURL;
        wOpen.focus();
        wOpen.moveTo(0, 0);
        wOpen.resizeTo(screen.availWidth, screen.availHeight);
        return wOpen;
    },

    Image: function (oElm, imgPath, header, subHeader, text, facts, highRes, motivid) {
        var imageElm = $(General.imageElm);
        var imgElm = $(this.imgElm);
        var imgHeader = $(this.imgHeader);
        var textHeader = $(this.textHeader);
        var textContent = $(this.textContent);
        var textFacts = $(this.textFacts);
        var imgHighRes = $(this.imgHighRes);

        if (General.movieOpen) {
            General.removeClassName($(General.movieElm), "display-block");
        }
        imgElm.src = imgPath;
        /*
        var soImageZoom = new SWFObject("/gui/flash/image_zoom.swf", "zoom", "100%", "100%", "8", "#000000");
        soImageZoom.addVariable("imgURL", imgPath);
        soImageZoom.addVariable("imgWidth", "1695");
        soImageZoom.addVariable("imgHeight", "2258");
        soImageZoom.addParam("quality", "high");
        soImageZoom.addParam("menu", "false");
        soImageZoom.addParam("scale", "noscale");
        soImageZoom.addParam("align", "middle");
        soImageZoom.write("image-flash");
        */
        if (imgHeader && header) {
            imgHeader.childNodes[0].innerHTML = header;
        }

        if (textHeader && subHeader) {
            textHeader.innerHTML = subHeader;
        }
        if (textContent) {
            textContent.innerHTML = text;
        }
        if (textFacts && facts) {
            textFacts.innerHTML = facts;
        }
        if (imgHighRes && highRes) {
            imgHighRes.href = highRes;
        }
        General.PositionImageSearch(oElm, "image");
        General.addClassName(imageElm, "display-block");
        General.removeClassName(imageElm, "display-none");
        General.imageOpen = true;
        $("motivid").value = motivid;
    },

    PrintImage: function () {
        if (document.createStyleSheet) {
            var newStyle = document.createStyleSheet("/gui/css/print-image.css", 0)
            newStyle.media = "print";
        }
        else {
            var styles = "/gui/css/print-image.css";
            var newStyle = document.createElement("link");
            newStyle.rel = "stylesheet";
            newStyle.type = "text/css";
            newStyle.media = "print";
            newStyle.href = escape(styles);
            document.getElementsByTagName("head")[0].appendChild(newStyle);
        }
        window.print();
    }
}
//addEvent(window, "load", function () { Search.Init(); })


