var $j = jQuery.noConflict();

$j(document).ready(function() {
    var brWidth = $j(window).width();
	var brHeight = $j(window).height();

	$j('#content-container').css({'height': brHeight-180+'px'});
		
	$j(".active").css({'position':'absolute', 'left':'0px', 'width':brWidth+'px'});
	$j(".next").css({'position':'absolute', 'left':brWidth+'px', 'width':brWidth+'px'});
	
	
	
	$j(".top-menu a, .cont-right h1 a, .paslaugos ul li a, .wp-pagenavi a, .cat-item a").livequery('click', (function(event) {
	    
	  $j(this).parent('li').parent('ul').children('li').removeClass('current-menu-item');
	  $j(this).parent('li').addClass('current-menu-item');
		
    	$j(".next").css({'left':brWidth+'px'});
		event.preventDefault();
		url = this.href;

		$j.get(  
             url,
             function(responseText){  
               var text = responseText;
               
               $j(".next").html('');
               $j(".next").append($j(text).find('.content-2').html());
			   Cufon.replace('.next');
			   

        $j('#content-container h1, #content-container h2, #content-container h3, #content-container h4, #content-container h5').css({ 'visibility' : 'visible' }); 
        $j('#content-container').css({ 'visibility' : 'visible' });

	$j(".active").animate({'left':'-'+brWidth+'px'});
	$j(".next").css({'position':'absolute', 'left':brWidth+'px', 'width':brWidth+'px'});
	$j(".next").animate({'left':'0px'});
	
	$j(".active").addClass("tmp");
	$j(".next").removeClass("next").addClass("active");
	$j(".tmp").removeClass("active").removeClass("tmp").addClass("next").html('').css({'height':'100%'});			   

		   }  
         );  
		if (typeof(window.history.replaceState) == 'function'){
			window.history.replaceState(null,jQuery(this).html(),jQuery(this).attr('href').replace('http://www.bigfish.lt', ''));
		} else {
			location.hash=jQuery(this).attr('href').replace('http://www.bigfish.lt/', '');
		}
    }));
});
