var home_img_id = 0;

$("document").ready(function(){
	
	// 初始化首页头条选择器
	selectorMouseover(1);
	
	// 首页头条内容选择器hover事件
	$("#home_imgs .selector img").hover(function(){
		var selector_id = $(this).parent().attr("id").substr(9,1);
		if( selector_id != home_img_id )
			selectorMouseover(selector_id);	
	},
	function(){
		
	});
	
});

// 首页头条内容选择器mouseover
function selectorMouseover(id){
	// 初始化
	$("#home_imgs .selector img").css("opacity","0.5");
	$("#home_imgs .selector").css("background","none");
	$("#home_imgs .home_img_content").stop(true,true);
	$("#home_imgs .home_img_content").css("display","none");
	// 实现目标
	$("#home_imgs #selector_" + id + " img").css("opacity","100");
	$("#home_imgs #selector_" + id).css("background","url(images/selector_selected_back.gif) right no-repeat");
	// $("#home_imgs #home_img_content_" + id).html("<img src='home_imgs/" + id + ".jpg' />");	
	$("#home_imgs #home_img_content_" + id).animate({height: 'toggle', opacity: 'toggle'}, "normal");
	home_img_id = id;
}

// 打开子菜单
function openSubMenu(id){
	hideSubMenuOtherThan(id);
	if($("#subMenu_" + id + ":visible").length == 1){
		$("#subMenu_" + id).hide("slow");
	}else{
		$("#subMenu_" + id).show("slow");
	}
}

// 关闭其他子菜单
function hideSubMenuOtherThan(id){
	$("#main_menu .subMenu").each(function(){
		if($(this).attr("id") != "subMenu_" + id)
			$(this).hide("slow");
	});
}

// 浏览照片
function viewPhoto(year,month,cate){
	$("#photo_browser_works .title .left").empty();
	$("#photo_browser_content").empty();
	$("#black_filter_works").fadeTo("slow",0.5,function(){
		$("#photo_browser_works").each(function(i,o){
			$(o).css("left",(($(window).width())/2-(parseInt($(o).width())/2))+"px");
			$(o).css("top",(($(window).height())/2-(parseInt($(o).height())/2))+"px");
			$(o).animate({ height: 'toggle'}, "slow", function(){
				var URLParams = "?year=" + year + "&month=" + month + "&cate=" + cate;
				var contentURL = "photo_browser_content.asp" + URLParams;
				var infoURL = "photo_browser_info.asp" + URLParams;
				$("#photo_browser_works .title .left").load(infoURL);
				$("#photo_browser_content").load(contentURL);
			});
		});
	});
}

// 关闭照片浏览器
function closeBrowser(){
	$("#photo_browser_works").animate({ height: 'toggle'}, "slow",function(){
		$("#black_filter_works").fadeOut("slow");
	});
}
