var _Common_ = {
	initRollovers:function(){
		$('img[class=over]').hover(function(){
			var src = $(this).attr("src");
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			$(this).attr("src",$(this).attr("src").replace(ftype,"_over"+ftype));
		},function(){
			$(this).attr("src",$(this).attr("src").replace("_over.","."));
		});
		return false;
	},
	rand:function(x){
		number = Math.floor(Math.random() * x);
		return number;
	},
	url_Parse:function(url){
		var _ = false;
		if(url.indexOf("?") > 0 && url.indexOf("=") > 0){
			_ = new Array();
			var array = url.split("#");
			array = array[0].split("?");
			array = array[1].split("&");
			for(var i=0;i<array.length;i++){
				array[i] = array[i].split("=");
				var hash = array[i][0];
				var value = array[i][1];
				
				_[hash] = value;
			}
			delete array;
		}
		return _;
	}

}
function z2h(value){
	var han= '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@_-.,:';
	var zen= '１２３４５６７８９０ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ＠＿－．，：';
	
	str = ""; 
	
	for (i=0; i<value.length; i++) {
		c = value.charAt(i);
		n = zen.indexOf(c,0);
		if (n >= 0) c = han.charAt(n); str += c; 
	}
	return str;	
}
function catalogSrh(){
	var keyword = $(".value").val();
	if(keyword == ""){
		if($(".search p").length < 1){
			$(".search").append("<p>検索ワードを入力してください。</p>")
		}else{
			$(".search p").text("検索ワードを入力してください。")
		}
		return false;
	}
	keyword = z2h(keyword);
	$(".catalogList").removeHighlight().highlight(keyword);
	if(($("span.highlight").length) < 1){
		if($(".search p").length < 1){
			$(".search").append("<p>見つかりませんでした。</p>")
		}
	}else{
		$(".search p").remove();
		$(".search").append("<p><strong>" + $("span.highlight").length + "</strong>件見つかりました。</p>")
	};
	/*
	try{
		window.find(keyword);
	}catch(e){
		alert(e);
	}
	*/
	
};
function tabinit(){
	$(".productTab a").click(function(){
		
		$(this).parent().parent().find("a").each(function(){
			
			$($(this).removeAttr("class").attr("href")).hide();
			
		});
		
		$($(this).attr("class","current").attr("href")).show();
		return false;
	});
	
	$(".tab a").click(function(){
		
		$(this).parent().parent().find("a").each(function(){
			
			$($(this).attr("href")).hide();
			
		});
		
		$($(this).attr("href")).show();
		return false;
	});
	$("div.none").hide();
};


$(function(){
	_Common_.initRollovers();
	
	
	$(".scroll").jScrollPane();
	
	
	$(".menu .products dt").each(function(x){
		$(this).click(function(){
			$(".menu .products dd").eq(x).slideToggle(300);
			return false;
		});
		
	});
	
	if($(".productDetail").length >0){
		tabinit();
	}
	
	
	$(".colorbox").colorbox();
	
});
