$(function() {
		   
$(".navdrop").css({'display' : 'none'});
$('.navtoplvl').hover(function() {
$(".navdrop").css({'display' : 'block'});
						 
}, function() {
	
$(".navdrop").css({'display' : 'none'});
	
});
	
	var rnum = Math.floor(Math.random()*13) + 1; 
	
   var images = $("#mainImage > img");
   var imageCount = images.length;
   images.hide();
	var chosen = images.filter("." + rnum).attr('longdesc');
   images.filter("." + rnum).show();
	var smallImage = $(chosen).attr('longdesc');
	var description = $(smallImage + "2").attr('longdesc');
	
	$("#gcontent").html(description);
	
   $("#GalleryNav img").animate({"opacity": .5 });		
			  
   $("#GalleryNav img").hover(function() {
      $(this).addClass("selected").stop().animate({"opacity": 1});
   }, function(){
      $(this).stop().animate({"opacity": .5}).removeClass("selected");
   });
   
   $("#GalleryNav img").click(function() {
    var imgID = $(this).attr('name');
    var imgDesc = $(this).attr('longdesc');
    $("#gcontent").fadeOut(200, function(){
        $("#gcontent").html(imgDesc).fadeIn(400);
    });
	 
    var counter = 0;  
      $(images).fadeOut(200, function(){
        counter++;
        if(counter == imageCount){
            $(imgID).fadeIn(400);
        }
      })
   });	
	
   var rnum2 = Math.floor(Math.random()*7 + 1);
   var stnd = "images/second-0";
    
	$('#secondimage').hide();
   $('#secondimage').attr('src', stnd + rnum2 + ".jpg");
	$('#secondimage').fadeIn(2000);
	 
	$('#secondimagesub').hide();
   $('#secondimagesub').attr('src', "../" + stnd + rnum2 + ".jpg");
	$('#secondimagesub').fadeIn(2000);
	
$('#GalleryNav img').click(function() {
var myShowG = $(this).attr('id');
$('#mainImage1 img').css({'display' : 'none'});
$('#' + myShowG + '_1').css({'display' : 'inline'});
});

   
});
