// checks if a text element is filled in a form
function isFilled(element) {
	if ((element.value == "") || (element.value == null)) { return false; }
	else { return true; }
}

// checks to see if string is a monetary value
function isPrice(value) {
	var pattern = /^(\d{1,5})((\.)(\d{2}))?$/;
	if (pattern.test(value)) { return true; }
	return false;
}

// checks to see if string is a number between min and max
function isNumeric(value, minimum, maximum) {
	var pattern = eval("/^\\d{" + minimum + "," + maximum + "}$/");
	if (pattern.test(value)) { return true; }
	return false;
}

// checks to see if a select box has any options
function hasOptions(obj) {
	if (obj.options[0] != undefined) { return true; }
	return false;
}

function openSampleWin(width, height, img) {
	url = "./view_sample.php?img=" + img;
	var newwin = window.open(url, "newwin", "location=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height);
	newwin.opener = window;
}

function isEmail(email) {
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	
	if(!reg1.test(email) && reg2.test(email)) {
		return true;
	}
	else {
		return false;
	}
}

function acceptLicense(choice) {
	if (choice == "no") {
		alert("You have chosen to not accept this license and therefore you will not be able to purchse this item.");
		location = './index.php?s=home_study';
		return false;
	} else { document.home_study.submit(); }
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}