// Variable fixed width on WRAP

wraphandler = {
  init: function() {
    if (!document.getElementById) return;
    // set up the appropriate wrapper
    wraphandler.setWrapper();
    // and make sure it gets set up again when you resize the window
    wraphandler.addEvent(window,"resize",wraphandler.setWrapper);
  },

  setWrapper: function() {
    // width stuff
    var theWidth = 0;
    if (window.innerWidth) {
	theWidth = window.innerWidth
    } else if (document.documentElement &&
                document.documentElement.clientWidth) {
	theWidth = document.documentElement.clientWidth
    } else if (document.body) {
	theWidth = document.body.clientWidth
    }
    if (theWidth != 0) {
      if (theWidth < 950) {
        document.getElementById('wrapper').className = 'narrow-layout';
      } else {
        document.getElementById('wrapper').className = 'standard-layout';
      }
    }
		//add a hook so other JS can do something after wrapper is set
		if(typeof doAfterApplyVariableFixedWidth == 'function') {
			doAfterApplyVariableFixedWidth();
		}
  },

// addEvent stuff
  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);

