$(document).ready(function () {	
	
	$("#wrapper").css("display", "none");
	$("#wrapper").fadeIn(1000);
	$('#link_home').addClass('active');
	
   var pathname = window.location.pathname;
   var pathname = pathname.split('/');
   var tester = pathname[pathname.length-1];
   
  $('#lava li a').each(function(){
       var test = $(this).attr('href');
       if (test == tester){
		   $('#link_home').removeClass('active');
           $(this).addClass('active');
		   }
       });
  
  $('#nav2 a').each(function(){
       var test = $(this).attr('href');
       if (test == tester){
           $(this).addClass('active');
		   $('#link_home').removeClass('active');
		   $('#link_profil').addClass('active');
       }
   });
   
   $('a.articletitlelink').each(function(){
		   $('#link_home').removeClass('active');
		   $('#link_news').addClass('active');
   });

		//transitions
		//for more transition, goto http://gsgd.co.uk/sandbox/jquery/easing/
		var style = 'easeOutElastic';
		
		//Retrieve the active item position and width
		var default_left = Math.round($('#lava li a.active').offset().left - $('#lava').offset().left);
		var default_width = $('#lava li a.active').width();

		//Set the floating bar position and width
		$('#box').css({left: default_left});
		$('#box .head').css({width: default_width});

		//if mouseover the menu item
		$('#lava li').hover(function () {
			
			//Get the position and width of the menu item
			left = Math.round($(this).offset().left - $('#lava').offset().left);
			width = $(this).width(); 

			//Set the floating bar position, width and transition
			$('#box').stop(false, true).animate({left: left},{duration:1000, easing: style});	
			$('#box .head').stop(false, true).animate({width:width},{duration:1000, easing: style});	
		
		//if user click on the menu
		});
		
		//If the mouse leave the menu, reset the floating bar to the active item
		$('#lava').mouseleave(function () {

			//Retrieve the active item position and width
			default_left = Math.round($('#lava li a.active').offset().left - $('#lava').offset().left);
			default_width = $('#lava li a.active').width();
			
			//Set the floating bar position, width and transition
			$('#box').stop(false, true).animate({left: default_left},{duration:1500, easing: style});	
			$('#box .head').stop(false, true).animate({width:default_width},{duration:1500, easing: style});		
			
		});
   
   
   $("#direksi img[title]").tooltip({
	   offset:[300, 100],
	   effect: 'slide'
	});
   
   
   
$("#main_scroll").scrollable({

	// basic settings
	vertical: true,

	// up/down keys will always control this scrollable
	keyboard: 'static',

	// assign left/right keys to the actively viewed scrollable
	onSeek: function(event, i) {
		horizontal.eq(i).data("scrollable").focus();
	}

// main navigator (thumbnail images)
}).navigator("#net_navi");

});

$(function() {
	$("img[rel]").overlay({top:150});
});

function closeForm(){
	setTimeout('$("#contactForm").slideUp("slow")', 2000);
}
 
Cufon.replace('h1, h2, h3, h4, #decor, .articletitlelink', { fontFamily: 'qlassik' });
