$(function(){
	$.ajax({
	  url: "head.html",
	  dataType: "html",
	  cache: false,
	  success: function(html){
		$("#header").html(html);
		set_nav();
		$(".about").DMenu(".about_in");
	  }
	})
	$.ajax({
	  url: "foot.html",
	  dataType: "html",
	  cache: false,
	  success: function(html){
		$("#footer").html(html);
	  }
	})
})

function set_nav(){
	var type=$("#header").attr("type");
	$(".nav a").each(function(e){
		if (e==type){
			$(this).addClass("set");	
		}
	})
side_list();
}

function side_list(){
	//$("#list_0").show();
	$(".side_content a").each(function(e){
		$(this).click(function(){
			if ($(this).attr("id")!="more_hr"){
				$(".side_content a").removeClass("set");
				$(".list_main").hide();
				$(this)	.addClass("set");		
				$("#list_"+e).show();
			}
		})							   
	})
}

function showpic(e){
	$("#list_"+e+" a").lightBox();
}
function buidpic(e,pic_path,pic_num){
	var title=$("#list_"+e+" h3").text();
	for (i=0; i<pic_num; i++){
		$("#list_"+e+" .life_pic").append("<a href=images/activity/"+pic_path+"/"+i+".jpg title="+title+"><img src=images/activity/"+pic_path+"/s_"+i+".jpg alt="+title+" /></a>");
	}
	showpic(e);
}

jQuery.fn.DMenu=function(showobj,timeout,speed){
	timeout=timeout?timeout:0;
	speed=speed?speed:200;
	var button=$(this);
	var timer=null;
	var hideDiv=$("<div style=\"z-index:10\"></div>");
	var Container=$("<div id=\"Container\"></div>");
	Container.hide();
	hideDiv.append(Container);
	var jqShowObj=$(showobj);
	jqShowObj.hide();
	var display=false;
	var offset=button.offset();
	var height=jqShowObj.height();
	var width=jqShowObj.width();
	var btnHeight=button.height();
	var btnWidth=button.width();
	$(document.body).prepend(hideDiv);
	Container.append(jqShowObj);
	var showMenu=function(){
		if (display)
		{
			return false;
		}
		Container.css({
			margin:"0 auto",
			width:btnWidth+"px",
			height:btnHeight+"px"
		});
		hideDiv.css({
			position:"absolute",
			top:offset.top-10+"px",
			left:offset.left+(btnWidth/2)-(width/2)+"px",
			height:height+"px",
			width:width+"px"
		}).show();
		Container.css({
			border:"1px solid #666666"
		});
		Container.animate({
			marginTop:btnHeight+4,
			height:height+4,
			width:width+4,
			opacity:'100'},speed,function(){
			jqShowObj.show();
			Container.append(jqShowObj);
			Container.css({
				border:"0px"
			});
			display=true;
			jqShowObj.mouseover(function(){
					clearTimeout(timer); 
			});
			jqShowObj.mouseout(function(){
				hideMenu();
			});
		});
	};

	var hideMenu=function(){
		clearTimeout(timer); 
		timer=setTimeout(function(){
		Container.css({
			border:"1px solid #666666"
		});
		Container.empty();
		Container.animate({
			  width:btnWidth,height:btnHeight,marginTop:'0', opacity: '0'
			}, speed,function(){
			Container.hide();
			hideDiv.hide();
			display=false;
		});
		}, timeout); 
	};

	button.hover(function(e){
		clearTimeout(timer); 
		timer=setTimeout(function(){
			showMenu();
		}, timeout); 
	},function(){
		clearTimeout(timer); 
		if(display){
			timer=setTimeout(function(){
				hideMenu();
			},timeout);
		}
	});
};