﻿// JavaScript Document

//////////////////////////////////////////////////////////// 画像ロールオーバー

$(function() {
$("body#top a img,#mainNav a img,h1 a img,#footer a img,.lineupList a img,.lineupHead aside a img,#lineupDetail a img,#otherLineup a img,section#trust a img,.contNav a img,.tableList a img,.archiveLeft .back a img,#listInner section a img,ul.linkBtn li a img").hover(
	function(){
		$(this).animate(
		{ opacity: 0.6 }, 200);},
	function(){
		$(this).animate(
		{ opacity: 1.0 }, 600);}
);
});

//////////////////////////////////////////////////////////// a.windowFadeの追加
$(function() {
$("a").addClass("windowFade");
$(".lineupHead aside a").removeClass("windowFade");
$("section.spec div.left a").removeClass("windowFade");
$(".tableList td a").removeClass("windowFade");
});


//////////////////////////////////////////////////////////// トップ画像の読み込み

$(function(){
		
		/*画像の読み込み*/
		
		/*IEの場合*/
		if(jQuery.browser.msie){
		$("body#top .left img,body#top .right img").ready(function () {
					   resizePhoto();
        });
		}

		/*それ以外のブラウザ*/
		else {
		$("body#top .left,body#top .right,body#top h1").hide();
		$("body#top .left img,body#top .right img").load(function () {
		resizePhoto();
		$('body#top h1').fadeIn(3000, function(){
		$('body#top .left,body#top .right').fadeIn(2000);
		});
        });
		}
		
		/*ウィンドウにリサイズイベントをバインドする*/
	  　$(window).bind('resize', function() {
			 resizePhoto();
		});
	   
		   
						
		function resizePhoto(){
				/*ダミーのイメージ要素を生成*/
				var theImage 	= new Image();
				theImage.src= $("body#top .left img,body#top .right img").attr("src");												
				var windowW=$(window).width();
				var windowH=$(window).height()/1.1;
				/*画像の横か縦がウィンドウサイズより大きい場合*/												
				if((theImage.width>windowW)||(theImage.height>windowH)){
							/*長辺が横の場合*/
							if(theImage.width>theImage.height){
											/*画像の長辺（横）とウィンドウ幅の比率をとる*/
											 var ratioW=theImage.width/windowW;
											 /*短辺（縦）を比率で割って、長辺（横）の比率に合わせる*/
											 var newImageHight=theImage.height/ratioW;							 
											 theImage.height = newImageHight;
											 theImage.width=windowW;
											/*上記の修正後さらに短辺（縦）がウィンドウの高さより長い場合*/		
											if(newImageHight>windowH){
														var ratioH=theImage.height/windowH;
														var newImageWidth=theImage.width/ratioH;
														theImage.width = newImageWidth;
														theImage.height= windowH;
											}														
							}
							else/*長辺が縦の場合*/
							{
											/*画像の長辺（縦）とウィンドウ高さの比率をとる*/
											var ratioH=theImage.height/windowH;
											/*短辺（横）を比率で割って、長辺（縦）の比率に合わせる*/
											var newImageWidth=theImage.width/ratioH;	
											theImage.height= windowH;
											theImage.width = newImageWidth;
											/*上記の修正後さらに短辺（横）がウィンドウの幅より長い場合*/
											if(newImageWidth>windowW){
													var ratioW=theImage.width/windowW;
													var newImageHight=theImage.height/ratioW;																	
													theImage.height= newImageHight;			
													theImage.width = windowW;
											}													
							}							 
				}
				/*最後に画像のプロパティに設定する*/
				$("body#top .left img,body#top .right img").css({
							'width':theImage.width+'px',
							'height':theImage.height+'px'
				});							
		}
	
})


//////////////////////////////////////////////////////////// STORYページ画像読み込み
$(function(){
		
		/*画像の読み込み*/
		
		$("section.story h3,section.story p,#storyFullImage").hide();	

		/*IEの場合*/
		if(jQuery.browser.msie){
		$("#storyFullImage img").ready(function () {
					   resizePhoto();
		$('section.story h3').fadeIn(1500, function(){
		$('section.story p').fadeIn(1500, function(){
		$('#storyFullImage').fadeIn(1500);
        });
		});
		});
		}

		/*それ以外のブラウザ*/
		else {
		$("#storyFullImage img").load(function () {
					   resizePhoto();
		$('section.story h3').fadeIn(2000, function(){
		$('section.story p').fadeIn(2000, function(){
		$('#storyFullImage').fadeIn(4000);
        });
		});
		});
		}
		
		/*ウィンドウにリサイズイベントをバインドする*/
	  　$(window).bind('resize', function() {
			 resizePhoto();
		});
						
		function resizePhoto(){
				/*ダミーのイメージ要素を生成*/
				var theImage 	= new Image();
				theImage.src= $("#storyFullImage img").attr("src");												
				var windowW=$(window).width();
				var windowH=$(window).height();
				/*画像の横か縦がウィンドウサイズより大きい場合*/												
				if((theImage.width>windowW)||(theImage.height>windowH)){
							/*長辺が横の場合*/
							if(theImage.width>theImage.height){
											/*画像の長辺（横）とウィンドウ幅の比率をとる*/
											 var ratioW=theImage.width/windowW;
											 /*短辺（縦）を比率で割って、長辺（横）の比率に合わせる*/
											 var newImageHight=theImage.height/ratioW;							 
											 theImage.height = newImageHight;
											 theImage.width=windowW;
											/*上記の修正後さらに短辺（縦）がウィンドウの高さより長い場合*/		
											if(newImageHight>windowH){
														var ratioH=theImage.height/windowH;
														var newImageWidth=theImage.width/ratioH;
														theImage.width = newImageWidth;
														theImage.height= windowH;
											}														
							}
							else/*長辺が縦の場合*/
							{
											/*画像の長辺（縦）とウィンドウ高さの比率をとる*/
											var ratioH=theImage.height/windowH;
											/*短辺（横）を比率で割って、長辺（縦）の比率に合わせる*/
											var newImageWidth=theImage.width/ratioH;	
											theImage.height= windowH;
											theImage.width = newImageWidth;
											/*上記の修正後さらに短辺（横）がウィンドウの幅より長い場合*/
											if(newImageWidth>windowW){
													var ratioW=theImage.width/windowW;
													var newImageHight=theImage.height/ratioW;																	
													theImage.height= newImageHight;			
													theImage.width = windowW;
											}													
							}							 
				}
				/*最後に画像のプロパティに設定する*/
				$("#storyFullImage img").css({
							'width':theImage.width+'px',
							'height':theImage.height+'px'
				});							
		}
	
});


//////////////////////////////////////////////////////////// CONCEPTページ画像読み込み
$(function(){
		
		/*画像の読み込み*/
		
		/*IEの場合*/
		if(jQuery.browser.msie){
		$("#conceptFullImage img").ready(function () {
					   resizePhoto();
		});
		}

		/*それ以外のブラウザ*/
		else {
		$("#conceptFullImage").hide();	
		$("#conceptFullImage img").load(function () {
					   resizePhoto();
		$('#conceptFullImage').fadeIn(1000);
		});
		}
		
		/*ウィンドウにリサイズイベントをバインドする*/
	  　$(window).bind('resize', function() {
			 resizePhoto();
		});
						
		function resizePhoto(){
				/*ダミーのイメージ要素を生成*/
				var theImage 	= new Image();
				theImage.src= $("#conceptFullImage img").attr("src");												
				var windowW=$(window).width()/2;
				var windowH=$(window).height();
				/*画像の横か縦がウィンドウサイズより大きい場合*/												
				if((theImage.width>windowW)||(theImage.height>windowH)){
							/*長辺が横の場合*/
							if(theImage.width>theImage.height){
											/*画像の長辺（横）とウィンドウ幅の比率をとる*/
											 var ratioW=theImage.width/windowW;
											 /*短辺（縦）を比率で割って、長辺（横）の比率に合わせる*/
											 var newImageHight=theImage.height/ratioW;							 
											 theImage.height = newImageHight;
											 theImage.width=windowW;
											/*上記の修正後さらに短辺（縦）がウィンドウの高さより長い場合*/		
											if(newImageHight>windowH){
														var ratioH=theImage.height/windowH;
														var newImageWidth=theImage.width/ratioH;
														theImage.width = newImageWidth;
														theImage.height= windowH;
											}														
							}
							else/*長辺が縦の場合*/
							{
											/*画像の長辺（縦）とウィンドウ高さの比率をとる*/
											var ratioH=theImage.height/windowH;
											/*短辺（横）を比率で割って、長辺（縦）の比率に合わせる*/
											var newImageWidth=theImage.width/ratioH;	
											theImage.height= windowH;
											theImage.width = newImageWidth;
											/*上記の修正後さらに短辺（横）がウィンドウの幅より長い場合*/
											if(newImageWidth>windowW){
													var ratioW=theImage.width/windowW;
													var newImageHight=theImage.height/ratioW;																	
													theImage.height= newImageHight;			
													theImage.width = windowW;
											}													
							}							 
				}
				/*最後に画像のプロパティに設定する*/
				$("#conceptFullImage img").css({
							'width':theImage.width+'px',
							'height':theImage.height+'px'
				});							
		}
	
});



////////////////////////////////////////////////////////////ツールチップ

$(function(){
			
			// 全要素をからTITLE属性を持っている要素だけに絞る
			$("div.icon img,section#salesMap img").filter(function(){
				return this.title && this.title.length>0;
			}).each(function(){
				// TITLE属性を持っている要素に適用する
				
				// あとで使う
				var self = $(this), title = self.attr("title");
				
				// TITLE属性を持っている要素にhover()で
				self.hover(
				
					// mouseover
					function(e){ // このeはevent自体を意味する
					
						// TITLEがあるとブラウザのチップが出るので一時的に空にしておく
						self.attr("title","");
					
						// とりあえず表示するtip要素を生成しておく
						$("body").append("<div class='title-tip'>"+title+"</div>");
						$(".title-tip").css({
							position: "absolute",
							
							// e.pageX(Y)でカーソルが要素に乗った時点でのX(Y)座標を取得する
							top: e.pageY+(-15), // カーソルと表示したtipが重なるとチラつくので少しずらす
							left: e.pageX+15
						});
					},
					
					// mouseout
					function(){
					
						// mouseoverで空にしたTITLEを戻す
						self.attr("title",title);
					
						// 要素から離れた場合はtipを非表示にして削除しておく
						$(".title-tip").hide().remove();
					}
				);
				
				// 要素上でカーソルが移動した場合は、逐一tipの位置を変える
				self.mousemove(function(e){
					$(".title-tip").css({
						top: e.pageY+(-15),
		    			left: e.pageX+15
					});		
				});
			});
					
		});



////////////////////////////////////////////////////////////ツールチップカスタム


$(function(){
$(".tipsImage").hide()		 

$("img.tips-oil").mouseover(function(){
$('#tips-oil').fadeIn(100);
});

$("img.tips-oil").mouseout(function(){
$('#tips-oil').fadeOut(100);
});

$("img.tips-metal").mouseover(function(){
$('#tips-metal').fadeIn(100);
});

$("img.tips-metal").mouseout(function(){
$('#tips-metal').fadeOut(100);
});

$("img.tips-oltanate").mouseover(function(){
$('#tips-oltanate').fadeIn(100);
});

$("img.tips-oltanate").mouseout(function(){
$('#tips-oltanate').fadeOut(100);
});

$("img.tips-power").mouseover(function(){
$('#tips-power').fadeIn(100);
});

$("img.tips-power").mouseout(function(){
$('#tips-power').fadeOut(100);
});

$("img.tips-silicon").mouseover(function(){
$('#tips-silicon').fadeIn(100);
});

$("img.tips-silicon").mouseout(function(){
$('#tips-silicon').fadeOut(100);
});

$("img.tips-color").mouseover(function(){
$('#tips-color').fadeIn(100);
});

$("img.tips-color").mouseout(function(){
$('#tips-color').fadeOut(100);
});

});




////////////////////////////////////////////////////////////お客様の声alt,title削除

$(function(){
$(".voiceList div.img img").removeAttr("alt")
$(".voiceList div.img img").removeAttr("title")
$("#voiceDetail img").removeAttr("alt")
$("#voiceDetail img").removeAttr("title")
});
