/* ===========================================
 * タキヤ
 * -------------------------------------------
 * UTF-8N
=========================================== */


/* Flash
=========================================== */

function drawSwf(id, url, w, h){
	var version = "8";
	var express = "";
	var flashvars = {};
	var attributes = {};
	var params = {
		quality: "high",
		menu: "false"
	};

	swfobject.embedSWF(url, id, w, h, version, express, flashvars, params, attributes);
}


/* GlobalNavi
=========================================== */

var gnavi = {
	setInit : function(){
		var p = location.pathname;
		var id = "";
		if(p.indexOf("/corporate/") == 0) id = "bt01";
		else if(p.indexOf("/sitemap/") == 0) id = "bt03";
		else if(p.indexOf("/recruit/") == 0) id = "gn06";
		else if(p.indexOf("/support/") == 0) id = "gn05";
		else if(p.indexOf("/items/") == 0) id = "gn04";
		else if(p.indexOf("/benefit/") == 0) id = "gn03";
		else if(p.indexOf("/search/") == 0) id = "gn02";
		else if(p.indexOf("/index") == 0 || p == "/") id = "gn01";
		if(id) $("#"+id+">a>img").each(function(){
			this.src = this.src.replace("_n.", "_o.");
		});
	}
}


/* RollOver
=========================================== */

var rollover = {
	setInit : function(){
		rollover.p = new Object();
		$("img[src*='_n.'],input[src*='_n.']").each(function(){
			var n = this.src;
			var o = n.replace("_n.", "_o.");
			if(!rollover.p[n]){
				rollover.p[n] = new Image();
				rollover.p[n].src = n;
				rollover.p[o] = new Image();
				rollover.p[o].src = o;
			}
			$(this).hover( 
				function(){ this.src = rollover.p[o].src; },
				function(){ this.src = rollover.p[n].src; }
			);
		});
	}
}


/* AnimeScroll
=========================================== */

jQuery.easing.quart = function(x, t, b, c, d){
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

var aniscroll = {
	setInit : function(){
		$('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;
					var targetTag = navigator.appName.match(/Opera/)? "html" : "html,body";
					$(targetTag).animate({scrollTop: targetOffset}, 'quart');
					return false;
				}
			}
		});
	}
}


/* ===========================================
 * START
=========================================== */

$(document).ready(function(){

	// GlobalNavi
	gnavi.setInit();

	// RollOver
	rollover.setInit();

	// AnimeScroll
	aniscroll.setInit();

	// Table
	$("table.even").each(function(){
		$(">tbody>tr:even",this).addClass("jq");
	});
	$("table.odd").each(function(){
		$(">tbody>tr:odd",this).addClass("jq");
	});

});


