// JavaScript Document
$(document).ready(function() {
	//calculate bar(middle part) width according current screen
	$("#bar_center").css("width",$(window).width()-234);	
	
	//event click for button-hide bar
	$(".hide_bar_hover").bind("click", function(){	
			$(this).blur();
			hideBar(); 
	});

	//event click for button-show bar
	$(".show_bar_hover").bind("click", function(){
			$(this).blur();
			showBar(true);		 
	});
	
	//resize bar according browser changed width
	$(window).resize(function() {
  			$("#bar_center").css("width", $(window).width()-234);
		});

	//	change link color on hover event
	$('#bar_center a, #top-links a').hover(
    function() {
       $(this).stop().animate({ color: '#00047a' }, 300);
    },
    function() {
       $(this).stop().animate({ color: '#ffffff' }, 300);
    }
	);
	
	//change image button on hover event
	$('#div_hide_hover, #div_show_hover ').hover(
    function() {
        $(this).find('span').stop().fadeTo(300, 1);
    },
    function() {
        $(this).find('span').stop().fadeTo(300, 0);
		
    }
	)
	
		//tooltip hover button
	$(".hide_bar_hover, .show_bar_hover").tooltip({ position: "top left",effect:"slide",slideFade: true, slideOutSpeed:0, offset:[10, 23]});
	
	page = location.href.substr(location.href.lastIndexOf("/")+1);
	
	if(page != "contact" && page != "site-map" ){
		//delay for showing bar
		setTimeout("showBar(false);",3000);
	}
	
});

function showBar(hideBar){	
	if(hideBar){		
		$("#bar_button_show").animate({"bottom": "-40px"}, 1000,function(){
				$("#bar_left, #bar_center, #bar_button_hide").stop().animate({"bottom": "0px"}, 1000);
			});		
	}
	else $("#bar_left, #bar_center, #bar_button_hide").stop().animate({"bottom": "0px"}, 1000);

}
function hideBar(){	
	$("#bar_left, #bar_center, #bar_button_hide").stop().animate({"bottom": "-58px"}, 1000, function(){
		$("#bar_button_show").stop().animate({"bottom": "0px"}, 1000);	
	});
}	
