/*▼CSSハック用*/
/* ----------------------------------------------------- */
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();

/*▼jquery ロード*/
/* ----------------------------------------------------- */
$(function(){
					 
	/* 関数呼び出し*/
	/* ----------------------------------------------------- */
	currentCheck();
	
	$('.lightbox').lightBox();
	
	if($('#slider').size()===1){
		$('#slider').s3Slider({  
				timeOut: 4000  
		});
	}
	
	/* ロールオーバー*/
	/* ----------------------------------------------------- */
	$('.over').not("[@src*='-o.']").hover(function()
	{
		Rollover($(this),$(this).attr('src'));	
	},function() {
		Rollover($(this),$(this).attr('src'));	
	});	

	/* ページ内スクロール */
	/* ----------------------------------------------------- */
  $('a[href^=#]').click(function(event) {
    var hash = this.hash;
		if(hash!==''){
			var tarPosition = $(hash).offset().top;
			if(undefined !== window.opera && "function" === typeof window.opera.version){ // opera
				$('html').animate({scrollTop: tarPosition}, 400, 'easeOutQuad'); 
			}
			else{
				$('html, body').animate({scrollTop: tarPosition}, 400, 'easeOutQuad');
			}
			return false;
		}
  });

	/*addclass*/
	$('#footer div:last-child').addClass('last');
	$('#side-nav dl:last').addClass('last');
	$('.common-table').find('tr:first-child').find('th').addClass('f-child');
	$('.common-table').find('tr:first-child').find('td').addClass('f-child');
	$('.common-table').find('tr:last-child').find('th').addClass('l-child');
	$('.common-table').find('tr:last-child').find('td').addClass('l-child');
	
	$('.common-table td').each(function(){
		$('ul',this).each(function(i){
			if(i===0){
				return
			}
			else{
				$(this).addClass('adj03');	
			}
		});
	});
	
	$('.privacy-note dd:last').addClass('l-child');
	$('#work .common-table:last').addClass('last');
	$('#top #feature div.pickup:last').addClass('last-pickup');

	$('#slider').hover(function()
	{
		$(this).addClass('slider-active');
	},function() {
		$(this).removeClass('slider-active');
	});
});

/* ----------------------------------------------------- */
/* カレントチェック*/
/* ----------------------------------------------------- */
var currentCheck = function(){
	if($('#top').size()!=1){
	var tar = $('#side-nav').attr('class');
	$('#side-nav dt').each(function(i){
		if($(this).attr('id')==tar){
			$(this).addClass('active').find('a');
		}
	});
	$('#side-nav li').each(function(i){
		if($(this).attr('id')==tar){
			$(this).addClass('active').find('a');
		}
	});
	}
}

/* ----------------------------------------------------- */
/*　ページ内スクロール用　*/
/* ----------------------------------------------------- */
jQuery.easing.easeOutQuad = function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
};

/* ----------------------------------------------------- */
/* ロールオーバー*/
/* ----------------------------------------------------- */
var Rollover = function(obj,thisSrc) {
	/*---変数宣言---*/
	var sTempSrc = thisSrc;
	var ftype = thisSrc.substring(thisSrc.lastIndexOf('.'), thisSrc.length);
	var hsrc = thisSrc.replace(ftype, '-o'+ftype);	
	var aPreLoad = new Image();

	/*---プリロード---*/
	aPreLoad.src = hsrc;

	re = new RegExp("-o");
	
	if(!sTempSrc.match(re)){
		$(obj).attr('src', hsrc);
	}
	
	if (sTempSrc.match(re)) {
		sTempSrc = $(obj).attr('src').replace('-o'+ftype, ftype);
		$(obj).attr('src', sTempSrc);
	}
}
