/*

Last UpDate 2010-02-04

修正内容：：
2010-02-04 カレンダーの追加(鈴木)
2010-02-04 flat-heightの説明追加(鈴木)

修正される方へのお願い：：
0.修正する際は、修正後のソースの動作確認を十分に行うこと
1.修正する場合は上記修正内容に、内容と名前を必ず書くこと
2.修正前のfunction.jsの内容をバックアップをすること
  「function.js old version」に日付付きで入れる
3.最後に、「Last Update」を更新日にすること

*/

$(function(){
	//現在居るファイル名	   
	var currentFile = location.href.split('/').pop();
	
	//ua取得
	var ua = navigator.userAgent;
	
	//classが、'nav'で終わるulの、最後のliに、'last'クラスを付ける
	$('ul[class$="nav"]').each(function(){
		$('li:last',this).addClass('last');
	});
	
	//classが、'list'で終わるulの、偶数の要素に、'even'クラスを付ける
	$('ul[class$="list"] li:nth-child(even)').addClass('even');
	
	//classが、'table'で終わるテーブルの、偶数trに、'even'クラスを付ける
	$('table[class$="table"] tr:nth-child(even)').addClass('even');
	
	//rollover
	$('a img').each(function(){
		var imgSrc = $(this).attr('src');
		//smartRollover
		if(imgSrc.match(/(.*)_off(\..*)/)){
			var repSrc = RegExp.$1+'_on'+RegExp.$2;
			$('<img />').attr('src',repSrc);
			$(this).hover(function(){
				$(this).attr('src',repSrc);
				$(this).css({opacity: '1',filter: 'alpha(opacity=100)'});
			},function(){
				$(this).attr('src',imgSrc);
			});
		//ウィンク効果
		}else if(!$(this).hasClass('not')){
			$(this).hover(function(){
				if((imgSrc.indexOf('_off') == -1) && (imgSrc.indexOf('_on') == -1)){
					$(this).css({
						opacity: '0.2',
						filter: 'alpha(opacity=20)'
					});
					$(this).fadeTo('slow',1.0);
				}else{
					$(this).css({opacity: '1',filter: 'alpha(opacity=100)'});
				}
			});
		}
	});
		
	//submit押した感 & ウィンクorsmartrollover
	$('form p.submit input').mousedown(function(){
		$(this).css({position:'relative',top:'1px',left:'1px'});
	}).mouseup(function(){
		$(this).css({position:'static'});
	}).mouseout(function(){
		$(this).css({position:'static'});
	})
	  /* ウィンク版 */
	  .hover(function(){
		$(this).css({opacity:0.2});
		$(this).fadeTo('slow',1.0);

	  /* smartrollover版　*/
	  /*.hover(function(){
		$(this).attr('src',$(this).attr('src').replace(/^(.*)_off.(.*)$/,'$1_on.$2'));
	},function(){
		$(this).attr('src',$(this).attr('src').replace(/^(.*)_on.(.*)$/,'$1_off.$2'));*/
	});
	
	//lightBox
	try{
		$('.lb a[href$=".jpg"],.lb a[href$=".png"],.lb a[href$=".gif"]').lightBox({
			overlayBgColor: '#000',
			overlayOpacity: 0.8,
			imageLoading:   'js/images/lightbox-ico-loading.gif',
			imageBtnPrev:   'js/images/lightbox-btn-prev.gif',
			imageBtnNext:   'js/images/lightbox-btn-next.gif',
			imageBtnClose:  'js/images/lightbox-btn-close.gif',
			imageBlank:     'js/images/lightbox-blank.gif'
		});
	}catch(error){
	}

	if($('div').is('#bowl')){
	$("#bowl div.cms").autoHeight({column:2});
	$('#bowl div.cms:nth-child(odd)').addClass('margin10');
	}

	if($('div').is('.cart_main')){
		$('.cart_main h2').not(":eq(0)").css({ "margin-top": "50px","font-size":"22px" });
	}
	
	$("#side li a").each(function(){
		if($(this).attr("href").split('/').pop() == currentFile){
			$(this).parent().addClass("current");
		}
	});

	//fancybox
	try{
		$("#thumbnail li a").fancybox({
			'zoomOpacity' : true,'overlayShow' : false,'zoomSpeedIn' : 500,'zoomSpeedOut' : 500});
	}catch(e){}

});



