$(document).ready(function() {
	// Store url for current page as global variable
	var current_page = document.location.href
	
		// Apply selected states depending on current page
		if (current_page.match(/Home/)) {
			$("ul#Nav li a:eq(0)").addClass('active');
		} else if (current_page.match(/Catalog/)) {
			$("ul#Nav li a:eq(1)").addClass('active');
		} else if (current_page.match(/ZLiner/)) {
			$("ul#Nav li a:eq(2)").addClass('active');
		} else if (current_page.match(/News/)) {
			$("ul#Nav li a:eq(3)").addClass('active');
		} else if (current_page.match(/About/)) {
			$("ul#Nav li a:eq(4)").addClass('active');
		} else if (current_page.match(/Contact/)) {
			$("ul#Nav li a:eq(5)").addClass('active');
		} else { // Do not mark any nav links as selected
			$("ul#Nav li").removeClass('active');
		};
	
	// Set Focus to Search Field
	$('#CatSearchText input').focus();
	
	// Clear Catalog Search		
	$("#ClearSearch input").click(function() {
		$("#CatSearchText input").attr("value","");
	});
	
	
	// Image Gallery
	$(".galleryPhoto").click(function() {
		var image = $(this).clone();
		var closeBtn = $('.closeBtn');
		var title = image.attr("title");
		var photoDetails = $('.photoDetails');
		$('.modalImage').addClass('show');
		photoDetails.text(title);
		image.appendTo('.imageHolder');
		image.removeClass('galleryPhoto');
		image.css("top", ($(window).height() / 2) - (image.height() / 2) );
		image.css("left", ($(window).width() / 2) - (image.width() / 2) );
		closeBtn.css("top", ($(window).height() / 2) - (image.height() / 2) - 10 );
		closeBtn.css("left", ($(window).width() / 2) - (image.width() / 2) - 10 );
		photoDetails.css("top", ($(window).height() / 2) - (image.height() / 2) - 32 );
		photoDetails.css("left", ($(window).width() / 2) - (image.width() / 2) + 25 );
		closeBtn.click(function () {
			$('.modalImage').removeClass('show');
			image.remove();
		});
		image.click(function () {
			$('.modalImage').removeClass('show');
			$(this).remove();
		});
	});
	
});
