// JScript source code
function MoveToNextField(szFieldIn,szFieldToMoveTo,iItemsInField){
		if(document.forms[0][szFieldIn].value.length >= iItemsInField)
			document.forms[0][szFieldToMoveTo].select();
	}
function checkEmail(email)
{
if(email.length > 0)
	{
	if (email.indexOf(' ') >= 0)
		alert("Emails cannot have spaces in them. Please enter a valid email.");
	else if (email.indexOf('@') == -1)
		alert("Emails must have a @. Please enter a valid email.");
	}
}		

function Rcertify(){
	popupWin = window.open('http://www.bbbonline.org/cks.asp?id=10305301412232616', 'Participant','location=yes,scrollbars=yes,width=450,height=300'); 
	window.name = 'opener';
} 
var allowChars = "123456789.";
function numbersonly(myfield, e, dec){
	var key;
	var keychar;

	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
	   return true;
	else if ((("0123456789.").indexOf(keychar) > -1)) // numbers
	   return true;
	else
	   return false;
}

function numbersonlydate(myfield, e, dec){
	var key;
	var keychar;

	if (window.event)
	key = window.event.keyCode;
	else if (e)
	key = e.which;
	else
	return true;
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
	return true;
	else if ((("0123456789/").indexOf(keychar) > -1)){ // numbers
		if((myfield.value).indexOf(".") > -1){
			if(keychar == ".")
				return false
			else
				return true
		}
		else
			return true;
	}
	else
		return false;
}

//Hide status bar msg II script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use

//function hidestatus(){
//window.status=''
//return true
//}

//if (document.layers)
//document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

//document.onmouseover=hidestatus
//document.onmouseout=hidestatus

function IsCCValid( CC ){                         
	if (CC.length > 19)
		return (false);

	var sum = 0; 
	var multiple = 1; 
	var CCLength = CC.length;
	var digit;
	for (i = 0; i < CCLength; i++){
		digit = CC.substring(CCLength-i-1,CCLength-i);
		tproduct = parseInt(digit ,10)*multiple;
		if (tproduct >= 10)
				sum += (tproduct % 10) + 1;
		else
				sum += tproduct;
		if (multiple == 1)
				multiple++;
		else
				multiple--;
	}
	if ((sum % 10) == 0)
		return (true);
	else
		return (false);
}

function checkABA(s) {

  var i, n, t;

  // First, remove any non-numeric characters.

  t = "";
  for (i = 0; i < s.length; i++) {
    c = parseInt(s.charAt(i), 10);
    if (c >= 0 && c <= 9)
      t = t + c;
  }

  // Check the length, it should be nine digits.

  if (t.length != 9)
    return false;

  // Now run through each digit and calculate the total.

  n = 0;
  for (i = 0; i < t.length; i += 3) {
    n += parseInt(t.charAt(i),     10) * 3
      +  parseInt(t.charAt(i + 1), 10) * 7
      +  parseInt(t.charAt(i + 2), 10);
  }

  // If the resulting sum is an even multiple of ten (but not zero),
  // the aba routing number is good.

  if (n != 0 && n % 10 == 0)
    return true;
  else
    return false;
}

function doPopUp(popup){
	window.open(popup,"","width=600,height=600,screenX=50,left=50,screenY=50,top=50,dependent,scrollbars,resizable");
}

function doPopUpL(popup){
	window.open(popup,"","width=800,height=600,screenX=50,left=50,screenY=50,top=50,dependent,scrollbars,resizable");
}

function refreshParent(refresh) {
 	if (refresh == 'Y') {
	 	window.opener.location.href = window.opener.location.href;
		if (window.opener.progressWindow) {
			alert("refresh");
			window.opener.progressWindow.close();
		}
	}
	window.close();
}
function gotoFormElement() {
	// may need to use eval function
	if (document.forms[0]) {
		if (document.forms[0].elements[0]) {
			if (document.forms[0].elements[0].type != "hidden") {
				document.forms[0].elements[0].focus();
			}
		}
	}
}
function Trim(s) 
{
  // Remove leading spaces and carriage returns
  // || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')
  while ((s.substring(0,1) == ' '))  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns
 // || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')
  while ((s.substring(s.length-1,s.length) == ' '))  {
    s = s.substring(0,s.length-1);
  }
  return s;
}
// to use checkEnter add onKeyPress="return checkEnter(event)" to each field
NS4 = (document.layers) ? true : false;
function checkEnter(event)
{ 	
	var code = 0;
	
	if (NS4)
		code = event.which;
	else
		code = event.keyCode;
	if (code==13)
		document.forms[0].submit();
}



