/*==============================================
 checkjs
==============================================*/
$(function(){$('body').removeClass('nojs');});

/*==============================================
 rootDir
==============================================*/
var rootDir = (location.protocol.match(/file/i))      ? 'htdocs'
            : (location.hostname.match(/localhost/i)) ? ''
            : (location.pathname.match(/109site/i))   ? '109site_new' : '';
var rootPath = location.pathname.replace(/\\/g,'/').replace(/\/+/g,'/');
if(rootDir) rootPath = rootPath.substr(rootPath.indexOf(rootDir)+rootDir.length);
function here(cnd,not){
  if(cnd instanceof Array) cnd = cnd.join('|');
  var apply = (rootPath.match(new RegExp(cnd,'i'))) ? true : false;
  return (not) ? !apply : apply;
}
here.is   = function(cnd){return here(cnd,false);};
here.isnt = function(cnd){return here(cnd,true);};

/*==============================================
 insert swf
==============================================*/
$.fn.insertSWF = function(opt) {
  var cfg = $.extend({
    wmode             : 'transparent',
    allowScriptAccess : 'always',
    allowFullScreen   : 'always',
    menu              : 'false',
    base              : '.',
    version           : 8,
    addMode           : 'html',
    requireCode       : '<p class="fullSpace requireFlashPlayer">こちらのコンテンツをご覧いただくには、最新のAdobe Flash Playerが必要です。<br />お手数ですが、以下バナーのリンク先から最新のAdobe Flash Playerを入手してください。<br /><br /><a href="http://get.adobe.com/jp/flashplayer/" target="_blank"><img src="/shared/img/bnr_adobe.jpg" alt="Get Adobe Flash Player" /></a></p>'
  }, opt);
  $(this).each(function(){
  	var addMode = cfg.addMode;
	var code    = '';
    if(DetectFlashVer(cfg.version,0,0) && cfg.src && cfg.width && cfg.height) {
      cfg.version = cfg.addMode = cfg.requireCode = null;
      code = AC_FL_RunContent(cfg);
	} else {
      code = cfg.requireCode;
    }
       (addMode == 'html')    ? $(this).html(code)
      :(addMode == 'append')  ? $(this).append(code)
      :(addMode == 'prepend') ? $(this).prepend(code)
      :(addMode == 'after')   ? $(this).after(code)
      :(addMode == 'before')  ? $(this).before(code)
      :(addMode == 'replace') ? $(this).replaceWith(code) : '';
  });
};

/*==============================================
 tab changer
==============================================*/
function tabChanger(){
	var controller = $('.tabController');
	var content    = $('.tabContents');
	content.not('.tabContentsCurrent').css({opacity:0,display:'none'});
	$('#returnTop').hide().show();
	$('.tabControllerCurrent img',controller).currentSet();
	$('a',controller).click(function(){
		$('a img',controller).currentReset();
		$('img',this).currentSet();
		content.css({opacity:0,height:0,display:'none'});
		$($(this).attr('href')).css({display:'block',height:'auto'}).animate({opacity:1},'normal');
		$('#returnTop').hide().show();
		return false;
	});
}


/*==============================================
 easily RollOver
==============================================*/
$.fn.imageRollOver = function(){
	var obj = obj || {};
	$(this).each(function(){
		var src  = this.src;
		var osrc = src.replace("_off.","_on.");
		obj[src] = new Image();
		obj[src+"_d"] = new Image();
		obj[src].src = osrc;
		obj[src+"_d"].src = src;
		$(this).hover(function(){
			if(!$(this).hasClass('current'))
				this.src = obj[src].src;
		},function(){
			if(!$(this).hasClass('current'))
			this.src = obj[src+"_d"].src;
		})
	})
}

$.fn.currentReset = function(){
	$(this).each(function(){
		var osrc = $(this).attr('src').replace("_on.","_off.");
		$(this).attr('src',osrc).removeClass('current');
	});

}

$.fn.currentSet = function(){
	$(this).each(function(){
		var csrc = $(this).attr('src').replace("_off.","_on.");
		$(this).attr('src',csrc).addClass('current');
	});
}


/*==============================================
 IE bgfix
==============================================*/
try{document.execCommand("BackgroundImageCache", false, true);} catch(e){}
