function uzdaryti(box){
	if (box == "box2") {$("#" + "ANXDCEE2A9FE08147D304FBE8CC44D6C371").remove();}
	$("#" + box).fadeOut(200, function () {
		$("#" + box).remove();
    });
}


$(document).ready(function() {

/*
$("body").disableTextSelect();
//$("#bot_block").enableTextSelect();

    $(document).bind("contextmenu",function(e){
	e.preventDefault();
        return false;
    });
	
$(document).keydown(function(e) {

 if(e.ctrlKey || e.which==17 || e.which==65){
	SelectText("bot_block");
	return false;
 }


});	
$(document).keyup(function(e) {

 if(e.ctrlKey || e.which==17 || e.which==65){
	SelectText("bot_block");
	return false;
 }


});	
		
$(document).keypress(function(e) {

 if(e.ctrlKey || e.which==17 || e.which==65){
	SelectText("bot_block");
	return false;
 }


});			
*/
 	
	$('.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;
	});
	

	
	$(".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'});
 	          
 	          //$(this).addClass("maz");
 	          //$(this).html("Suskleisti");
 	          //$(this).removeClass("daugiau");
 	          
 	          window.location.hash = 'b'+kuris;
 	          pageTracker._trackPageview(window.location.pathname+kuris);
		    
	    }
    });
	
    $(".maziau, .maz").bind('click', function(){
	    
	    var kuris = $(this).attr('id');
	    if ($("#a"+kuris).css('display') == "block"){
		    $("#a"+kuris).slideUp({opacity:'hide'}, 200);
		    $(".daugiau").animate({opacity:'show'});
		    //$(".maz").html("Skaitykite daugiau");
		    //$(".maz").addClass("daugiau");
		    //$(".maz").removeClass("maz");
	    }
    });	
    
  
	
	
	
	
	
	
  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();
	 });
	 

	 

		
  }	    
    
  
  
  $.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});
  
    if($.getUrlVar('mact') || $_POST["mact"]) {
	 $('html,body').animate({scrollTop: $('.mainp').height()}, 800);
	 }
	
	
	
	var speed = 4000;

	$('#nuotraukos, #nlist li').css({width:$('#t_hpht').width(), marginLeft: '1px'});	
	//$('#nlist').width($('#t_hpht').width() * $('#nlist li').length);
	$('#nuotraukos, #nlist li, #zinutes, #zlist li').height($('#t_hpht').height()-12);
	//alert($('#nuotraukos').find($("li")).size());
	var kiek_f = $('ul#nlist > li').length*900+5+"px";
	
	$('#nlist').css({width: kiek_f});
	
	
$("ul#nlist > li > img").each(function() {
    $(this).css({width:'900px'});
});	
	
	
	//Assign a timer, so it will run periodically
	var run = setInterval('newsscoller(0)', speed);	
	
	$('#nlist li:first, #zlist li:first').addClass('selected');
 
	//Pause the slidershow with clearInterval
	$('#btn-pause').click(function () {
		clearInterval(run);
		return false;
	});
 
	//Continue the slideshow with setInterval
	$('#btn-play').click(function () {
		run = setInterval('newsscoller(0)', speed);	
		return false;
	});
	
	//Next Slide by calling the function
	$('#btn-next').click(function () {
		clearInterval(run);
		newsscoller(0);	
		return false;
	});	
 
	//Previous slide by passing prev=1
	$('#btn-prev').click(function () {
		clearInterval(run);
		newsscoller(1);	
		return false;
	});	
	
	//Mouse over, pause it, on mouse out, resume the slider show
	$('#t_hpht').hover(
	
		function() {
			clearInterval(run);
		}, 
		function() {
			run = setInterval('newsscoller(0)', speed);	
		}
	); 	
	

	
$('#nuotraukos_inner, #nlist_inner li').css({width: '416px', marginLeft: '0px'});	
	$('#nuotraukos_inner, #nlist_inner li').height('263px');
	$('#zinutes_inner, #zlist_inner li').height('15px');
	var kiek_f = $('ul#nlist_inner > li').length*417+5+"px";
	
	$('#nlist_inner').css({width: kiek_f});
	
	
	$("ul#nlist_inner > li").each(function(i) {
		$(this).find('a').attr('target', '_blank');
		var a=i+1;
		$(this).find('a').attr('href', $("ul#zlist_inner li:nth-child("+a+")").find('a').html());
		
	    $(this).find('img').css({width:'416px', border: '0'});
	    //$(this).css({width:'416px', border: '0'});
	});	
	
	
	$('#nlist_inner li:first, #zlist_inner li:first').addClass('selected');
	
	//Next Slide by calling the function
	$('#btn-next_inner').click(function () {
		imgscoller(0);	
		return false;
	});	
 
	//Previous slide by passing prev=1
	$('#btn-prev_inner').click(function () {
		imgscoller(1);	
		return false;
	});		
	
	
});
 
 
function newsscoller(prev) {
 
	//Get the current selected item (with selected class), if none was found, get the first item
	var current_image = $('#nlist li.selected').length ? $('#nlist li.selected') : $('#nlist li:first');
	var current_excerpt = $('#zlist li.selected').length ? $('#zlist li.selected') : $('#zlist li:first');
 
	//if prev is set to 1 (previous item)
	if (prev) {
		
		//Get previous sibling
		var next_image = (current_image.prev().length) ? current_image.prev() : $('#nlist li:last');
		var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $('#zlist li:last');
	
	//if prev is set to 0 (next item)
	} else {
		
		//Get next sibling
		var next_image = (current_image.next().length) ? current_image.next() : $('#nlist li:first');
		var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $('#zlist li:first');
	}
 
	//clear the selected class
	$('#zlist li, #nlist li').removeClass('selected');
	
	//reassign the selected class to current items
	next_image.addClass('selected');
	next_excerpt.addClass('selected');
 
	//Scroll the items
	$('#nuotraukos').scrollTo(next_image, 800);		
	$('#zinutes').scrollTo(next_excerpt, 800);					
	
}

function imgscoller(prev) {
 
	//Get the current selected item (with selected class), if none was found, get the first item
	var current_image = $('#nlist_inner li.selected').length ? $('#nlist_inner li.selected') : $('#nlist_inner li:first');
	var current_excerpt = $('#zlist_inner li.selected').length ? $('#zlist_inner li.selected') : $('#zlist_inner li:first');
 
	//if prev is set to 1 (previous item)
	if (prev) {
		
		//Get previous sibling
		var next_image = (current_image.prev().length) ? current_image.prev() : $('#nlist_inner li:last');
		var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $('#zlist_inner li:last');
	
	//if prev is set to 0 (next item)
	} else {
		
		//Get next sibling
		var next_image = (current_image.next().length) ? current_image.next() : $('#nlist_inner li:first');
		var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $('#zlist_inner li:first');
	}
 
	//clear the selected class
	$('#zlist_inner li, #nlist_inner li').removeClass('selected');
	
	//reassign the selected class to current items
	next_image.addClass('selected');
	next_excerpt.addClass('selected');
 
	//Scroll the items
	$('#nuotraukos_inner').scrollTo(next_image, 800);		
	$('#zinutes_inner').scrollTo(next_excerpt, 800);	
}	


function SelectText(element) {
    var text = document.getElementById(element);
    if ($.browser.msie) {
        var range = document.body.createTextRange();
        range.moveToElementText(text);
        range.select();
    } else if ($.browser.mozilla || $.browser.opera) {
        var selection = window.getSelection();
        var range = document.createRange();
        range.selectNodeContents(text);
        selection.removeAllRanges();
        selection.addRange(range);
    } else if ($.browser.safari) {
        var selection = window.getSelection();
        selection.setBaseAndExtent(text, 0, text, 1);
    }
}
