$(document).ready( function() {
  $('div.accordion-button').click(function() {
    $('div.accordion-content').slideUp('normal');	
    $(this).next().slideDown('normal');
  });
  
  //This is original --first Header Bar
  $("div.accordion-content").not('.open').hide();
  $('div#firstContent').show();
       $("div.ProductHeaderBar#1-1").click(function(){
     $("div.ProductContentPanel#1-2").slideToggle("fast");
  });
  //This is original --second Header Bar
  $("div.accordion-content").not('.open').hide();
       $('div#firstContent').show();
       $("div.ProductHeaderBar#2-1").click(function(){
     $("div.ProductContentPanel#2-2").slideToggle("fast");
  });
  //This is original --first Header Bar
  $("div.accordion-content").not('.open').hide();
    $('div#firstContent').show();
       $("div.ProductHeaderBar#3-1").click(function(){
     $("div.ProductContentPanel#3-2").slideToggle("fast");
  });
  
  $("div.ProductContentPanel").hide();

  $('div#full-column').show();
  $('div.faq-sub-header').click(function() {
    $('div.faq-content').slideUp('normal');	
    $(this).next().slideDown('normal');
  });
  $("div.faq-content").hide();

  $('div#full-column').show();
  $('div.assort-header').click(function() {
    $('div.assort-content').slideUp('normal');	
    $(this).next().slideDown('normal');
  });
  $("div.assort-content").hide();

  $('div#full-column').show();
  $('div.template-sub-header').click(function() {
    $('div.template-content').slideUp('normal');	
    $(this).next().slideDown('normal');
  });
  $("div.template-content").hide();

  $('div#full-column').show();
  $('div.submission-sub-header').click(function() {
    $('div.submission-contents').slideUp('normal');	
    $(this).next().slideDown('normal');
  });
  $("div.submission-contents").hide();	

  $('div#left-column').show();
  $('div.data-header').click(function() {
    $('div.data-contents').slideUp('normal');	
    $(this).next().slideDown('normal');
  });
  $("div.data-contents").hide();	

  $('#carousel').infiniteCarousel();

  $("#tabs").tabs();



  /* Auto focus
  -----------------------------------------------------------*/
  $('form .focus').focus();
  
  /* Toggle English / Japanese for any tag which has en="" attribute
  -----------------------------------------------------------*/
  if ( $('body.translatable') ) {
    var current_lang = 'ja';
    var translatable_tags = $('[en]');
    // Set the ja attr to the content of the tag
    translatable_tags.each( function() {
      $(this).attr('ja', $(this).html());
    });
    
    $(document).bind('keydown', 'Shift+esc', function() {
      // Hotkey was pressed, switch language for all translatable_tags
      if (current_lang == 'ja') {
        // Translate to English
        translatable_tags.each( function() {
          $(this).html( $(this).attr('en') ).hide().fadeIn();
        });
        current_lang = 'en';
      }
      else {
        // Translate back to Japanese
        translatable_tags.each( function() {
          $(this).html( $(this).attr('ja') ).hide().fadeIn();
        });
        current_lang = 'ja';
      }
      return false;
      //console.log(current_lang);
    });
  }
  
});

