function subContent(action){
	var timestamp = Math.round(((new Date()).getTime()-Date.UTC(1970,0,1))/1000);
	$('#sub_content_table').hide() ;
	$('#sub_content_title').hide() ;
	$('#loadingGif').show() ;
	$.post("ajax.php?t="+timestamp, { action: action },
   	function(data) {
    	if( data!='' && data!=null ){
			//alert(data.action) ;
			$('.menuBtn').css('background-color','') ;
			$('#'+nowMenu).css('background-color','#004A5F') ;
			$('#loadingGif').hide() ;
			$('#sub_content_table').show() ;
			$('#sub_content_title').attr('src',data.title) ;
			$('#sub_content_table_a').html( data.subContentTableA ) ;
			$('#sub_content_table_b').html( data.subContentTableB ) ;
			$('#sub_content_title').fadeIn() ;
			
		}
	}, "json");
		
}

function nextAlbum(){
	if( nowMenu=='menu_home' ){
		//alert(nCurPanel) ;
		if( nCurPanel>13 ){
			goSide = '.left' ;
		}else if( nCurPanel==1 ){
			goSide = '.right' ;
		}
		$(goSide).trigger("click");
		setTimeout("nextAlbum();",8000);
	}
}

$('document').ready(function(){
	
	$('.careersBtn').click(function(){	
		window.open('./careers/','careers',"menubar=0,resizable=0,location=0,status=0,scrollbars=1,width=840,height=600");
	});
	
	$('.menuBtn').mouseover(function() {
		$('.menuBtn').css('background-color','') ;
 		$(this).css('background-color','#004A5F') ;
	});
	
	$('.menuBtn').mouseleave(function() {
 		$('.menuBtn').css('background-color','') ;
		$('#'+nowMenu).css('background-color','#004A5F') ;
	});
	
	$('.menuBtn').click(function(){	
		var id = $(this).attr('id') ;
		nowMenu = id ;
		if( id=='menu_home' ){
			$('#sub_content').hide();
			$('#content').show();
			setTimeout("nextAlbum();",8000);
		}else{
			$('#content').hide();
			$('#sub_content').show();
			subContent(id) ;
		}
	});
	
	$('.menuBtn2').click(function(){	
		var gid = $(this).attr('gid') ;
		nowMenu = gid ;
		if( gid=='menu_home' ){
			$('#sub_content').hide();
			$('#content').show();
			setTimeout("nextAlbum();",8000);
		}else{
			$('#content').hide();
			$('#sub_content').show();
			subContent(gid) ;
		}
	});

	setTimeout("nextAlbum();",8000);
	
});
