/* Resize routine to automatically reload a page or a page within a frame.      */ 
/* This technique checks the original page width and height against the current */
/* live page width and height. Whenever a difference is noticed the onresize    */
/* event is triggered before the page body ever loads.                          */
	  var livePageWidth;
	  var livePageHeight;
	  var originalWidth;
	  var originalHeight;
      var newPathJS; 	  


  function getDimensions()
  {
	  if (window.top.document.body.clientWidth != null)
	    livePageWidth = window.top.document.body.clientWidth; 		
      else
	  {  
	     if (window.top.innerWidth != null)
		   livePageWidth = window.top.innerWidth;	  
         else
	       livePageWidth = null; 
	  }
	  
	  if (window.top.document.body.clientHeight != null)
	    livePageHeight = window.top.document.body.clientHeight; 		
      else
	  {  
	     if (window.top.innerHeight != null)
		   livePageHeight = window.top.innerHeight;	  
         else
	       livePageHeight = null; 
	  }	  
     
     originalWidth = livePageWidth;   
     originalHeight = livePageHeight;  
          
   /*   alert('Area1' + '\n' +
              'livePageWidth = ' + livePageWidth + '\n' +
              'OrgImageRes = ' + OrgImageRes);   */

  } 
	
/* This function is only called when the onresize event is triggered.           */
/* The onresize event is checked in the HTML heading section before the page or */
/* any images have a chance to load.                                            */	
/* This function checks the current Page Width against the original Page Width. */
/* If there is a difference then the page is reloaded.                          */
/* (Actually replaced so the browser's history is not updated with this page    */
/* 2 times.)    
                                                                */
  function reloadPage()
	{
	   var currentWidth;
	   var currentHeight;

	   if (window.top.document.body.clientWidth != null)
	     currentWidth = window.top.document.body.clientWidth; 	     
       else
	   {  
	     if (window.top.innerWidth != null)
	       currentWidth = window.top.innerWidth;	   
         else
	       currentWidth = null; 
	   }
	   
       if (window.top.document.body.clientHeight != null)
	     currentHeight = window.top.document.body.clientHeight; 	     
       else
	   {  
	     if (window.top.innerHeight != null)
	       currentHeight = window.top.innerHeight;	   
         else
	       currentHeight = null; 
	   }	   
     	   
/*    alert('Reload, originalWidth = ' + originalWidth + '\n' +
	        'Reload, currentWidth = ' +  currentWidth);  */
 
	  if (currentWidth != originalWidth || currentHeight != originalHeight)
	  {
	   /* alert('Resize - Reload'); */
	    updtPathReload('Resize');
	    window.location.replace(newPathJS);
	  }
	  else
	   { /* alert('Resize function, but no Reload - original size same as current size'); */ }
	 
	 
   }

/* Code to update the QueryString parameter for screen resolution. */
/* Based on the livePageWidth. When the livePageWidth > 800 then   */
/* the href path is always updated to be "RS=High" but when the    */
/* livePageWidth <= 800 the href path is always updated to be      */
/* "RS=Low".                                                       */
   
function updtPathReload(xyz) { 

    var newPath; 

    var QsScreenResolution; 
    var ScreenResolution;

    livePageWidth = findLivePageWidth();

/*  alert('updtPathReload - livePageWidth = ' + livePageWidth); */

    if (livePageWidth != null) 
     {if (livePageWidth <= 800)
       {ScreenResolution = "Low";}
      else
       {ScreenResolution = "High";} 
     }
    else
     { ScreenResolution = "Low"; }    

    
    QsScreenResolution = "\&RS=" + ScreenResolution; 

 /* alert('QsScreenResolution = ' + QsScreenResolution);  */

    newPath = window.location.href; 
    /* alert('updateReload' + '\n' +
             'QsScreenResolution = ' + QsScreenResolution + '\n' +
             'newPath = ' + newPath);    */
              
    if (newPath.indexOf("\&RS=") != -1) 
      { 
          
        if (newPath.indexOf("\&RS=High") != -1 || newPath.indexOf("\&RS=Low") != -1) 
         {  
          if (newPath.indexOf("\&RS=High") != -1) 
            { newPathJS = newPath.replace(/\&RS=High/, QsScreenResolution); } 
          else 
            { newPathJS = newPath.replace(/\&RS=Low/, QsScreenResolution); }             
          } 
        else 
          { newPathJS = newPath.replace(/\&RS=/, QsScreenResolution); }    
                   
      }           
    else 
      {    
       newPathJS = newPath + QsScreenResolution; 
        /* alert('newPath = ' + newPath + '\n' +
                 'newPathJS = ' + newPathJS); */
      } 


  }


	 
  onresize = reloadPage;


  if ((livePageWidth != null) && (livePageWidth != ""))
  {

   /* alert('Flow thru area, livePageWidth = ' + livePageWidth); */
  
    if (OrgImageRes == "High")
    {
      if (livePageWidth <= 800)
       {updtPathReload();
        /* alert('window.location.replace, Width LE 800' + '\n' +
                 'OrgImageRes = ' + OrgImageRes + '\n' +
                 'livePageWidth = ' + livePageWidth + '\n' +
                 'newPathJS = ' + newPathJS);   */
        window.location.replace(newPathJS); }         
    }
    else
    {
      if (livePageWidth > 800)
       {updtPathReload();
        /* alert('window.location.replace, Width GT 800' + '\n' +
                 'OrgImageRes = ' + OrgImageRes + '\n' +
                 'livePageWidth = ' + livePageWidth + '\n' +
                 'newPathJS = ' + newPathJS);   */
        window.location.replace(newPathJS); }                   
         
    }
  
  } 
  else
  {
    /* alert('livePageWidth - null or empty'); */

  } 

