function switchDetailP(w){
	$(".detailP img:visible").hide();
	$(".detailP img:eq("+(w-1)+")").fadeIn("slow");
	$(".sepDetailP a").each(function(i){
		if($(this).data("n")==w){
			$(this).addClass("now");						 
		}else{
			$(this).removeClass("now");
		}
		if($(this).data("n")==0 && w==1){
			$(this).css({visibility:"hidden"});
		}else if($(this).data("n")==(pAmount+1) && w==pAmount){
			$(this).css({visibility:"hidden"});
		}else{
			$(this).css({visibility:"visible"});
		}
	});
	
	$(".zoomBtn").attr("href", $(".detailP img:eq("+(w-1)+")").attr("alt"));
	
	nowDetailP=w;
}

$(document).ready(function(){	
	$(".detailP img:not(:first)").hide();
	
	pAmount=$(".detailP img").get().length;
	nowDetailP=1;
	$(".sepDetailP a").each(function(i){
		$(this).data("n", i);
		$(this).click(function(){
			if($(this).data("n")>0 && $(this).data("n")<=pAmount){
				if($(this).data("n")!=nowDetailP){
					switchDetailP($(this).data("n"));
				}
			}else if($(this).data("n")==0){
				switchDetailP(nowDetailP-1);
			}else if($(this).data("n")==pAmount+1){
				switchDetailP(nowDetailP+1);
			}
			return false;
		}).focus(function(){
			$(this).blur();
		});
	});
	switchDetailP(nowDetailP);
	
	$(".zoomBtn").lightBox();
});

