
$().ready(function(){
	//slide("slide_area",15000,90,120);	
	//slide("slide_area1",6000,75,100);
	//slide("slide_area2",6000,75,100);
	//slide("slide_area3",15000,90,120);
	
});
function pictrueInit1(obj){
    var imgobjs = obj.find("li:nth-child(1)").find("img[path]");
    getImageSize(imgobjs,90,120);
}
function addPictrueBefore1(obj){
    var imgobjs = obj.find("li:nth-child(2)").find("img[path]");
    getImageSize(imgobjs,90,120);
}
function addPictrueAfter1(obj){

}


function pictrueInit2(obj){
    var imgobjs = obj.find("li:nth-child(1)").find("img[path]");
    getImageSize(imgobjs,75,100);
}

function addPictrueBefore2(obj){
    var imgobjs = obj.find("li:nth-child(2)").find("img[path]");
    getImageSize(imgobjs,75,100);
}
function addPictrueAfter2(obj){

}




function getImageSize(imgobjs,width,height){
    var imgPaths = [];
    imgobjs.each(function(){$(this).attr("src",$(this).attr("path"));imgPaths.push($(this).attr("path"));});
    if(imgPaths.length > 0){
		$.post("getDemi.asp",{"paths":imgPaths.join(","),"width":width,"height":height},function(text){	
			var retText = eval(text);																				 
			imgobjs.each(function(i){
			    $(this).parent().html(retText[i])});																					 
		});
	}
}


function slide(id,interval,width,height){
	var children = $("#"+id+">div");
	children.each(function(i){ $(this).hide(); }); 
	children.parent().show();
	subSlide(id,0,interval,width,height);
}
function subSlide(idStr,index,interval,width,height){
	//alert("subSlide("+idStr+","+(index+1)+","+interval+")");
	var children = $("#"+idStr+">div");
	if(index>= children.size()) index = 0;
	var preIndex = index-1 <0 ? children.size()-1:index-1;
	
	var imgs = $(children[index]).find("img");
	var imgPaths = [];
	//alert(imgs.length);
	var imgPath = $(imgs[0]).attr("path");
	//alert(imgPath + ":" + width +":" + height);
	if(imgPath && imgPath != ""){
		imgs.each(function(){$(this).attr("src",$(this).attr("path"));imgPaths.push($(this).attr("path"));});
		$.post("getDemi.asp",{"paths":imgPaths.join(","),"width":width,"height":height},function(text){	
			var retText = eval(text);																				 
			imgs.each(function(i){$(this).parent().html(retText[i])});																					 
			$(children[preIndex]).fadeOut("slow",function(i){$(this).hide();
				$(children[index]).fadeIn("slow");
				setTimeout("subSlide('"+idStr+"',"+(index+1)+","+interval+"," + width +","+height+")",interval);
			});	
		});
	}else{
		$(children[preIndex]).fadeOut("slow",function(i){$(this).hide();
			$(children[index]).fadeIn("slow");
			setTimeout("subSlide('"+idStr+"',"+(index+1)+","+interval+"," + width +","+height+")",interval);
		});	
	}
}
