$(document).ready(function(){

	// Main menu rollovers
	var image_path = '/wp-content/themes/wood-leaf-studios/images/';
	$('#home img').hover(function(){ $(this).attr('src', image_path + 'home-button-rollover.jpg'); }, function(){ $(this).attr('src', image_path + 'home-button.jpg'); });
	$('#exhibit_grade_furniture img').hover(function(){ $(this).attr('src', image_path + 'exhibit-grade-furniture-button-rollover.jpg'); }, function(){ $(this).attr('src', image_path + 'exhibit-grade-furniture-button.jpg'); });
	$('#exhibit_grade_built_ins img').hover(function(){ $(this).attr('src', image_path + 'exhibit-grade-built-ins-button-rollover.jpg'); }, function(){ $(this).attr('src', image_path + 'exhibit-grade-built-ins-button.jpg'); });
	$('#specialty_pieces img').hover(function(){ $(this).attr('src', image_path + 'specialty-pieces-button-rollover.jpg'); }, function(){ $(this).attr('src', image_path + 'specialty-pieces-button.jpg'); });
	$('#our_journal img').hover(function(){ $(this).attr('src', image_path + 'our-journal-button-rollover.jpg'); }, function(){ $(this).attr('src', image_path + 'our-journal-button.jpg'); });
	$('#our_creative_process img').hover(function(){ $(this).attr('src', image_path + 'our-creative-process-button-rollover.jpg'); }, function(){ $(this).attr('src', image_path + 'our-creative-process-button.jpg'); });

	// Drop-down menus
	$("#main_menu li").hover(function(){ 
		$(this).children('ul').show(268); 
		}, function(){ 
		$(this).children('ul').css('display', 'none');
	});

	$('a.alternate_view').click(function(){
		$("#portfolio_image").attr('src', $(this).attr('href'));
		return false;
	});

	// Set the current page and deactivate unnecessary scrollers
	var current_page = 1;
	$("#left_scroller").css('display', 'none');
	$.get("http://www.woodleafstudios.com/wp-content/themes/wood-leaf-studios/image-scroller.php", { page: (current_page + 1) }, function(data){
		if (data.indexOf('<img') == -1){
			$("#right_scroller").css('display', 'none');
		}
	});
	
	// Set the action of the left scroller
	$("#left_scroller").click(function(){
		current_page--;
		if (current_page < 1){
			current_page = 1;
		}
		else {
			$("#left_scroller").css('display', 'block');
			$("#right_scroller").css('display', 'block');
			$.get("http://www.woodleafstudios.com/wp-content/themes/wood-leaf-studios/image-scroller.php", { page: current_page }, function(data){
				$("#recent_container").html(data);
			});
		}
		if (current_page == 1){
			$("#left_scroller").css('display', 'none');
		}
		return false;
	});
	
	// Set the action of the right scroller
	$("#right_scroller").click(function(){
		current_page++;
		$.get("http://www.woodleafstudios.com/wp-content/themes/wood-leaf-studios/image-scroller.php", { page: current_page }, function(data){
			if (data.indexOf('<img') == -1){
				current_page--;
			}
			else {
				$("#left_scroller").css('display', 'block');
				$("#recent_container").html(data);
				$.get("http://www.woodleafstudios.com/wp-content/themes/wood-leaf-studios/image-scroller.php", { page: (current_page + 1) }, function(data){
					if (data.indexOf('<img') == -1){
						$("#right_scroller").css('display', 'none');
					}
				});
			}
		});
		return false;
	});

});