App = typeof App === 'undefined' ? {} : App;

App.Constants = (function(){
  
  return {
  
    getSubCookiesName : function() {
      return 'olayforyou';
    },

    getToolStepsJsonUrl : function() {
      // you can place any logic here to take into account current language etc.
      var language_id = App.Cookies.get('LanguageID');
      return '../_toolData.ashx?ToolID=231&LanguageID=' + language_id;
    },
        
    getIntroVideoPath : function() {
      // you can place any logic here to take into account current language etc.
      return '../flv/russia_final_comp_rev.flv';
    },
    
    getQuestionsToThankYouTransition : function() {
      // you can place any logic here to take into account current language etc.
      return '../flv/3_mirror_transition_russia.flv';
    },
    
    getWelcomeToQuestionsVideo : function() {
      // you can place any logic here to take into account current language etc.
      return '../flv/3_mirror_transition_russia.flv';
    },
    
    getRecapPageContentUrl : function() {
      var cart_id = App.Cookies.get('CartID');
      var language_id = App.Cookies.get('LanguageID');
      return '../_recapText.ashx?CartID=' + cart_id + '&LanguageID=' + language_id;
    },
    
    getRecommendationsPageLink : function() {
      return 'productListing.aspx';
    },

    // make a redirect with POST parameters submitting
    redirectToResultsPage : function() {
      document.location = this.getRecommendationsPageLink();
    },
    
    reportToolStepAnswer : function(toolStepId, answerId, callback) {
      if (typeof callback === 'undefined') {
          $.get("../_updateCart.ashx", { 
          ToolStepID: toolStepId,
          SelectionList: answerId 
        });
      } else {
      $.get("../_updateCart.ashx", { 
          ToolStepID: toolStepId,
          SelectionList: answerId 
        }, callback);
      }
    }
  };
})();

// this event is triggered when a user clicks "Next" or "Back" button
// event.toolStep - object containing current toolstep data (got from json)
// event.answerId - ToolStepOptionID string for 'slider', 'ageslider', 'icon' and 'radio' questions
//                   ... or an array of ToolStepOptionIDs for 'checkbox' questions
//                   ... or "" (empty string) or [] (empty array) if nothing was selected
$('body').bind('toolstep-complete', function(event) {
  App.Constants.reportToolStepAnswer(
    event.toolStep.ToolStepID, 
    event.answerId
  );
});

// this event is triggered when a user starts to answer given questions
$('body').bind('toolsteps-start', function() {
  // put your code here
});

