$(document).ready(function(){
	$('.sf-menu').superfish({
		animation:   {opacity:'show'},
		speed:       'fast',
		dropShadows:   false
	});	
	
    if ($('#slideshow').length > 0) {
        $('#slideshow').cycle({
            timeout: 7500,
            speed: 2000,
            pause: 1
        });
    }
    
    if ($('#slickbox').length > 0) {
        // hides the slickbox as soon as the DOM is ready
        $('#slickbox').hide();
        // toggles the slickbox on clicking the noted link
        $('#slick-toggle').click(function() {
            $('#slickbox').toggle(400);
            return false;
        });
    }

    if ($('#slider1').length > 0) {
        $('#slider1').anythingSlider({
            startStopped    : false, // If autoPlay is on, this can force it to start stopped
            //theme           : 'metallic',
            autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
            resumeDelay     : 10000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
            onSlideComplete : function(slider){
                // alert('Welcome to Slide #' + slider.currentPage);
            },
            resizeContents  : false,
            easing          : "swing",
            delay           : 10000
        });
    }
     
    if ($('#slideshow1').length > 0) {
        $('#slideshow1').cycle({ 
            prev:   '#prev', 
            next:   '#next'
        });
    }
    
    if ($('a.terms').length > 0) {
        $("a.terms").fancybox({
            'width': 900,
            'height': 500
        });
    }
	
	//$("div.tickerPanelWrapper").css({'height' : '100px'});	
    $("div.tickerPanel").each(function(i) {
        var panelLeft = (i) * 246 + 'px';
        $(this).css({'float' : 'none', 'margin-right' : '0', 'position' : 'absolute', 'left' : panelLeft, 'top' : '0px'});
    });
    animatePanels2(0);
		
    function animatePanels2(firstPanel) {
		$("div.tickerPanel").each(function(i) {
			$(this).animate(
				{
					left: "-=246px"
				},
				500,
				"linear",
				function(){
					if ($("div.tickerPanel").size() - 1 == i) {
						var panelLeft = (($("div.tickerPanel").size() - 1) * 246) + 'px';
						$("div.tickerPanel").eq(firstPanel).css({'left' : panelLeft});
						firstPanel++;
						if ($("div.tickerPanel").size() == firstPanel) firstPanel = 0;
						setTimeout(function(){animatePanels2(firstPanel);}, 5000);
					}
				}
			);
		});
	}
});
