//------------------------------------------------------------
// Global Vars
//------------------------------------------------------------
var LoginPathPage

//------------------------------------------------------------
// Place anything that should load with page here.
//------------------------------------------------------------
function AutoLoadMethods(ApplicationPath, HostName, PageName, UserType, Domain)
{  
  //alert(ApplicationPath);
  //alert(HostName);
  //alert(PageName); 
  //alert(UserType);
  //alert(Domain);
    
  //Get rid of any back button logic.  
 // window.history.forward(1);   
     
  //Round corners around boxes
  //MakeRoundCorners();  
  
  //---------------------------------------------------
  // Timeout logic. Agency 20 minutes, Amerisure 170
  //---------------------------------------------------  
  var AdminTimeout = 19; 
  var UserTimeout = 19; 
  var CurrentURL = 'http://' + Domain +  ApplicationPath + PageName; 
  
  var ErrorPage = "";
  if (UserType == 'U')
  {
     //ErrorPage =  'http://' + Domain + ApplicationPath + 'Message.aspx?ID=0';
     ErrorPage =  'http://' + Domain + ApplicationPath + PageName;
     //alert(ErrorPage);
  }
  else //Site Admin on URL
  {
     ErrorPage =  'http://' + Domain + ApplicationPath + 'SiteAdmin/Message.aspx?ID=2';
  }
     
  //alert(CurrentURL);
  //alert(ErrorPage);
  
  //Default to Admin
  var TimeOut = AdminTimeout;  
  if (UserType == 'U')
  {    
    TimeOut = UserTimeout;
  }  
  
  window.setTimeout('TimeoutControl(' + "'" + UserType + "'" + ',' 
                                      + "'" + CurrentURL + "'"  + ',' 
                                      + "'" + ErrorPage + "'" + ')', TimeOut * 60 * 1000);  
  
}
//-------------------------------------------------------------------------
// Direct Admin user to timeout page. User shopping, refresh the page.
//-------------------------------------------------------------------------
function TimeoutControl(UserType, LastURL, ErrorPage)
{  
  //Admin timeout out, eCommerce site refresh
  if (UserType == 'A')
  { 
     window.location.href=ErrorPage;  
  } 
  else
  {
     window.location.href=LastURL;      
  }
}

//-------------------------------------------------------------------------
// Close the popup window if it times out.
//-------------------------------------------------------------------------
function PopUpAutoLoadMethod(ForwardTime)
{
  //Bring the popup to the front
  window.setTimeout('self.focus()', ForwardTime);
    
  //close the window before 20 minutes
  window.setTimeout('window.close()', 18 * 60 * 1000); 
}
//-------------------------------------------------------------------------
//This function makes corners of boxes round. See the CSS and Left Nav
//-------------------------------------------------------------------------
function MakeRoundCorners()
{
 var els = document.getElementsByTagName('div'); 
 for(var i=0; el=els[i]; i++) 
 if(el.className.indexOf('round')>-1 && el.firstChild && el.firstChild.className!='t') 
    el.innerHTML = '<b class="t"><b class="r"></b></b><div class="c"><b class="br"></b>'+el.innerHTML+'<b class="br"></b></div><b class="b"><b class="r"><!----></b></b>';
}
//-------------------------------------------------------------------------
// POPUP Center Window with Parms 
//' <A class='LayerControlLink' HREF="#" onclick="javascript:openCenteredWindow('GeneralPopUp.aspx?Name=XML&Value=JobID','800','600');">JobID</A>
//-------------------------------------------------------------------------
function OpenCenteredWindow(url, xHeight, xWidth)
{
   var myWindow;
   var height = xHeight;
   var width = xWidth;
   var left = parseInt((screen.availWidth/2) - (width/2));
   var top =  parseInt((screen.availHeight/2.2) - (height/2.2));
   //var top = 1;
   var windowFeatures = 'width=' + width + ',height=' + height + ',resizable=0,dependent,titlebar=no,scrollbars=no,menubar=no,status=no,left=' + left + ',top=' + top + 'screenX=' + left + ',screenY=' + top;
   
   //Window called PopUp is named here so only one window can be opened at a time.
   myWindow = window.open(url, 'PopUp', windowFeatures);
}
//-------------------------------------------------------------------------
//Some of the windows need to scroll. Instead of adding a param and changing all the code new method added below
//-------------------------------------------------------------------------
function OpenCenteredWindowScroll(url, xHeight, xWidth)
{
   var myWindow;
   var height = xHeight;
   var width = xWidth;
   var left = parseInt((screen.availWidth/2) - (width/2));
   var top =  parseInt((screen.availHeight/2.2) - (height/2.2));
   //var top = 1;
   var windowFeatures = 'width=' + width + ',height=' + height + ',resizable=0,dependent,titlebar=no,scrollbars=yes,menubar=no,status=no,left=' + left + ',top=' + top + 'screenX=' + left + ',screenY=' + top;
   
   //Window called PopUp is named here so only one window can be opened at a time.
   myWindow = window.open(url, 'PopUp', windowFeatures);
}

//-------------------------------------------------------------------------
// Specfic to the SearchPage
//-------------------------------------------------------------------------
function toggleSearchStatus(div, state) // 1 visible, 0 hidden
{
    var Show;

    if (state == 1)
    {
     Show = 'visible';
    }
    else
    {
      Show = 'hidden';
    }

    document.getElementById(div).style.visibility = Show;
    
    //in xp_progress.js
    bar1.showBar();
    
    //In Timer.js
    TimerReset();
}