;(function($){
	'use strict';
	jQuery('document').ready(function($){
	    jQuery('body').on('submit', '.exwf-reviews #commentform', function (e) {
	        //serialize and store form data in a variable
	        var commentform = $(this);
	        commentform.addClass('ex-loading');
	        var statusdiv = commentform.find('#comment-status');
	        var formdata = commentform.serialize();
	        //Add a status message
	        //Extract action URL from commentform
	        var formurl=commentform.attr('action');
	        //Post Form with data
	        $.ajax({
	            type: 'post',
	            url: formurl,
	            data: formdata,
	            error: function(request, textStatus, errorThrown)
	                {
	                	commentform.removeClass('ex-loading');
	                	var wpErrorHtml = request.responseText.split("<p>"),
            			wpErrorStr = wpErrorHtml[1].split("</p>");
	                    statusdiv.html(wpErrorStr);
	                },
	            success: function(data, textStatus){
	            	
	                //if(data == "success" ){
	                //    statusdiv.html('<p class="ajax-success" >Thanks for your comment. We appreciate your response.</p>');
	                //}else{
	                	commentform.removeClass('ex-loading');
	                    var wpErrorHtml = data.split("<p>"),
						wpErrorStr = wpErrorHtml[1].split("</p>");
						statusdiv.html(wpErrorStr);
	                //}
	            }
	        });
	        return false;
	    });
		jQuery('body').on( 'click', '.exwf-reviews #respond p.stars a', function() {
			var $star   	= $( this ),
				$rating 	= $( this ).closest( '#respond' ).find( '#rating' ),
				$container 	= $( this ).closest( '.stars' );

			$rating.val( $star.text() );
			$star.siblings( 'a' ).removeClass( 'active' );
			$star.addClass( 'active' );
			$container.addClass( 'selected' );

			return false;
		} );
	});
    
}(jQuery));