$(document).ready(function() {
    $('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		pause:   1      // true to enable "pause on hover" 
	});
	
	$('#subsubject-list a').click(function() {
		$(".subsubject-item").removeClass("current");
		$(this).addClass("current");
		$(".each-subject").hide();
		$($(this).attr("href")).show();
		return false;
	});
	
	
	$(".each-artwork a").click(function() {
		$("#main-image img").attr("src", $(this).attr("href"));
		
		$("#main-image-caption").text($(this).attr("title"));
		return false;
	});
	
	
	//cache nav
	var nav = $("#nav_menu-3");
	
	//add indicator and hovers to submenu parents
	nav.find("li").each(function() {
		if ($(this).find("ul").length > 0) {

			//show subnav on hover
			$(this).mouseenter(function() {
				$(this).find("ul").stop(true, true).slideDown();
			});
			
			//hide submenus on exit
			$(this).mouseleave(function() {
				$(this).find("ul").stop(true, true).slideUp();
			});
		}
	});
	
	

	// replaces the featured image with a gallery image on click
	$('.gallery_thumb').click(function(){
		
		var link = $(this).attr('href');
		
		
		$('#entry-image a img').attr('src', link);
			
	
		return false;
	});
	
	
	//gallery options
	$('.startdate').hide();
	
	var selected = $('#courselength').val();
	
	if (selected=="6 Week Course"){
		$('#startdate6').show();
		$('#startdate4').attr('selectedIndex','0');
		$('#startdate1').attr('selectedIndex','0');
	}
	
	if (selected=="4 Week Course"){
		$('#startdate6').attr('selectedIndex','0');
		$('#startdate4').show();
		$('#startdate1').attr('selectedIndex','0');
	}
	
	if (selected=="1 Week Course"){
		$('#startdate6').attr('selectedIndex','0');
		$('#startdate4').attr('selectedIndex','0');
		$('#startdate1').show();
	}
	
	$('#courselength').change(function(){
		$('.startdate').hide();
		var selected = $(this).val();
	
		if (selected=="6 Week Course"){
			$('#startdate6').show();
			$('#startdate4').attr('selectedIndex','0');
			$('#startdate1').attr('selectedIndex','0');
		}
		
		if (selected=="4 Week Course"){
			$('#startdate6').attr('selectedIndex','0');
			$('#startdate4').show();
			$('#startdate1').attr('selectedIndex','0');
		}
		
		if (selected=="1 Week Course"){
			$('#startdate6').attr('selectedIndex','0');
			$('#startdate4').attr('selectedIndex','0');
			$('#startdate1').show();
		}
	});
	
	
		
});
