// -------------------- 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);
}

function drawSwfTrs(id, url, w, h){
	var version = "8";
	var express = "";
	var flashvars = {};
	var attributes = {};
	var params = {
		quality: "high",
		menu: "false",
		wmode: "transparent"
	};

	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("/eco_social/") == 0) id = "navi08";
		else if(p.indexOf("/franchise/") == 0) id = "navi07";
		else if(p.indexOf("/recruit/") == 0) id = "navi06";
		else if(p.indexOf("/company/ir/") == 0) id = "navi05";
		else if(p.indexOf("/company/") == 0) id = "navi04";
		else if(p.indexOf("/ministopfan/") == 0) id = "navi02";
		else if(p.indexOf("/index") == 0 || p == "/") id = "navi01";
		if(id) $("#"+id+" img").each(function(){
			this.src = this.src.replace("_n.", "_s.");
		});
	}
}


// -------------------- 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();
});

