﻿/* ++++++++++++++++++++++++
hoverでターゲット要素点滅
[初期化 + hover|stop|fadeTo + 初期化]

要html側でターゲット設定
$(function() {
	  $('targetID etc').btnFlash();
});
@Komura.Yukihiro
+++++++++++++++++++++++++++ */
(function($) {
	
	//alpha --- 0→1→0
	$.fn.btnFlash = function(tgt){
		
		//IE7,8 判定----------------------------
		if (typeof document.body.style.maxHeight != 'undefined') {
		    if (!/*@cc_on!@*/false){
		        // Not IE.
			//}else if(document.documentMode >=8){
				//alert('IE8//' + document.documentMode);
			}
			else {
		        //IE7, IE8（IE7 mode)
		        //置き換え処理----------------------------
				//大丈夫な箇所以外には処理を加えない
				var _tgtIE;
				try{ _tgtIE = ($(this).find('img').attr('src')).indexOf('logoMovie.png') }catch(e){ _tgtIE = 0 };
				
				//文字列が見つからなかった場合
				if( _tgtIE == -1 ){
				}
				//見つかった場合
				else {
					$(this).each(function(){
						var milk = $(this).find('img').attr('src');
						$(this).find('img').css({filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + milk + '", sizingMethod=scale)'});
					});
				}
		    }
		}
		
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++
		
		var pm = { a1:1, a2:0.2, _speed:'slow' };
		$(this).each(function(){
				$(this)	.css({ opacity:pm.a1, filter:'alpha(opacity='+pm.a1*100+')'})
					.hover(
						function(){
							$(this).stop();
							$(this)	.css({ opacity:pm.a2, filter:'alpha(opacity='+pm.a2*100+')'})
							$(this).fadeTo(pm._speed,pm.a1);
						},function(){
							$(this).css({opacity: pm.a1,filter: 'alpha(opacity='+pm.a1*100+')'});
						}
					)
		})
	};
	//alpha --- ON:1→0 OFF:0→1
	$.fn.btnOverOut1_0 = function(tgt){
		var pm2 = { a1:1, a2:0.3, _speed:500 };
		$(this).each(function(){
				$(this)	.css({ opacity:pm2.a1, filter:'alpha(opacity='+pm2.a1*100+')'})
					.hover(
						function(){
							$(this).stop();
							$(this)	.css({ opacity:pm2.a1, filter:'alpha(opacity='+pm2.a1*100+')'})
							$(this).fadeTo(pm2._speed,pm2.a2);
						},function(){
							$(this).stop();
							$(this).css({opacity: pm2.a2,filter: 'alpha(opacity='+pm2.a2*100+')'});
							$(this).fadeTo(pm2._speed,pm2.a1);
						}
					)
		})
	};
	//alpha --- ON:0→1 OFF:1→0
	$.fn.btnOverOut0_1 = function(tgt){
		var pm3 = { a1:0, a2:1, _speed:500 };
		$(this).each(function(){
				$(this)	.css({ opacity:pm3.a1, filter:'alpha(opacity='+pm3.a1*100+')'})
					.hover(
						function(){
							$(this).stop();
							$(this)	.css({ opacity:pm3.a1, filter:'alpha(opacity='+pm3.a1*100+')'})
							$(this).fadeTo(pm3._speed,pm3.a2);
						},function(){
							$(this).stop();
							$(this).css({opacity: pm3.a2,filter: 'alpha(opacity='+pm3.a2*100+')'});
							$(this).fadeTo(pm3._speed,pm3.a1);
						}
					)
		})
	};

})(jQuery);
