// DYNAMIC RESOLUTION SWITCHER
// Originally from ParticleTree
// Simplified with Prototype by Ian White of Argument from Design 2008
// include prototype.js (>=1.6) before this file

// you need to edit this function as per your situation
function applyDynamicLayout() {
  var width = document.viewport.getWidth();
  if (width <= 750 )                 { applyStylesheet("thin") }
  if (width > 750 && width <= 950)  { applyStylesheet("wide") }
  if (width > 950)                   { applyStylesheet("wider") }
  //alert(width)
}

// you shouldn't need to edit past here
function applyStylesheet(title) {
  var i, stylesheet;
  for(i=0; (stylesheet = document.getElementsByTagName("link")[i]); i++) {
    // is it a stylesheet with a title attribute?
    if(stylesheet.getAttribute("rel").indexOf("style") != -1 && stylesheet.getAttribute("title")) {
      stylesheet.disabled = true;
      if (stylesheet.getAttribute("title") == title) {
        stylesheet.disabled = false;
      }
    }
  }
}

//Run applyDynamicLayout function when window is ready and when it resizes.
//Event.observe(document, 'dom:ready', applyDynamicLayout); //jon - this didnt seem to detect the page loading

// RH: commented this out as it was causing layout to "jump around" - now fixed width
// note that i would have removed the link altogether, but the skin doesn't seem to use main_template
// for loatsd of the content? will rectify this at some point and remove link centrally
//Event.observe(window, 'load', applyDynamicLayout);
//Event.observe(window, 'resize', applyDynamicLayout);
