
$(function() {
	var lu = location.href.split("#");
	var ln = 0;


	if (lu.length > 1) {
		if (lu[1].indexOf("tab",0) > -1) {
			ln = lu[1].substring(3,4) - 1;
		}
	}

	$("#tabs li a").click(function(){
		$("#tabview").html('<img src="../common/img/loading.gif" width="16" height="16" alt="" class="loading" />');
		var hash = "#tab" + ($("#tabs li").index($(this).parent())+1);
		$("#tabview").load($(this).attr("href"),"",function(){tab_init();});

		$("#tabs li a").removeClass("currenttab");
		$(this).addClass("currenttab");
		location.href = lu[0] + hash;
		$(this).blur();
		return false;
	});

	$("#tabs li a").hover(function(){
		$(this).animate({ opacity: 0.8 },0);
	}, function(){
		$(this).animate({ opacity: 1 },0);
	});

	$("#tabs li").eq(ln).find("a").click();
	$("#searchbox").animate({height: "toggle", opacity: "toggle"},{duration: "slow"});

});

function tab_init() {
	$("#tabinselect").change(function(){
		$("#tabinview").html('<img src="../common/img/loading.gif" width="16" height="16" alt="" class="loading" />');
		$("#tabinview").load($("option:selected",this).val(),"",function(){tabin_init();});
	});

	$(":not(#tabinview) #tabinmenu li a").click(function(){
		$("#scrollbox").html('<img src="../common/img/loading.gif" width="16" height="16" alt="" class="loading" />');
		$("#searchtitle").text($(this).attr("title"));
		$("#scrollbox").load($(this).attr("href"));

		$("#tabinmenu li").removeClass("currentmenu");
		$(this).parent().addClass("currentmenu");
		$(this).blur();
		return false;
	});

	$("#searchmap #searchmap_map area").click(function(){
		flag = 0;
		$("#scrollbox").html('<img src="../common/img/loading.gif" width="16" height="16" alt="" class="loading" />');
		$("#searchtitle").text($(this).attr("title"));
		$("#searchmapwindow").css("top","210px");
		$(this).blur();
		var thiscopy = this;
		$("#searchmapwindow").animate({top: "10px",height: "toggle", opacity: "0.9"},300,function(){
			$("#scrollbox").load($(thiscopy).attr("href"));
		});
		return false;
	});

	$("#searchmapwindowclose").click(function(){
		$("#searchmapwindow").animate({height: "toggle", opacity: "0"},300);
	});

	var searchmap_img = $("#searchmap > img").attr("src");
	var flag = 0;

	$("#searchmap #searchmap_map area").hover(function(){
		$("#searchmap > img").attr("src",$(this).attr("rel"));
			flag = 1;
	},function(){
		if (flag) {
			$("#searchmap > img").attr("src",searchmap_img);
			flag = 0;
		}
	});

	$("#tabinselect").change();
	$("#tabinmenu li.currentmenu a").click();

}

function tabin_init() {

	rollover();

	$("#tabinmenu li a").click(function(){
		$("#scrollbox").html('<img src="../common/img/loading.gif" width="16" height="16" alt="" class="loading" />');
		$("#searchtitle").text($(this).attr("title"));
		$("#scrollbox").load($(this).attr("href"));

		$("#tabinmenu li").removeClass("currentmenu");
		$(this).parent().addClass("currentmenu");
		$(this).blur();
		return false;
	});

	$("#tabinmenu li.currentmenu a").click();
}

$(function() {
	rollover();
});

function rollover() {
	var image_cache = new Object();
	$('[src*=_roll.]').not("[src*='_on.']").each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
		$(this).hover(
			function() { this.src = imgsrc_on; },
			function() { this.src = imgsrc; }
		);
	});
}

$(function(){
	if (document.URL.match(/\?print$/)) {
		$('link[media="print"]').attr({media: "all"});
	}
});



