/* //OLD menu hover stuff
$(document).ready(function(){
	$('#menu ul li a.static').mouseover(function(){
			$(this).stop().animate({fontSize: "19px"}, 150);

            if($(this).attr("rel") != '') {
                $('#visual').stop(true,true).fadeOut("fast");
                $('#visual').css({
                  'backgroundImage': 'url('+$(this).attr("rel")+')'
                });
                $('#visual').stop(true,true).fadeIn("fast");
            }
		}).mouseout(function(){
			$(this).stop().animate({fontSize: "15px"}, 150);
            if($(this).attr("rel") != '') {
              $('#visual').stop(true,true).fadeOut("normal");
                $('#visual').css({
                  'backgroundImage': '' +$('#visual').attr("rel") + ''
                });
              $('#visual').stop(true,true).fadeIn("fast");
            }
	}); 
});
*/

$(document).ready(function(){
  $("#navmenu-h li,#navmenu-v li").hover(
  function() {
    $(this).addClass("iehover");
  },
  function() {
    $(this).removeClass("iehover");
  });
});

	var currentImage;
    var currentIndex = -1;
    var interval;
    function showImage(index){
        if(index < $('#visual img').length){
        	var indexImage = $('#visual img')[index]
            if(currentImage){   
            	if(currentImage != indexImage ){
                    $(currentImage).css('z-index',2);
                    clearTimeout(myTimer);
                    $(currentImage).fadeOut('slow', function() {
					    myTimer = setTimeout("showNext()", 3000);
					    $(this).css({'display':'none','z-index':1})
					});
                }
            }
            $(indexImage).css({'display':'block', 'opacity':1});
            currentImage = indexImage;
            currentIndex = index;
            //$('#thumbs li').removeClass('active');
            //$($('#thumbs li')[index]).addClass('active');
        }
    }
    
    function showNext(){
        var len = $('#visual img').length;
        var next = currentIndex < (len-1) ? currentIndex + 1 : 0;
        showImage(next);
    }
    
    var myTimer;
    
    $(document).ready(function() {
	    myTimer = setTimeout("showNext()", 3000);
		showNext(); //loads first image
        $('#thumbs li').bind('click',function(e){
        	var count = $(this).attr('rel');
        	showImage(parseInt(count)-1);
        });
	});
