function showDetail(id, area) {
	$.ajax({
		url: basePath+"/index.xml",
		dataType:"xml", 
		success:function(xml) {
			$(xml).find("urlset > url").each( function() {
				if ($(this).attr("id") == (id + "")) {
					var userName = $(this).find("userName").text();
					var userUrl = $(this).find("userUrl").text();
					var userImg = $(this).find("userImg").text();
					var userInfo = $(this).find("userInfo").text();
					var goodsName = $(this).find("goodsName").text();
					var goodsUrl = $(this).find("goodsUrl").text();
					var goodsPrice = $(this).find("goodsPrice").text();
						
					$("#userName").html(userName);
					$("#userName").attr("href", userUrl);
					
					$("#userImg").attr("src", userImg);
					$("#userInfo").html(userInfo);
					
					$("#goodsName").html(goodsName);
					$("#goodsName").attr("href", goodsUrl);
					
					$("#goodsPrice").html(goodsPrice);
					
					if (id < 8) {
						var commendReason = $(this).find("commendReason").text();
						$("#commendReason").html(commendReason);
						$("#clear").show();
						$("#commendReason").show();
					} else {
						$("#clear").hide();
						$("#commendReason").hide();
					}
					
					$("#detail").attr("class", "");					
					if (id == 1 || id == 3 || id == 4 || id == 5 || id == 6 || id == 7 || id == 14 || id == 15 || id == 16 || id == 17 || id == 18) {
						$("#detail").attr("class", "moou_" + 1 + " moucenter weizsmal" + id);
					} else {
						$("#detail").attr("class", "moou_" + 2 + " moucenter weizsmal" + id);
					}
					$("#detail").show(300);
					
					area.onclick = function() {
						window.open(goodsUrl);
					}
					return;
				}
			});
		}
	});
}

function hideDetail() {
	$("#detail").hide();
}

function onDetail() {
	$("#detail").show();
	clearInterval(interval);
}

function outDetail() {
	$("#detail").hide();
	startInterval();
}

$(function() {
	setTimeout(function() {
		startInterval();
	}, 1000);
});

function startInterval() {
	interval = setInterval(function() {
		var showing = $(".showing");
		var hover = $("#centerUL").children(".hover");
		
		showing.removeClass("showing").hide();
		$(".shift").removeClass("hover");
		
		var last = $(".banner").last();
		var isLast = (showing[0] === last[0]);
		if (isLast) {
			$(".banner").first().addClass("showing").fadeIn("slow");
			$(".shift").first().addClass("hover");
		} else {
			showing.next().addClass("showing").fadeIn("slow");
			hover.next().addClass("hover");
		}
	}, 8000);
}

function shiftBanner(li) {
	if ($(li).hasClass("hover")) {
		return;
	}
	
	clearInterval(interval);
	
	$(".shift").removeClass("hover");
	$(".banner").removeClass("showing").hide();
	
	$(li).addClass("hover");
	
	var index = $(li).index();
	$(".banner:eq(" + index + ")").addClass("showing").fadeIn("slow");
	
	startInterval();
}

function showPage(curPage) {
	if (parseInt($("#curPage").val()) == curPage) {
		return;
	}
	var startIndex = (curPage - 1) * 3;
	$(".goodsList").each(function(index) {
		if (index < startIndex || index >= (startIndex + 3)) {
			$(this).hide();
		} else {
			$(this).show();
		}
	});
	$(".fenye_btnhover").removeClass("fenye_btnhover");
	$(".fenye_btn:eq(" + (curPage - 1) + ")").addClass("fenye_btnhover");
	$("#curPage").val(curPage);
}
