// --------------------------------------------------------------------
// PRELOAD IMAGES ? SEE NeillAnthony JS AND http://jquery-howto.blogspot.com/2009/02/preload-images-with-jquery.html
// --------------------------------------------------------------------

//var image1 = $('<img />').attr('src', 'images/temp_logo.jpg');
//var image2 = $('<img />').attr('src', 'images/temp_nav_unhover.jpg');

// --------------------------------------------------------------------

$(document).ready(function(){

// --------------------------------------------------------------------
// ON LOAD
// NB fadeIn WILL display a DIV which was display:none, but animate WON'T
// --------------------------------------------------------------------

// PREP NAV HOVERS
// set nav button opacities to 0 (buttons must be transparent until hover)
$("#logonav1,#logonav2,#logonav3,#logonav4,#logonav5").animate({opacity: 0}, 0);

// DISPLAY FRAME
// fadein frame (which was display:none) but nav hovers will still be invisible due to opacity 0
//$("#frame").fadeIn(1000);
$("#frame").fadeIn(500);

// PREP THE fadelink CLASS SO IT HOVERS PROPERLY
$('.fadelink').css('color','996633');


// --------------------------------------------------------------------
// NAV FUNCTIONALITY
// --------------------------------------------------------------------


// MOUSEOVER FADING OF REGULAR HYPERLINKS
      $('.fadelink').hover( 
        function () {
          $(this).animate({color:'#CC6600'}, {queue:false,duration:300});
        }, function () { 
          $(this).animate({color:'#996633'}, {queue:false,duration:300});
        });
// using info found at http://www.theruntime.com/blogs/thomasswilliams/archive/2008/11/24/jquery-hover-fading-on-mouse-over-and-mouse-out-without.aspx




// MOUSEOVER FADING-IN/OUT OF NON-DROPDOWNED NAV BUTTONS
$("#logonav3,#logonav4,#logonav5").hover(
        function () {
			$(this).stop().animate({opacity: 1}, 300);
        }, function () { 
			$(this).stop().animate({opacity: 0}, 600);
        }); 


// --------------------------------------------------------------------
// ***BOOKS DROPDOWN MENU below the Books nav button***
// --------------------------------------------------------------------

// NB BOOKS OVERVIEW PAGE IS OMITTED, SO logonav2 DOESNT NEED TO TURN YELLOW ON HOVER
$("#logonav2").hover(
	function() {
//			$(this).stop(true,false).animate({opacity: 1}, 300); // SEE NB ABOVE
			$("#booksdropdown").stop(true,false).fadeTo(300,1);
	}, function() {
//			$(this).stop(true,false).animate({opacity: 0}, 600); // SEE NB ABOVE
			$("#booksdropdown").stop(true,false).fadeOut(300);
});
$("#booksdropdown").hover(
	function() {
			$(this).stop(true,false).fadeTo(300,1);
//			$("#logonav2").stop(true,false).animate({opacity: 1}, 0); // SEE NB ABOVE
	}, function() {
			$(this).stop(true,false).fadeOut(300);
//			$("#logonav2").stop(true,false).animate({opacity: 0}, 600); // SEE NB ABOVE
});

$("#konstantin_button").hover( 
        function () {
          $(this).attr('src', 'images/konstantin_button_over.gif'); return true;
        }, function () { 
          $(this).attr('src', 'images/konstantin_button.gif'); return true;
        });
$("#tcg_button").hover( 
        function () {
          $(this).attr('src', 'images/tcg_button_over.gif'); return true;
        }, function () { 
          $(this).attr('src', 'images/tcg_button.gif'); return true;
        });
$("#a_button").hover( 
        function () {
          $(this).attr('src', 'images/a_button_over.gif'); return true;
        }, function () { 
          $(this).attr('src', 'images/a_button.gif'); return true;
        });

// --------------------------------------------------------------------
// ***OTHER FUNCTIONALITY***
// --------------------------------------------------------------------

// back to top script
$('.backtotop').click(function(){
	$('html, body').animate({scrollTop:0}, 1500);
	return false;
});


// --------------------------------------------------------------------
}); // end JQ document ready
