$(document).ready(function() {

$('.menu').hide();
$('#papildomospaslaugos_menu').hide();

$('#papildomospaslaugos').hover(function () {
$('#papildomospaslaugos_menu').show();
});

$('.avvzx').hover(function (){
$('#papildomospaslaugos_menu').hide();
});

$('#papildomospaslaugos_menu').mouseleave( (function () {
$('#papildomospaslaugos_menu').hide();
}));

$('.slepti').mouseleave( (function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");
$('#papildomospaslaugos_menu').hide();
}));

$('#t2').hover(function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");

$('#s2').show();
$(this).css("background", "url(images/bg.png) no-repeat");
$('#t2 a').css("color", "#db356f");
});



$('#t3').hover(function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");

$('#s3').show();
$(this).css("background", "url(images/bg.png) no-repeat");
$('#t3 a').css("color", "#db356f");
});


$('#t4').hover(function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");

$('#s4').show();
$(this).css("background", "url(images/bg.png) no-repeat");
$('#t4 a').css("color", "#db356f");
});

$('#t5').hover(function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");

$('#s5').show();
$(this).css("background", "url(images/bg.png) no-repeat");
$('#t5 a').css("color", "#db356f");
});

$('#t6').hover(function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");

$('#s6').show();
$(this).css("background", "url(images/bg.png) no-repeat");
$('#t6 a').css("color", "#db356f");
});

$('#t7').hover(function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");

$('#s7').show();
$(this).css("background", "url(images/bg.png) no-repeat");
$('#t7 a').css("color", "#db356f");
});

$('#t8').hover(function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");

$('#s8').show();
$(this).css("background", "url(images/bg.png) no-repeat");
$('#t8 a').css("color", "#db356f");
});

$('#t9').hover(function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");

$('#s9').show();
$(this).css("background", "url(images/bg.png) no-repeat");
$('#t9 a').css("color", "#db356f");
});



$('.menu tbody').mouseleave( (function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");
}));


$('#t').hover(function () {
$('.menu').hide();
$('.menupasirinkt').css("background", "transparent");
$('.menupasirinkt a').css("color", "#333333");

$(this).css("background", "url(images/bg0.png) no-repeat");
$('#t a').css("color", "#db356f");
});

$('#t').mouseleave( (function () {
$(this).css("background", "transparent");
$('#t a').css("color", "#333333");
}));

$('.asdf').hover(function () {
$('#prediction').slideUp();
});




$("select[name=m[1]]").livequery(function(){
$("select[name=m[1]]").change(function () {

var stringas = $("select[name=m[1]] option:selected").val();
$('#kraunasi').css('display','inline');

$.ajax({
			url: "/ajaxmiestai.php?id=" + stringas,
			cache: false,
			success: function (data) {
				$('select[name=m[2]]').html(data);
				$('#mikrorajonai').hide();
				$('#gatves').hide();
				$('select[name=m[3]]').html('');
				$('select[name=m[4]]').html('');
				$('#kraunasi').css('display','none');
			}
		});

}); }); 

$("select[name=m[2]]").livequery(function(){
$("select[name=m[2]]").change(function () {

var stringas = $("select[name=m[2]] option:selected").val();
$('#kraunasi').css('display','inline');

$.ajax({
			url: "/ajaxrajonai.php?id=" + stringas,
			cache: false,
			success: function (data) {
			if(data!='0'){
				$('#mikrorajonai').show();
				$('select[name=m[3]]').html(data);}
				else{
				$('#mikrorajonai').hide();
				$('select[name=m[3]]').html('');
				}
				$('#kraunasi').css('display','none');
			}
		});
		
$.ajax({
			url: "/ajaxgatves.php?id=" + stringas,
			cache: false,
			success: function (data) {
			if(data!='0'){
				$('#gatves').show();
				$('select[name=m[4]]').html(data);}
			else{
			$('#gatves').hide();
				$('select[name=m[4]]').html('');
			}
				$('#kraunasi').css('display','none');
			}
		});

}); }); 




});



function balsuoti(balso_id){

$.ajax({
			url: "/ajaxvote.php?balso_id=" + balso_id,
			cache: false,
			success: function (data) {
				
					$('.pasirinkimai').hide();
					$('.pasirinkimai').html(data).fadeIn();
	
			}
		});
		
}

function neatsakyti(){

$.ajax({
			url: "/ajaxvote.php?neatsakyti=1",
			cache: false,
			success: function (data) {
				
				$('.apklausa_div').fadeOut();
	
			}
		});
		
}



function perkelti(kur){
window.location=kur;}

function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789.").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

