
function isEmail(s){
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(s)){
return true;
}
else return false;
}

// Remove invalid form input characters on keyup
function checkInt(val) {
	var strPass = val.value;
	var strLength = strPass.length;
	var badchar = false;
	
	for ( i = 0; i < strLength; i++ ) {
		  var lchar = val.value.charAt(i);
		  if(isNaN(parseInt(lchar))) {
		     badchar = true;
		  }
	}

	if(badchar) {
		var newStr = '';
		for ( i = 0; i < strLength; i++ ) {
			  var lchar = val.value.charAt(i);
			  if( !isNaN(parseInt(lchar))) {
			  	newStr += lchar;
			  }
		}
		val.value = newStr;
	}
}

function fixInt(val,defaultval) {
	if(isNaN(parseInt(val.value))) {
	   val.value = defaultval;
	}
}


function getRadioValue(radio) {
	var ckVal = "";
	if(radio.length) {
		for (var i = 0; i < radio.length; i++) {
			if (radio[i].checked) {
				ckVal = radio[i].value;
				break;
			}
		}
	}
	return ckVal;
}

function checkedCount(checkbox) {
	var selected = 0;
	if(checkbox.checked) {
		selected = 1;
	}
	else {
		for (counter = 0; counter < checkbox.length; counter++) {
			if (checkbox[counter].checked) { selected = selected + 1; }
		}
	}
	return selected;
}

function emailToFriend(item_type,item_id) {
	var theURL = "/popups/emailfriend_popup.cfm?item_type="+item_type+"&item_id="+item_id;
	window.open(theURL,'emailfriend','resizable=yes,scrollbars=yes,width=500,height=500');
}