var Across = {

    FormType: 'update',
	UpdateData : 0,
	
    setType: function(to)
    {
        Across.FormType = to;
    },

    back: function()
    {
        history.go(-1);
    },

    reloadWin: function(to)
    {
        if (to == false)
        {
            window.location = window.location.href;
        }
        else
        {
            window.location = to;
        }
    },

    clearField: function(item)
    {
        $(item).attr('value', '');
    },
	
    sendM : function (thisFom)
    {
        Across.actualForm = thisFom;

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

                if (data.error)
                {
					$('#reg-errors').addClass('error-block');
					
					var string = '';
					
					jQuery.each(data.items, function(i, val) {
						string += '<label for="'+i+'">'+val+'</label><br/>';
				    });

					$('#reg-errors').html(string);
                }
                else
                {
					$('#reg-errors').removeClass('error-block');
					$('#reg-errors').html('');
					Across.actualForm.reset();
                    alert(data.message);
                }
            },
            "json"
            );
    },
	
    sendApplication : function (thisFom)
    {
        Across.actualForm = thisFom;
		
		$.post("/", 
			'Func=news.events.sendApplication&'+$(thisFom).serialize(), 
			function(data) {

				if (data.error)
				{
					$('#reg-errors').addClass('error-block');
					
					var string = '';

					jQuery.each(data.items, function(i, val) {
						string += '<label for="'+i+'">'+val+'</label><br/>';
				    });

					$('#reg-errors').html(string + '</ul>');
				}
				else
				{
					$('#reg-errors').removeClass('error-block');
					$('#reg-errors').html('');
					Across.actualForm.reset();
                    alert(data.message);
				}
			},
			"json"
		);
    },
	
	sendWineApplication : function (thisFom)
    {
        Across.actualForm = thisFom;
		
		$.post("/", 
			'Func=news.winetastes.sendApplication&'+$(thisFom).serialize(), 
			function(data) {

				if (data.error)
				{
					$('#reg-errors').addClass('error-block');
					
					var string = '';

					jQuery.each(data.items, function(i, val) {
						string += '<label for="'+i+'">'+val+'</label><br/>';
				    });

					$('#reg-errors').html(string + '</ul>');
				}
				else
				{
					$('#reg-errors').removeClass('error-block');
					$('#reg-errors').html('');
					Across.actualForm.reset();
                    alert(data.message);
				}
			},
			"json"
		);
    },

	Toggle : function (id)
	{
		$('#'+id).toggle();
	},
	eventpop : function(cls)
	{
		$('.'+cls).show();
	},
	closepop : function(cls)
	{
		$('.'+cls).hide();
	}

};

$(document).ready(function()
{

});

