/* =======================================

 Common Javascript

 -----------------------------------------
 INDEX
 -----------------------------------------
 	1.IE6で砂時計回避
	
	2.Gallery Tab
	
	3.Smooth Scroll
	
	4.Mouse Over
 

========================================== */

/* 1.IE6で砂時計回避
========================================== */
try {
	document.execCommand('BackgroundImageCache', false, true);
}catch(e){}


/* 2.Gallery Tab
=========================================== */
$(function() {
	$('body#galleryIndex .thumbnailSection').hide();
	
	if(location.hash == '#galleryWeb') {
		$('body#galleryIndex .thumbnailSection#galleryWeb').show();
		location.hash = '#galleryWeb';
	}else if(location.hash == '#galleryGraphic'){
		$('body#galleryIndex .thumbnailSection#galleryGraphic').show();
		location.hash = '#galleryGraphic';
	}else{
		$('body#galleryIndex .thumbnailSection:eq(0)').show();
		$('body#galleryIndex ul.thumbnailSectionNavi li a').show();
		$('body#galleryIndex ul.thumbnailSectionNavi li:eq(0) a').hide();
	}
	
	$('body#galleryIndex .visualNavi a').click(function(){
		$('body#galleryIndex .thumbnailSection').hide();
		$('body#galleryIndex .thumbnailSection'+$(this).attr('href')).show();
	});
	
	$('body#galleryIndex ul.thumbnailSectionNavi li a').click(function(){
		$('body#galleryIndex ul.thumbnailSectionNavi li a').show();
		$(this).hide();
		$('body#galleryIndex .thumbnailSection').hide();
		$('body#galleryIndex .thumbnailSection'+$(this).attr('href')).show();
		return false;
	});
});


/* 3.Smooth Scroll
========================================== */
$(function(){ 
	$('a[href^=#]:not(a[href$=#])').click(function(){
		var href= this.hash;
		var $target = $(href == '#_top' ? 'body' : href);
		
		// AJ[Ny[W??s
		if($target.size()){
			var top = $target.offset().top;
			$($.browser.safari ? 'body' : 'html').animate({scrollTop:top}, 500, 'swing');
		}
		return false;
	});
});


/* 4.Mouse Over
========================================== */
$(function() {
  var image_cache = new Object();
  $(".swap").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_on;
    $(this).hover(
      function() { this.src = imgsrc_on; },
      function() { this.src = imgsrc; });
  });
});


/* 5.Check Flash Version
========================================== */
function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

$(function() {
	MM_CheckFlashVersion('7,0,0,0','このページのコンテンツを表示するには最新バージョンの Macromedia Flash Player が必要です。今すぐダウンロードしますか?');
});


