// Dynamically change layout based on window sized
// Based on work by Simon Collison et al
// http://www.collylogic.com/?/comments/redesign-notes-1-width-based-layout/


wraphandler = {
  init: function() {
    if (!document.getElementById) return;
    // set up the appropriate wrapper
    wraphandler.setWrapper();
    // and make sure it gets set up again if you resize the window
    wraphandler.addEvent(window,"resize",wraphandler.setWrapper);
  },

  setWrapper: function() {
    // width stuff from ppk's http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/index.html
    var theHeight = 0;
    if (window.innerHeight) {
	theHeight = window.innerHeight
    } else if (document.documentElement &&
                document.documentElement.clientHeight) {
	theHeight = document.documentElement.clientHeight
    } else if (document.body) {
	theHeight = document.body.clientHeight
    }
    if (theHeight != 0) {
      if (theHeight < 535) {
        document.getElementById('wrapper').className = 'deadcentre_alt';
      } else {
        document.getElementById('wrapper').className = 'deadcentre';
      }
    }
  },

  addEvent: function( obj, type, fn ) {
    if ( obj.attachEvent ) {
      obj['e'+type+fn] = fn;
      obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
      obj.attachEvent( 'on'+type, obj[type+fn] );
    } else {
      obj.addEventListener( type, fn, false );
    }
  }
}

wraphandler.addEvent(window,"load",wraphandler.init);
