

    function signupFormSubmit()
    {
        var _alphaRegx 	  = /^([a-zA-Z\s]{2,})$/;
        var _emailRegx 	  = /^([\w-.]{2,})@([\w-.]{3,})(.[\w]{2,4})$/;
        
        var _arr          = [];
        var i;
        
        _arr['first_name']= {test: _alphaRegx.test( $('#first_name').val()) , error: 'please enter your first name'};
        _arr['email'] 	  = {test: _emailRegx.test( $('#email').val() )   , error: 'please enter a valid email address'};
      
        for(i in _arr)
        {
            if(_arr[i].test == false)
            {
                alert( _arr[i].error );
                return false;
            }
        }
        
        twcSignup();
    }

    function twcSignup()
    {	
		var __ajax = new ajaxObject();

		var send_obj  = 
		{
			first_name	: $('#first_name').val(),   
			email		: $('#email').val()
		}
		
        __ajax.setUrl(document.URL+'php/signup.php');
		__ajax.setCallback( signupResponse );
		__ajax.sendRequest(send_obj, 'POST');
		
		return;
     
    			
    }
    
    function signupResponse(_responseText, _status, _responseXML)
    {
        if ( _responseText.indexOf('ok') > -1 )
        {
            var msg = "";
            msg += "Thanks for subscribing to our 2 week challenge. \n";
            msg += "Tomorrow you will receive your first key.  \n";
            msg += "If you don’t receive it please check your junk folder.\n\n";
            msg += "Make sure you have your bottle of Amazing Meal to start the challenge \n";
            msg += "if you don’t go to http://www.amazinggrass.com/about-amazing-meal.html and pick one up. \n\n\n"
            msg += "Amazing Grass"; 
            
            $('#first_name').val('');   
            $('#email').val('');
            
            alert(msg);
            
            return;
            
        }else if(_responseText.indexOf('active') > -1)
        {   
            var error = _responseText.replace('active=', '');
            
            var msg = "";
            msg += error +"\n\n";
            msg += "Please contact customer support if you need assistance \n";
            
            alert(msg);
            
            return;
        }
        
        
        var msg = "";
        msg += "There was an error processing your request \n";
        msg += "Please try again or contact customer support \n";
        
        alert(msg);
    }

