<!--//
function emailCheck(theField){
	var j = theField.value.length;
	var k = j-1;
	var l = j+1;
	var firstChar = 'N';
	var dot = 0;
	var thingy = 0;
	for(var i = 0; i < j; i++){
		var ch = theField.value.substring(i, i+1);
		if (ch == " "){
			alert('Please enter a valid email address.');
			theField.focus();
			theField.select();
			return false;
		}
		if (i ==0 && ch != "@"){
			firstChar = 'Y';
		}
		if (i !=0 && ch == "@"){
			thingy++;
			l = i+1;
			continue;
		}
		if (i != l && i != k && ch == "." && thingy != 0){
			dot++;
			continue;
		}
	}
	if(j > 0){
		if (firstChar == 'N' || dot == 0 || thingy == 0 || thingy > 1){
			alert('Please enter a valid email address.');
			theField.focus();
			theField.select();
			return false;
		} else {
			return true;
		}
	} else {
		return true;
	}
}

function phoneCheck(theField, theLabel){
	j = theField.value.length;
	k = 0;
	for(var i = 0; i < j; i++){
		var ch = theField.value.substring(i, i+1);
		if ((ch < "0" || "9" < ch) && (ch != "-") &&(ch != " ")){
			alert('Your '+ theLabel +' should contain numerals only.');
			theField.focus();
			theField.select();
			i = j;
			k = 1;
			return false;
		}
	}
	if(k == 0){
		return true;
	} else {
		return false;
	}
}

function isNumber(theField){
	for(var i = 0; i < theField.value.length; i++){
		var ch = theField.value.substring(i, i+1);
		if (ch < "0" || "9" < ch){  
			return false;
		}
	}
	return true;
}

function isFieldBlank(theField){
	if(theField.value.length == 0)		
		return true;		
	else			
		return false;	
}

function isTextareaBlank(theField){
	if(theField.value == "")		
		return true;		
	else			
		return false;	
}

function check_form(form,formtype){
	
	if(formtype == 0){
		if ( !form.cd_rom1.checked && !form.cd_rom2.checked ){
			alert('Please select the product you are registering for.');
			form.cd_rom1.focus();
		}else if(isFieldBlank(form.first_name)){
			alert('Please enter your first name.');
			form.first_name.focus();
		}else if(isFieldBlank(form.last_name)){
			alert('Please enter your last name.');
			form.last_name.focus();
		}else if(isFieldBlank(form.street1)){
			alert('Please enter your address.');
			form.street1.focus();
		}else if(isFieldBlank(form.city)){
			alert('Please enter your city.');
			form.city.focus();
		}else if(isFieldBlank(form.state)){
			alert('Please enter your state.');
			form.state.focus();
		}else if(isFieldBlank(form.zip)){
			alert('Please enter your postal code.');
			form.zip.focus();
		}else if(isFieldBlank(form.country)){
			alert('Please enter your country.');
			form.country.focus();
		}else if(isFieldBlank(form.email)){
			alert('Please enter your email address.');
			form.email.focus();
		}else if(!emailCheck(form.email)){
			//alert('Please enter a valid email address');
			form.email.focus();
		}else{
			form.submit();
		}
	}

}
//-->
