var detail=350;

function init_slide(image_object, images, width, aspect_ratio, delay, slide_time)
{
	setTimeout(function() { slide_img(image_object,images,width,aspect_ratio,delay,slide_time,0); },delay);
}

function slide_img(image_object, images, width, aspect_ratio, delay, slide_time, cur)
{
	var split_time=Math.floor(slide_time/detail);
	var resize_part=(2*(width-10))/detail;
	cur++;
	/*if(cur >= images.length) {
		cur=0;
	}*/
	if(cur < images.length) {
		setTimeout(function() { slide_part(image_object,images[cur],1,resize_part,(width-resize_part),aspect_ratio,0,0,split_time); },split_time);
		setTimeout(function() { slide_img(image_object,images,width,aspect_ratio,delay,slide_time,cur); }, delay+slide_time);
 	} else {
		setTimeout(function() { slide_part(image_object,images[0],1,resize_part,(width-resize_part),aspect_ratio,0,0,split_time); },split_time);
	}
}


function slide_part(image_object,img, piece, resize_part, target_width, ratio, margin_top, margin_left, split_time)
{
	image_object.width = target_width;
	if(piece==(detail/2)+1) {
		image_object.src=img;
	}
	if(piece<=(detail/2)) {
		margin_left+=resize_part;
		margin_top+=resize_part*ratio;
	} else {
		margin_left-=resize_part;
		margin_top-=resize_part*ratio;
	}
	image_object.style.marginTop = Math.round(margin_top/4)+"px";
	image_object.style.marginLeft = Math.round(margin_left/2)+"px";
	
	if(piece<=(detail/2)) {
		target_width-=resize_part;
	} else {
		target_width+=resize_part;
	}
	
	if(piece<detail) {
		setTimeout(function() { slide_part(image_object,img,piece+1,resize_part,target_width,ratio,margin_top,margin_left,split_time); }, split_time);
	}
}