<!--

// ENGLISH
var popupPath = "help/"
var popupCriteria = 1, popupGeoLoc = 2, popupColDisplay = 3, popupSortResults = 4;


function isANumber(strNumber)
{ for (var i = 0; i < strNumber.length; i++)
    if ((strNumber.charAt(i) != "0") && !parseFloat(strNumber.charAt(i)))
      return false;
  return true;
}
	// This function will select all provinces and counties or deselect them.  
function selectAll()
{
	for (i = 0; i < document.all.tags("input").length; i++)
		if (document.all.tags("input")[i].id)
			document.all.tags("input")[i].checked = !(document.all.tags("input")[i].checked);
	return false;
}
		
/*This function will pop up the appropriate help dialog;  choice tells you what part of the 
help file will popup; browserVersion will tell you whether they have IE or something else*/
/*window.open("http://www.w3schools.com",	"my_new_window","toolbar=yes,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,
	resizable=,copyhistory=yes,width=400,height=400")
	if browserVersion.toLowerCase() = "IE" 
		
		{*/
function popup (choice)
{
	var page_url;

	switch (choice)
	{
		case popupCriteria:
			page_url = popupPath + "ListCriteriaHelp.html";
			window.open(page_url,"view","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width=610,height=440");
			break;

		case popupGeoLoc:
			page_url = popupPath + "ListGeoLocHelp.asp";
			window.open(page_url, "view","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=610,height=220");
			break;
	
		case popupColDisplay:
			page_url = popupPath + "ListColDisplay.html";
			window.open(page_url, "view", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width=640,height=600");
			break;

		case popupSortResults:
			page_url = popupPath + "ListSortResultsHelp.asp";
			window.open(page_url, "view", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=610,height=180");
			break;
	}

	return false
}
// checks for a valid date of the form YYYY-MM-DD
function isValidDate (elmElement)
{
	var langEnterValidDate = "Please enter a date in the format YYYY-MM-DD.";
	var strValue = elmElement.value;

	if (strValue)
	{
		var datePat = /^(.+)-(.+)-(.+)$/;
		var dateArray = strValue.match(datePat);

		if (dateArray == null)
		{
			alert(langEnterValidDate);
			elmElement.value = "";
			elmElement.focus();
			return false;
		}
	
		var yearValue = dateArray[1];
		var monthValue = dateArray[2];
		var dayValue = dateArray[3];
		var dayCheck = dayValue.match(/\D/);
		var monthCheck = monthValue.match(/\D/);
		var yearCheck = yearValue.match(/\D/);
		
		if ((dayCheck != null) || (monthCheck != null) || (yearCheck != null))
		{
			alert(langEnterValidDate);
			elmElement.value = "";
			elmElement.focus();
			return false;
		}
		
		var dtmDate = new Date(yearValue, monthValue-1, dayValue);
		if ((dtmDate.getDate() != dayValue) || (dtmDate.getMonth() != monthValue-1) || (yearValue<1900) || (yearValue>2100))
		{
			alert(langEnterValidDate);
			elmElement.value = "";
			elmElement.focus();
		}
		return false;
	}
	return true;
}

function checkDateOrder()
{ // makes sure the end date is later than the start date
  if ((document.form1.strDateLower.value!="") && (document.form1.strDateUpper.value!=""))
  { var datePat = /^(.+)-(.+)-(.+)$/;
    var dateArrayStart = document.form1.strDateLower.value.match(datePat);
    var dateArrayFinish = document.form1.strDateUpper.value.match(datePat);
    var datStart = new Date(dateArrayStart[1], dateArrayStart[2], dateArrayStart[3]);
    var datFinish = new Date(dateArrayFinish[1], dateArrayFinish[2], dateArrayFinish[3]);
    if (datStart.getTime() >= datFinish.getTime())
    { alert("The first date cannot be the same as, or later than, the second date.");
	  document.form1.strDateLower.focus();
	  return false;
    }
  }
  return true;
}

// makes sure a money field contains valid non-negative numbers
function checkMoney(txtBox)
{ var strCurrent
  var intCounter = 0
  var blnInvalidFlag = false
  var intIndex

  for (intIndex = 0; intIndex < txtBox.value.length; intIndex++)
  { strCurrent = txtBox.value.substring(intIndex, intIndex+1);
	  switch(strCurrent)
	  { case '$':
  	  case ',':
	    case '.':
	    case ' ':
	    case '-':
	    case '0':
	    case '1':
	    case '2':
	    case '3':
	    case '4':
	    case '5':
	    case '6':
	    case '7':
	    case '8':
	    case '9':
		  break;
	    default:
		  blnInvalidFlag = true;
		  break;
	  }
  }

  if (blnInvalidFlag)
  {	alert("Please enter a valid number in this field.");
  	txtBox.focus();
	  return false;
  }
  txtBox.value = stripMoney(txtBox.value);
  return true;
}

// removes commas, spaces and dollar signs from money fields
function stripMoney(strNumber)
{ var strStrippedNumber;
  var strChar;
  var i;
  strStrippedNumber = "";
  if (strNumber != null)
    for (i = 0; i < strNumber.length; i++)
    { strChar = strNumber.substring(i, i+1);
	  //if (strChar != '$' && strChar != '.' && strChar != ',' && strChar != ' ')
	  if (strChar != '$' && strChar != '.' && strChar != ',' && strChar != ' ')
		strStrippedNumber = strStrippedNumber + strChar;
	}
  return strStrippedNumber;
}

function stripChars(txtBox)
{ var strStrippedBox;
  var strChar;
  var i;
  strStrippedBox = "";
  if (txtBox.value != null)
    for (i = 0; i < txtBox.value.length; i++)
    { strChar = txtBox.value.substring(i, i+1);
	  if ((strChar.charCodeAt() > 31) && (strChar.charCodeAt() < 127) && (strChar.charCodeAt() != 60) && (strChar.charCodeAt() != 62) && (strChar.charCodeAt() != 34))
		strStrippedBox = strStrippedBox + strChar;
	}
  txtBox.value = strStrippedBox;
  return true;
}

-->
