$(document).ready(function() {
   setEqualHeight($("div.eq"));
	$("a.bigpopup").lightBox();
	$("#callback_form").jqm({trigger:$('a#callback_btn')});
	//$('#callback_form form').ajaxForm({clearForm:true,success:function(){$('#callback_form').jqmHide()}});
	$('#callback_form a.close').click(function(){$('#callback_form').jqmHide()});
	$('#callback_form form').validate();
	$('#callback_form2 form').validate({
		errorPlacement: function(error, element) {
			error.insertBefore( element.parent());
		}
   });
	//$('#callback_form .phone').mask("(999) 999-99-99");
	$('#callback_form form').submit(function(){
		if($(this).validate().form()){
			$.post('/callback.php',$(this).serialize());
			$(this)[0].reset();
			$('#callback_form').jqmHide();
			$("body").append('<div style="position:fixed; top:0; left:0; width:100%; height:100%; background:#000;opacity: 0.75;"></div>');
			$("body").append('<div class="message">Спасибо за использование нашего сайта! Менеджер обязательно свяжется с вами в ближайшее время!</div>');
			//console.log($(window).height(),$(window).width());
			var m = $('.message');
			m.css('top',(parseInt($(window).height())-parseInt(m.height()))/2).css('left',(parseInt($(window).width())-parseInt(m.width()))/2);
			setTimeout(function(){$('.message').prev().remove();$('.message').remove();},3000);
		}
		return false;
	});
$('#callback_form2 form').submit(function(){
		if($(this).validate().form()){
			$.post('/callback.php',$(this).serialize());
			$(this)[0].reset();
			$("body").append('<div style="position:fixed; top:0; left:0; width:100%; height:100%; background:#000;opacity: 0.75;"></div>');
			$("body").append('<div class="message">Спасибо за использование нашего сайта!</div>');
			//console.log($(window).height(),$(window).width());
			var m = $('.message');
			m.css('top',(parseInt($(window).height())-parseInt(m.height()))/2).css('left',(parseInt($(window).width())-parseInt(m.width()))/2);
			setTimeout(function(){$('.message').prev().remove();$('.message').remove();},3000);
		}
		return false;
	});
  });

function setEqualHeight(columns)
{
   var tallestcolumn = 0;
   columns.each(
     function()
     {
       currentHeight = $(this).height();
       if(currentHeight > tallestcolumn)
       {
         tallestcolumn  = currentHeight;
       }
     }
   );
   columns.height(tallestcolumn);
}

