/*

Last UpDate 2010-12-09

修正内容：：
2010-02-04 カレンダーの追加(鈴木)
2010-02-04 flat-heightの説明追加(鈴木)
2010-12-09 oapcityの変更（三品）

修正される方へのお願い：：
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'クラスを付ける
	$('ol[class$="list"] li:nth-child(even)').addClass('even');
	$('ul[class$="list"] li:nth-child(even)').addClass('even');
		
	//classが、'table'で終わるテーブルの、偶数trに、'even'クラスを付ける
	$('table[class$="table"] tr:nth-child(even)').addClass('even');
	
	$('div[class$="colorsample"] dl:nth-child(5n)').addClass('right');
	
	//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.8',
						filter: 'alpha(opacity=80)'
					});
					$(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'));
	});
	
	//fancybox
	try{
		$("div#results a").fancybox({
			'zoomOpacity' : true,'overlayShow' : false,'zoomSpeedIn' : 500,'zoomSpeedOut' : 500});
	}catch(e){}
	try{
		$("div#material a").fancybox({
			'zoomOpacity' : true,'overlayShow' : false,'zoomSpeedIn' : 500,'zoomSpeedOut' : 500});
	}catch(e){}
	try{
		$("div#works a").fancybox({
			'zoomOpacity' : true,'overlayShow' : false,'zoomSpeedIn' : 500,'zoomSpeedOut' : 500});
	}catch(e){}
	
	//flatHeights設定
		var sets = [], temp = [];
		$('div#works dl').each(function(i) {
			temp.push(this);
			if (i % 5 == 4) {
				sets.push(temp);
				temp = [];
			}
		});
		if (temp.length) sets.push(temp);
		
		/* 各組ごとに高さ揃え */
		$.each(sets, function() {
			$(this).flatHeights();
		});
	
});



