var Across = {

    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"
            );
    }
};

$(document).ready(function()
{
	$.fn.idle = function(time)
	  {
		  var o = $(this);
		  o.queue(function()
		  {
			 setTimeout(function()
			 {
				o.dequeue();
			 }, time);
		  });
		  return this;
	  }


	$('.popup-overlay').idle(500).fadeIn(300).css({
		'height':$(document).height(),
		'z-index':'201'
	});
	
	$('.btn-close, .popup-overlay').click(function(){
		$('.popup-overlay').fadeOut(300);
	});
	
	$('.popup-container').click(function(e){
		e.stopPropagation();
	});
	
	

});

