﻿    var currentPage = 0;
    var highlights = [];
    var intervalID = 0;
    
    function SlideShow() {
        var pageNumber = currentPage + 1;
        if (currentPage == highlights.length - 1) {
            pageNumber = 0;
        }

        ChangeHighlight(pageNumber)


        var link = jQuery(".highlightNavigationLink").get(currentPage);
        ColorLink(link);

        
    }

    
    function Initialize() {
        var page = 0;
        var pictureUrl = highlights[page].url;
        var title = highlights[page].title;
        var pictureType = 1;

        //alert(title);
        if (pictureUrl.substring(pictureUrl.lastIndexOf('.') + 1) == "swf") {
            pictureType = 2;
        }

        $top = jQuery("#highlight-container-first-page-background2");
        $bottom = jQuery("#highlight-container-first-page-background1");

        $bottom.css("dsiplay", "none");
        $top.css("display", "block");
        if (pictureType == 1) {
            $top.css("background-image", "url('" + pictureUrl + "')");
            jQuery("#mymovie").remove();
        }
        else {
            $top.css("background-image", "none");
            var so = new SWFObject(pictureUrl, "mymovie", "400", "100%", "8", "#336699");
            so.addParam("wmode", "transparent");
            so.write($botom.attr("id"));
        }

        jQuery(".highlight-content-vec").html(title);

        var link = jQuery(".highlightNavigationLink").get(currentPage);
        ColorLink(link);
    }

    function GoToPage(page, link) {
        clearInterval(intervalID);
        ChangeHighlight(page);
        ColorLink(link);
    }

    function ColorLink(link) {
        jQuery(".highlightNavigationLink").css("background", "#abcc00");
        jQuery(link).css("background", "#f6f6f6"); 
    }

    function ChangeHighlight(page) {
        var pictureUrl = highlights[page].url;
        var title = highlights[page].title;
        var pictureType = 1;
        if (pictureUrl.substring(pictureUrl.lastIndexOf('.') + 1) == "swf") {
            pictureType = 2;
        }


        if (currentPage != page) {

            var $botom = jQuery("#highlight-container-first-page-background1");
            var $top = jQuery("#highlight-container-first-page-background2");

            if ($top.css("display") == "none") {
                $botom = jQuery("#highlight-container-first-page-background2");
                $top = jQuery("#highlight-container-first-page-background1");
            }

            if (pictureType == 1) {
                $botom.css("background-image", "url('" + pictureUrl + "')");
                jQuery("#mymovie").remove();
            }
            else {
                $botom.css("background-image", "none");
                var so = new SWFObject(pictureUrl, "mymovie", "400", "100%", "8", "#336699");
                so.addParam("wmode", "transparent");
                so.write($botom.attr("id"));

            }
            
            $botom.fadeIn("slow");
            $top.fadeOut("slow");

            jQuery(".highlight-content-vec").html(title);
            
            currentPage = page;
        }
    }