You could make a moveObjectLeft function and call it when the flag gets to the end like this:
Code:
function moveObjRight(obj)
{
obj.style.left=Hmove;
Hmove+=4;
if(Hmove<900)
window.setTimeout("moveObjRight(" +obj.id+ ");", 0);
else
moveObjLeft(obj);
}
function moveObjLeft(obj)
{
obj.style.left=Hmove;
Hmove-=4;
if(Hmove>0)
window.setTimeout("moveObjLeft(" +obj.id+ ");", 0);
else
moveObjRight(obj);
}
Why are you using setTimeout with a time of 0? why not just call the function directly?
Also I'm guessing you've only tested in internet explorer - HTML elements' ids are not usually global variables, so when you call moveObjxx you should really be explicit and use
document.getElementById("bar3") (both at the bottom and in the setTimeout call)
Edit - two more things - 1) language=javascript isn't really used any more, it's standard to use type="text/javascript" and 2) it's a good idea to always use some unit when setting CSS values (
obj.style.left=Hmove+"px")