/*

@with thickbox
@page scrol
@tab
@product category
@zebra style
@add css3 style
@function_exists

*/
jQuery.easing.quart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

$(document).ready(function() {

/*-------------------------------------
	with thickbox
-------------------------------------*/
	if(function_exists('tb_init')) {
		tb_init('a[href$=".jpg"]:not(.thickbox, a[href*="?"]), a[href$=".gif"][href!="?"]:not(.thickbox, a[href*="?"]), a[href$=".png"][href!="?"]:not(.thickbox, a[href*="?"]),a[href$=".JPG"]:not(.thickbox, a[href*="?"]), a[href$=".GIF"][href!="?"]:not(.thickbox, a[href*="?"]), a[href$=".PNG"][href!="?"]:not(.thickbox, a[href*="?"])');
	}

/*-------------------------------------
	page scroll
-------------------------------------*/
	$('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 }, 1200, 'quart');
				return false;
			}
		}
	});

/*-------------------------------------
	tab
-------------------------------------*/
	$(function() {
		$("a.tab").click(function() {
			$(".active").removeClass("active");
			$(this).addClass("active");
			$(".tab-content").hide('slow');
			var contentId = $(this).attr("rel");
			$("#" + contentId).show('slow'); 
		});
	});
	

/*-------------------------------------
	product category
-------------------------------------*/
	$('#searchBox li').hover(
		function() { $('ul', this).css('display', 'block'); },
		function() { $('ul', this).css('display', 'none'); }
	);
	
/*-------------------------------------
	zebra style
-------------------------------------*/
	$("ul, ol").each(function(){
		$(this).find("li:even").addClass("even");
		$(this).find("li:odd").addClass("odd");
	});
	$("table, tbody").each(function(){
		$(this).find("tr:even").addClass("even");
		$(this).find("tr:odd").addClass("odd");
	});
	
/*-------------------------------------
	add css3 style
-------------------------------------*/
	//:first-child, :last-childをクラスとして追加
	$('body :first-child').addClass('firstChild');
	$('body :last-child').addClass('lastChild');
	//css3の:emptyをクラスとして追加
	$('body :empty').addClass('empty');


});

/*-------------------------------------
	function_exists
-------------------------------------*/
function function_exists( function_name ) {
    if (typeof function_name == 'string'){
        return (typeof window[function_name] == 'function');
    } else{
        return (function_name instanceof Function);
    }
}
