function isNumeric(val){return(parseFloat(val,10)==val);}

function CheckFieldNum(fldName, fldCalled) {
  fld = eval('window.document.form1["'+ fldName +'"]');
  if (!fld.value || !isNumeric(String(fld.value).replace(/,/g,''))) {
    alert('Please fill ' + fldCalled + ' field with numeric value.');
    fld.focus();
    return false;
  };
  return true;
}

function CheckFieldMoney(fldName, fldCalled) {
  fld = eval('window.document.form1["'+ fldName +'"]');
  if (!fld.value || !isNumeric(String(fld.value).replace(/,/g,''))) {
    alert('Please fill ' + fldCalled + ' field with numeric value.');
    fld.focus();
    return false;
  };
  return true;
}

function CheckField(fldName, fldCalled) {
  fld = eval('window.document.form1["'+ fldName +'"]');

  if (!fld.value) {
    alert('Please fill ' + fldCalled + ' field.');
    fld.focus();
    return false;
  };
  return true;
}
function CheckRadio(theForm, fldName, fldCalled){

	var fld = eval('theForm["' + fldName + '"]');
	for (var i=0; i < fld.length; ++i) {
		if(document.form1.Business[i].checked) {
			return true;
		}
	};
	alert('Please select ' + fldCalled + '.');
	fld[0].focus();
	return false;
}


function CheckRadio(fldName, fldCalled) {
  fld = eval('window.document.form1["'+ fldName +'"]');

  for (var i=0; i < fld.length; ++i) if(fld[i].checked) return true;

  if (!fld.value) {
    alert('Please select on of the options for ' + fldCalled + '.');
    fld[0].focus();
    return false;
  };
  return true;
}


function isEmail (s)
{   
//    if (isBlank(s)) return false;
    
    var i = 1;
    var sLength = s.length;

    while ((i < sLength) && (s.charAt(i) != "@")) i++

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != ".")) i++

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function CheckEmailField(fldName, fldCalled) {
  fld = eval('window.document.form1["'+ fldName +'"]');

  if (!isEmail(fld.value)) {
    alert('Please fill ' + fldCalled + ' with valid email.');
    fld.focus();
    return false;   
  }
  return true;    
}

function GetQueryString() {
	var arrQS = new Array();
	var QS = window.document.location.search;
	if (QS.charAt(0) == '?') {
		QS = QS.slice(1);
		var arrTMP = QS.split('&');
		var Name, Value;
		for (var i = 0; i < arrTMP.length; ++i ) {
			strTMP = arrTMP[i];
			pos = strTMP.indexOf('=');
			if ( pos != 0 )	{
				Name = strTMP.substr(0, pos);
				Name = unescape(Name.replace(/\+/g, ' '));
				Value = strTMP.substr(pos + 1, strTMP.length);
				Value = unescape(Value.replace(/\+/g, ' '));	
				arrQS[Name] = Value;
			}
		}
	}
	return arrQS;
}

function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
	}

function convertMoneyToNumeric(val) {
	return val.replace(/,/g,'');
}
