/* IE6背景画像ちらつき対処 */
try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}

/* jquery基本 */
$(document).ready(function() {
	/* ロールオーバー */
	var preLoad = new Object();
	$('img.Over,input.Over').not("[src*='_o.']").each(function(){
		var imgSrc = this.src;
		var fType = imgSrc.substring(imgSrc.lastIndexOf('.'));
		var imgName = imgSrc.substr(0, imgSrc.lastIndexOf('.'));
		var imgOver = imgName + '_o' + fType;
		preLoad[this.src] = new Image();
		preLoad[this.src].src = imgOver;
		$(this).hover(
			function (){ this.src = imgOver;},
			function (){ this.src = imgSrc;}
		);
	});

	/* 外部リンク指定 */
	$('a[href^="http://"]').attr("target", "_blank");
	$("a[class='blank']").click(function(){
		this.target = "_blank";
	});

	/* ページスクロール */
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 800);
				return false;
			}
		}
	});
});

/* ドロップダウン処理 */
function mainmenu(){
$("#nav ul").css({display: "none"});
	$("#nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
	},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
	});
}
$(document).ready(function(){					
	mainmenu();
});


/* バナー光沢処理 */
$(document).ready(function(){
	$('#banner li').hover(function(){
		$(this).find(".shine").stop();
		$(this).find(".shine").css('background-position','-100px 0');
		$(this).find(".shine").animate({backgroundPosition:'135px 0'},350);
	}, function(){
		$(this).stop();
	});
});

/* 透過処理 */
$(document).ready(function() {
	$('#related li a').hover(function(){
		$(this).fadeTo("fast", 0.7);
	},function(){
		$(this).fadeTo("slow", 1.0);
	});
});

/* リンクアニメーション */
$(document).ready(function() {
	$('#contents_right h3 a').append('<span class="hover"></span>').each(function () {
		var $span = $('> span.hover', this).css('opacity', 0);
		$(this).hover(function () {
			$span.stop().fadeTo(350, 1);
		}, function () {
			$span.stop().fadeTo(700, 0);
		});
	});
});

/* テーブルを1行ごとに色変更 */
$(document).ready(function(){
	$('#contents #contents_main.membar tr:odd').addClass('odd');
});

/* フォントサイズ変更 */
$(document).ready(function() {
	if($.cookie('TEXT_SIZE')) {
		$('body').addClass($.cookie('TEXT_SIZE'));	
	}
	$('#fontsize a').click(function() {
		var textSize = $(this).parent().attr('class');
		$('body').removeClass('small medium large').addClass(textSize);
		$.cookie('TEXT_SIZE',textSize, { path: '/', expires: 10000 });
		return false;
	});
});

/* cookie */
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires='; expires='+date.toUTCString()}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('')}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break}}}return cookieValue}};
