function handleSignup() {
	$('div.error').remove();
    var container = '#email-signup > fieldset > ';
    var cdata = {
            'email' : $(container+'input[name=email]').val(),
            'name' : $(container+'input[name=name]').val(),
            'country' : $(container+'select[name=country]').val(),
            'art_stars_updates' : $('input[name=art_stars_updates]').val(),
            'general_polo_updates' : $('input[name=general_polo_updates]').val(),
            'csrfmiddlewaretoken' : $('input[name=csrfmiddlewaretoken]').val()
    }

    var postData = '';

    if (cdata['email']!=''&&cdata['name']!=''&&(cdata['art_stars_updates']=='on'||cdata['general_polo_updates']=='on')) {

        for(key in cdata) {
            postData += key + '=' + cdata[key] + '&';
        }
        $.ajax({
            type: 'POST',
            url: '/signup/',
            data: postData,
            dataType: 'html',
            success: function(html) {
                $('#email-signup').html(html);
            },
            error: function(html, stat, eThrown) {
                //$('#make-comment').html(html);
            }
        });
    } else {
        //alert('Please fill in the form');
		$('<div class="error">Please complete the above form.</div>').insertAfter('#id_country').hide().fadeIn();
    }
    return false;
}

$(document).ready(function() {
    $('#email-signup').submit(function(e) {
        e.preventDefault();
        handleSignup();
    });
});


