$(document).ready(function(){
		$('.menu_item').mouseover(function(){
			$(this).children('div.smenu').css('top',$(this).offset().top-3);
			$(this).children('div.smenu').css('left',$(this).offset().left+190);
			$(this).children('div.smenu').show();
			});
		$('.menu_item').mouseout(function(){
			$(this).children('div.smenu').hide();
			});
		$('.faq_question').click(function(){
			$('.faq_answer').hide();
			$(this).siblings('.faq_answer').show();
			});

		//filler height stretch
		filler_resize();
		});

function filler_resize()
{
	$('#menu_fill').height($('#menu_fill_inner').height());
	var filler_height=$('#content').offset().top+$('#content').height()-$('#menu_fill').offset().top+20;
	if(filler_height > $('#menu_fill').height()) $('#menu_fill').height(filler_height);
}
function street_selected()
{
	$.post('ajax.php',{ query: 'houses',id: $("#street").val() },function(data){ $('#house_div').html(data); $('#house_info').html(''); },"html");
}
function house_selected()
{
	$.post('ajax.php',{ query: 'house_info',id: $("#house").val() },function(data){ $('#house_info').html(data); },"html");
}
function apply_commit()
{
	if(!$('#approve').attr('checked'))  { alert('Информация не подтверждена'); return;}
	if($('#flat').val()=='') { alert('Не указана квартира'); return;}
	if($('#name').val()=='') { alert('Не указано имя'); return;}
	if($('#phone').val()=='') { alert('Не указан телефон'); return;}
	if(!$('#house').val() && $('#address').val()=='') { alert('Не указан адрес'); return;}

	$.post('ajax.php',{query: 'apply_commit',
			apply_type: $('#apply_type').val(),
			street: $('#street').val(),
			house: $('#house').val(),
			address: $('#address').val(),
			flat: $('#flat').val(),
			name: $('#name').val(),
			phone: $('#phone').val(),
			comment: $('#comment').val() },function(data){ $('#apply').html(data); },"html");
}

function epg_selected()
{
	$.post('ajax.php',{ query: 'epg',channel: $("#channel").val(), category: $("#category").val() },function(data){ $('#epg_table').html(data); filler_resize(); },"html");
}

function vote_commit()
{
	values=Array();
	$('input[name^="channel"]:checked').each(function(){ values.push( { name: $(this).attr('name'), value: $(this).val() } ); });
	if(values.length<5) { alert('Отметьте хотя бы 5 каналов, пожайлуста'); }
	else {	$.post('ajax.php',{ query: 'vote', votes: values },function(data){ $('#vote').html(data); filler_resize(); },"html"); }
}

