﻿window.onscroll = scrollEvent;
window.onresize = resizeEvent;

function scrollEvent() {
   
  // change the display size and location
  // DO SOMETHING
  //alert('scroll event occurred');
}

function resizeEvent() {
   
    // change the display size and location
    // do something

    var objDiv, nBrowserWidth, nPageWidth;
    nBrowserWidth = getBrowserWidth();
    //alert ('width: ' + nBrowserWidth);

    var nPageWidth, nPageRemainWidth, nContOutWidth, nContLeftWidth, nContMiddleWidth, nContRightWidth, nMarginBlockWidth, nLatestTechnologyWidth, nNavWidth, nMainWidth

    //browser parse
    var browserName=navigator.appName;
    var browserVersion=navigator.appVersion;
    var majorVersion=parseFloat(browserVersion);
    var pageName = file_name_only(location.href);
    var urlPage = window.location.href
    
    //DEBUG STUFF
    //alert ('page: ' + window.location.href );
    
    //Additional pixel for IE6
    var nAddIE6 = 0
    
   //Check for XMLHttpRequest as BEST way to check for IE6
    
    if (window.XMLHttpRequest) {    // IE 7, mozilla, safari, opera 9   
        nAddIE6 = 0;
    } else {                        // IE6, older browsers
        nAddIE6 = 1;
    }
    
  //SSE DEBUG STUFF
  //alert ('nBrowserWidth: ' + nBrowserWidth );
  if (nBrowserWidth > 998) {
    
    nPageWidth = nBrowserWidth;
    
    //outer content is full page width
    nContOutWidth = nPageWidth
    
    //middle content is 80% of page width
    nContMiddleWidth = parseInt(nPageWidth * 0.8)
    
    //right content is 80% of remaining page width
    nPageRemainWidth = nPageWidth - nContMiddleWidth;
    nContRightWidth = parseInt(nPageRemainWidth * 0.8)
    
    //left content is remaining widtth (approx. 4% of page width)
    nContLeftWidth = nPageRemainWidth - nContRightWidth;
    
    nLatestTechnologyWidth = parseInt(nContRightWidth * 0.8)-1;
    nMarginBlockWidth = nContRightWidth - (parseInt(nContRightWidth * 0.8) + 2);
    
    //
    //alert ('Name: ' + browserName + ' ' + majorVersion + ' ' + pageURL);
    //if ((browserName == "Microsoft Internet Explorer") && (majorVersion == 4) && (nBrowserWidth <= 1025)){
    //  //nPageWidth = nBrowserWidth - 26;
    //  //alert ('nPageWidth: ' + nPageWidth);
    //  nMainWidth  = parseInt(nContMiddleWidth * 0.8)- 1;
    //  nNavWidth   = nContMiddleWidth - nMainWidth - 1;
    //  document.getElementById('marginBlockSpacer1').innerHTML = 'IE4';
    //}else{
      nMainWidth  = parseInt(nContMiddleWidth * 0.8);
      nNavWidth   = nContMiddleWidth - nMainWidth;
    //}
    
  
  }else{
    
    //objDiv
    nContOutWidth           = 998;
    nContLeftWidth          = 39;
    nContMiddleWidth        = 797;
    nContRightWidth         = 160;
    nLatestTechnologyWidth  = 138;
    nMarginBlockWidth       = 19;
    
    nMainWidth  = parseInt(nContMiddleWidth * 0.79);
    nNavWidth   = nContMiddleWidth - nMainWidth;
    
    // Added 20080407 - B.RMc
    // Remove RHS column if 800 x 600
    if (nBrowserWidth <= 800) {
        nContOutWidth = 778;
        nContMiddleWidth = 778;
        nMainWidth = 618;
      
        if (window.XMLHttpRequest) {    // IE 7, mozilla, safari, opera 9   
            nMainWidth = 610;
        } else {                        // IE6, older browsers
            nMainWidth = 610;
        }
    
      nContLeftWidth = 1;
      nContRightWidth = 1;

      document.getElementById('containerColLHS').style.display      = 'none';
      document.getElementById('containerColRHS').style.display      = 'none';
      if (urlPage.indexOf('/lasik/')>0) {
        document.getElementById('internetSpecialTitle').style.display = 'block';
      }
      //document.getElementById('iFrameGoogleMap').style.width        = '350px';
      
      // toggle display of div's in Nav Col Bottom
      if (urlPage.indexOf('/lasik/')>0) {
          document.getElementById('navCataract').style.display = 'block';
          document.getElementById('navRequestInfo').style.display = 'none';
          document.getElementById('linkCallBottom').style.display = 'block';
      }
      
    }else{
      document.getElementById('containerColLHS').style.display      = 'block';
      document.getElementById('containerColRHS').style.display      = 'block';
      if (urlPage.indexOf('/lasik/')>0) {
        document.getElementById('internetSpecialTitle').style.display = 'none';
      }
      
      // toggle display of div's in Nav Col Bottom
      if (urlPage.indexOf('/lasik/')>0) {
        document.getElementById('navRequestInfo').style.display = 'block';
        document.getElementById('navCataract').style.display = 'none';
        document.getElementById('linkCallBottom').style.display = 'none';
      }
    }
  
  }
  
  if ((browserName == "Microsoft Internet Explorer") && (majorVersion >= 4) && (pageName == 'home')){
    //alert ('hiding main overflow in default/home page');
    document.getElementById('main').style.overflow = 'hidden';
  }
  
  document.getElementById('containerLeft').style.width    = (nContLeftWidth-1) + 'px';
  document.getElementById('containerRight').style.width   = (nContRightWidth-1) + 'px';
  document.getElementById('containerMiddle').style.width  = (nContMiddleWidth) + 'px';
  document.getElementById('containerOuter').style.width   = (nContOutWidth) + 'px';
  
  //masthead sizes
  var iMastheadBookWidth, iMastheadRequestWidth, iMastheadCallWidth
  
  iMastheadBookWidth = parseInt(nContMiddleWidth * 0.38);
  iMastheadRequestWidth = parseInt(nContMiddleWidth * 0.25);
  iMastheadCallWidth = nContMiddleWidth - (iMastheadBookWidth + iMastheadRequestWidth) - 30;  
  
  document.getElementById('mastheadBook').style.width    = iMastheadBookWidth    + 'px';
  document.getElementById('mastheadCall').style.width    = iMastheadCallWidth    + 'px';
  document.getElementById('mastheadRequest').style.width = iMastheadRequestWidth + 'px'; 
  
  document.getElementById('latestTechnology').style.width     = (nLatestTechnologyWidth)  + 'px';
  document.getElementById('marginBlockSpacer1').style.width   = (nMarginBlockWidth)       + 'px';
  document.getElementById('marginBlockSpacer2').style.width   = (nMarginBlockWidth)       + 'px'; 
  
  document.getElementById('containerContentNav').style.width        = nNavWidth   + 'px';
  document.getElementById('containerContentTitleMain').style.width  = (nMainWidth-nAddIE6)  + 'px';
  
  document.getElementById('nav').style.width      = nNavWidth + 'px';
  document.getElementById('linksite').style.width = nNavWidth + 'px';
  //document.getElementById('pageTitle').style.width= (nMainWidth-1) + 'px';
  document.getElementById('main').style.width     = (nMainWidth-2-nAddIE6) + 'px';
  document.getElementById('content').style.width  = parseInt(nMainWidth * 0.9) + 'px';
  
}

function file_name_only(str) { 
  var slash = '/' 
  if (str.match(/\\/)) { 
    slash = '\\' 
  } 
  return str.substring(str.lastIndexOf(slash) + 1, str.lastIndexOf('.')) 
} 

// IE Load Event
if (window.attachEvent) window.attachEvent('onload', resizeEvent);

// Mozilla Load Event
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", resizeEvent, false);
}