
  var isIE = ( navigator.userAgent.indexOf( "MSIE" ) != -1 );
  var isFirefox = ( navigator.userAgent.indexOf( "Firefox" ) != -1 );
  var clearImg = "http://hendershotts.com/heads/resources/images/layout/clear.gif";

  function loadCssPopup()
  {
    popupElement = document.createElement( "DIV" );
    document.body.insertBefore( popupElement, document.body.lastChild );
    popupElement.id = "cssPopup";
    popupElement.style.top = "20px";
    popupElement.style.left = "50%";
    popupElement.style.marginLeft = "-431px";    
    popupElement.style.width = "862px";
    popupElement.style.height = "";        
    popupElement.style.position = "absolute"; 
    popupElement.style.zIndex = 10000001;       // some ads have a z-index of 999999
    popupElement.style.display = "none";
    popupElement.style.backgroundColor = "#000000";
    popupElement.style.color = "#ffffff";
    popupElement.style.border = "2px solid #ffffff";
  }
  
  
  function showCssPopup() 
  {
    if( isIE ) { hideDropdowns(); }
    
    loadBackgroundOverlay();
    popupDiv = document.getElementById( 'cssPopup' );    
    if( popupDiv != null ) { popupDiv.style.display = ''; }
  }
  

  function closeCssPopup() 
  { 
    if( isIE ) { showDropdowns(); }
    
    popupDiv = document.getElementById( 'cssPopup' );
    if( popupDiv != null ) { popupDiv.style.display = 'none'; }
    closeBackgroundOverlay();
  }




  // fadeout overlay
  // ========================================================================================================================
  var coverDiv;

  function loadBackgroundOverlay()
  {
    coverDiv = document.createElement( "IMG" );
    document.body.insertBefore( coverDiv, document.body.lastChild ); 
    coverDiv.id = "coverDiv";
    coverDiv.src = clearImg;
    coverDiv.alt = "";
    coverDiv.style.height = getWindowHeight() + 'px';
    coverDiv.style.width = "100%";
    coverDiv.style.cursor = "not-allowed";
    coverDiv.style.left = "0px";
    coverDiv.style.top = "0px";
    coverDiv.style.position = "absolute"; 
    coverDiv.style.display = "block";
    coverDiv.style.visibility = "visible";
    coverDiv.style.backgroundColor = "#ffffff";
    coverDiv.style.zIndex = 10000000;
    coverDiv.style.opacity = 0.9;       // standard
    coverDiv.style.MozOpacity = 0.9;    // Mozilla
    if( coverDiv.style.setAttribute ) coverDiv.style.setAttribute( "filter", "alpha( opacity = 90 );" ); // IE 
    
    document.getElementById( "flashcontent" ).style.visibility = "hidden";
  }


  function closeBackgroundOverlay()
  {
    coverDiv = document.getElementById( "coverDiv" );
    if( coverDiv ) document.body.removeChild( coverDiv );
    document.getElementById( "flashcontent" ).style.visibility = "visible";
  }


  function getWindowHeight()
  {
    var pageHeight;

    if( window.innerHeight && window.scrollMaxY ) // Firefox //Fix for IE7 (at then end)
      pageHeight = window.innerHeight + window.scrollMaxY;
    else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
      pageHeight = document.body.scrollHeight;
    else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
      pageHeight = document.body.offsetHeight + document.body.offsetTop; 

    return pageHeight;
  }




  // IE fix - dropdowns controls in IE aren't covered by the overlay, so hide them when showing the popup
  // =======================================================================================================
  var dropdownStyles = new Array();
  var dropdownStylesIndex = 0; 
  
  function hideDropdowns() 
  { 
    try
    { 
      dropdownStylesIndex = 0;
    
      for( i = 0; i < document.forms.length; i++ )
      {
        for( k = 0; k < document.forms[ i ].elements.length; k++ )
        {
          if( document.forms[ i ].elements[ k ].type == "select-one" )
          {
            dropdownStyles[ dropdownStylesIndex++ ] = document.forms[ i ].elements[ k ].style.visibility;   // back up the current value in a global array
            document.forms[ i ].elements[ k ].style.visibility = "hidden";
          }
        }
      }
    }
    catch( e ) {}
  }
  

  function showDropdowns() 
  { 
    try
    {
      dropdownStylesIndex = 0;
    
      for( i = 0; i < document.forms.length; i++ )
      {
        for( k = 0; k < document.forms[ i ].elements.length; k++ )
        {
          if( document.forms[ i ].elements[ k ].type == "select-one" )
          {
            document.forms[ i ].elements[ k ].style.visibility = dropdownStyles[ dropdownStylesIndex++ ];   // restore styles
          }
        }
      }
    }
    catch( e ) {}
  }




  // utility
  // ========================================================================================================================
  
  //  Unobtrusively add event handlers to objects without overwriting any existing events that are attached.
  function addEvent( obj, eventType, fn )
  {
    if( obj.addEventListener ) 
    { 
      obj.addEventListener( eventType, fn, false );
      return true; 
    }
    else if( obj.attachEvent )
    { 
      var r = obj.attachEvent( "on" + eventType, fn );
      return r; 
    }
    else { return false; } 
  }
  
  
  
  // ========================================================================================================================
  
  addEvent( window, 'load', loadCssPopup );
  
  
  function showPricingAndContact()
  {
    popupDiv = document.getElementById( 'cssPopup' );    
    if( popupDiv != null ) 
    {       
      var text = '<div style="line-height: 18px; padding: 10px;">';
      text += '<div style="margin-bottom: 10px; float: left; width: 80%; display: inline;">';
      text += '  <div style="margin: 20px 0 0 0; text-align: center; width: 276px;">';
      text += '    <div style="margin-bottom: 13px;"><img src="resources/images/layout/logo_black.jpg" alt="Adam Hendershott" border="0"></div>';
      text += '    <a href="http://hendershotts.com" target="_blank" onmouseover="rolloverOn( \'hendershottsLink_black\' )" onmouseout="rolloverOff( \'hendershottsLink_black\' )"><img name="hendershottsLink_black" src="resources/images/layout/hendershotts-link_black.jpg" alt="www.hendershotts.com" border="0"></a>';
      text += '  </div>';
      text += '</div>';
      text += '<div style="float: left; width: 20%; display: inline; margin-top: 1px; text-align: right;">[ <a href="javascript: closeCssPopup();" onmouseover="rolloverOn( \'closePopup\' )" onmouseout="rolloverOff( \'closePopup\' )"><img name="closePopup" src="resources/images/layout/info_close.gif" width="56" height="12" alt="Close" border="0"></a> ]</div><br clear="all">';
      text += '<div style="margin-top: 80px; height: 280px; text-align: center;">';
      text += '  <img src="resources/images/layout/contact-pane.jpg" border="0"><br/>';
      text += '  <a href="mailto:sylvia@hendershotts.com" onmouseover="rolloverOn( \'mailto\' )" onmouseout="rolloverOff( \'mailto\' )"><img src="resources/images/layout/mailto.jpg" name="mailto" border="0"></a>';
      text += '</div></div>';
      
      popupDiv.innerHTML = text; 
      
      showCssPopup();
      window.scrollTo( 0, 0 );
    }
  }