/* javascript for Subjective Photons - photo porfolio of Wouter Walmink */

function selectCategory(selected_category)
{	
	$(".CategoryItem").attr("id", "");
	$(".CategoryItem[dbid='" + selected_category + "']").attr("id", "selected");
	
	$(".SubjectMenu").css("display", "none");
	$(".SubjectMenu[categoryid='" + selected_category + "']").css("display", "block");
}

function selectImage(selectedImage)
{
	$(".Thumb").attr("id", "");
	$(".Thumb[thumbid='" + selectedImage + "']").attr("id", "selected");

	$(".MainImage").attr("id", "");
	$(".MainImage[imageid='" + selectedImage + "']").attr("id", "selected");
}

function selectPreviousImage()
{
	if( $("#MainImages > #selected").prev().length != 0 ) {
	
		if( $("#ThumbSection #selected").prev().hasClass("Thumb") )
			$("#ThumbSection #selected").prev().attr("id", "selected");
		else 
			$("#ThumbSection #selected").prevAll(2).eq(2).attr("id", "selected");
		$("#ThumbSection > #selected:eq(1)").attr("id", "");
		
		$("#MainImages > #selected").prev().attr("id", "selected");
		$("#MainImages > #selected:eq(1)").attr("id", "");
	}
}

function selectNextImage()
{
	if( $("#MainImages > #selected").next().length != 0 ) {
	
		if( $("#ThumbSection #selected").next().hasClass("Thumb") )
			$("#ThumbSection #selected").next().attr("id", "selected");
		else 
			$("#ThumbSection #selected").nextAll(2).eq(2).attr("id", "selected");
		$("#ThumbSection > #selected:eq(0)").attr("id", "");
	
		$("#MainImages > #selected").next().attr("id", "selected");
		$("#MainImages > #selected:eq(0)").attr("id", "");
	}
}