var t=0,x=0,y=0,timer;
var xxxx=0;
function pos_Top(obj) {
	pos_T = obj.offsetTop;
	while (obj.offsetParent!=null) {
		pos_T+=obj.offsetParent.offsetTop;
		obj = obj.offsetParent;
	}
	return pos_T;
}
   
function pos_Left(obj){
	pos_L = obj.offsetLeft;
	while (obj.offsetParent!=null) {
		pos_L+=obj.offsetParent.offsetLeft;
		obj = obj.offsetParent;
	}
	return pos_L;
}

function init_scroll(xxxx) {
	//alert(document.getElementById('txt').style.marginTop);
	//b=eval(document.getElementById('pos_tab').height-16)
	if (xxxx !=null) {
		this.xxxx = xxxx;
	}
	y=0;
	x=0;
	speed=20;
	InnerBlock = document.getElementById('roll');
	BorderBlock = document.getElementById('liscont');
	InnerBlock.style.marginLeft = x+"px";
	InnerBlock.style.marginTop = x+"px";
	max_height = InnerBlock.offsetHeight -  BorderBlock.offsetHeight;


	max_width = this.xxxx - BorderBlock.offsetWidth;
	
	//if (InnerBlock.childNodes[1] !=null) {
	//	max_width = InnerBlock.childNodes[1].clientWidth - BorderBlock.offsetWidth;
	//} else {
	//	max_width = InnerBlock.offsetWidth - BorderBlock.offsetWidth;
	//}

	//alert(this.xxxx);
	//alert(max_width);
	//alert(InnerBlock.childNodes[1]);
	//alert(InnerBlock.childNodes[1].clientWidth);
	//alert(BorderBlock.offsetWidth);
}
/******************* BOTTOM section *************/
function roll_bottom() {
	if (Math.abs(y)<=max_height) {
		y-=2;
		InnerBlock.style.marginTop = y+"px";
		timer=setTimeout("roll_bottom()",speed); 
	} else {
		roll_speed_bottom();
	}
}
function roll_speed_bottom() {
	y=-max_height;
	InnerBlock.style.marginTop = y+"px";
}
/******************* BOTTOM section *************/
/******************* TOP section ****************/
function roll_top() {
	if (y<0) {
		y+=2;
		InnerBlock.style.marginTop = y+"px";
		timer=setTimeout("roll_top()",speed);
	} else {
		roll_speed_top();
	} 
}
function roll_speed_top() {
	y=0;
	InnerBlock.style.marginTop = y+"px";
}
/******************* TOP section ****************/
/******************* RIGHT section **************/
function roll_right() {
	//alert(max_width);
	if (Math.abs(x)<=max_width) {
		x-=2;
		InnerBlock.style.marginLeft = x+"px";
		timer=setTimeout("roll_right()",speed);
	} else {
		//roll_speed_right();
	}
}

function roll_speed_right() {
	x=-max_width;
	InnerBlock.style.marginLeft = x+"px";
}
/******************* RIGHT section **************/
/******************* LEFT section ***************/
function roll_left() {
	if (x<0) {
		x+=2;
		InnerBlock.style.marginLeft = x+"px";
		timer=setTimeout("roll_left()",speed);
	} else {
		//roll_speed_left();
	}
}
function roll_speed_left() {
	x=0;
	InnerBlock.style.marginLeft = x+"px";
}
/******************* LEFT section ***************/
function stop(a) {
	clearTimeout(timer);
}

window.onresize = init_scroll;
