﻿$(document).ready(function(){
	//$("#iCurrentPath").html("KS Images Gallery" + (window.location.search == "" ? "" : window.location.search.replace("?Folder=", "").replace(/\//g, " > ")));
	
	if (navigator.appName == "Netscape") {
	    var myFolder = UTF8.decode(unescape(window.location.search)).replace("?Folder=", "").replace(/\//g, " > ");
	} else {
	    var myFolder = window.location.search.replace("?Folder=", "").replace(/\//g, " > ");
	}
	
	$("#iCurrentPath").html("KS Images Gallery" + (window.location.search == "" ? "" : myFolder ));
	
	
	if (window.location.search == "" || window.location.search == "?Folder=")
	{
		$("#iBackButton").empty().css("padding-bottom", "0px");
	}
	else
	{
		$("#iBackButton a").attr("href", window.location.pathname + window.location.search.substring(0, window.location.search.lastIndexOf("/")));
	}
	$(".Folder").each(function(i,e){
		e = $(e)
		e.html("<a href='" + window.location.pathname + "?Folder=" + e.attr("Folder").replace("KSGallery", "") + '/' + e.attr("Picture") + "' target='_self'><img src='/_layouts/images/mysite_titlegraphic.gif'/><br/><div class='FolderName'>" + e.attr("Picture") + "</div></a>");
	});
	$(".Picture").each(function(i,e){
		e = $(e)
		if ((/\.gif$/).test(e.attr("Picture").toLowerCase()) ||
			(/\.jpg$/).test(e.attr("Picture").toLowerCase()) ||
			(/\.jpeg$/).test(e.attr("Picture").toLowerCase()) ||
			(/\.png$/).test(e.attr("Picture").toLowerCase()))
		{
			e.html("<a href='/" + e.attr("Folder") + '/' + e.attr("Picture") + "' onclick='window.open(this.href, \"_blank\", \"width=" + (parseInt(e.attr("ImageWidth")) + 40) + ",height=" + (parseInt(e.attr("ImageHeight")) + 30) + ",scrollbars=1\"); return false;'><img src='/" + e.attr("Folder") + '/_t/' + e.attr("Picture").replace(/\.([^\.]+$)/, "_$1") + ".jpg'/></a>");
		}
		else
		{
			//e.hide();
			e.remove();
		}
	});
	$(".KSIG:nth-child(5)").after("<div class='clear'></div>");
	$(".Detail").show();
});

