/* Flash
=========================================== */

function drawSwf(id, url, w, h){
	var version = "8";
	var express = "";
	var flashvars = {};
	var attributes = {};
	var params = {
		quality: "high",
		menu: "false",
		wmode: "opaque"
	};

	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("/shops/") == 0) id = "gn06";
		else if(p.indexOf("/service/") == 0) id = "gn05";
		else if(p.indexOf("/collection/") == 0) id = "gn04";
		else if(p.indexOf("/emerald_cut/") == 0) id = "gn03";
		else if(p.indexOf("/concept/") == 0) id = "gn02";
		else if(p.indexOf("/index") == 0 || p == "/") id = "gn01";
		if(id) j$("#"+id+">a>img").each(function(){
			this.src = this.src.replace("_n.", "_o.");
		});
	}
}


/* RollOver
=========================================== */

var rollover = {
	setInit : function(){
		rollover.p = new Object();
		j$("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;
			}
			j$(this).hover(
				function(){ if(this.src.lastIndexOf("_n.") > -1) this.src = rollover.p[o].src; },
				function(){ if(this.src.lastIndexOf("_o.") > -1) 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(){
		j$('a[href*=#]').click(function(){
			if(location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname){
				var j$target = j$(this.hash);
				j$target = j$target.length && j$target || j$('[name='+this.hash.slice(1)+']');
				if(j$target.length){
					var targetOffset = j$target.offset().top;
					var targetTag = navigator.appName.match(/Opera/)? "html" : "html,body";
					j$(targetTag).animate({scrollTop: targetOffset}, 'quart');
					return false;
				}
			}
		});
	}
}


/* ===========================================
 * START
=========================================== */

var j$ = jQuery.noConflict();

/* ---------------------------------------- */

j$(document).ready(function(){

	// GlobalNavi
	gnavi.setInit();

	// RollOver
	rollover.setInit();

	// AnimeScroll
	aniscroll.setInit();

});


