function _l(msg){
	if(window.console){
		console.log(msg);
	}
}

$(document).ready(function(){
	$("a.tooltip").tooltip(
		{
			showURL: false 
		}
	);
	$("#top_menu").superfish(
			{
				delay: 0,
				speed: "fast",
				animation: {height:'show'}
			});
	$("#phone").keyup(function(){return true;
		$("#messages").html('');
		if($.trim($(this).val())=="")
		{
			$("#send").attr('disabled','disbaled')
		}
		else
		{
			$("#send").removeAttr('disabled')
		}
	})
	$("#feedback_form").live('submit',function(e){
		var phone,comment;
		phone = $("#phone").val();
		comment = $("#comment").val();
		$("#messages").html('');
		if($.trim(comment)=="")
		{
			$("#messages").html("Введите текст сообщения")
			return false;
		}
		if($.trim(phone)=="")
		{
			$("#messages").html("Укажите как с вами связаться")
			return false;
		}
		
		$.post('/ajax/feedback.php',{phone : phone, comment : comment} ,function(data){
			if(typeof data.messages != "undefined")
			{
				$("#messages").html(data.messages)
			}
			else
			{
				$("#thanx").show();
				$("#feedback_form").hide();
			}
			
		},"json")
		//e.stopPropagation();
		return false;
	});
	$("#feedback_link").click(function(){
		$("#feedback_form").show();
		overlay.load();
		return false;
	});
	
	 var overlay = $("#feedback-form-div").overlay({
		mask: {
			color: '#ebecff',
			loadSpeed: 200,
			opacity: 0.8
		},
	    closeOnClick: true,
	    closeOnEsc: true,
	    load: false,
	    api: true 
	});
	 if($("div.thumb").length>1)
	 {
		 $(".scrollable").scrollable({circular: true}).autoscroll({ autoplay: true, interval: 5000 });
	 }
});
