function verifyQuickSearchForm(form) {
	if (document.form1.keywords.value == "") {
		alert("Please enter a keyword or phrase.");
		document.form1.keywords.focus();
		return false;
	}
}

function isEmail(str) {
  	// are regular expressions supported?
  	var supported = 0;
  	if (window.RegExp) {
    	var tempStr = "a";
    	var tempReg = new RegExp(tempStr);
    	if (tempReg.test(tempStr)) supported = 1;
  	}
  	if (!supported) 
    	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  	return (!r1.test(str) && r2.test(str));
}

function verifyContactForm(form) {
	if (document.contactForm.person.value == "") {
		alert("Please enter your name.");
		document.contactForm.person.focus();
		return false;
	}
	if (document.contactForm.ad.value == "") {
		alert("Please enter your eMail address.");
		document.contactForm.ad.focus();
		return false;
	} else {
		var validMail = isEmail(document.contactForm.ad.value);
		if (!validMail) {
			alert("Please enter a VALID eMail address.");
			document.contactForm.ad.focus();
			return false;
		}
	}
	if (document.contactForm.comments.value == "") {
		alert("Please enter your mail message.");
		document.contactForm.comments.focus();
		return false;
	}
}

function verifyForm(form) {
	
	// Verify the user's account information is formatted correctly
	
	if (document.registerForm.first_name.value == "") { // First name
		alert("Please enter your first name.");
		document.registerForm.first_name.focus();
		return false;
	} else {
		if (document.registerForm.first_name.value.length < 2) {
			alert("Please enter a valid first name.");
			document.registerForm.first_name.focus();
			return false;
		}
	}
	 
	if (document.registerForm.last_name.value == "") { // Last name
		alert("Please enter your last name.");
		document.registerForm.last_name.focus();
		return false;
	} else {
		if (document.registerForm.last_name.value.length < 2) {
			alert("Please enter a valid last name.");
			document.registerForm.last_name.focus();
			return false;
		}
	}
	
	if (document.registerForm.email.value == "") { // eMail address
		alert("Please enter your eMail address.");
		document.registerForm.email.focus();
		return false;
	} else {
		var validMail = isEmail(document.registerForm.email.value);
		if (!validMail) {
			alert("Please enter a valid eMail address.");
			document.registerForm.email.focus();
			return false;
		}
	}
	
	if (document.registerForm.phone.value == "") { // Telephone
		alert("Please enter your telephone number.");
		document.registerForm.phone.focus();
		return false;
	} else {
		if (document.registerForm.phone.value.length < 7) {
			alert("Please enter a valid telephone number.");
			document.registerForm.phone.focus();
			return false;
		}
	}
	
	if (document.registerForm.address.value == "") { // Street address
		alert("Please enter your mailing address.");
		document.registerForm.address.focus();
		return false;
	} else {
		if (document.registerForm.address.value.length < 5) {
			alert("Please enter a valid mailing address.");
			document.registerForm.address.focus();
			return false;
		}
	}
	
	if (document.registerForm.city.value == "") { // City
		alert("Please enter your city.");
		document.registerForm.city.focus();
		return false;
	} else {
		if (document.registerForm.city.value.length < 3) {
			alert("Please enter a valid city.");
			document.registerForm.city.focus();
			return false;
		}
	}
	
	if (document.registerForm.state.value == "") { // State
		alert("Please enter your state or province.");
		document.registerForm.state.focus();
		return false;
	} else {
		if (document.registerForm.state.value.length < 2) {
			alert("Please enter a valid state or province.");
			document.registerForm.state.focus();
			return false;
		}
	}
	
	if (document.registerForm.zip_code.value == "") { // Postal code
		alert("Please enter your postal code.");
		document.registerForm.zip_code.focus();
		return false;
	} else {
		if (document.registerForm.zip_code.value.length < 5) {
			alert("Please enter a valid postal code.");
			document.registerForm.zip_code.focus();
			return false;
		}
	}
	
	if (document.registerForm.country.value == "") { // Country
		alert("Please enter your country.");
		document.registerForm.country.focus();
		return false;
	} else {
		if (document.registerForm.country.value.length < 2) {
			alert("Please enter a valid country.");
			document.registerForm.country.focus();
			return false;
		}
	}
	
	if (document.registerForm.password.value == "") { // Password
		alert("Please enter your password.");
		document.registerForm.password.focus();
		return false;
	} else {
		if (document.registerForm.password.value.length < 5) {
			alert("Your password must contain at least 5 characters.");
			document.registerForm.password.focus();
			return false;
		}
	}
	
	if (document.registerForm.confirm.value == "") { // Confirm password
		alert("Please confirm your password.");
		document.registerForm.confirm.focus();
		return false;
	} else if (document.registerForm.password.value != document.registerForm.confirm.value) {
		alert("Your password and your password confirmation are not the same. Please try again.");
		document.registerForm.confirm.focus();
		return false;
	}

	if (document.registerForm.hint.value == "") { // Password hint
		alert("Please enter your password hint.");
		document.registerForm.hint.focus();
		return false;
	}

}

function verifyCompanyForm(form) {
	
	// Verify the user's account information is formatted correctly
	
	if (document.registerCompanyForm.first_name.value == "") { // First name
		alert("Please enter your first name.");
		document.registerCompanyForm.first_name.focus();
		return false;
	} else {
		if (document.registerCompanyForm.first_name.value.length < 2) {
			alert("Please enter a valid first name.");
			document.registerCompanyForm.first_name.focus();
			return false;
		}
	}
	 
	if (document.registerCompanyForm.last_name.value == "") { // Last name
		alert("Please enter your last name.");
		document.registerCompanyForm.last_name.focus();
		return false;
	} else {
		if (document.registerCompanyForm.last_name.value.length < 2) {
			alert("Please enter a valid last name.");
			document.registerCompanyForm.last_name.focus();
			return false;
		}
	}
	
	if (document.registerCompanyForm.title.value == "") { // Last name
		alert("Please enter your title.");
		document.registerCompanyForm.title.focus();
		return false;
	} else {
		if (document.registerCompanyForm.title.value.length < 2) {
			alert("Please enter a valid title.");
			document.registerCompanyForm.title.focus();
			return false;
		}
	}

	if (document.registerCompanyForm.company.value == "") { // Last name
		alert("Please enter your company.");
		document.registerCompanyForm.company.focus();
		return false;
	} else {
		if (document.registerCompanyForm.company.value.length < 2) {
			alert("Please enter a valid company name.");
			document.registerCompanyForm.company.focus();
			return false;
		}
	}

	if (document.registerCompanyForm.email.value == "") { // eMail address
		alert("Please enter your eMail address.");
		document.registerCompanyForm.email.focus();
		return false;
	} else {
		var validMail = isEmail(document.registerCompanyForm.email.value);
		if (!validMail) {
			alert("Please enter a valid eMail address.");
			document.registerCompanyForm.email.focus();
			return false;
		}
	}
	
	if (document.registerCompanyForm.phone.value == "") { // Telephone
		alert("Please enter your telephone number.");
		document.registerCompanyForm.phone.focus();
		return false;
	} else {
		if (document.registerCompanyForm.phone.value.length < 7) {
			alert("Please enter a valid telephone number.");
			document.registerCompanyForm.phone.focus();
			return false;
		}
	}
	

	if (document.registerCompanyForm.accounts_payable_contact.value == "") { // First name
		alert("Please enter your accounts payable contact name.");
		document.registerCompanyForm.accounts_payable_contact.focus();
		return false;
	} else {
		if (document.registerCompanyForm.accounts_payable_contact.value.length < 2) {
			alert("Please enter a valid accounts payable contact name.");
			document.registerCompanyForm.accounts_payable_contact.focus();
			return false;
		}
	}

	if (document.registerCompanyForm.accounts_payable_phone.value == "") { // First name
		alert("Please enter your accounts payable telephone number.");
		document.registerCompanyForm.accounts_payable_phone.focus();
		return false;
	} else {
		if (document.registerCompanyForm.accounts_payable_phone.value.length < 2) {
			alert("Please enter a valid accounts payable telephone number.");
			document.registerCompanyForm.accounts_payable_phone.focus();
			return false;
		}
	}

	if (document.registerCompanyForm.purchasing_contact.value == "") { // First name
		alert("Please enter your purchasing contact name.");
		document.registerCompanyForm.purchasing_contact.focus();
		return false;
	} else {
		if (document.registerCompanyForm.purchasing_contact.value.length < 2) {
			alert("Please enter a valid purchasing contact name.");
			document.registerCompanyForm.purchasing_contact.focus();
			return false;
		}
	}

	if (document.registerCompanyForm.purchasing_phone.value == "") { // First name
		alert("Please enter your purchasing telephone number.");
		document.registerCompanyForm.purchasing_phone.focus();
		return false;
	} else {
		if (document.registerCompanyForm.purchasing_phone.value.length < 2) {
			alert("Please enter a valid purchasing telephone number.");
			document.registerCompanyForm.purchasing_phone.focus();
			return false;
		}
	}

	if (document.registerCompanyForm.address.value == "") { // Street address
		alert("Please enter your mailing address.");
		document.registerCompanyForm.address.focus();
		return false;
	} else {
		if (document.registerCompanyForm.address.value.length < 5) {
			alert("Please enter a valid mailing address.");
			document.registerCompanyForm.address.focus();
			return false;
		}
	}
	
	if (document.registerCompanyForm.city.value == "") { // City
		alert("Please enter your city.");
		document.registerCompanyForm.city.focus();
		return false;
	} else {
		if (document.registerCompanyForm.city.value.length < 3) {
			alert("Please enter a valid city.");
			document.registerCompanyForm.city.focus();
			return false;
		}
	}
	
	if (document.registerCompanyForm.state.value == "") { // State
		alert("Please enter your state or province.");
		document.registerCompanyForm.state.focus();
		return false;
	} else {
		if (document.registerCompanyForm.state.value.length < 2) {
			alert("Please enter a valid state or province.");
			document.registerCompanyForm.state.focus();
			return false;
		}
	}
	
	if (document.registerCompanyForm.zip_code.value == "") { // Postal code
		alert("Please enter your postal code.");
		document.registerCompanyForm.zip_code.focus();
		return false;
	} else {
		if (document.registerCompanyForm.zip_code.value.length < 5) {
			alert("Please enter a valid postal code.");
			document.registerCompanyForm.zip_code.focus();
			return false;
		}
	}
	
	if (document.registerCompanyForm.country.value == "") { // Country
		alert("Please enter your country.");
		document.registerCompanyForm.country.focus();
		return false;
	} else {
		if (document.registerCompanyForm.country.value.length < 2) {
			alert("Please enter a valid country.");
			document.registerCompanyForm.country.focus();
			return false;
		}
	}
	
	if (document.registerCompanyForm.password.value == "") { // Password
		alert("Please enter your password.");
		document.registerCompanyForm.password.focus();
		return false;
	} else {
		if (document.registerCompanyForm.password.value.length < 5) {
			alert("Your password must contain at least 5 characters.");
			document.registerCompanyForm.password.focus();
			return false;
		}
	}
	
	if (document.registerCompanyForm.confirm.value == "") { // Confirm password
		alert("Please confirm your password.");
		document.registerCompanyForm.confirm.focus();
		return false;
	} else if (document.registerCompanyForm.password.value != document.registerCompanyForm.confirm.value) {
		alert("Your password and your password confirmation are not the same. Please try again.");
		document.registerCompanyForm.confirm.focus();
		return false;
	}

	if (document.registerCompanyForm.hint.value == "") { // Password hint
		alert("Please enter your password hint.");
		document.registerCompanyForm.hint.focus();
		return false;
	}

}

function verifyPassForm(form) {
	if (document.requestPassForm.adr.value == "") {
		alert("Please enter your eMail address.");
		document.requestPassForm.adr.focus();
		return false;
	} else {
		var validMail = isEmail(document.requestPassForm.adr.value);
		if (!validMail) {
			alert("Please enter a valid eMail address.");
			document.requestPassForm.adr.focus();
			return false;
		}
	}
}

function verifySubscribeForm(form) {

	if (document.subscribeForm.email.value == "" || document.subscribeForm.email.value == "email@address.com") {
	
		alert("Please enter your eMail address.");
		document.subscribeForm.email.focus();
		return false;
		
	} else {
	
		var validMail = isEmail(document.subscribeForm.email.value);
		if (!validMail) {
			alert("Please enter a VALID eMail address.");
			document.subscribeForm.email.focus();
			return false;
		}
		
	}
	
}

function Open_Window(url, name) { 
	window.open(url, name, "resizable=yes,height=450,width=500,scrollbars=yes,toolbar=no,status=yes,menubar=no"); 
}


function orwnd(muzenbr,type){
		window.open("album_reviews.inc.php?muzenbr="+muzenbr+"&type="+type, "review", "resizable=yes,height=600,width=600,scrollbars=yes,toolbar=no,status=yes,menubar=no"); 	
}
