function loaddynamic()
{
  /* Nav */
  if (document.all&&document.getElementById)
  {

    var navs = new Array("share-menu", "hundredfilms-nav", "top-nav", "oscars-nav", "scenes-nav", "bestof-nav", "history-nav", "posters-nav", "quotes-nav", "genres-nav", "reference-nav", "directors-nav");

    for(i=0;i<navs.length;i++)
    {
      var node = document.getElementById(navs[i]);
      
      if(node)
      {
        node.onmouseover=function() 
        {
          if(this.className != "current selected")
            this.className="selected";
        }
        node.onmouseout=function()
        {
          if(this.className == "selected")
            this.className="";
        }
      }


    }
  }
  
  /* Tabs */
  var nodes = document.getElementsByTagName("ul");
  for(i=0;i<nodes.length;i++)
  { 
    if(nodes[i].className == "tabs")
    {
      var tabs = nodes[i].getElementsByTagName("a");

      for(j=0;j<tabs.length;j++)
      {
        // Move href link (for javascript-off state) int select-tab attribute
        var href = tabs[j].getAttribute("href");
        href = href.substring(href.indexOf('#'), href.length);
        tabs[j].setAttribute("select-tab", href.replace("#",""));
        //tabs[j].removeAttribute("href");
        tabs[j].setAttribute("href", "javascript:void(0);");
      
        // Tab mousedown handler
        tabs[j].onmousedown=function()
        {
          // Deselect other tabs
          others = this.parentNode.parentNode.getElementsByTagName("li");
          for(k=0;k<others.length;k++)
          {
            others[k].className="";
          }         

          // Set clicked tab as current
          
          this.parentNode.className="current";

          // Set associated tab page as current
          others = this.parentNode.parentNode.parentNode.getElementsByTagName("div");

          for(k=0;k<others.length;k++)
          {

            if(others[k].className.indexOf("page-module ") != -1 )
            { 
              others[k].className = others[k].className.replace("current ","");
            }
            
          } 
          
          page = document.getElementById(this.getAttribute("select-tab"));
          
          page.className = "current " + page.className

        }

        
      }
    }
  }
  
  /* Polls */
  var nodes = document.getElementsByTagName("div");
  for(i=0;i<nodes.length;i++)
  { 
    if(nodes[i].className.match("poll-module"))
    { 
      
      var forms = nodes[i].getElementsByTagName("form");
      for(j=0;j<forms.length;j++)
      {     
        var inputs = forms[j].getElementsByTagName("input");
          
        for(k=0;k<inputs.length;k++)
        {
          // Replace buttons with links
          if(inputs[k].type == "submit")
          {
            inputlink = document.createElement("a");
            inputlink.className = "button";
            
            linktext = document.createTextNode(inputs[k].value);
            inputlink.appendChild(linktext);
            
            inputlink.setAttribute("href","#");

            inputs[k].parentNode.appendChild(inputlink);

            inputs[k].parentNode.removeChild(inputs[k]);

            inputlink.onclick=function()
            {
  
              var s = this.parentNode.action;

              var inputs = this.parentNode.getElementsByTagName("input");

              for(k=0;k<inputs.length;k++)
              {
                s += "&" + inputs[k].name + "=" + inputs[k].value;
              }

              var iframe = this.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("iframe")[0];

              iframe.src=s;
              iframe.className="poll-results-frame";
              
              return false;

            }
          }

        }         
        
      }
      
    
      

    }
  }

  /* Slideshow */
  var anchors = document.getElementsByTagName("a");
  for(i=0;i<anchors.length;i++)
  { 
    if(anchors[i].className.match("slideshowlink"))
    { 
      
      
        anchors[i].onclick=function()
        {   
          
          popupurl = this.href;
          
          window.open(popupurl, 'popupsupersize', 'toolbar=0,scrollbars,location=0,menubar=0,width=828,height=600');
          
          return false;
          
        }
        
    
      }
      
    
      

    }
    
    flashfix();
  

}

/* Elegeant Online Legal Assisting System for Simple Transparent Flash Update */

function flashfix()
{

  /* IE Detect Code */
  var ua = navigator.userAgent.toLowerCase();
  isOpera = (ua.indexOf('opera') != -1); 
  isIE = (ua.indexOf('msie') != -1 && !isOpera && (ua.indexOf('webtv') == -1) ); 
  versionMinor = parseFloat(navigator.appVersion); 
  if (isIE && versionMinor >= 4)
      versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
  versionMajor = parseInt(versionMinor); 
  isIE6up = (isIE && versionMajor >= 6);

  if (isIE6up)
  {
    objects = document.getElementsByTagName("object");

    for(i=0; i < objects.length; i++)
    {
      obj = objects[i];

      obj.parentNode.innerHTML = obj.parentNode.innerHTML;
    }
  }
}

//DOM-ready watcher
function domReady()
{
  //start or increment the counter
  this.n = typeof this.n == 'undefined' ? 0 : this.n + 1;
  
  //if DOM methods are supported, and the body element exists
  //(using a double-check including document.body, for the benefit of older moz builds [eg ns7.1] 
  //in which getElementsByTagName('body')[0] is undefined, unless this script is in the body section)
  //>>> and any elements the script is going to manipulate exist
  if
  (
    typeof document.getElementsByTagName != 'undefined' 
    && (document.getElementsByTagName('body')[0] != null || document.body != null)
      && document.getElementById('top-nav') != null 
  )
  {
  //>>>-- DOM SCRIPTING GOES HERE --<<<
  
  
    loaddynamic();


  //>>>-----------------------------<<<
  }

  //otherwise if we haven't reached 60 (so timeout after 15 seconds)
  //in practise, I've never seen this take longer than 7 iterations [in kde 3.2.2 
  //in second place was IE6, which takes 2 or 3 iterations roughly 5% of the time]
  else if(this.n < 60)
  {
    //restart the watcher
    //using the syntax ('domReady()', n) rather than (domReady, n)
    //because the latter doesn't work in Safari 1.0
    setTimeout('domReady()', 250);
  }
};
//start the watcher
domReady();



