
var nr=0;
window.onload = function load_modules(){
document.getElementById("gallery_left_arrow").onclick=Function('clearTimeout(ti);left();setTimeout("loop()",5000);return false');
document.getElementById("gallery_right_arrow").onclick=Function('loop();return false');
ti=setTimeout('loop()',2000);
}

function left(){
var g=document.getElementById("browse").style.marginLeft.split("px").join("");
var w=document.getElementById("browse").getElementsByTagName('span')[0].offsetWidth+20;
var c=parseInt(g)+(1*w);
if(c<=0){
opacity("browse", parseInt(g), c, 500,"marginLeft");
}else{
opacity("browse", parseInt(g), (document.getElementById("browse").getElementsByTagName('span').length-4)*-w, 500,"marginLeft");	
}
}

function right(){
var g=document.getElementById("browse").style.marginLeft.split("px").join("");
var w=document.getElementById("browse").getElementsByTagName('span')[0].offsetWidth+20;

if(!g){g=0;}
var c=parseInt(g)-(1*w);
if(c>=(document.getElementById("browse").getElementsByTagName('span').length-4)*-w){
opacity("browse", parseInt(g), c, 500,"marginLeft");
}else{
opacity("browse", parseInt(g), 0, 500,"marginLeft");
}
}



var ti;
function loop(){
clearTimeout(ti);
right();
ti=setTimeout('loop('+nr+')',5000);
}



function opacity(id, opacStart, opacEnd, speed,type) {
exampleFx = new Fx.Tween(id, {property: type,duration: speed, transition: Fx.Transitions.Quart.easeInOut});
exampleFx.start(opacStart,opacEnd);
return exampleFx;
}
