﻿function $(ObjID){
	return document.getElementById(ObjID);
}
function $2(ObjID){
	return document.getElementById(ObjID);
}


function ScrollImg(ObjDiv,Obj1,Obj2,Direction,Speed){ 
    var demo1 = $2(Obj1);
    var demo2 = $2(Obj2);
    var mydiv = $2(ObjDiv);
	var Tid;
	switch(Direction){
	case "left":
		if (demo1.offsetWidth<=mydiv.offsetWidth) return;
		break;
	case "right":
		if (demo1.offsetWidth<=mydiv.offsetWidth) return;
		break;
	case "top":
		if (demo1.offsetHeight<=mydiv.offsetHeight) return;
		break;
	case "bottom":
		if (demo1.offsetHeight<=mydiv.offsetHeight) return;
		break;
	}
    demo2.innerHTML=demo1.innerHTML;
    Tid=setInterval(Marquee,Speed)
    mydiv.onmouseover=function(){clearInterval(Tid)}
    mydiv.onmouseout=function(){Tid=setInterval(Marquee,Speed)}
    
    function Marquee(){
		switch(Direction){
		case "left":
            if(mydiv.scrollLeft==demo1.offsetWidth)
                mydiv.scrollLeft=0;
            else
                mydiv.scrollLeft++;
			break;
		case "right":
            if(mydiv.scrollLeft==0)
                mydiv.scrollLeft=demo1.offsetWidth;
            else
                mydiv.scrollLeft--;
			break;
		case "top":
			if(mydiv.scrollTop>=demo2.offsetHeight)
                mydiv.scrollTop=0;
            else
                mydiv.scrollTop++;
			break;
		case "bottom":
			if(mydiv.scrollTop==0)
                mydiv.scrollTop=demo1.offsetHeight;
            else
                mydiv.scrollTop--;
			break;
		}
    }
}


function AutoHeight(ObjID1,ObjID2){
	var LeftHeight=$(ObjID1).scrollHeight;
	var RightHeight=$(ObjID2).scrollHeight;
	
	if (LeftHeight<RightHeight){
		$(ObjID1).style.height=RightHeight+"px";
	}
	else{
		$(ObjID2).style.height=LeftHeight+"px";
	}
}

