google.load("jquery", "1");
 
// Place init code here instead of $(document).ready()
google.setOnLoadCallback(function() { 
	var selected = $('#lang .selected p');
	var list = $('#lang .list');
	
	$(selected).click(function () { 
      $(list).slideToggle('fast'); 
    });
	
	$('.menu li.parent li:first').addClass('first');
	$('.menu li.parent li:last').addClass('last');
	
	$('#faq .faqMore').click(function(){answer = $(this).parent().children('.answer'); text = ($(answer).is(":visible"))? 'Rodyti atsakymą &raquo;' : 'Suskleisti atsakymą &raquo;'; $(this).children('span').html(text); $(answer).slideToggle('fast')});

	/* page layout adjustment*/
	var leftHeight = $('#leftSidebar').height();
	var centerHeight = $('#centerCol').height();
	var hDiff = Math.abs(centerHeight - leftHeight);
	
	var leftToAdjust = $('.leftSidebar .content').last();
	var leftToAdjustMinHeight = parseInt($(leftToAdjust).css('min-height'));
	if (centerHeight < leftHeight && leftHeight){
		// adjust left column if possible
		$(leftToAdjust).css('min-height', (leftToAdjustMinHeight - hDiff) + 'px');
		// then if center has only one box - adjust center area
		leftHeight = $('#leftSidebar').height();
		hDiff = Math.abs(centerHeight - leftHeight);
		//var toAdjust = $('#centerCol .box .content').last();
		var toAdjust = $('#centerCol .box .adjust').last();
		// if center area has only wide boxes and not column boxes (not home page)
		if ( ! $('#centerCol .boxCol').length ) {
			//$(toAdjust).css('height', ($(toAdjust).height() + hDiff) + 'px');
			$(toAdjust).css('height', hDiff + 'px');
		}
	}else{
		$(leftToAdjust).css('height', ($(leftToAdjust).height() + hDiff - 1) + 'px');
	}
	
	/* adjust center col boxes - make them have equal height */
	var centerBoxLeftCol = $('#centerCol .boxCol.fl .content').last();
	var centerBoxRightCol = $('#centerCol .boxCol.fr .content').last();
	var h1 = $(centerBoxLeftCol).height();
	var h2 = $(centerBoxRightCol).height();
	var toAdjust = (h1 < h2)? centerBoxLeftCol : centerBoxRightCol;
	$(toAdjust).css('height', Math.max(h1, h2) + 'px');
	/**/
	
	$('#footAds').html('<div id="footAds1"></div><div id="footAds2"></div>');
	
	var rotateInd = 1;
	rotate = function(){
		if (imgLogos.length){
			var s = '';
			imgLogos.sort( function(){return 0.5 - Math.random()} );
			for (i=0;i<4;i++)
				s += '<img src="' + imgRoot + '/' + imgLogos[i] + '" alt="" />';
		}
		var divShow = '#footAds' + ((rotateInd % 2 == 0)? 1 : 2);
		var divHide = '#footAds' + ((rotateInd % 2 == 0)? 2 : 1);
		//$(divShow).hide();
		$(divShow).attr('class', 'footAdBottom');
		$(divShow).html(s);
		$(divHide).attr('class', 'footAdTop');
		$(divShow).fadeIn(1500, "linear");
		$(divHide).fadeToggle(1500, "linear", function(){  $(divShow).attr('class', 'footAdTop');  });
		if (rotateInd==10) rotateInd = 1;
		else rotateInd++;
	};
	rotate();
	setInterval(rotate, 7000);
});

