var firsttime = 1;
var isIE = 0;

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
 if (ieversion>=8)
  isIE = 8;
 else if (ieversion>=7)
  isIE = 7;
 else if (ieversion>=6)
  isIE = 6;
 else if (ieversion>=5)
  isIE = 5;
} else {
  isIE = getInternetExplorerVersion();
}

function adjustDisplayedColumns(table_id) {
   var iw = "iw(" + document.getElementById(table_id).clientWidth + ")";
   var table_id = "fp_c";
   document.getElementById("fp_c5").style.display = ""
   document.getElementById("fp_c5").style.display = "none";
   document.getElementById("fp_c5").style.display = "";
   var y = document.getElementById(table_id);
   var cols = y.rows[0].cells.length;
   //var w = y.clientWidth;
   var w = y.offsetWidth;
   //var pc1 = Math.floor(document.getElementById(table_id).clientWidth / 305);
   var pc1 = Math.floor(document.getElementById(table_id).offsetWidth / 315);
   //var pc2 = document.getElementById(table_id).clientWidth % 305.0;
   var pc2 = document.getElementById(table_id).offsetWidth % 315.0;
   var pc3 = (pc2 > 170) ? 1 : 0;
   var pc = pc1 + pc3;
   var pcm1 = 100 / (pc - 1);
   document.getElementById("col_c1").width = pcm1 + "%";
   if ( firsttime == 1 ) {
      firsttime = 0;
      pc = pc - 1;
      if ( pc <= 0 ) pc = 1;
   }
   for(idx = 2; idx <= 10; idx++ ){
      var z = document.getElementById("fp_c" + idx.toString());
      if ( z == null ) break;
      if ( isIE <= 0 )
         var zz = document.getElementById("col_c" + idx.toString());
      if ( idx < pc ) {
         z.style.display = "";
         if ( isIE <= 0 )
            zz.width = pcm1 + "%";
      } else {
         z.style.display = "none";
         if ( isIE <= 0 )
            zz.width = "0%";
      }
   }
   // window.defaultStatus = "ie(" + isIE + "pc1(" + pc1 + ")pc2(" + pc2 + ")pc3(" + pc3 + ")w(" + w + ")wd(" + y.clientWidth +")" + iw;
   rtn = "pc1(" + pc1 + ")pc2(" + pc2 + ")pc3(" + pc3 + ")w(" +  w + ")wd(" + y.clientWidth +")" + iw;
   return rtn;
  }

var signedIn = 0;
var orderNumber = null;
var firstName = null;
var lastName = null;
var userInfo = null;
var pendingUpdate = 0;

function updateInfo()
{
  if ( pendingUpdate == 1 && userInfo.readyState == 4 && userInfo.status == 200){
    pendingUpdate = 0;
    displayUserInfo();
  } else {
    window.setTimeout('updateInfo();',200); 
  }
}

function getInfo(){
    //userInfo = new XMLHttpRequest();
    //pendingUpdate = 1;
    //didDisplay = 0;
    //userInfo.open("GET","https://www.soapalchemy.com/getinfo",true);
    //userInfo.setRequestHeader("User-Agent", "browser5");
    //userInfo.send(null);
    //displayInfo();
}

function displayInfo()
{
    var info = userInfo.responseText.split(/[:]{2}[$][:]{2}/);
    while ( info.length > 0 ) {
      var value = info.pop();
      var id = info.pop();
      var element = null;
      element = document.getElementById(id);
      if ( element != null ) {
         element.value = value;
      }
    }
}

function setAction(userAction)
{
  var x = document.getElementById("loginAction");
  x.value = userAction;
}

