$(function() {
	//smartRollover

	var imgCount = 0;
	var images_pre = new Array();
	$('img[src*="_off."],input[src*="_off."]').each (function(){
		images_pre[imgCount] = new Image();
		images_pre[imgCount].src = $(this).attr("src").replace("_off.", "_on.");
		$(this).hover(
			function () {
				$(this).attr("src", $(this).attr("src").replace("_off.", "_on."));
			},
			function () {
				$(this).attr("src", $(this).attr("src").replace("_on.", "_off."));
			}
		);
		imgCount ++;
	});



	// opacity Rollover

	$('img[src*="_op."],input[src*="_op."]').hover(
		function () {
			$(this).css('opacity', 0.7);
		},
		function () {
			$(this).css('opacity', 1);
		}
	);



	// external

	var notBlank = new Array("");

	var n = "";
	for (var i = 0; i < notBlank.length; i ++) if(notBlank[i]) n += ":not([href*='" + notBlank[i] + "'])";
	if(document.domain) n += ":not([href*='" + document.domain + "'])";

	$("a[rel='external'], a[href$='.pdf']").attr("target", "_blank");
	$("a[href^=http]"+n).attr("target", "_blank");



	// smoothScroll

	$('a[href^=#]').each (function(){
		var hash = this.hash;
		if(hash.length > 1 && !this['rel']){
			$(this).click(function() {
				smoothScroll(hash);
				return false;
			})
		}
	});
	
	
	// 
	$('#index #sidebar li::nth-child(1)').css('margin-bottom', 0);
	$('#index #sidebar li::nth-child(2)').css('margin-bottom', '5px');
	
	
	// stripe
	$(".stripe1 > li:nth-child(even)").addClass("even");
	$(".stripe1 > li:nth-child(odd)").addClass("odd");
	$(".stripe2 > li:nth-child(even)").addClass("even");
	$(".stripe2 > li:nth-child(odd)").addClass("odd");

	$(".table_box table:nth-child(odd)").not(".stripe").not(".stripe_reverse").not(".no-stripe").addClass("odd");
	$(".table_box table.stripe tr:nth-child(even)").addClass("odd");
	$(".table_box table.stripe_reverse tr:nth-child(odd)").addClass("odd");

	$('a.map').fancybox();

	// opera only
	if($.browser.opera) {
		$("#navi").css("padding-left", 1)
	}


	// pop
	$('a[rel=pop]').click( function(e){
		e.preventDefault();
		var wo = window.open($(this).attr("href"), "pop", "width=660, height=800, scrollbars=1, menubar=1, resizable=1, menubar=1");
	});

});

function smoothScroll(hash) {
	var target = $(hash).offset().top;

	$(($.browser.safari) ? 'body' : 'html')
		.animate({scrollTop: target >= 15 ? target - 15 : target}, 600, 'swing', function(){$(this).unbind("mousewheel DOMMouseScroll");})
		.bind("mousewheel DOMMouseScroll",function(){
			$(this).queue([]).stop();
			$(this).unbind("mousewheel DOMMouseScroll");
		})
}

// DD_belatedPNG
if($.browser.msie && $.browser.version < 7){
	DD_belatedPNG.fix('img');
}
