$(function() {
	//scroll animation
	$('a[href^=#]').click(function() {
		var speed = 400;
		
		var href= $(this).attr("href");
		var target = $(href == "#" || href == "" ? 'html' : href);
		var position = target.offset().top;
		$($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
		return false;
	});
	
	//simple tooltip
	$(".tooltip a").hover(function() {
		$(this).next("span").animate({opacity: "show", top: "-75"}, "slow");}, function() {
		$(this).next("span").animate({opacity: "hide", top: "-85"}, "fast");
	});
	
	//rollover
	$("img.onbanner").mouseover(function(){
	        $(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_r$2"))
    }).mouseout(function(){
        $(this).attr("src",$(this).attr("src").replace(/^(.+)_r(\.[a-z]+)$/, "$1$2"));
    }).each(function(){
        $("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_r$2"))
	});

	
	$("#errorbox").live('click',function(){
		$(this).hide()
		$("#error").hide()
	})
	$("#error").live('click',function(){
		return false;
	})
	$("#btnerrorclose").live('click',function(){
		$("#errorbox").hide();
		$("#error").hide();
	});


});
function showMsgbox(msg, errflg){
	$('body').append('<div id="errorbox"></div><div id="error"><div id="errormodalbox"><div class="closebtn"><p id="btnerrorclose">閉じる</p></div><div id="errormsg"></div></div></div>');
	$('#error').css({marginLeft: '-' + parseInt((450 / 2),10) + 'px', width: 450 + 'px'});
	$('#error').css({marginTop: '-' + parseInt((300 / 2),10) + 'px'});
	$('#errormsg').html(msg);
	if (errflg){
		$('#errflg').html('- エラー -');
		$('#errflg').css({color:'#f00', fontWeight:'bold'});
		$('#errormsg').css({color:'#f00'});
	}else{
		$('#errflg').css({display:'none'});
	}
	$("#errorbox").show();
	$("#error").show();
}

