function execute_a(){
		if (this.href.search(/dj-ira.com/) == 7) {
			$("#contents_container, .background_photo").animate({opacity: '0.0'}, 300);
	        $.historyLoad(this.href.replace(/^.*#/, ''));
	        return false;
		} else {
			location.replace(this.href);
			return true;
		}
}

$(document).ready(function () {
	if(window.location.hash == '') window.location.hash = 'home';
	$.historyInit(callback);
    $("a").not(".close_button, .external, .gallery_photo a").click(execute_a);
});

function callback(hash)
{	
	if(hash) {
		$.getJSON("/ajax.php?hash=" + hash, 
			function(data)
			{
				hashArray = hash.split('.');
				if(hash == 'home') {
					$("#contents_container").removeClass("contents_container").addClass("contents_container_home");
					$("#contents_line").removeClass("contents_line").addClass("contents_line_home");
					$("#logotype_container").removeClass("logotype_container").addClass("logotype_container_home");
					$("#section_title_img").attr("src", "/graphics/spacer.gif");
				} else {
					$("#contents_container").removeClass("contents_container_home").addClass("contents_container");
					$("#contents_line").removeClass("contents_line_home").addClass("contents_line");
					$("#logotype_container").removeClass("logotype_container_home").addClass("logotype_container");
					$("#section_title_img").attr("src", "/graphics/sections_titles/title_" + hashArray[0] + ".gif");
				}	
				
				document.title = data.title;
				
				$(".background_photo").css({"background-image": "url(" + data.bg_image + ")"});
				$(".breadcrumbs_container").html(data.breadcrumbs);
				$("#contents_container").html(data.html);
				$('div.section div.section_text div.text_container, div.gallery div.gallery_photo').jScrollPane({showArrows:false,scrollbarWidth:7,dragMaxHeight:38});
				$("div.gallery div.gallery_photo a").click(function () {
					$(".modal").css({display: "block"});
					$(".modal").animate({opacity: '0.9'}, 500);
					preloadImage ($(this).attr("href"), $(this).children("img").attr("title"));
					
					return false;
				});
				$('.menu_link_container img').each(function () {
					$(this).attr("src", $(this).attr("src").replace(/_selected.gif/, ".gif"));
					$(this).removeClass("selected");
				});
				if (hash != 'home') {
					$('.menu_link_container img#' + hashArray[0]).attr("src", $('.menu_link_container img#' + hashArray[0]).attr("src").replace(/.gif/, "_selected.gif"));
					$('.menu_link_container img#' + hashArray[0]).addClass("selected");
				}
				
				setTimeout('$("#contents_container, .background_photo").animate({opacity: "1.0"}, 500)', 500);
			    $("a").not(".close_button, .external, .gallery_photo a").click(execute_a);
			});
	} else {
		window.location.hash = 'home';
	}
}