// JQuery JavaScript Document
$(document).ready(function(){

        /*
         * Global vars
         */
         var s = 0;
         var n = $(".thumbs-box ul li").length;
         $(".thumbs-box ul li").bind("mouseenter",hoverItem);
         $("#thumb-select").click(function () {
                 window.location = $(".thumbs-box ul li:eq("+s+") > a").attr("href");
         });

        /*
        * function mouse enter Motion
        */
        function hoverItem(){
                clearInterval(gallery_interval);
                s = $(".thumbs-box ul li").index(this);
                showItem();
        }

        function showItem(){
                var xPos = s*111 + 11;
                $("#thumb-select").animate({left: xPos}, "fast");

                // hide unselected main content and show selection
                if( $(".main-box ul li:eq("+s+")").css("display") == "none") {
                        for(var i=0; i<n; i++){
                                if(i != s){
                                        //hideHeader(i);
                                        $(".main-box ul li:eq("+i+")").fadeOut("slow", function () {
                                                $(".main-box ul li:eq("+s+")").fadeIn("slow");
                                        });
                                }
                        }
                }
        }

         /*
         * function galleryTimer
         * this timer cycles through the images
         */
         function galleryTimer() {
                //hideHeader(s);
                if(s < n-1) {
                        s++;
                } else {
                        s=0;
                }
                showItem();
         }

        /*
         * function selectThumbnail
         * hide the H2 header
         */
         function clickItem() {
                window.location=$(this).find("a").attr("href"); return false;
         }

         /*
         * Initialize script
         */
         showItem();
         gallery_interval = setInterval(galleryTimer,7000);



 });