$(document).ready(function() {

    //startTime=new Date().getTime();


  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////////////// HOVER MENU
  	var buttonMenu = $('#buyers #button_menu');
  	buttonMenu.hide();
  	$('#buyers #button').hover(
		function() {
			buttonMenu.show();
			buttonMenu.hover(
				function() {
					$(this).show();
				},
				function() {
					$(this).hide();
				}
			);
		},
		function() {
			buttonMenu.hide();
		}
	);



  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////// STRUCTURE
	$('#header').wrap("<div id=\"header_shadow\"></div>");
	$('.button.bottom').after("<span class=\"clear_both\"></span>");



	///////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////// GALLERY 
	$('HTML').addClass('JS');
	
	$('#gallery #photos img:nth-child(odd)').css("margin-right","2px");
	
	var photos = $('#photos img');
	photos.animate({ opacity: 0.5 }).hover(
		function(e) {
			var photo = $(e.target); 
			photo.stop().animate({ opacity: 1 }, "fast");
			var newCaption = photo.attr('alt');
			$('p.caption').html('<span>Photo: </span>' + newCaption);
			var newPhoto = photo.attr('src');
			$('#current_photo').attr('src', newPhoto);
		},
		function() {
			$(this).stop().animate({ opacity: 0.5 });
		}
	);
	
	$.fn.fadeToggle = function(speed, easing, callback) {
	   return this.animate({opacity: 'toggle'}, speed, easing, callback);
	};
	var moreInfo = $('#more_information');
	var listingInfo = $('#listing_information');
	moreInfo.click(function() { 
		listingInfo.fadeToggle();
		moreInfo.toggleClass("not_selected");
		return false;
	});
	$('#close').click(function() {
		listingInfo.fadeToggle();
		moreInfo.addClass("not_selected");
		return false;
	});
	
	
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////// TIME
	var Months = new Array('January','February','March','April','May','June','July',
	                       'August','September','October','November','December');
	var today = new Date();
	var month = Months[today.getMonth()];
	var year = today.getFullYear();
	$('#time').html("Last updated "+month+" "+year);
	


	///////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////// CONTENT 
	$('body#faq ul+h2').css('margin-top','10px');
	$('body#faq ul+p').css('margin-top','10px');
	$('#listings #thumbnails div:nth-child(4n)').css("margin-right","0px");
	var thumbnails = $('#thumbnails img');
	thumbnails.animate({ opacity: 0.75 }).hover(
		function(e) {
			$(e.target).stop().animate({ opacity: 1 }, "fast");
		},
		function(e) {
			$(e.target).stop().animate({ opacity: 0.75 });
		}
	);
	$('#thumbnails span.status').animate({ opacity: 0.7 });
	
	//endTime=new Date().getTime();
	//alert(((endTime-startTime)/1000)+' seconds.');
});