function checkSubscribeForm() {
	var msg="";
	if ( isEmpty(document.subscribeForm.email) )							msg += "- Please enter the email\n";
	else if ( !isEmail(document.subscribeForm.email.value) )	msg += "- Please enter a valid email address\n";
	
	if ( msg.length > 1 )	{
		alert ( msg );
		return false;
	}
	return true;	
}

function checkCartForm() {
	var msg="";
	if ( isEmpty(document.cartForm.s_address1) )				msg += "- Please enter your address (for shipping)\n";
	if ( isEmpty(document.cartForm.s_city) ) 						msg += "- Please enter the city (for shipping)\n";
	if ( document.cartForm.thesame.checked==false ) {
		if ( isEmpty(document.cartForm.b_address1) )			msg += "- Please enter your address (for billing)\n";
		if ( isEmpty(document.cartForm.b_city) ) 					msg += "- Please enter the city (for billing)\n";
	}
	
	if ( msg.length > 1 )	{
		alert ( msg );
		return false;
	}
	return true;
}

function checkLoginForm() {
	var msg="";
	if ( isEmpty(document.loginForm.email) )							msg += "- Please enter your email\n";
	else if ( !isEmail(document.loginForm.email.value) )	msg += "- Please enter a valid email address\n";
	if ( isEmpty(document.loginForm.pass) )								msg += "- Please enter your password\n";
	
	if ( msg.length > 1 )	{
		alert ( msg );
		return false;
	}
	return true;
}

function checkContactForm() {
	var msg="";
	if ( isEmpty(document.contactForm.name) )								msg += "- Please enter your name\n";
	if ( isEmpty(document.contactForm.email) )							msg += "- Please enter your email\n";
	else if ( !isEmail(document.contactForm.email.value) )	msg += "- Please enter a valid email address\n";
	if ( isEmpty(document.contactForm.subject) )						msg += "- Please fill in the subject\n";
	if ( isEmpty(document.contactForm.message) )						msg += "- Please fill in the message\n";
	
	if ( msg.length > 1 )	{
		alert ( msg );
		return false;
	}
	return true;
}

function checkUserRegisterForm() {
	var msg="";
	if ( isEmpty(document.userRegisterForm.firstname) ) 				msg += "- Please enter your first name\n";
	if ( isEmpty(document.userRegisterForm.lastname) ) 					msg += "- Please enter your last name\n";
	if ( isEmpty(document.userRegisterForm.email) ) 						msg += "- Please enter your email address\n";
	else if ( !isEmail(document.userRegisterForm.email.value) )	msg += "- Please enter a valid email address\n";
	if ( isEmpty(document.userRegisterForm.address1) ) 					msg += "- Please enter your address\n";
	if ( isEmpty(document.userRegisterForm.city) ) 							msg += "- Please enter the city\n";
	
	if ( msg.length > 1 )	{
		alert ( msg );
		return false;
	}
	return true;
}

function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}

function isEmpty(aTextField) 
{
	if ( (aTextField.value.length==0 ) || (aTextField.value==null) ) 
		return true;
	else
		return false;
}