var appSite;

function getRoot() {
    var root = document.URL;
    var i = root.indexOf('index.php');
    var mainti = root.toUpperCase().indexOf('MAINTENANCE');
    if(mainti>-1){
        return root.substr(0,i);
    } else {
        return 'http://www.ParkSupplyOfAmerica.com/';
    }
}
 
function getRootWithProto() {
    var root = document.URL;
    var i = root.indexOf('index.php');
    return root.substr(0,i);
}

function onLoad() {
    document.form1.action = getRoot() + 'chkpw.asp';
    appSite = getRootWithProto() + 'AppMethod.htm';
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function validateForm() {
   if(document.form1.UserName.value== ''){
      document.form1.UserName.focus();
      document.returnValidateForm = false;
   }
   else if(document.form1.Password.value== ''){
      document.form1.Password.focus();
      document.returnValidateForm = false;
   }
   else {
      document.returnValidateForm = true;
   }
}

function setUserFocus() {
   document.form1.UserName.focus();
}

function cancelApp() {
    window.history.back();
}

function enterAsGuest() {
   if(detectFlash()) {
       var newWindow;
       prevOpen = true;
         var x = screen.width - screen.availWidth;
       var y = screen.height - screen.availHeight;
       var windowParam = 'width='+screen.availWidth;
       windowParam += ',height=' + screen.availHeight;
       windowParam += ',screenX=' + x;
       windowParam += ',screenY=0'
       windowParam += ',left=' + x;                                    
       windowParam += ',top=0';
       newWindow = window.open('http://www.parksupplyofamerica.com/permloginGuest.html','',windowParam,true);
       newWindow.focus(); 
   } else {
    window.location = 'http://www.parksupplyofamerica.com/downloadFlash.htm';
   }
}

function showAppMethod() {
    var newWindow = window.open('http://www.parksupplyofamerica.com/AppMethod.htm','','width=400,height=225,left=300,top=300',true);
    newWindow.focus();
}

var prevOpen = false;
var activeX = false;
var hasPlugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) 
             ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : false;
if (hasPlugin) {
   hasPlugin = (parseInt(hasPlugin.description.substring(hasPlugin.description.indexOf(".")-1)))>=6;
}
// ******************************


function detectFlash() {
   if(activeX){
      return navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && navigator.userAgent.indexOf("Windows")>=0;
   } else {
      return hasPlugin;
   }
}