/* abostop - setup functions */
// TODO: add your java script functions here
// 2008-03-10 - swh tooltip now hook: {target: 'topRight', tip: 'bottomLeft'} wegen den Buttons, die überdeckt wurden
// 2008-03-15 - swh tooltip showOn(mouseover) hide(mouseout) now hook: {target: 'topRight', tip: 'bottomLeft'} wegen den Buttons, die überdeckt wurden
  Event.observe(window, 'load', function() {
      if ($('my-timeline')) { // wg. timeline
          t1 = null;
      }
      if ($('basic-accordian')) {
          ba = new Accordian('basic-accordian',5,'header_highlight');
      }
  });

  function animateFlashMessage(){
      // do the flash disapear (duration 5.0 sec)- swh 2007-12-25
      var f = $('flashMessage');
      if (f && f.style.display != 'hidden') {
          new Effect.Parallel([
                new Effect.Fade(f, {sync: true})
                ], { duration: 5.0
                });
      }
  }
  function animatehandycosts(){
      // do the flash disapear (duration 5.0 sec)- swh 2007-12-25
      var f = $('handycosts');
      if (f) {
          new Effect.Parallel([
                new Effect.Grow(f, {sync: true})
                ], { duration: 5.0
                });
      }
  }
  function doAboForm() {
      // put grafikbuttons on the forms
      $$('input[type=submit]', 'input[type=button]', 'button').each(function(e) {
          if (e) { e.addClassName('grafikbutton'); }
      });
      // tooltips for input fields with alt tags prototip - swh 2007-12-30
      $$('input[alt]', 'textarea[alt]', 'select[alt]').each(function(e){
          new Tip(e, e.getAttribute('alt'),
                  {className: 'abotip',
                      showOn: 'mouseover', //'focus',
                      hideOn: 'mouseout',
                      offset: {x:10,y:0},
                      fixed: true,
                          delay: 0.5,
                          effect: 'appear',
                          hook: {target: 'topRight', tip: 'bottomLeft'}
                  });
      });
      $$('input[type=checkbox]').each(function(e){
           if (e && e.getAttribute('alt'))
           {
               new Tip(e, e.getAttribute('alt'),
                       {className: 'abotip',
                           showOn: 'mouseover', //focus vorher
                           hideOn: 'mouseout',
                           offset: {x:100,y:15}, // vorher 15
                           fixed: true,
                               delay: 0.5,
                               effect: 'appear',
                               hook: {target: 'topRight', tip: 'bottomLeft'}
                       });
           }
       });
      $$('div[class=prototip]','div[class=prototip highest]').each(function(e){
			e.parentNode.removeChild(e);
      });
      // focus handling via focus/blur of current field - swh 2008-01-04
      $$('input', 'textarea', 'select').each(function(input){
            Event.observe(input, 'focus', inputFocus);
            Event.observe(input, 'blur', inputBlur);
            });
      doCal();
  }
  Event.observe(window, 'load', function () {
      animateFlashMessage();
      animatehandycosts();
      doAboForm();
  });
function doCal() {
      $$('input[class=dateselect]').each(function(e){
            Event.observe(e, 'click', inputCal);
            Event.observe(e, 'blur', inputCalBlur);
            });
}

function inputCal(event) {
    var input = Event.element(event);
    new CalendarDateSelect(input,{year_range:10} );
}

/*
** PH, 2008-03-12
** Schliessen aller Kalender-Popups beim Verlassen des Eingabefelds
*/
function inputCalBlur(event) {
    var input = Event.element(event);
    $$('div[class=calendar_date_select]').each(function(e){
        //e.parentNode.removeChild(e);
    });
}

function inputFocus(event){
    var input = Event.element(event);
    $$('div[class=calendar_date_select]').each(function(e){
        e.parentNode.removeChild(e);
    });
    input.style.backgroundColor='#d7fed0';
    input.style.borderBottom = '3px solid #28fa03';
    input.style.color='#155da7';

}
function inputBlur(event){
    var input = Event.element(event);
    input.style.backgroundColor='#edffea';
    input.style.borderBottom = '3px solid #d7fed0';
    input.style.color='#000'; // '#337fde';
}
// function validateForm
/* hiermit sollen die Tabs selectiert werden, damit klar ist, welchen angewählt worden ist
das geht, indem das Event mit onclick ausgelöst wird (wird durch $$('menutabs') gebunden ....*/
function tabSelect(event){
    var tab = Event.element(event);
    input.style.backgroundColor = 'white';
    input.style.color = 'black';
}
// Adresszuordnung
function showbig(v) {
    var x = $(v.id);
    x.down(0).style.display = 'none';
    x.down(1).style.display = 'block';
}
function showsmall(v) {
    var x = $(v.id);
    x.down(1).style.display = 'none';
    x.down(0).style.display = 'block';
}

