/*
 * SimpleModal Confirm Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2008 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: confirm.js 170 2008-12-04 19:03:12Z emartin24 $
 *
 */

$(document).ready(function () {
	$('#confirmDialog input.confirm_subscribe, #confirmDialog a.confirm_subscribe').click(function (e) {
		var customers_id = $(this).attr('customers_id');
		var azione = $(this).attr('azione');
		e.preventDefault();
		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("Sei sicuro di voler accettare la richiesta?", function () {
			$.post( '/ext/subscribe.php' , {groups_id:$("#groups_id").val() , customers_id: customers_id , stato:azione }
				 , function(data){
				 	if ( data=='1' )
				 	{
				 		alert( "Procedura eseguita correttamente." );
				 		$("#user" + customers_id ).hide();
				 		document.location.reload();
				 	}
				 }
				);
		});
	});

	$('input.confirm_dellete_categories, a.confirm_dellete_categories , img.confirm_dellete_categories').click(function (e) {
		var cat_id = $(this).attr('categories_id');
		e.preventDefault();
		// example of calling the confirm function
		// you must use a callback function to perform the "yes" action
		confirm("Sei sicuro di voler cancellare la categoria selezionata?", function () {
			$.post( '/ext/delete_categorie.php' , {groups_id:$("#groups_id").val() , categories_id: cat_id }
				 , function(data){
				 	alert( data );
				 	if ( data=='1' )
				 	{
				 		alert( "Procedura eseguita correttamente." );
				 		$("#cat" + categories_id ).hide();
				 	}
				 }
				);
		});
	});

});
