
var FS = {
  tab:
  {
    init: function()
    {
      var dl = $('hotJourney').down('dl');
      this.dts = dl.getElementsByTagName('dt');
      this.dds = dl.getElementsByTagName('dd');
      
      for(var i = 0; i < 7; i++ )
      {
        Event.observe(this.dts[i],'mouseover',this.hoverTab.bindAsEventListener(this));
      }
      
      this.preIndex = 0;
      this.setTab(0);
    },
    setTab: function(num)
    {
      this.dts[num].addClassName('current');
      this.dds[num].style.display = 'block';
    },
    hoverTab: function(e)
    {
      var element = Event.findElement(e,'dt');
      this.clearTab(this.preIndex);
      this.preIndex = parseInt(element.id.replace('journey',''));
      this.setTab(this.preIndex);
    },
    clearTab: function(num)
    {
      this.dts[num].removeClassName('current');
      this.dds[num].style.display = 'none';
    }
  },
  steps:
  {
    goPreviousStep: function(e)
    {
      if(CURRENT_STEP == 5)
      {
        var p = confirm("確定要返回上一步?");
        if(!p) return false;
      }
      var preStep = CURRENT_STEP - 1;
      var form = $('switchStep').down();
      form.setAttribute('action', SERVICE_STEP_BASE + "?step=" + preStep);
      form.submit();
    },
    checkFields: function(e)
    {
/*
      'photographer_click_status',
      'stylist_click_status',
      
      'photographer_name',
      'stylist_name',
      );
*/
      
      var required = $(
        'booking_date_year',
        'product_click_status',
        'photographer_click_status',
        'stylist_click_status',
        'groom_name',
        'groom_birthdate',
        'bride_name',
        'bride_birthdate');
      
      var suspend = 0;
      for ( var i = 0, len = required.length; i < len; i++ )
      {
        this.clearHighlight(required[i].up(1));
        if ( required[i].value == "" )
        {
          this.highlight(required[i].up(1));
          suspend++;
        }
      }
      
      if ( $('photographer_click_status').value == 1 && $('photographer_name').value == "" )
      {
        this.highlight($('photographer_click_status').up(1));
        suspend++;
      }
      if ( $('stylist_click_status').value == 1 && $('stylist_name').value == "" )
      {
        this.highlight($('stylist_click_status').up(1));
        suspend++;
      }
      
      
      
      if (suspend)
      {
        $('notice').setStyle({padding:'20px',background:'lightyellow',color:'#500',fontWeight:'bold',textAlign:'center',letterSpacing:'2px',margin:'20px'});
        $('notice').update('請填寫紅色區塊 (' + suspend + ')');
        window.location.href = "#notice";
        Event.stop(e);
      }
//      return false;
    },
    highlight: function(element)
    {
      element.style.background = 'pink';
      element.style.border = '1px solid #900';
    },
    clearHighlight: function(element)
    {
      element.style.background = 'transparent none';
      element.style.border = 'none';
    }
  }
}
