scrollStep=2;
timerDown="";
timerTop="";
dir=0;

function rzCC(s){
	for(var exp=/-([a-z])/; exp.test(s); s=s.replace(exp,RegExp.$1.toUpperCase()));
	return s;
}

function _setStyle(element, declaration) {
   	if (declaration.charAt(declaration.length-1)==';')
    	declaration = declaration.slice(0, -1);
   	var k, v;
   	var splitted = declaration.split(';');
   	for (var i=0, len=splitted.length; i<len; i++) {
	   	k = rzCC(splitted[i].split(':')[0]);
	   	v = splitted[i].split(':')[1];
		eval("element.style."+k+"='"+v+"'");
	}
}

function scroll(){
	if(dir==0){
		clearTimeout(timerDown);
		clearTimeout(timerTop);
		document.getElementById("motioncontainer").scrollTop+=1;
		timerDown=setTimeout("scroll()",100);
		if(document.getElementById("motioncontainer").scrollTop>=20)
			dir=1;
	}
	if(dir==1){
		clearTimeout(timerDown);
		clearTimeout(timerTop);
		document.getElementById("motioncontainer").scrollTop-=1;
		timerTop=setTimeout("scroll()",100);
		if(document.getElementById("motioncontainer").scrollTop==0)
			dir=0;
	}
}

function scrollDown(){
	stopMe();
	document.getElementById("motioncontainer").scrollTop+=scrollStep;
	timerDown=setTimeout("scrollDown()",50);
}

function scrolltoTop(){
	stopMe();
	document.getElementById("motioncontainer").scrollTop-=scrollStep;
	timerTop=setTimeout("scrolltoTop()",50);
}

function stopMe(){
	clearTimeout(timerDown);
	clearTimeout(timerTop);
}

function loadImg(imgName){
// 	if(orientation){
// 		_setStyle(document.getElementById('bigimage'),"width:500px;height:"+img_height+"px;");
// 	}else{
// 		_setStyle(document.getElementById('bigimage'),"height:375px;width:"+img_height+"px;");
// 	}
	document.getElementById('bigimage').setAttribute("src",imgName);
}

