window.addEvent('domready', function() {
  /*
  var my_height = $('all_page').getSize().y - 10;
  

  $$('div.element').setStyle('width', my_widht);
  $$('div.element').setStyle('height', my_height);
  $$('h3.toggler').setStyle('height', my_height);
  */
  window.onresize = recalc_onresize;
  recalc_onresize();
  function recalc_onresize(){

    var my_height = 500;
    var my_width = $('all_page').getSize().x - 250;
    $('home_content').setStyle( 'width', my_width );
    $('photos_content').setStyle( 'width', my_width );
    var contact_width = my_width;
    if ( my_width > 500 ) {
        contact_width = 350;
    }
    $('contact_content').setStyle( 'width', contact_width );
    var start_tab = 0;
    var url = location.href;
    url = url.split("?");
    var pairs = {};
    if(url.length > 1){
      url = url[1].split("#");
      if(url.length > 1) pairs["hash"] = url[1];
      url[0].split("&").each(function(item,index){
        item = item.split("=");
        pairs[item[0]] = item[1];
      });
    }

    // if we are viewing, don't reset tabs
    if ( 'albumid' in pairs ){
        start_tab = 1;
        if ( pairs['albumid'].length < 1 ){
            window.location = '?&view_photos=1'
        }
    }
    if ( 'view_photos' in pairs){
        start_tab = 1;
    }

    //create our Accordion instance
    var myAccordion = new Fx.Accordion($('accordion'), 'h3.toggler', 'div.element', {
      opacity: false,
      height: my_height,
      width: my_width,
      fixedWidth: my_width,
      fixedHeight: my_height,
      show: start_tab,
      onActive: function(toggler, element){
        toggler.setStyle('color', '#FFF');
        //element.setStyle('visibility', 'visible');
      },
      onBackground: function(toggler, element){
        toggler.setStyle('color', '#528CE0');
        //element.setStyle('visibility', 'hidden');
      },
    });

  }
});
