window.addEvent('domready', function() {
	
	/*---Product Invitation Form---*/
	$('invitationForm').addEvent('submit', function(e) {
	//Prevents the default submit event from loading a new page.
	new Event(e).stop();
	//e.stop();
	//Empty the log and show the spinning indicator.
	var log = $('log_res_ModifyCategory').empty().addClass('ajax-loading');
	//Set the options of the form's Request handler. 
	//("this" refers to the $('addCatForm') element).
	this.set('send', {onComplete: function(response) { 
		log.removeClass('ajax-loading');
		//get vars
		var status = JSON.decode(response);
		//validate that all proceed as planned CODE: 1 = TRUE
		if (status.code == 1){
			//Display a message of congratulations
			log.set('html', status.message);
			//parent.tb_remove();
			//parent.location.reload(1);
			//redirect
			//window.location = 'modifyRegistry.php?status=2';
		}
		else
		{
			//display the Errors
			log.set('html', status.message)
			
		}
		
	}});
	//Send the form.
	this.send();
	});
	
});

/*Reassign jQuery to another shortcut*/
    var $j = jQuery;
$j(document).ready(function() {
	$j("#alert_message").hide();
	$j("#product_form").submit(function() {
		var quantityVal = $j("#quantity").val();
		var productidVal = $j ("#productID").val();
		//Post
		$j('#alert_message').show();
		$j.post("includes/addtoRegistry.php", { productID: productidVal, quantity: quantityVal },
		
		function(data) {
			$j("#alert_message").slideDown("normal").show().html(data);
			});
		return false;
	});
});

