function show_banner(id, width, height)
{
	var base = document.getElementsByTagName('base')[0];
	document.write('<iframe src="'+base.href+'banner.php?id='+id+'" width="'+width+'" height="'+height+'" frameborder="0" scrolling="no"></iframe>');
}
try { document.execCommand("BackgroundImageCache", false, true); } catch (e) {}

function showqf()
{
	$('#qform-fon').css({'opacity': 0.7, 'display': 'block'}).height($('#container').height());
	$('#qform').css({'display': 'block', 'top': $(window).scrollTop() + 50});
}

function hideqf()
{
	$('#qform-fon').css('display', 'none');
	$('#qform').css('display', 'none');
}

function resetqf()
{
	$("#qform form")[0].reset();
}

$(document).ready(function(){
	$('.p-gal a, #hgalery li a').lightBox();
	$('#qform-fon').css('opacity', 0.7).click(function(){ hideqf() });
	$('#qf-back').click(function(){
		hideqf()
	});
	$("#qform form").submit(function(event) {
		event.preventDefault(); 

		var $form = $( this ),
			data = {
				name: $form.find( 'input[name="name"]' ).val(),
				phone: $form.find( 'input[name="phone"]' ).val(),
				email: $form.find( 'input[name="email"]' ).val(),
				msg: $form.find( 'textarea[name="msg"]' ).val()
			},
			url = $form.attr( 'action' );
		$.ajax({
			type: 'POST',
			url: url,
			data: data,
			success: function(res)
			{
				eval('res = ' + res + ';');
				if (res.sent == 'error')
				{
					var s = [];
					if (res.error.noName)
						s.push('Укажите имя');
					if (res.error.noName)
						s.push('Укажите телефон');
					if (res.error.noName)
						s.push('Укажите вопрос');
					alert(s.join("\n"));
				}
				else
				{
					location.href = 'map.html?sent=ok';
//					$('#qf-form').css('display', 'none');
//					$('#qf-ok').css('display', 'block');
				}
			}
		});
	});
});
