//Add common variables for a page - consistant accross all pages
//*****************************************************************
var Page_Submitted = false;
//*****************************************************************

// Check if page has been submitted
function SetSubmitted(subVal)
{
	this.Page_Submitted = subVal;
}

// Trim whitespace off of strings
function trim(strOldString) {
  var strNewString;
  
  strNewString = (""+strOldString).replace(/^\s*/,'');
  strNewString = strNewString.replace(/\s*$/,'');
  return strNewString;
}

// Check if a value exists
function checkExists(objText) {
	objText.value = trim(objText.value);
	return (objText.value == "")?false:true;
}

// Check if a field value is numeric
function checkIsFloat(objText) {
  var dblValue;
  
  // Extract integer value from the text box
  objText.value = trim(objText.value);
  dblValue = parseFloat(objText.value);
  
  // Confirm that the value is a number
  if (isNaN(dblValue) == true) {
    objText.value = '';
    return false;
  } else {
    objText.value = dblValue.toString();
    return true;
  }
}

// Check if a field value is numeric
function checkIsInt(objText) {
  var intValue;
  
  // Extract integer value from the text box
  objText.value = trim(objText.value);
  intValue = parseInt(objText.value,10);
  
  // Confirm that the value is a number
  if (isNaN(intValue) == true) {
    objText.value = '';
    return false;
  } else {
    objText.value = intValue.toString(10);
    return true;
  }
}

// Check if a field value is numeric, and is within a given range
function checkFloatRange(objText, dblMin, dblMax) {
  var dblValue;

  // Confirm that the value is a number
  if (checkIsFloat(objText) == false) {
    return false;
  }
  
  // Extract integer value from the text box
  dblValue = parseFloat(objText.value);
    
  // Confirm we are within max/min values
  if (dblValue > dblMax) {
    dblValue = dblMax;
    objText.value = dblValue.toString();
    return false;
  }
  if (dblValue < dblMin) {
    dblValue = dblMin;
    objText.value = dblValue.toString();
    return false;
  }
  
  // Passed max/min test.  Return true.
  objText.value = dblValue.toString();
  return true;
}

// Check if a field value is numeric, and is within a given range
function checkIntRange(objText, intMin, intMax) {
  var intValue;

  // Confirm that the value is a number
  if (checkIsInt(objText) == false) {
    return false;
  }
  
  // Extract integer value from the text box
  intValue = parseInt(objText.value,10);
    
  // Confirm we are within max/min values
  if (intValue > intMax) {
    intValue = intMax;
    objText.value = intValue.toString(10);
    return false;
  }
  if (intValue < intMin) {
    intValue = intMin;
    objText.value = intValue.toString(10);
    return false;
  }
  
  // Passed max/min test.  Return true.
  objText.value = intValue.toString(10);
  return true;
}

// See if two values match
function checkMatch(objText1, objText2) {
	objText1.value = trim(objText1.value);
	objText2.value = trim(objText2.value);
	return (objText1.value == objText2.value)?true:false;
}

// Submit the form to any specified "Action" URL
function submitForm(objForm, strAction) {
  if (strAction.length > 0) {
    objForm.action = strAction;
  }
	objForm.submit();
}