// GOOD written functions that have global reach go here
function facebook_login()
{
	$.ajax({
		url: "/users/facebook_login",
		success: function(msg){
		  if(msg==1)
		  {
		  	window.location.reload();
		  }
		  else
		  {
		  	//display associate account form
		  	tb_show('Facebook','/users/facebook_create?width=750&height=400&modal=true');
		  	tb_show('Facebook','/users/facebook_account?width=750&height=400&modal=true');
		  }
		}
	});
}

function clearField(id) {
	//we need to add the # so the jQuery grabs the right field
	var idVar = '#' + id;

	if (($(idVar).val() == 'AaBbCc') || $(idVar).val() == '********') {
		$(idVar).val('');
	}
}

function facebook_logout()
{
	window.location='/logout';
}

function tb_wait()
{
	$('#TB_window').css('width',208)
	.css('margin-top',0)
	.css('margin-left',-100)
	.html("<img src='"+tb_pathToImage+"' >");
}
function validateEmail(email) {

    $(".error").hide();

    var hasError = false;
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

    if( (email == '') || (email == 'your email address')) {
        //alert('error!');
        $("#newsLetterBtn").after('<div class="error">You forgot to enter the email address.</span>');
        hasError = true;
    } else if(!emailReg.test(email)) {
        $("#newsLetterBtn").after('<div class="error">Please enter a valid email address</span>');
        hasError = true;
    }
    return false;
}
