function startup()
{
}



function trim(inString)
{
  if(inString == null)
    return "";

  return inString.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
}



function toggleImgLoad(inImg, inPercent)
{
  inImg.style.height = (inImg.height * inPercent) + 'px';
}



function toggleImg(inImg, inPercent)
{
  if(inImg.style.height == '')
  {
    inImg.style.height = (inImg.height * inPercent) + 'px';

    if(inPercent == 1)
      inImg.title = "";
    else
      inImg.title = "Click for full size";
  }
  else
  {
    inImg.style.height = '';

    if(inPercent == 1)
      inImg.title = "";
    else
      inImg.title = "Click for reduced size";
  }
}



function expand(inID)
{
  var e = document.getElementById(inID);
  var ie = document.getElementById(inID + "Expand");
  var ic = document.getElementById(inID + "Contract");

  if(e)
  {
    if(e.style.display == "none")
    {
      e.style.display = "";
      ie.style.display = "none";
      ic.style.display = "";
    }
    else
    {
      e.style.display = "none";
      ie.style.display = "";
      ic.style.display = "none";
    }
  }
}



function getControlValue(inControl)
{
  var theVal = trim(inControl.value);
  inControl.value = theVal;

  return theVal;
}



function validateControl(inForm, inText, inName)
{
  var theControl = inForm[inName];
  var theValue = getControlValue(theControl);

  if(theValue == "")
  {
    alert("Please enter " + inText + ".");
    theControl.select();
    theControl.focus();
    return false;
  }

  return true;
}



function validateCommercialInfoForm(inForm)
{
  if(!validateControl(inForm, "a company name", "companyName"))
    return false;

  if(!validateControl(inForm, "a company address", "companyAddress"))
    return false;

  if(!validateControl(inForm, "a company phone", "companyPhone"))
    return false;

  if(!validateControl(inForm, "a primary contact name", "contactName"))
    return false;

  if(!validateControl(inForm, "a primary contact email address", "contactEmail"))
    return false;

  return true;
}



function validateUpgradeForm(inForm)
{
  if(!validateControl(inForm, "your name", "urName"))
    return false;

  if(!validateControl(inForm, "your email address", "urEmail"))
    return false;

  if(!validateControl(inForm, "your User ID", "urUID"))
    return false;

  if(!validateControl(inForm, "the last 5 digits of your License Key", "urLKPart"))
    return false;

  return true;
}



function validateUpgradeCodeForm(inForm)
{
  if(!validateControl(inForm, "upgrade code", "upgradeCode"))
    return false;

  return true;
}

