/***********************
* Adobe Edge Animate Composition Actions
*
* Edit this file with caution, being careful to preserve 
* function signatures and comments starting with 'Edge' to maintain the 
* ability to interact with these actions from within Adobe Edge Animate
*
***********************/
(function($, Edge, compId){
var Composition = Edge.Composition, Symbol = Edge.Symbol; // aliases for commonly used Edge classes

   //Edge symbol: 'stage'
   (function(symbolName) {
      
      
      Symbol.bindElementAction(compId, symbolName, "document", "compositionReady", function(sym, e) {
         // insert code to be run when the composition is fully loaded here
         var answer = sym.$("answer");
         inputMessage = $('<textarea />').attr({'type':'textarea','rows':'3','value':'', 'id':'message'});
         inputMessage.css ('line-height', 2);
         inputMessage.css ('font-size', 18);
         inputMessage.css ('color', '#ffffff');
         inputMessage.css ('resize', 'none');
         inputMessage.css ('background-color', 'transparent');
         inputMessage.css ('border', 0);
         inputMessage.css ('box-shadow', 'transparent');
         inputMessage.css ('width', 378);
         inputMessage .css ('height', 110);
         
         inputMessage.appendTo(answer);
         
         function alertMessage(){
         	 alertify.alert("เกิดข้อผิดพลาด","กรุณาเติมคำในช่องว่าง").setting({transition:'fade'}).show(); 
         }
         sym.$("btncheck").bind("click",function(){
         	 if(message.value == ''){
         			alertMessage();
         
         	 }else{
         	  		sym.play("checkQ");
         	  		console.log("asdfasfasf");
         	 }
         });

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 0, function(sym, e) {
         sym.stop();
         

      });
      //Edge binding end

      

      

      

      

      Symbol.bindSymbolAction(compId, symbolName, "creationComplete", function(sym, e) {
         yepnope({
             load: [
         		"js/alertifyjs/alertify.min.js",
         		"js/energize.js",
         		"js/alertifyjs/css/alertify.min.css",
         		"js/alertifyjs/css/themes/default.min.css"
         	],
         	complete: function () {
              console.log("allscript complete");
           }
         });
         

      });
      //Edge binding end

   })("stage");
   //Edge symbol end:'stage'

   //=========================================================
   
   //Edge symbol: 'sym_text'
   (function(symbolName) {   
   
   })("sym_text");
   //Edge symbol end:'sym_text'

   //=========================================================
   
   //Edge symbol: 'btncheck'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 0, function(sym, e) {
         sym.stop();

      });
      //Edge binding end

   })("btncheck");
   //Edge symbol end:'btncheck'

})(jQuery, AdobeEdge, "EDGE-4701652");