
/* Code to Redirect/Reload page after Resize event */
/* window.location.href will cause a redirect, but not always a reload. */
/* Appears to reload whenever the entire path is different (including query string parameters) */
/* Even if only 1 parameter is different. */
/* If the path is still in the browser's (client machine) cache then no reload takes place */
/* Netscape 4 that uses CSS, always needs a reload for a resize event. Other browsers can */
/* save time by using cached pages. */
    
function updtPathReloadS2(xyz) { 
 /* alert('updateReloadS2 - xyz = ' + xyz);  */
    var newPathtypeBef; 
    var newPathtypeAft; 
    var newPath; 
    var newPathJS; 
    var QsScreenResolution; 
    var ScreenResolution;
    var livePageWidth;
    livePageWidth = findLivePageWidth();

    if (livePageWidth != null) 
     {if (livePageWidth <= 800)
       {ScreenResolution = "Low";}
      else
       {ScreenResolution = "High";} 
     }
    else
     { ScreenResolution = "Low"; }    

    
    QsScreenResolution = "\?RS=" + ScreenResolution; 

    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); */
        /* Activate the following IF statement to prevent this function from */
        /* changing a href string without a "?RS=" to an href with a "?RS+"  */
        /* HTTP string. The purpose is to stop this function from running    */
        /* twice (to update the string and then reload the program with the  */
        /* updated string). Only applies to screens of "HiRes", will always  */
        /* need to loop to update screens of "LoRes" since the default is    */
        /* assumed to be "HiRes".                                            */

        /*
          if (ScreenResolution == "High")
            { return; }
                           */

      } 


/* Checking for Screen Resolution match. When actual windows screen resolution */
/* is HIGH and the QueryString is RS=High or windows screen resolution is LOW  */
/* and the QueryString is RS=Low then ResolutionMatch flag is set = "yes".     */
/* Code was implemented to prevent infinite loops due to onload event          */
/* triggering itself after execution of window.location.replace or href.       */

  var ResolutionMatch;
  ResolutionMatch = "no";

  if ((ScreenResolution == "High") && (newPath.indexOf("\?RS=High") != -1))
    {ResolutionMatch = "yes";}
  else
  {
  if ((ScreenResolution == "Low") && (newPath.indexOf("\?RS=Low") != -1))
    {ResolutionMatch = "yes";}  
  }

/* alert('ScreenResolution = ' + ScreenResolution +'\n' +
       'ResolutionMatch = ' + ResolutionMatch); */

/* (Occurs only when back arrow used on browser after resizing screen)      */
/* When xyz = 'lx', 'hx', 'mlx' or 'mhx' then a resolution descrepancy      */ 
/* has occurred.                                                            */
/* Each time a page is loaded onto a client browser's screen the screen     */
/* size/resolution is checked. If the page was originally presented for     */
/* the screen in low resolution, but the screen has subsequently changed to */
/* high resolution display, then the page is replaced on the screen.        */
/* Location.replace will request a new page from the server, but not        */
/* update the history object.                                               */
/* window.location.href - will check the client's cache first and if no     */
/* prior version of this page exist then the page is redirected back to the */
/* server for a new page. When the page is still in the client's cache      */
/* then it is immediately reloaded from the client's browser.               */

 
    if (xyz == 'lx' || xyz == 'hx' || xyz == 'mlx' || xyz == 'mhx' || ResolutionMatch == 'no') 
     { 
   /* alert('hash = ' + window.location.hash + "\n" +
            'href = ' + window.location.href + "\n" +
            'search = ' + window.location.search + "\n" +           
            'Original Path = ' + "\n" + newPath + "\n" +
            'Updated Path = ' + "\n" + newPathJS + "\n" +      
            'window.location.replace = ' + "\n" + newPathJS);  */
            
        var locHash;
        locHash = window.location.hash;  
          
/* Correcting problem with NetScape not recognizing hash when window.location.hash is undefined,     */
/* causing the JavaScript to abruptly end before updating the HREF path with the correct resolution. */
/*            if (window.location.hash != null || window.location.hash > " ")  */
        if (window.location.hash)        //Testing for Netscape to see if hash object exists.
        {
        if (locHash != null || locHash > " ")         
           { 
            /* alert('hash = ' + window.location.hash);    */
            newPathJS2 = newPathJS.replace(locHash, ""); 
            newPathJS = newPathJS2; 
            /* alert('hash = ' + window.location.hash + "\n" +
                     'newPathJS = ' + newPathJS); */  
           }
         }
       /* alert('newPathJS = ' + newPathJS); */
       window.location.replace(newPathJS);
     } 
    else
     { /* alert('No path updates needed!'); */  }
    
    /*  {alert('Original Path = ' + "\n" + newPath + "\n" +
            'Updated Path = ' + "\n" + newPathJS + "\n" +  
            'window.location.href = ' + "\n" + newPathJS); 
        window.location.href = newPathJS; } */
       
                   
 /*    { window.location.href = newPathJS; }    */
 /* alert('Href  = ' + window.location.href + "\n" +  
          'Location  = ' + window.location + "\n" +
          'QString   = ' + QsScreenResolution + "\n" +
            'newPathJS = ' + newPathJS);  */   
  
  
   /*    window.location.reload(true) */
   /*  window.location.href = newPathJS; */       
      
  } 
    
     
     
