var up=0;
var mt=0;
var move_c=0;

function afterFlyDown() {
			$('#listpage_'+up).find("img").css('border','solid 0px #00a8ff')			
			up=up-move_c;	
			$('#listpage_'+up).find("img").css('border','solid 2px #00a8ff')						
}

function afterFlyUp() {
		$('#listpage_'+up).find("img").css('border','solid 0px #00a8ff')		
		up=up+move_c;	
		$('#listpage_'+up).find("img").css('border','solid 2px #00a8ff')		
}

function afterFlyLast() {
		$('#listpage_'+up).find("img").css('border','solid 0px #00a8ff')		
		up=move_c;	
		$('#listpage_'+up).find("img").css('border','solid 2px #00a8ff')			
}

function initMoveIcon(dest){
		
		var parray=$('#'+dest).position();
		mt=parray.top;
		//alert(mt);
}

function moveUp(dest,d,sp,mh) {
	
	var obj2 = document.getElementById(dest);
	if (parseInt($('#'+dest).height()) > mh) {
	//	alert(d);
//	$('#'+dest).ellipsis();
	if ((up+1) <= d) {
		up++;
		$('#'+dest).animate({"top": "-="+sp+"px"}, 500);

	}
	}
	
}
function moveDown(dest,d,sp,mh) {
		//alert('aaa');	
	var obj2 = document.getElementById(dest);
	if (parseInt($('#'+dest).height()) > mh) {
		//alert('aaa');
//	$('#'+dest).ellipsis();	
//alert(up+";"+d);
	if ((up-1) >= 0) {	
//		alert(obj2.offsetTop);
		up--;
		$('#'+dest).animate({"top": "+="+sp+"px"}, 500);	
				
	}
	}
}


function flyUp(dest,d,sp,c,mh) {
	
	var obj2 = document.getElementById(dest);
	if (parseInt($('#'+dest).height()) > mh) {
	//	alert(d);
//	$('#'+dest).ellipsis();
	if ((up+c) <= d) {
		move_c=c;
		$('#'+dest).animate({"top": "-="+(c*sp)+"px"}, 900, afterFlyUp());

	}
	}
	
}
function flyDown(dest,d,sp,c,mh) {
		//alert('aaa');	
	var obj2 = document.getElementById(dest);
	if (parseInt($('#'+dest).height()) > mh) {
		//alert('aaa');
//	$('#'+dest).ellipsis();	
		if ((up-c) >= 0) {	
	//		alert(obj2.offsetTop);
			move_c=c;
			$('#'+dest).animate({"top": "+="+(c*sp)+"px"}, 900,afterFlyDown());	

					
		}
	}
}

function flyLast(dest,sp,c,mh) {
	
	if (parseInt($('#'+dest).height()) > mh) {
//		alert(c+";"+up);
//	$('#'+dest).ellipsis();
		if (up < c) {
			move_c=c;	
			$('#'+dest).animate({"top": "-="+(sp*(c-up))+"px"}, 900 , afterFlyLast());
	
		}
	}
	
}
function flyFirst(dest,mh) {
	if (parseInt($('#'+dest).height()) > mh) {
		if (up > 0) {	
			up=0;
			move_c=0;			
			$('#'+dest).animate({"top": mt+"px"}, 900);	
					
		}
	}
}
