// prepare the form when the DOM is ready 
$(document).ready(function() { 
    // bind form using ajaxForm 
    $('#submissionsForm').ajaxForm({ 
        // dataType identifies the expected content type of the server response 
        dataType:  'json', 
 
        // success identifies the function to invoke when the server response 
        // has been received 
        success:   processSubmissions 
    }); 
});

function processSubmissions(data) { 
    
	// Reset form style
	/*$("form input").each(function() {
       this.css("border", "1px solid black"); 
     });*/
	
	$("#form_name").css("background-color", "#0f1012");
	$("#form_email").css("background-color", "#0f1012");
	$("#form_title").css("background-color", "#0f1012");
	$("#form_url").css("background-color", "#0f1012");
	
	if(data.response == 2){
		$.each(data.data, function(i,item){
				$("#" + item).css("background-color", "#492d2c"); 
		});
	}else{
		$("#submissionsForm").html(data.data.message);
		$("#unapproved").html(data.data.unapproved);	
	}
		
}