/*==================================================================
//
//  LIKN
//
==================================================================*/
function clickLink(URL, target){
	if(URL != "" ){
		if(target == "top"){
			top.location.href = URL;
		}else if(target == "blank"){
			window.open(URL, "");
		}else if(target != ""){
			eval("parent.' + target + '.location.href = URL");
		}else{
			location.href = URL;
		}
	}
}

/*==================================================================
//
//  ROLL OVER
//
==================================================================*/
function initClickableArea()
{
	//画像のロールオーバー
	var obj = $(".rollover a img, img.rollover");
	$.each(obj, function() {
		changeBt($(this), $(this));
	});
	//==============================
	//画像の透過
	$(".imgOver a img").hover (
		function ()
		{
			$(this).fadeTo(100, 0.7);
		},
		function ()
		{
			$(this).fadeTo(100, 0.999999);
		}
	);
	//==============================
	//テキスト要素のみ
	$(".clickableArea").find("[onclick*='clickLink']").addClass("clickable");
	//
	var obj = $(".clickableArea .clickable");
	$.each(obj, function(){
		var _target = $(this).hover(
			function ()
			{
				$(this).addClass("over");
			},
			function ()
			{
				$(this).removeClass("over");
			}
		);
		//画像のボタンがある場合
		if (_target.find("div").is(".rolloverBt"))
		{
			changeBt(_target.find("a img"), _target);
		}
	});
	//==============================
	//画像を含む時
	$(".clickableAreaContainImg").find("[onclick*='clickLink']").addClass("clickableContainImg");
	//
	var obj = $(".clickableAreaContainImg .clickableContainImg");
	$.each(obj, function(){
		var _target = $(this).append("<span class='imgCover'></span>");
		//
		_target.css({
			position: "relative",
			zIndex: "100"
		});
		//
		var imgCover = _target.find(".imgCover").css({
			width: _target.outerWidth(),
			height: _target.outerHeight(),
			background: "url('../images/common/spacer.gif')",
			display: "block",
			position: "absolute",
			top: "0px",
			left: "0px",
			zIndex: "100",
			cursor: "pointer"
		});
		//
		imgCover.hover(
			function ()
			{
				$(this).parent().addClass("over");
				//
				$(this).parent().find("a img").fadeTo(100, 0.7);
				//
				$(this).parent().find("img.cap")
					.animate({top: 30}, 0).animate({top: 40}, 80)
					.animate({top: 34}, 60).animate({top: 40}, 60)
					.animate({top: 36}, 30).animate({top: 40}, 30);
			},
			function ()
			{
				$(this).parent().removeClass("over");
				//
				$(this).parent().find("a img").fadeTo(100, 0.999999);
			}
		);
		//
		//画像のボタンがある場合
		if (_target.find("div").is(".rolloverBt"))
		{
			changeBt(_target.find("a img"), _target.find(".imgCover"));
		}
	});
	//
	function changeBt(target, clickableArea)
	{
		var image_cache = new Object();
		//
		target.not("[src*='_on.']").each(function(i) {
			var _this = this; 
			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;
			//
			clickableArea.hover(
				function() { _this.src = imgsrc_on; },
				function() { _this.src = imgsrc; }
			);
		});
	};
}
//
$(document).ready(initClickableArea);

/*==================================================================
//
//  feature（flashがアクティブでないとき用）
//
==================================================================*/
$(document).ready(
	function()
	{
		$("#fetureFlash .noFlash .featureBlock").find(".feature").each(
			function(index, domEle)
			{
				//右端の処理
				if (Number(index + 1) % 3 == 0)
				{
					$(this).css({
						marginRight: "0px"
					});
				}
				//
				//[new]アイコン
				if ($(this).hasClass("new"))
				{
					$(this).append("<span class='newIcon'><img src='images/top/newIcon.png' width='24' height='13' alt='NEW' title='NEW' class='pingFix' /></span>");
				}
				//
				//coming soon
				if ($(this).hasClass("ready"))
				{
					$(this).append("<span class='readyImg'><img src='images/top/readyImg.png' width='270' height='160' alt='COMING SOON' title='COMING SOON' class='pingFix' /></span>");
					//
					$(this).css({
						position: "relative"
					});
					//
					$(this).find(".readyImg").css({
						position: "absolute",
						top: "0px",
						left: "0px",
						zIndex: "100"
					});
				}
			}
		);
	}
);

/*==================================================================
//
//  バルーンの動き
//
==================================================================*/
var degree = 0;
//
function liniereMoveBal()
{
	$("img.bal").css({
		top: 16 + 10 * Math.sin(Math.PI / 180 * degree) + "px",
		left: 15 * Math.sin(Math.PI/180 * (degree * 0.4)) + "px"
	})
	//
	degree++;
}
//
var topDegree = 0;
//
function moveBal()
{
	$("img.bal").css({
		top: -35 + 10 * Math.sin(Math.PI / 180 * degree) + "px",
		right: 7 + 20 * Math.sin(Math.PI/180 * (degree * 0.4)) + "px"
	})
	//
	degree++;
}
//
$(document).ready(
	function()
	{
		if($("#catalog").find("img.bal").hasClass("liniere"))
		{
			liniereTimerID = setInterval("liniereMoveBal()",10);
		}
		//
		if($("#catalogImg").find("img.bal").hasClass("top"))
		{
			TimerID = setInterval("moveBal()",10);
		}
	}
);