var iMax;
var iScroll;
var topPos;
var scrolltimer;

function initScroll(){
	document.getElementById('contentmain').style.top=0;
	if (document.layers) {
		iMax = document.layers['contentmain'].document.height;
		iScroll = document.layers['contentmask'].document.height;
		var butdown = eval(document.arrowdown);
	}else if (document.getElementById) {
		iMax = document.getElementById('contentmain').clientHeight;
		if(iMax == 0){
			iMax = document.getElementById('contentmain').scrollHeight;	
		}
		iScroll = document.getElementById('contentmask').clientHeight;
		if(iScroll == 0){
			iScroll = document.getElementById('contentmask').scrollHeight;
		}
		var butdown = eval("document.getElementById('arrowdown').style");
	}else if (document.all) {
		iMax = document.all['contentmain'].clientHeight;
		iScroll = document.all['contentmask'].clientHeight;
		var butdown = eval(document.all.document.arrowdown.style);
    }
	if(iMax > iScroll){
		butdown.backgroundImage = "url(" + sImgs[3] + ")";
	}
}

function verScroll(dir, spd, loop) {
	loop = true;
	direction = "up";
	speed = 15;
	scrolltimer = null;
	if (document.layers) {
		var page = eval(document.contentmain);
	}else if (document.getElementById) {
		var page = eval("document.getElementById('contentmain').style");
	}else if (document.all) {
		var page = eval(document.all.contentmain.style);
    }
	direction = dir;
	speed = parseInt(spd);
	var y_pos = parseInt(page.top);
	if (document.layers) {
		var butup = eval(document.arrowup);
		var butdown = eval(document.arrowdown);
	}else if (document.getElementById) {
		var butup = eval("document.getElementById('arrowup').style");
		var butdown = eval("document.getElementById('arrowdown').style");
	}else if (document.all) {
		var butup = eval(document.all.document.arrowup.style);
		var butdown = eval(document.all.document.arrowdown.style);
	}
	if (loop == true) {
		if (direction == "dn") {
			topPos = parseInt(document.getElementById('contentmain').style.top);
			if (topPos*-1<iMax-iScroll){ 
				page.top = (y_pos - (speed)) + 'px';
				butup.backgroundImage = "url(" + sImgs[1] + ")";
			}else{
				butdown.backgroundImage = "url(" + sImgs[2] + ")";
				clearTimeout(scrolltimer);
				return false;
			}
		} else {
			if (y_pos < 0) {
				page.top = (y_pos + (speed)) + 'px';
				butdown.backgroundImage = "url(" + sImgs[3] + ")";
			} else {
				butup.backgroundImage = "url(" + sImgs[0] + ")";
				clearTimeout(scrolltimer);
				return false;
	  		}
		}
	try{
		scrolltimer = setTimeout("verScroll(direction,speed)", 1);
	}catch(e){
		//
	}
   }
}

function stopScroll() {
	try{
		loop = false;
		clearTimeout(scrolltimer);
	}catch(e){
		//
	}
}


