﻿	    var isFirstLoad =       true;    
        var isPaused =          false;
        var isInAnimation =     false;
        var isThumbsOpen =      false;
        var intervalTime =       12000;
        var transitionSpeed =    800;
        var loadingIndex=        0;
        var currentIndex =       -1;
        var slideshow_interval;
        var _visibleIconsCount = 0;
        var _iconHeight =        40;
        var _minHeight = 180;
        var _curIconsPositionIndex = 0;

        $(document).ready(function () {
            $(window).resize(function () { resizeStage(); });
            closeTopMenu();
            resizeStage();
            prepareStage();
            setIconsScrollers();

            $(document).keydown(function (e) {
                if (_isAllLoaded) {
                    if (e.keyCode == 37) {
                        setAutoState(false); loadSlideByDirection(-1); //<<<
                        return false;
                    }
                    if (e.keyCode == 39) {
                        setAutoState(false); loadSlideByDirection(1); //>>>
                        return false;
                    }
                }
            });
            initHpFooterSitemap();//js external file
        });


        var isHpAllHidden = false;
        function hpCloseAllPanels() {
            isHpAllHidden = true;
            $("#nmenu").hide();
            $("#hpControlPanel").hide();
            $(".sm_wrapper").hide();
            $("#footerInnerWrapper").hide();
            $(".hpInfoPanel").hide();
            $(".userStatusPanel").hide();
            $("#btnCloseAllHp").hide();
            $("#btnShowAllHpWrapper").hide();
            $("#btnShowAllHpWrapper").show();
        }
        function hpShowAllPanels() {
            isHpAllHidden = false;
            $("#nmenu").show();
            $("#hpControlPanel").show();
            $(".sm_wrapper").show();
            $("#footerInnerWrapper").show();
            $(".hpInfoPanel").show();
            $(".userStatusPanel").show();
            $("#btnCloseAllHp").show();
            $("#btnShowAllHpWrapper").show();
            $("#btnShowAllHpWrapper").hide();
        }



        function prepareStage() {

            //setTimeout("resizeStage();", 2000); //only if ie7
            fixIEpng();            
            initPanelState();
            initInfoState();
            if (startInIndex > 0) {
                setAutoState(false);//pause 
            }
            loadImage(startInIndex); //(0);
        }

        //---------------------------------------------------------------
        //  RESIZE LOGIC
        //---------------------------------------------------------------
        function resizeStage()
        {
            resizeImg(currentIndex);
        }    
        function resizeImg(imgIndex)
        {
            var isIphone = false;
            if (userMode.indexOf("iphone")>-1){isIphone=true;}
        
            var imgObj = $('#img'+imgIndex);   
		    var ratio = 1608/1202;
		    var imagewidth = $(imgObj).width();
		    var imageheight = $(imgObj).height();
    		
		    var browserwidth = $(window).width();
		    var browserheight = $(window).height();
		    if(isIphone)
		    {
	            $(imgObj).height(browserheight);
	            $(imgObj).width(browserheight * ratio);	
                var newx = (browserheight - $(imgObj).width())/2;
	            $('#imgWrapper').css('left', newx+'px');		    
		    }
		    else
		    {
		        if ((browserheight/browserwidth) > ratio)
		        {
		            $(imgObj).height(browserheight);
		            $(imgObj).width(browserheight * ratio);		
		        } else 
		        {
		            $(imgObj).width(browserwidth);
		            $(imgObj).height(browserwidth / ratio);
		        }
                var newY = (browserheight - $(imgObj).height())/2;
                $('#imgWrapper').css('top', newY + 'px');

                //if ie fix menu and footer bug:
                if (jQuery.browser.msie) {
                    $(".hpMenuWrapper").css("width", browserwidth + "px");
                    $(".hpFooterWrapper").css("width", browserwidth + "px");
                }
		    }
        }        
        function resizeImg2(imgIndex)
        {
            var isIphone = false;
            if (userMode.indexOf("iphone")>-1){isIphone=true;}
            
            //{
                var imgObj = $('#img'+imgIndex);   
		        var ratio = 1608/1202;
		        var imagewidth = $(imgObj).width();
		        var imageheight = $(imgObj).height();
        		
		        var browserwidth = $(window).width();
		        var browserheight = $(window).height();
		        if (browserheight>browserwidth && isIphone==true)
		        {
		            $(imgObj).height(browserheight);
		            $(imgObj).width(browserheight * ratio);	
                    var newx = (browserheight - $(imgObj).width())/2;
		            $('#imgWrapper').css('left', newx+'px');		            	
		        } else 
		        {
		            $(imgObj).width(browserwidth);
		            $(imgObj).height(browserwidth / ratio);
                    var newY = (browserheight - $(imgObj).height())/2;
		            $('#imgWrapper').css('top', newY+'px');
		            
		        }
		    //}
        }
        
        
        function loadImage(index)
        {
            ////alert('XXX');
            


            selectThumb(index);
                    
            var dataItem = $(".imgData:[index="+index+"]");
            var oldIndex = currentIndex;         
            var image = new Image();
            image.onload = function () {
                //SAVE INDEX IN COOKIE
                try {
                    updateHttpCookie("StartSlideIndexCookie", index);
                } catch (e) { }

                image.id = "img" + index;
                $('#img' + index).css('z-index', '0');
                $('#img' + index).css('position', 'absolute');
                document.getElementById('imgWrapper').appendChild(image);

                resizeImg(index);
                if (isFirstLoad) {
                    isFirstLoad = false;
                    preloadBigImages();
                    $('#infoPanel1').css("left", "-1000px");
                    if (isHpAllHidden == false) { $('#infoPanel1').show(); }
                    updateTextPanel(index);

                }
                else {
                    isInAnimation = true;
                    $('#img' + oldIndex).css('z-index', '1');
                    $('#img' + oldIndex).css('position', 'absolute');
                    $('#img' + oldIndex).fadeOut(transitionSpeed, function () {
                        document.getElementById('imgWrapper').removeChild(document.getElementById('img' + oldIndex));
                        isInAnimation = false;
                        updateTextPanel(index);
                    });
                }


                currentIndex = index;

                if (!isPaused) {
                    restartSlideshowTimer();
                }

            };
            image.src = dataItem.attr('imgsrc');                    
        }    
        function restartSlideshowTimer()
        {
            slideshow_interval = setInterval("nextAutoSlide()", intervalTime);
        }
        function stopSlideshowTimer()
        {
            clearInterval(slideshow_interval);
        }
        function nextAutoSlide()
        {
            if(isPaused || isInAnimation) return false;     
            stopSlideshowTimer();
            var nextItem = currentIndex+1;
            if(nextItem==imagesCount){nextItem=0;}
            var dataItem = $(".imgData:[index="+nextItem+"]");
            var isLoaded = $(dataItem).attr('loaded');
            if(isLoaded)
            {
                loadImage(nextItem);
            }
        }
        function loadSlideByDirection(direction)
        {
            if(isInAnimation) return false;     
            var nextItem = currentIndex+direction;
            if(nextItem==imagesCount){nextItem=0;}
            if(nextItem<0){nextItem=imagesCount-1;}
            loadImage(nextItem);
        }
        
        
        //---------------------------------------------------------------
        //  PRELOADING ALL LARGE IMAGES
        //---------------------------------------------------------------
        var _isAllLoaded = false;
        function preloadBigImages()
        {
            var dataItem = $(".imgData:[index="+loadingIndex+"]");
            var image = new Image();
            image.onload = function () {
                $(".imgData:[index=" + loadingIndex + "]").attr('loaded', 'true');

                loadingIndex++;
                if (loadingIndex < imagesCount) {
                    preloadBigImages();
                }
                else {
                    _isAllLoaded = true;
                    showNavigationPanel();
                    $("#ttThumbsInfo").fadeTo(200,1);//will show only if not in cookie!!!!
                }
            };
            image.src = dataItem.attr('imgsrc');   
        }
        
        
        
        //---------------------------------------------------------------
        //  THUMBNAILS PANEL AREA
        //---------------------------------------------------------------    
        function initPanelState()
        {
            showThumbsInnerPanel(false,false);  
            setThumbsDefaultState();  
        }    
        
        function showNavigationPanel()
        {
            $('#hpControllerLoader').hide();
            $('#hpControllerButtons').show();
            
            $('#btnPre').css('cursor','pointer');
            $('#btnNext').css('cursor','pointer');
            $('#btnPlay').css('cursor','pointer');
            $('#btnPause').css('cursor','pointer');
            $('#btnThumbs').css('cursor','pointer');
            $('.thumbLink').css('cursor','pointer');
            $('#btnSlideInOut').css('cursor','pointer');
            

            $('#btnSlideInOut').mousedown(function() 
            {
                slideControlPanel(!isControlPanelOpen);
            }); 

            $(".thumbLink").hover(function() 
            {
                setThumbState(this,true);
                updateThumbsTitle($('.thumbLink').index(this));
            },
            function()
            {
                if($('.thumbLink').index(this)!=currentIndex)
                {
                    setThumbState(this,false);
                    updateThumbsTitle(currentIndex);
                }
            });         
            $('.thumbLink').mousedown(function() 
            {
                var cindex = $('.thumbLink').index(this);setAutoState(false);loadImage(cindex);
            });              
            $('#btnPause').mousedown(function() 
            {
                setAutoState(false);
            });      
            $('#btnPlay').mousedown(function() 
            {
                setAutoState(true);
            });      
            $('#btnPre').mousedown(function() 
            {
                setAutoState(false);loadSlideByDirection(-1);
            });      
            $('#btnNext').mousedown(function() 
            {
                setAutoState(false); loadSlideByDirection(1);
            });
            $('#btnThumbs').mousedown(function () 
            {
                showThumbsInnerPanel(!isThumbsOpen, true);
                removeFirstTimeTooltip("ttHP");
            });      
            $('#thumbsPanelClose').mousedown(function() 
            {
                showThumbsInnerPanel(false,true);
            });         
            setAutoState(!isPaused);
        }
        function setThumbsDefaultState()
        {
            var alphaVal = 0.3;
            if(jQuery.browser.msie)
            {
                $('.thumbLink').find('img').fadeTo(1, alphaVal);
            }          
            else
            {
                $('.thumbLink').find('img').fadeTo(1, alphaVal);
            }         
        }    
        function setThumbState(thumbBox,isOver)
        {
            var alphaVal = 0.3;
            if(isOver)
            {
                alphaVal=1;
            }
            if(jQuery.browser.msie)
            {
                $(thumbBox).find('img').fadeTo(100, alphaVal);
            }          
            else
            {
                $(thumbBox).find('img').fadeTo(100, alphaVal);
            }               
        }  
        function selectThumb(thumbIndex)
        {
            $('.thumbLink').each(function(index)
              {
                var cindex = $('.thumbLink').index(this);
                if(cindex==thumbIndex)
                {
                    updateThumbsTitle(thumbIndex);
                    setThumbState(this,true);
                }
                else
                {
                    setThumbState(this,false);
                }
              });         
        }  
        function updateThumbsTitle(tIndex)
        {
            var titleText1 = $(".imgData:[index="+tIndex+"]").attr('panel_title1');
            var titleText2 = $(".imgData:[index="+tIndex+"]").attr('panel_title2');
            $(".thumbsTitle1").html(titleText1); 
            $(".thumbsTitle2").html(titleText2);             
        }
        
        
        
        
        
        var isControlPanelOpen=true;
        function slideControlPanel(isOpen)
        {
	        isControlPanelOpen=isOpen;
            var panelX=0;  
            if(!isOpen)
            {
                panelX=0-253;
                $('#btnOpenPanel').show();
                $('#btnClosePanel').hide();
            }  
            else
            {
                $('#btnOpenPanel').hide();
                $('#btnClosePanel').show();        
            }
            $('#hpControlPanel').animate(
            {
                right: panelX
            }, 
            {
                duration: 500
            });    
        }
        function setAutoState(isPlay)
        {
            if(isPlay)
            {
                isPaused=false;
                restartSlideshowTimer();
                $('#btnPlay').hide();
                $('#btnPause').show();
            }
            else
            {
                isPaused=true;
                stopSlideshowTimer();
                $('#btnPlay').show();
                $('#btnPause').hide();
            }
        }	
	    function showThumbsInnerPanel(isOpen,isMotion)
	    {
	        isThumbsOpen=isOpen;
            var panelY=0;
            var openCloseDuration = 500;
            if(!isOpen)
            {
                panelY=$('#thumbsMask').css('height');
            }	
            if(!isMotion)
            {
                openCloseDuration=0;
            }            
            $('#thumbsPanel').animate({top: panelY}, {duration: openCloseDuration});       
	    }

        function fixIEpng()
        {
            if(jQuery.browser.msie)
            {
                $('#thumbsPanelInner').css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader'); 
                $('.tImg').css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader'); 
            }
        }	
    	
    	





        //---------------------------------------------------------------
        //  INFO AREA xxx
        //---------------------------------------------------------------
        var dataItem;
        function updateTextPanel(index) {
            $("#iconsAbs").css("top", "0px"); //scroll icons to top of mask
            _curIconsPositionIndex = 0;
            _visibleIconsCount = 0;
            setScrollerButtonsState();

            dataItem = $(".imgData:[index="+index+"]");
            var cid = $(dataItem).attr('cid');

            $("#hpIconsScrollUp").hide();
            $("#hpIconsScrollDown").hide();

            $('#infoText').hide();
            $('.infoTitle').html($(dataItem).attr('title'));
            $('.infoDescText').html($(dataItem).find('.itext').html());
            $('.iphotos').find('a').attr('rel', ''); //reset all galleries

            //var h1 = $('.infoDescText').height();
            //alert("h1=" + h1);

            //alert("iconsTotalHeight=" + iconsTotalHeight + "  newHeight=" + newHeight);


            
            var ReadMoreURL = $(dataItem).attr('url');
            if(ReadMoreURL.length>0)
            {
                $('.readMoreLink').show();
                $('#btnMore').show();
                //$('.readMoreLink').attr('href',ReadMoreURL);
                //$('#thumbTitleLink').attr('href',ReadMoreURL);
                //$('#linkToMore').attr('href', ReadMoreURL);
                //$('#linkToMore2').attr('href', ReadMoreURL);

                $('.readMoreLink').attr('href', baseURL + 'windows/winPagePreview.aspx?CID=' + cid);
                $('#linkToMore').attr('href', baseURL + 'windows/winPagePreview.aspx?CID=' + cid);
                $('#linkToMore2').attr('href', baseURL + 'windows/winPagePreview.aspx?CID=' + cid);


                _visibleIconsCount++;
            }
            else
            {
                $('.readMoreLink').hide();
                $('#thumbTitleLink').attr('href', '#');
                $('#btnMore').hide();
                $('#linkToMore').attr('href', '#');
                $('#linkToMore2').attr('href', '#'); 
            }
            
            var lastIconVisible ="";
            
            //CHECK ISSUU LINK---------------------------------------------------------------------
            if($(dataItem).attr('useISSUU')=="1")
            {
                lastIconVisible="linkToIssuuIcon";
                $('#btnISSUUE').show();
                $('#linkToIssuu').attr('href',baseURL+'windows/winIssuu.aspx?CID='+cid);
                $('#linkToIssuu2').attr('href', baseURL + 'windows/winIssuu.aspx?CID=' + cid);
                _visibleIconsCount++;
            }
            else
            {
                $('#btnISSUUE').hide();
                $('#linkToIssuu').attr('href','#');
                $('#linkToIssuu2').attr('href','#');            
            }
            //CHECK VIDEO LINK---------------------------------------------------------------------
            if($(dataItem).attr('useVideo')=="1")
            {
                lastIconVisible="linkToVideoIcon";
                $('#btnVIDEO').show();
                $('#linkToVideo').attr('href',baseURL+'windows/winVideo.aspx?CID='+cid);
                $('#linkToVideo2').attr('href', baseURL + 'windows/winVideo.aspx?CID=' + cid);
                _visibleIconsCount++;
            }
            else
            {
                $('#btnVIDEO').hide();
                $('#linkToVideo').attr('href','#');
                $('#linkToVideo2').attr('href','#');            
            }   
            //CHECK PHOTOS---------------------------------------------------------------------
            if($(dataItem).attr('useGallery').length>0)
            {
                lastIconVisible="linkToPhotosIcon";
                $('#btnPHOTOS').show();
                $(dataItem).find('.iphotos').find('a').attr('rel','HP_GALLERY');
                $("a[rel='HP_GALLERY']").colorbox();
                $('#linkToPhotos2').attr('href', $(dataItem).attr('useGallery'));
                _visibleIconsCount++;           
            }
            else
            {
                $('#btnPHOTOS').hide();
            }  
            //CHECK MINISITE---------------------------------------------------------------------
            if($(dataItem).attr('useMinisite').length>0)
            {
                lastIconVisible="linkToMinisiteIcon";
                $('#btnMINISITE').show();
                //$('#linkToMinisite2').attr('href', $(dataItem).attr('useMinisite'));
                $('#linkToMinisite').attr('href', baseURL + 'windows/winMinisite.aspx?CID=' + cid);
                $('#linkToMinisite2').attr('href', baseURL + 'windows/winMinisite.aspx?CID=' + cid);
                _visibleIconsCount++;          
            }
            else
            {
                $('#btnMINISITE').hide();
            }    
            //CHECK SLIDESHOW---------------------------------------------------------------------
            if($(dataItem).attr('useSlideshow').length>0)
            {
                lastIconVisible = "linkToSlidesIcon";
                $('#btnSLIDESHOW').show();
                $('#linkToSlides').attr('href', baseURL + 'windows/winPresentation.aspx?CID=' + cid);
                $('#linkToSlides2').attr('href', baseURL + 'windows/winPresentation.aspx?CID=' + cid);
                //$('#linkToSlides').attr('href', $(dataItem).attr('useSlideshow'));
                _visibleIconsCount++;       
            }
            else
            {
                $('#btnSLIDESHOW').hide();
            }  
            //CHECK ENEWS---------------------------------------------------------------------
            if($(dataItem).attr('useEnews').length>0)
            {
                lastIconVisible="linkToEnewsIcon";
                $('#btnENEWS').show();
                //$('#linkToEnews2').attr('href', $(dataItem).attr('useEnews'));
                $('#linkToEnews').attr('href', baseURL + 'windows/winNewsletter.aspx?CID=' + cid);
                $('#linkToEnews2').attr('href', baseURL + 'windows/winNewsletter.aspx?CID=' + cid);
                _visibleIconsCount++;        
            }
            else
            {
                $('#btnENEWS').hide();
            }

            //CHECK PRINTS LINK---------------------------------------------------------------------
            //CHECK PRINTS LINK---------------------------------------------------------------------
            //CHECK PRINTS LINK---------------------------------------------------------------------

            $(".num_index1").hide();
            if ($(dataItem).attr('usePrints1') == "1") {
                lastIconVisible = "linkToPrintsIcon";
                $('#btnPrints').show();
                $('#linkToPrints').attr('href', baseURL + 'windows/winIssuu.aspx?INDEX=0&TYP=PRINTS&CID=' + cid);
                $('#linkToPrints2').attr('href', baseURL + 'windows/winIssuu.aspx?INDEX=0&TYP=PRINTS&CID=' + cid);
                _visibleIconsCount++;
            }
            else {
                $('#btnPrints').hide();
                $('#linkToPrints').attr('href', '#');
                $('#linkToPrints2').attr('href', '#');
            }
            if ($(dataItem).attr('usePrints2') == "1") {
                $(".num_index1").show();
                lastIconVisible = "linkToPrintsIcon2";
                $('#btnPrints2').show();
                $('#linkToPrints_2').attr('href', baseURL + 'windows/winIssuu.aspx?INDEX=1&TYP=PRINTS&CID=' + cid);
                $('#linkToPrints_22').attr('href', baseURL + 'windows/winIssuu.aspx?INDEX=1&TYP=PRINTS&CID=' + cid);
                _visibleIconsCount++;
            }
            else {
                $('#btnPrints2').hide();
                $('#linkToPrints_2').attr('href', '#');
                $('#linkToPrints_22').attr('href', '#');
            }
            if ($(dataItem).attr('usePrints3') == "1") {
                lastIconVisible = "linkToPrintsIcon3";
                $('#btnPrints3').show();
                $('#linkToPrints_3').attr('href', baseURL + 'windows/winIssuu.aspx?INDEX=2&TYP=PRINTS&CID=' + cid);
                $('#linkToPrints_32').attr('href', baseURL + 'windows/winIssuu.aspx?INDEX=2&TYP=PRINTS&CID=' + cid);
                _visibleIconsCount++;
            }
            else {
                $('#btnPrints3').hide();
                $('#linkToPrints_3').attr('href', '#');
                $('#linkToPrints_32').attr('href', '#');
            }








            //CHECK PRODUCTS FAMILY LINK---------------------------------------------------------------------
            if ($(dataItem).attr('useProFamily').length > 0)
            {
                lastIconVisible = "linkToProFamilyIcon";
                $('#btnProFamily').show();
                $('#linkToProFamily').attr('href', $(dataItem).attr('useProFamily'));
                $('#linkToProFamily2').attr('href', $(dataItem).attr('useProFamily'));
                _visibleIconsCount++;
            }
            else {
                $('#btnProFamily').hide();
            }


            //$('#infoPanel1').show();
            //$('#infoPanel1').css("left", "-1000px");
            //$('#infoText').show();
            //$('.infoTitle').show();
            //$('.infoDescText').show();
            var iconsTotalHeight = _visibleIconsCount * _iconHeight;
            var newHeight = $('#infoText').height();

            //alert("newHeight=" + newHeight);
            if (isHpAllHidden == false) { $('#infoPanel1').show(); }
            if (_isInfoPanelInScreenBounds) {
                //move the panel in only if not closed by user
                $('#infoPanel1').css("left", "0px");
            }

            newHeight = newHeight + 70;
            $('.infoTitle').html('');
            $('.infoDescText').html('');
            if (isHpAllHidden == false) { $('#infoPanel1').show(); }

            if (newHeight < _minHeight) 
            {
                newHeight = _minHeight;
            }
            var iconsBarHeight = iconsTotalHeight + 60;
            



            ///////////CHECKING IF ICONS NEEDS MASKING WITH SCROLLER

            
            if (newHeight < iconsBarHeight) 
            {
                $("#iconsMask").css("height", "116px"); //show only 3 icons (3*40)
                newHeight = newHeight + 15;// 90; //add the scroller buttons height
                $("#hpIconsScrollUp").show();
                $("#hpIconsScrollDown").show();
            }
            else {
                $("#iconsMask").css("height", iconsTotalHeight+"px"); //show all icons no scrolling
            }

            var btnTogglePanelYpos = (newHeight / 2) - 22;

            if (_isInfoPanelInScreenBounds) {
                $(".btnInfoPanelWrapper").hide();//hide it only if the info panel is not closed by user
            }

            $(".btnInfoPanelWrapper").css("top", btnTogglePanelYpos + "px");
            
            $('#expendableInfoCell').animate({ height: newHeight },
                {
                    duration: 255
                    , complete: function () {
                        $('.infoTitle').html($(dataItem).attr('title'));
                        $('.infoDescText').html($(dataItem).find('.itext').html());
                        $('#infoText').fadeTo(400, 1);
                        $(".btnInfoPanelWrapper").show();
                    }
                });
        }












        //////////////////////////////////
        //////////////////////////////////
        //////////////////////////////////
        //////////////////////////////////
        //////////////////////////////////
        //////////////////////////////////
        function setIconsScrollers() {
            $('#hpIconsScrollUp').mousedown(function () {
                scrollIconsByDir(-1);
            });
            $('#hpIconsScrollDown').mousedown(function () {
                scrollIconsByDir(1);
            });

            $("#hpIconsScrollUp").hover(function () {
                if (_curIconsPositionIndex > 0) {
                    $('#hpIconsScrollUp').css("background-position", "-45px 0px");
                }
            }, function () {
                if (_curIconsPositionIndex > 0) {
                    $('#hpIconsScrollUp').css("background-position", "0px 0px");
                }
            });
            $("#hpIconsScrollDown").hover(function () {
                if (_curIconsPositionIndex < _visibleIconsCount - 3) {
                    $('#hpIconsScrollDown').css("background-position", "-135px 0px");
                }
            }, function () {
                if (_curIconsPositionIndex < _visibleIconsCount - 3) {
                    $('#hpIconsScrollDown').css("background-position", "-90px 0px");
                }
            });
        }
        function scrollIconsByDir(dir) 
        {
            _curIconsPositionIndex = _curIconsPositionIndex + dir;
            if (_curIconsPositionIndex < 0) {
                _curIconsPositionIndex = 0;
            }
            if (_curIconsPositionIndex > _visibleIconsCount - 3) {
                _curIconsPositionIndex = _visibleIconsCount - 3;
            }
            var iconsY = 0-(_curIconsPositionIndex*_iconHeight);
            $('#iconsAbs').animate({ top: iconsY }, { duration: 200, complete: function () { setScrollerButtonsState(); } });
        }
        function setScrollerButtonsState() {
            if (_curIconsPositionIndex == 0) {
                $('#hpIconsScrollUp').css("pointer", "default");
                $('#hpIconsScrollUp').css("background-position", "0px -40px");
            }
            else {
                $('#hpIconsScrollUp').css("pointer", "pointer");
                $('#hpIconsScrollUp').css("background-position", "0px 0px");
            }
            if (_curIconsPositionIndex == _visibleIconsCount - 3) {
                $('#hpIconsScrollDown').css("pointer", "default");
                $('#hpIconsScrollDown').css("background-position", "-90px -40px");
            }
            else {
                $('#hpIconsScrollDown').css("pointer", "pointer");
                $('#hpIconsScrollDown').css("background-position", "90px 0px");
            }
            fixScrollersOnIE();
        }
        function fixScrollersOnIE() {
            if (jQuery.browser.msie) {
                $('#hpIconsScrollDown').css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader');
                $('#hpIconsScrollUp').css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader');
            }
        }



        
        function initInfoState()
	    {
	        setLightbox();	    
	        $('.linkToIssueTT').hide();
	        $('.linkToVideoTT').hide();
	        $('.linkToPhotosTT').hide();
	        $('.linkToMinisiteTT').hide();    
	        $('.linkToSlidesTT').hide();    
	        $('.linkToEnewsTT').hide();
	        $('.linkToMoreTT').hide();
	        $('.linkToPrintsTT').hide();
	        $('.linkToPrintsTT2').hide();
	        $('.linkToPrintsTT3').hide();
	        $('.linkToProFamilyTT').hide();

            $("#btnISSUUE").hover(function(){setIconState(true,'linkToIssueTT');},function(){setIconState(false,'linkToIssueTT');});	  
            $("#btnVIDEO").hover(function(){setIconState(true,'linkToVideoTT');},function(){setIconState(false,'linkToVideoTT');});	  
            $("#btnPHOTOS").hover(function(){setIconState(true,'linkToPhotosTT');},function(){setIconState(false,'linkToPhotosTT');});	  
            $("#btnMINISITE").hover(function(){setIconState(true,'linkToMinisiteTT');},function(){setIconState(false,'linkToMinisiteTT');});	  
            $("#btnSLIDESHOW").hover(function(){setIconState(true,'linkToSlidesTT');},function(){setIconState(false,'linkToSlidesTT');});
            $("#btnENEWS").hover(function () { setIconState(true, 'linkToEnewsTT'); }, function () { setIconState(false, 'linkToEnewsTT'); });
            $("#btnMore").hover(function () { setIconState(true, 'linkToMoreTT'); }, function () { setIconState(false, 'linkToMoreTT'); });
            $("#btnPrints").hover(function () { setIconState(true, 'linkToPrintsTT'); }, function () { setIconState(false, 'linkToPrintsTT'); });
            $("#btnPrints2").hover(function () { setIconState(true, 'linkToPrintsTT2'); }, function () { setIconState(false, 'linkToPrintsTT2'); });
            $("#btnPrints3").hover(function () { setIconState(true, 'linkToPrintsTT3'); }, function () { setIconState(false, 'linkToPrintsTT3'); });
            $("#btnProFamily").hover(function () { setIconState(true, 'linkToProFamilyTT'); }, function () { setIconState(false, 'linkToProFamilyTT'); });



            $('.readMoreLink').mousedown(function () { setAutoState(false); });
            $('#btnMore').mousedown(function () { setAutoState(false); });
            $('#btnMINISITE').mousedown(function () { setAutoState(false); });
            $('#btnSLIDESHOW').mousedown(function () { setAutoState(false); });
            $('#btnENEWS').mousedown(function () { setAutoState(false); });            
            $('#btnISSUUE').mousedown(function () { setAutoState(false); });
            $('#btnPrints').mousedown(function () { setAutoState(false); });
            $('#btnPrints2').mousedown(function () { setAutoState(false); });
            $('#btnPrints3').mousedown(function () { setAutoState(false); });
            $('#btnPHOTOS').mousedown(function () { setAutoState(false); });
            $('#btnSLIDESHOW').mousedown(function () { setAutoState(false); });
            $('#btnVIDEO').mousedown(function () { setAutoState(false); });


	    }    
	    
	    function setIconState(isOver,TooltipItem)
	    {
	        if(isOver)
	        {
	            $('.'+TooltipItem).show();
	            $('.infoIconsCell').css('width','170px');
	        }
	        else
	        {
	            $('.'+TooltipItem).hide();
	            $('.infoIconsCell').css('width','45px');
	        }
	    }




	    var _isInfoPanelInScreenBounds = true;
	    function openHpInfoPanel() {
	        setInfoPanelState(true);
	    }
	    function closeHpInfoPanel() {
	        setInfoPanelState(false);
	    }
	    function setInfoPanelState(isOpen) {
	        _isInfoPanelInScreenBounds = isOpen;
	        var panelXpos = 0;
	        if (isOpen) {
	            panelXpos = 0;
	            $("#btnOpenInfoPanel").hide();
	            $("#btnCloseInfoPanel").show();
	        }
	        else {
	            panelXpos = -536;
	            $("#btnOpenInfoPanel").show();
	            $("#btnCloseInfoPanel").hide();
	        }
	        $('.hpInfoPanel').animate({ left: panelXpos },
                {
                    easing: 'easeInOutCubic',duration: 600, complete: function () {}
            });
	    }
