$.ajaxSetup({
	timeout: 5000,
	type: "GET",
	cache: false,
	async: true,
	contentType: "application/x-www-form-urlencoded"
});
$(document).ready(function(){
	$('.search-box input').focus(function(){if ($(this).attr('value') == 'поиск по сайту') $(this).attr('value', '');});
	$('.search-box input').blur(function(){if ($(this).attr('value') == '') $(this).attr('value', 'поиск по сайту');});

	$(".fancy").fancybox({
		'overlayShow': true,
		'overlayOpacity': 0.8,
		'hideOnContentClick': true,
		'titleShow': false,
		'transitionIn': 'elastic',
		'transitionOut': 'elastic'
	});

	$('#feedback').click(function(){
		var data = '';
		$('div.feedback table tr td input, div.feedback table tr td textarea').each(function(){
			data += $(this).attr('name')+'='+$(this).val()+'&';
		});
		$.ajax({
			type: "POST",
			url:"/ajax/feedback/",
			data : data,
			success: function(answer)
			{
				answer = answer.split('@@');
				$('div.feedback div.message').html(answer[0]).show();
				if (answer[1] == 'ok') setTimeout('document.location.reload()', 1500);
			}
		});
	});

	$(".menu > li").hover(
		function() {if($(this).has("ul").length) {$(this).addClass("active");};},
		function() {$(this).removeClass("active");}
	);

	$('div.map a').click(function(){
		$('div.offices > div.of-list').hide();
		$('div.offices > div#c-'+$(this).attr('name')).show();
		$('div.map > div.sel').removeClass('sel');
		$(this).parent('div').parent('div').addClass('sel');
	});

	$('select[name=qty]').change(function(){
		$.ajax({
			type: "POST",
			url:"/ajax/qty/"+$(this).val(),
			success: function(answer)
			{
				document.location.reload();
			}
		});
	});
});
