$(document).ready(function() {
	
	
	// meniu
	$('#meniu li').not('#meniu li li').not('#meniu li.inac').hover(function() {
		$(this).addClass('hover');
		
	},function() {
		
	   if ($(this).find('a').attr('class')!='curr cur')	{
		$(this).removeClass('hover');
	   }
	});
	
	$('#meniu').droppy();	
	
	$("#partners a, .navi a").bind('mouseover', function() {
		  var konkretus = $(this).find('img');
		  var adr = konkretus.attr('src');
		  adr = adr.replace('_.gif', '_ov.gif');
		  konkretus.attr('src', adr);
     });
	
	     
     
	$("#partners a, .navi a").bind('mouseout', function() {
		  var konkretus = $(this).find('img');
		  var adr = konkretus.attr('src');
		  adr = adr.replace('_ov.gif', '_.gif');
		  konkretus.attr('src', adr);
     });	
     
     
 	if ($("h2:first-child").html()){$("h2:first-child").css({marginTop:'-12px'});}
 	else {$("h2").css({marginTop:'-12px'});}
 	
 	//alert($("h2:first-child").html());
 	
 	$(".hd").css({display:'none'});

 	$(".home_banner").css({display:'none'});
 	$(".home_banner:first-child").css({display:'block'});
 	
	$(".hd:first-child").css({display:'block'});
	$(".dginfo").css({display:'none', position:'absolute'});
	
	
	$('.kont').bind ('click', function(){
		var dbr = window.pageYOffset;
		$('html,body').animate({scrollTop: $('.mainp').height()}, function(){
			var dbr2 = window.pageYOffset;
			var skirt = dbr2-dbr;
			if (skirt < 50 ){
				window.location.replace('/kontaktai')
			}
			
		});
		
		return false;
	});
	
//$(".daugiau").blink();
	
	$(".mov").mouseover(function(e){
		var bid =   $(this).attr("id");
		var p=0; var a=-20;
		//alert ($(this).offset().left);
		
		$("."+bid).animate({opacity:'show'},20)
		$('.'+bid).css({left: $(this).offset().left+p+"px"});	
		$('.'+bid).css({top: $(this).offset().top-a+"px"});		
		
	});
	
 	$(".mov").mouseout(function(){
	 	bid = $(this).attr("id");
		$("."+bid).animate({opacity:'hide'},0)		
	});			
	
    $(".daugiau").bind('click', function(){
	    
	    var kuris = $(this).attr('id');
     
	    
	    if ($("#a"+kuris).css('display') == "none"){

		      $("#a"+kuris).slideDown({opacity:'show'}, 200);
 	          $(this).animate({opacity:'hide'});
 	          window.location.hash = 'b'+kuris;
 	          pageTracker._trackPageview(window.location.pathname+kuris);
		    
	    }
    });
	
    $(".maziau").bind('click', function(){
	    var kuris = $(this).attr('id');
	    if ($("#a"+kuris).css('display') == "block"){
		    $("#a"+kuris).slideUp({opacity:'hide'}, 200);
		    $(".daugiau").animate({opacity:'show'});
		    
	    }
    });	
	
	
	
	
	
	
  if (window.location.hash){
  
     var aktyv=window.location.hash;
     aktyv = aktyv.replace('#b', '');
     var scrl = $("#"+aktyv).offset().top-120;
     
     
     
     
	 $('html,body').animate({scrollTop: scrl}, 800, function(){

		 /*
		 var e = document.createEvent('MouseEvents');
		 e.initEvent( 'click', true, true );
		 $("#"+aktyv).each(function(){this.dispatchEvent(e);})	 
		 */
		 $("#"+aktyv).click();
	 });
	 

	 

		
  }	    
    
  $(".pasl-pav").bind("click", function(e){
	  	var mleft = $('.cnt').offset().left;
		var kuris = $(this).attr('id');
		var tleft = mleft+70;
		
		
		var ttop = $(this).offset().top-50;
		
		$(".dginfo").animate({opacity:'hide'}, 200);
	    if ($("#a"+kuris).css('display') == "none"){
		    $("#a"+kuris).css({left:tleft, top:ttop});
		    $("#a"+kuris).animate({opacity:'show'}, 200);
		    
		    
	    }
  });
   
  $(".dginfo").bind("click", function(e){

		$(this).animate({opacity:'hide'}, 200);
  });  
	

  $(".rpav").bind("click", function(e){
		var kuris = $(this).attr('id');
		$(".hd").animate({opacity:'hide'}, 200);
		$("#a"+kuris).animate({opacity:'show'}, 200);
  });  
  
   

  
});



(function($)
{
    
    $(function()
    {

        
       
        /*
         * Homepage
         */
        var banners_change_interval = 5000;
        function home_show_banner(holder)
        {
            $("#home_banner_choosers .holder_active").each(function()
            {
	                            
	            
                var current_index   = $(this).attr('id')
                    .replace('home_banner_holder_', '');
                $("#home_banner_holder_"+current_index).removeClass('holder_active');
                $("#home_banner_holder_"+current_index).addClass('holder');
                $("#home_banner_"+current_index).fadeOut();
                
            });
            
            var next_index      = $(holder).attr('id').replace('home_banner_holder_', '');
            $("#home_banner_holder_"+next_index).addClass('holder_active');
            $("#home_banner_"+next_index).fadeIn();
            
            var prev_index  = next_index-1;

        }
        if ($("#home_banner_choosers .holder").length > 0) {
            $("#home_banner_choosers").everyTime(banners_change_interval, function() {
                if ($(".holder_active", this).nextAll(".holder").length) {
                    home_show_banner($(".holder_active", this).nextAll(".holder"));
                } else {
                    home_show_banner($(".holder:eq(0)", this));
                }
            });
            
            $("#home_banner_choosers .holder").each(function()
            {
                var holder = this;
                $(".item", this).click(function()
                {
	                
                    $("#home_banner_choosers").stopTime(); 
                    home_show_banner(holder);
                });
            });
        }
        

    });
})(jQuery);


function ch(id, tlin, hght, wdth){
   if (typeof wdth == 'undefined' ) var wdth="0";
   wdth = wdth-7;
	var pozicija = document.body.scrollTop;	
	if (pozicija == 0){ if (window.pageYOffset)	pozicija = window.pageYOffset; 	else   	pozicija = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0; }
 	
	pozicija=pozicija+1;
	var pozicija2=pozicija-2;
	document.getElementById(id).style.display='block';
	var aukstis = document.getElementById(id).offsetHeight; 
	if (!aukstis) {aukstis = 400}
	aukstis = aukstis-15;
	document.getElementById(id).style.display='none';
    var braukstis = document.documentElement.clientHeight-70;

        
    if (!braukstis) {braukstis = 400;}


			if ((navigator.appName == "Microsoft Internet Explorer") && (parseFloat(navigator.appVersion.split("MSIE")[1])) < 8) {
				 if (aukstis > braukstis){var mright="33"; var pwidth=467+wdth*1;}else{var mright="15"; var pwidth=485+wdth*1;}
		 	}else{var mright="15"; var pwidth=485+wdth*1;}
		 	
	if (aukstis > braukstis){aukstis = braukstis;}	
	
	if (hght) {aukstis = hght;}
	
$.floatbox({
        content: document.getElementById(id).innerHTML,
        aukstis: document.getElementById("content").offsetHeight+280,
        baukstis: aukstis,
        pozicija: pozicija,
        pozicija2: pozicija2,
        mright: mright,
        pwidth: pwidth,        
        fade: true,
        wdth: wdth
    });

}


function zemelapis(koord){
 if ((navigator.appName == "Microsoft Internet Explorer") && (parseFloat(navigator.appVersion.split("MSIE")[1])) < 7) {	
	 window.open ("http://kemimap.w.texus.lt/?z="+koord,"zemelapis");
 }else{ 
	if (typeof koord == 'undefined' ) var koord="";
	document.getElementById('ifr').style.height = '555px';
	document.getElementById('ifr').style.width = '680px';
	document.getElementById('ifr').src = 'http://kemimap.w.texus.lt/?z='+koord;
 }
}


