setTimeout(loop, 50000);
function returns an object in JS. There is clearTimeout function that take this object as parameter.
So on event handler mouseover:
var timeout = setTimeout(loop, 50000);
slideshow.onmouseover(function(){
clearTimeout(timeout);
});
And on mouse out:
slideshow.onmouseout(function(){
setTimeout(loop, 50000);
});