jQuery(function(){
	var $ecpp = jQuery.noConflict();
	
	$ecpp('.cppForm').submit(function(){
		// organize the data properly. Conver all form fields to url query format
		var data = $ecpp(this).serialize();
		
		$ecpp.ajax({
		    url: $ecpp(this).attr('action'), 
		     
		    type: $ecpp(this).attr('method'),

		    //pass the data         
		    data: data,     
		     
		    //Do not cache the page
		    cache: false,
		     
		    //success
		    success: function (responseText) {
				if(responseText.ecpp_auth == 1)
					location.reload(true);
				else
					alert('Incorrect password. Please try again.');   
		    },
		    
		    dataType: 'json'
		});
		
		return false;
	});
});

