$(document).ready(function(){
	
		// functions 
		jQuery.fn.initButton = function(node){
			$(node).addClass('active');
		}
	
		function init(){
			// global menu layout
			setMenuHeight();
			$(window).resize( setMenuHeight );
	
			var categorieButtons = $('#workpage #category_list li');
			if(categorieButtons.length>0){
				setCategoryMenu(categorieButtons);
			}
		}
		
		
		function setMenuHeight(){
			var winWid = Math.max($(window).width(), 1000);
			var mnleft = (winWid*.5-500)+655;
			$('#menu_layer').css('left',mnleft);
			
			var targetHeight = $('#content_layer').height();
			var windowHeight = $(window).height()-6;
			if(windowHeight>targetHeight){
				targetHeight = windowHeight;
			}
			$('#menu_layer').height(targetHeight);
		}
		
		
		
		// -------------------- 
		
		function setCategoryMenu(arr_){
			for(var i=0; i<arr_.length; i++){
				$(arr_[i]).css('cursor','pointer').mouseover( 
					function(){ 
						//$(this).css('background-color','#eee'); 
						$(this).children('p').children('a').css('color', '#ccc');
						$(this).children('p').css('color', '#ccc');
					} 
				).mouseout(
					function(){ 
						//$(this).css('background-color','#fff');
						$(this).children('p').children('a').css('color', '#000');
						$(this).children('p').css('color', '#666'); 
					} 				
				).click(
					function(){
						location.href = $(this).children('.catename_en').children('a')[0];
					}
				);
			}
			
			
			var recommendList = $('#workpage #recommend_list li');
			for(var j=0; j<recommendList.length; j++){
				$(recommendList[j]).css('cursor','pointer').mouseover( 
					function(){ 
						$(this).children('.wname').children('a').css('color', '#999');
					} 
				).mouseout(
					function(){ 
						$(this).children('.wname').children('a').css('color', '#fff');
					} 				
				).click(
					function(){
						location.href = $(this).children('.wname').children('a')[0];
					}
				);	
			}
		}
		
		
		
		// initialize
		$("#menu_to_top").click(function(){$.scrollTo( 0, 150 );});	
		init();
});

