var Across = {

    NewLink : '',

    sendM : function (thisFom)
    {
        Across.actualForm = thisFom;

		$.post("/", 
			'Func=contacts.sendMessage&'+$(thisFom).serialize(), 
			function(data) {

				if (data.error)
				{
					jQuery.each(data.items, function(i, val) {
						$('#'+i).val(val);
				    });
				}
				else
				{
					Across.actualForm.reset();
					alert(data.message);
				}
			},
			"json"
		);
    },

    sendInvitation : function (thisFom)
    {
        Across.actualForm = thisFom;

		$.post("/", 
			'Func=users.invite.sendInvitation&'+$(thisFom).serialize(), 
			function(data) {

				if (data.error)
				{
					if (data.items)
					{
						jQuery.each(data.items, function(i, val) {
							$('#'+i).val(val);
						});
					}

					if (data.message)
					{
						alert(data.message);
					}
				}
				else
				{
					Across.actualForm.reset();
					alert(data.message);
				}
			},
			"json"
		);
    },

	reload : function ()
	{
		window.location = window.location.href;
	},

	clearField : function (item)
	{
		$(item).attr('value', '');
	},
	
	setRank : function (item, rank)
	{
		$.post("/", {
				Func : 'recipes.setRank',
				item : item,
				rank : rank
			}, 
			function(data) {

				if (data.error == true)
				{
					alert(data.message);
				}
				else
				{
					Across.reload();
				}
			},
			"json"
		);
	},

	toogleFavo : function (item, id)
	{
		$.post("/", {
				Func : 'recipes.toggleFavo',
				id   : id
			}, 
			function(data) {

				if (data.error == true)
				{
					alert(data.message);
				}
				else
				{
					Across.reload();
				}
			},
			"json"
		);
	},

	showUserlist : function (list)
	{
		if (list == 'favo')
		{
			$('#list-selector').addClass('favourites-list');

			$('#list-favourites').css('display', 'block');
			$('#list-recipes').css('display', 'none');
		}
		else
		{
			$('#list-selector').removeClass("favourites-list");

			$('#list-favourites').css('display', 'none');
			$('#list-recipes').css('display', 'block');
		}
	}
};
