  ///////////////////////////////////////////////////////////////////////////////
  ///
  ///  External Functions Called from Flash SWF 
  ///
  ///  Last modified: 8/13/09
  ///
  ///////////////////////////////////////////////////////////////////////////////

  // Modify as needed for a given implementation 
  var CALC_NAME = "LessWeb";

  // To enable in html page, be sure to add the onresize="" and onscroll="" handlers to 
  // the <body> tag. 
  
  /**
  * Registers handlers for browser window resize and scrolling  
  * 
  * Disabled - IE not handling addEventListeners properly. Adding on body element directly instead. 
  **/   
  //window.addEventListener("resize", browserWindowChangeHandler, false); 
  //window.addEventListener("scroll", browserWindowChangeHandler, false); 
  
  
  /**
  * Returns the Y center of the browser window. Called externally from the Flash SWF.  
  **/  
  function getYCenter()
  {
      var h = 0;

      // Non-IE browsers 
      if (typeof( window.innerHeight ) == 'number') 
          h = window.innerHeight
      //IE 6+ in 'standards compliant mode'
      else if ( document.documentElement && document.documentElement.clientHeight ) 
          h = document.documentElement.clientHeight
      // Legacy IE     
      else if ( document.body &&  document.body.clientHeight ) 
          h = document.body.clientHeight;
  
      return ( document.all ? document.body.scrollTop : window.pageYOffset ) + (h/2);
   }
 
 
 /**
  * Returns the adjusted bottom Y position of the browser - called using ExternalInterface 
  **/    
  function getBrowserBottomPos()
  {
  
      var windowHeight = window.innerHeight ? 
                        window.innerHeight : document.documentElement.clientHeight ? 
                        document.documentElement.clientHeight : document.body.clientHeight;

      var scrollYPos = getScrollY(); 

      return windowHeight+scrollYPos; 
  }
  
  /**
  * Returns the scrolling y offset - used by getBrowserBottomPos()
  **/    
  function getScrollY() 
  {
      var scrOfY = 0;
      if( typeof( window.pageYOffset ) == 'number' ) 
      {
          //Netscape compliant
          scrOfY = window.pageYOffset;
      } 
      else if ( document.body && document.body.scrollTop ) 
      {
          //DOM compliant
          scrOfY = document.body.scrollTop;
      } 
      else if ( document.documentElement && document.documentElement.scrollTop ) 
      {
          //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
      }
      return scrOfY;
}


  /**
  * Returns the y position of the SWF file. Called externally from the Flash SWF.  
  **/  
  function findPosY(obj)
  {
      var curtop = 0;
      if(obj.offsetParent)
        while(1)
        {
            curtop += obj.offsetTop;
            if(!obj.offsetParent)
              break;
            obj = obj.offsetParent;
        }
      else if(obj.y)
        curtop += obj.y;
      return curtop;
  }
  
  /**
  * Adjusts the height of the Flash SWF at runtime. Called externally from the Flash SWF.  
  **/     
  function setFlashHeight(newHeight)
  {
      var viewportwidth;
      var viewportheight;
   
      // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
   
      if (typeof window.innerWidth != 'undefined')
      {
        viewportwidth = window.innerWidth; 
        viewportheight = window.innerHeight; 
      }
      // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) 
      else if (typeof document.documentElement != 'undefined'
                && typeof document.documentElement.clientWidth !=
                'undefined' && document.documentElement.clientWidth != 0)
      {
          viewportwidth = document.documentElement.clientWidth; 
          viewportheight = document.documentElement.clientHeight; 
      }
      // older versions of IE 
      else
      {
          viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
          viewportheight = document.getElementsByTagName('body')[0].clientHeight; 
      }
   
      if (newHeight == "100%")
        document.getElementById(CALC_NAME).style.height = newHeight
      else 
        document.getElementById(CALC_NAME).style.height = (viewportheight > newHeight) ? viewportheight + 'px' : newHeight + 'px'; 
    }

  /**
  * Handler for any event that impacts the y position of the browser. Calls AS3 method. 
  **/     
  function browserWindowChangeHandler()
  {
      var yPos = getBrowserBottomPos(); 
      flashMovieInstance(CALC_NAME).windowYChanged(yPos); 
  }
  
  /**
  * Handler for any event that impacts the y position of the browser. Calls AS3 method. 
  **/     
  function flashMovieInstance(movieName) 
  {
       // IE 
       if (navigator.appName.indexOf("Microsoft") != -1) 
       {
           return window[movieName];
       } 
       // Non-IE 
       else 
       {
           return document[movieName];
       }
  }


  
  