var clickTuch;
var bindId;
var easFx;
var btnId;
if (window.ontouchstart === undefined){clickTuch=1; }else if (window.ontouchstart === null){clickTuch=0;};
$(function(){
   function demoAct(){
	       if(bindId=='eas01'){easFx='easeInSine'}
	  else if(bindId=='eas02'){easFx='easeOutSine'}
	  else if(bindId=='eas03'){easFx='easeInOutSine'}
	  else if(bindId=='eas04'){easFx='easeInQuad'}
	  else if(bindId=='eas05'){easFx='easeOutQuad'}
	  else if(bindId=='eas06'){easFx='easeInOutQuad'}
	  else if(bindId=='eas07'){easFx='easeInCubic'}
	  else if(bindId=='eas08'){easFx='easeOutCubic'}
	  else if(bindId=='eas09'){easFx='easeInOutCubic'}
	  else if(bindId=='eas10'){easFx='easeInQuart'}
	  else if(bindId=='eas11'){easFx='easeOutQuart'}
	  else if(bindId=='eas12'){easFx='easeInOutQuart'}
	  else if(bindId=='eas13'){easFx='easeInQuint'}
	  else if(bindId=='eas14'){easFx='easeOutQuint'}
	  else if(bindId=='eas15'){easFx='easeInOutQuint'}
	  else if(bindId=='eas16'){easFx='easeInExpo'}
	  else if(bindId=='eas17'){easFx='easeOutExpo'}
	  else if(bindId=='eas18'){easFx='easeInOutExpo'}
	  else if(bindId=='eas19'){easFx='easeInCirc'}
	  else if(bindId=='eas20'){easFx='easeOutCirc'}
	  else if(bindId=='eas21'){easFx='easeInOutCirc'}
	  else if(bindId=='eas22'){easFx='easeInBack'}
	  else if(bindId=='eas23'){easFx='easeOutBack'}
	  else if(bindId=='eas24'){easFx='easeInOutBack'}
	  else if(bindId=='eas25'){easFx='easeInElastic'}
	  else if(bindId=='eas26'){easFx='easeOutElastic'}
	  else if(bindId=='eas27'){easFx='easeInOutElastic'}
	  else if(bindId=='eas28'){easFx='easeInBounce'}
	  else if(bindId=='eas29'){easFx='easeOutBounce'}
	  else if(bindId=='eas30'){easFx='easeInOutBounce'};
   };//function demoAct(){
   
   function Initialize(){//Actionの初期化
         $('#take01').css({'width':'0%'});$('#take02').css({'top':'0px','opacity':'0'});
   };//function Initialize(){
   function popup(){//Demo Form の表示
       $("#demo").fadeIn(300).css({'display':'block'}); demoAct(); Initialize(); $('#easename').val(easFx);
   };
   function acton(){demoAct();  Initialize(); $('#take01').animate({'width': '100%'},700,easFx); 
                    $('#take02').animate({'top': '300px','opacity': '1'},700,easFx); 
                   };
   function actoff(){$("#demo").fadeOut(300).css({'display':'non'}); Initialize(); 
                    };
   
   $('.eas').each(function(){  //easing 関数選択時に対して
	  if(clickTuch===1){$(this).bind('click', function(){ bindId= $(this).attr("id"); popup();});
	  }else{ /*clickTuch===0  タッチデバイス*/
	      var isTouch = false;
	      $(this).on('touchstart',function(){ isTouch=true;}                                
                ).on('touchmove',function(){isTouch=false;}
                ).on('touchend',function(){ if(isTouch==true){ bindId= $(this).attr("id"); popup(); } }
          ); // $(this).on
      };// if(clickTuch
    });// $('.eas').each(function(){ 

   $('.btn').each(function(){ //「Action button」と「Close button」 選択時に対して
	  if(clickTuch===1){
	      $(this).bind('click', function(){btnId= $(this).attr("id"); 
	                                       if (btnId=='btnst'){ acton();
                                           }else if(btnId=='btncl'){ actoff();
                                                                     };//if (btnId=='btnst')
	      });//$(this).bind('click', function()
	  }else{ /*clickTuch===0 タッチデバイス*/
	      var isTouch = false;
	      $(this).on('touchstart',function(){ isTouch=true;}                                
                ).on('touchmove',function(){isTouch=false;}
                ).on('touchend',function(){ if(isTouch==true){ btnId= $(this).attr("id"); 
	                                                           if (btnId=='btnst'){ acton();
                                                               }else if(btnId=='btncl'){actoff();
                                                               };//if (btnId=='btnst')
	                                        };//if(isTouch==true)
          });//$(this).on(
      };//if(clickTuch===1){
    });//$('.btn').each(function(){
});//$(function(){