$(document).ready(function(){
						   
		$("#secondary-links-t li a").each(function(index){	
		var index1 = $(this).attr('rel');
			$(this).hover(function(){				
				onBg(index1,0);
			},
			function(){				
				onBg(index1,1);
			});		
		});
		if (typeof document.body.style.maxHeight != "undefined") {
		  $(document).ready(function(){ 
			changeLayout();
		  });
		  $(window).resize(function(){
			changeLayout();
		  });
		  }
		
		  $(window).scroll(function(){
		  changeLayout();
		  })
	});
	
	function navScrollBg(i,index,flag) {
		var a=[0,160,320,480];	
		var spans = $("#secondary-links-t .link" + index+" .decorate");
		if(flag == 0){
			spans.css("background-position",(0 - a[i]) + "px" + " " + (0-((index-1)*110)) +"px");			
		}
		else{
			a.sort(function(b,c){return c-b;});			
			spans.css("background-position",(0 - a[i]) + "px" + " " + (0-((index-1)*110)) +"px");
		}
	}
	function onBg(index,flag){
		for(var i=0; i<4; i++){
			setTimeout("navScrollBg(" + i + "," + index +","+flag+")",40 * i);  
		}
	}
	
	function changeLayout(){
		if($(window).height()>700)
		{
			$('div.page-header,body').removeAttr('style');
			return 0;
		}
	  var _offset_y = 0;
	  _offset_y = $(window).height();
	   _header_y = $('div.page-header').height();
		_container_y = $('.page-container').height();
	   _container_y = Math.max(_container_y,_offset_y);
	   _scroll_Y  = $(window).scrollTop();
	   $('body').height(_container_y);
		if(_container_y - _offset_y - _scroll_Y < 154){
		  $('div.page-header,body').removeAttr('style');
		  $('div.page-header').css({
								  height: _header_y,
								  position: 'absolute',
								  top: (_container_y-700)+'px'
								  });
		}else{
		  $('div.page-header,body').removeAttr('style');
		}
	}


