function buyClick()
{
	$('#buynow_button').click(function(){
		window.location.href = 'buynow.php';					
	});
}

function buyClick2()
{
	$('#buynow_button2').click(function(){
		window.location.href = 'buynow_economy.php';					
	});
}

function emailSignupClick()
{
	$('#email_submit_btn').click(function(){
		var errors = '';
		if($('#name').val() == '')
		{
			errors = 'Please enter your name\n';
		}
		
		if($('#email').val() == '')
		{
			errors += 'Please enter your email address\n';
		} else {
			if(!validate_email($('#email').val()))
			{
				errors += 'Please enter a valid email address\n';
			}
		}
		
		if(errors != '')
		{
			alert(errors);
		} else {
			$.getJSON('ajax_funcs.php',{type: "add_email", name: $('#name').val(), email: $('#email').val()},function(data){
					if(data.error)
					{
						alert('Sorry, we encountered an error recording your email address, please try again. If the problem persists, please contact us.');
					} else {
						$('#email_text').html('Thank you for signing up and good luck in the draw!');
					}
				});	
		}
	})
	
}

function validate_email(address) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(address) == false) {
		return false;
	} else {
		return true;
	}
}
