function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters. \n";
       }
    }
return error;    
}

function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "Please enter a phone number.\n";
	return error;
}
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters. \n";
  
    }
    if (!(stripped.length < 17)) {
	error = "The phone number is the wrong length. Make sure you included an area code.\n";
    } 
return error;
}

function checkCCNum (string) {
var error ="";
		if (string =="") {
			error = "Please enter a valid Credit Card number. \n";
		}
		
	 	if (isNaN(parseInt(string))) {
			error = "Please enter a valid Credit Card number. \n"
			}
		if (!(string.length == 16)) {
			error = "Please enter a valid 16-digit Credit Card number. \n"
			}
return error;
	}

function checkCVC (string, cardtype) {

var error ="";	

	if (string == "") {
			error = "Please enter a valid CVC.  \n";
			return error;
		}
	if (isNaN(string)) {
			error = "Please enter a valid CVC.  \n";
			return error;
		}
	if (cardtype == "AMEX") {
			if (!(string.length) == 4) {
				error = "Please enter a valid 4 digit CVC.  \n";
				return error;
			}
	}
	if (cardtype != "AMEX") {
			if(!(string.length) == 3) {
				error = "Please enter a valid 3 digit CVC. \n";
				return error;
			}
return error;
}

}

function checkZIP (string) {
	var error = "";
	if (string == "") {
		error= "Please enter a valid ZIP code. \n";
		}
	if (isNaN(parseInt(string))) {
		error= "Please enter a valid ZIP code. \n";	   
	}
	if(!(string.length) == 5) {
			error = "Please enter a valid ZIP code. \n";
			}
	
return error;
	}
	
function checkQty (string) {
	var error = "";
	
	if (isNaN(parseInt(string)) || string == 0) {
		error= "Please enter a valid quantity. \n";	   
	}
		
return error;
	}

function isEmpty(strng, name) {
var error = "";
  if (strng.length == 0) {
     error = "Please Include your " + name + " \n";
  }
return error;	  
}

function checkDropdown(choice, name) {
    var error = "";
    if (choice == 0) {
       error = "Please include your " + name + "\n";
    }    
return error;
}    

function validateConfirm(check)
{var error = "";
  if (check.checked == false) {

  // if we get here then the validation has failed

  var error = '\nPlease check the Customer Agreement\n ';
 
  } 
 return error;
}

function setSpanText(spanID,newText) {
	t = document.createTextNode(newText);
	mySpan = document.getElementById(spanID);
	children = mySpan.childNodes;
	if (children.length)
	{
		mySpan.replaceChild(t, children[0]);
	}
	else
	{
		mySpan.appendChild(t);
	}
};

function makeInt(val) {
	<!-- establish variables -->
	n = val;
	re = /[0-9]+/;
	x = n.match(re);
	<!-- figure out if value is not a valid number... set to zero -->
	if (isNaN(n) || (n.length == 0) || (x == null))
	{
		n = 0;
	}
	else
	<!-- find absolute value if not an integer -->
	{
		n = parseInt(n);
		if (n < 0)
		{
			n = Math.abs(n);
		}
	}
	return n;
};
