var i=(Math.ceil(Math.random()*10));
var c=0;
var t;

//Main Image
function image()
{
document.getElementById("gallery").src=("gallery"+i+".JPG");
i++;
if (i>10)
 {  i=1;  }
timedCount();
}

function timedCount()
{
c++;
t=setTimeout("timedCount()",1000);

if (c>6)
  {
  clearTimeout(t);
  c=0;
  image(); 
  } 
}