$(document).ready(function(){
	$('#reg_submit').click(function(){
            $.post("/ajax/reg_add.php", $("#reg_form").serialize(),
                function(data){
                    if(data.result!='success'){
                        if(data.errors){
                            alert(data.errors);
                        }else{
                            alert("You registration did not complete. Please try again");
                        }
                    }else{
						location.reload();
                    }
                   
                },"json"); 		
	});
    
    $('#reg_login').click(function(){
            $.post("/ajax/reg_authenticate.php", $("#reg_auth_form").serialize(),
                function(data){
                    if(data.result!='success'){
                        if(data.errors){
                            alert(data.errors);
                        }else{
                            alert("You login did not complete. Please try again");
                        }
                    }else{
                        location.reload();
                    }
                   
                },"json");         
    });
    
    $('#reg_forgotten_password_submit').click(function(){
            $.post("/ajax/reg_retrieve_password.php", $("#reg_forgotten_password_form").serialize(),
                function(data){
                    if(data.result!='success'){
                        if(data.errors){
                            alert(data.errors);
                        }else{
                            
                        }
                    }else{
                        alert("Your password has been emailed to: " + data.email);
                        location.reload();
                    }
                   
                },"json");         
    });
    
    
    
    
    $('#reg_sign_up_form_container').hide();
    
    $('#reg_forgotten_password').hide();
    
    $('#reg_form_sign_in').click(function() {
        $('#reg_auth_form_container').show();
        $('#reg_forgotten_password').hide();
        $('#reg_sign_up_form_container').hide();       
    });
    
    $('#reg_form_register').click(function() {
        $('#reg_auth_form_container').hide();
        $('#reg_forgotten_password').hide();
        $('#reg_sign_up_form_container').show();       
    });
    
    $('#reg_form_forgotton_password_tab').click(function() {
        $('#reg_auth_form_container').hide();
        $('#reg_sign_up_form_container').hide();
        $('#reg_forgotten_password').show();       
    });   
    
});



