$(document).ready(function(){				
	
	$("#java").hide(); 
	
	var path = window.location.pathname;
	var s = path.match(/[a-zA-Z0-9-]+/);
	$("#nav div").append("<a href='../../" + s + ".html'><span>" + s + "</span>/&nbsp;</a>");
	$("#set").load("data.html #set");
	$("#thumb").load("data.html div.pic", thumb);
	$("#one").load("data.html div.pic", enlarge);
	$("#txl").load("data.html div.txt", data);

});

function thumb(){
	
	$("#thumb div").each(
		function(){
		$(this).html( $(this).html().replace(/\u00A0|&nbsp;/g,""));
		if( $(this).html().match(/img/i) )
		{var bg = "url(" + $(this).children("img").attr("src").replace(/thumb/,"over") + ")";
		$(this).css("background-image",bg);}
		}
	);
	$("#thumb div:lt(2)").children().css("visibility","hidden");
	
	var n = $("#thumb img").length;
	if (n <= 7) {$("#thumb, #thumb-td").css("width","95px");}
	if (n > 7) {$("#thumb, #thumb-td").css("width","170px");}
	if (n > 14) {$("#thumb, #thumb-td").css("width","250px");}
	if (n > 21) {$("#thumb, #thumb-td").css("width","330px");}
	
	$("#thumb div").click(
		
		function(){
			var x = $("#thumb div").index(this);
			var z = x/2;


			$("#thumb div").children().css("visibility","visible").end().eq(x).children().css("visibility","hidden");
		
			$("#txl div:visible").fadeOut(300);
			$("#txr div:visible").fadeOut(300);
			$("#two div:visible").fadeOut(300);
			$("#one div:visible").fadeOut(300,
				function(){
				$("#one div").eq(z).fadeIn(500);
				$("#two div").eq(z).fadeIn(500);
				$("#txl div").eq(z).fadeIn(500);
				$("#txr div").eq(z).fadeIn(500);
				}
			);
			
		
			if( x % 2 == 1 )
			{$(this).prev().children().css("visibility","hidden");}
			else{$(this).next().children().css("visibility","hidden");}
		
		}
	);

}



function enlarge(){
	
	
	$("#one div").each(	
		function(){
		$(this).html( $(this).html().replace(/\u00A0|&nbsp;/g,""));
		if( $(this).html().match(/img/i) )
		{var s = $(this).children("img").attr("src").replace(/thumb/, "large");
		$(this).children("img").attr("src", s).removeAttr("width").removeAttr("height");}
		}
	);
	$("#one").children(":gt(1)").hide().end().children(":odd").appendTo("#two");
	
}


function data(){	
	$("#txl div").each(
		function(){
		$(this).html( $(this).html().replace(/\u00A0|&nbsp;/g,""));
		}
	);
	$("#txl").children(":gt(1)").hide().end().children(":odd").appendTo("#txr");
}

