// Determine browser and version.

function Browser() {
  var ua, s, i;
  this.isIE    = false;
  this.isNS    = false;
  this.version = null;
  ua = navigator.userAgent;
  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
  // Treat any other "Gecko" browser as NS 6.1.
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

function checkPhone (obj) {
  var str = obj.value.replace(/[^0-9]+?/g, '');
  switch (str.length) {
   case 0:
     alert('Please enter numbers only.');
     obj.select();
     return;
   case 7:
     str = str.substr(0,3)+"-"+str.substr(3,4);
     break;
   case 10:
     str = "("+str.substr(0,3)+") "+str.substr(3,3)+"-"+str.substr(6,4);
     break;
   default:
     alert('Please enter a 7 digit phone number (with area code, if applicable).');
     obj.select();
     return;
  }
  obj.value = str;
 }
 
function chkNumericValue(e,val2) {
	// onkeypress="return(chkNumericValue(event,''));"
	var val = "0123456789";
	var key = (!document.all)?e.which:e.keyCode;
	var str = String.fromCharCode(key);
	if( val.indexOf(str) > -1 || val2.indexOf(str) > -1 || key < 30) {
		return true;
	} else {
		return false;
	}
}

function chkAlphaValue(e,val2) {
	// onkeypress="return(chkAlphaValue(event,''));"
	var val = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var key = (!document.all)?e.which:e.keyCode;
	var str = String.fromCharCode(key);
	if( val.indexOf(str) > -1 || val2.indexOf(str) > -1 || key < 30) {
		return true;
	} else {
		return false;
	}
}
