t = 0;


function openimage(imgname,hgt,wid,orgname,imgnum,topmargin){
curimg = imgnum;
document.getElementById('mainsource').src = imgname;
document.getElementById('mainsource').height = hgt;
document.getElementById('mainsource').width = wid;
document.getElementById('mainimage').style.top = topmargin + 'px';
document.getElementById('mainimage').style.display = 'block';
document.getElementById('maindesc').innerHTML = orgname;
document.getElementById('gallarea').style.opacity = 0.1;
document.getElementById('gallarea').style.filter = 'alpha(opacity=10)';
document.getElementById('footer').style.opacity = 0.1;
document.getElementById('footer').style.filter = 'alpha(opacity=10)';
}

function closeimage(){
document.getElementById('mainimage').style.display = 'none';
document.getElementById('gallarea').style.opacity = 1;
document.getElementById('gallarea').style.filter = 'none';
document.getElementById('footer').style.opacity = 1;
document.getElementById('footer').style.filter = 'none';
stopgallery();
}

function nextimage(){
curimg++;
if(curimg == imgcount){
curimg = 0;
}
document.getElementById('mainsource').src = imnamarr[curimg];
document.getElementById('mainsource').height = imhgtarr[curimg];
document.getElementById('mainsource').width = imwidarr[curimg];
document.getElementById('maindesc').innerHTML = imrlnarr[curimg];
}

function previmage(){
curimg--;
if(curimg == -1){
curimg = imgcount - 1;
}
document.getElementById('mainsource').src = imnamarr[curimg];
document.getElementById('mainsource').height = imhgtarr[curimg];
document.getElementById('mainsource').width = imwidarr[curimg];
document.getElementById('maindesc').innerHTML = imrlnarr[curimg];
}

function startgallery(){
theimg = document.getElementById('mainsource');
fcounter = 100;
t = setTimeout("fadedown()",1);
document.getElementById('gstart').style.display = 'none';
document.getElementById('gstop').style.display = 'inline'
}

function stopgallery(){
theimg = document.getElementById('mainsource');
clearTimeout(t);
theimg.style.opacity = 1;
theimg.style.filter = 100;
document.getElementById('gstop').style.display = 'none'
document.getElementById('gstart').style.display = 'inline';
}

function fadedown(){
fcounter--;
newop = fcounter/100;
theimg.style.opacity = newop;
ieop = 'alpha(opacity=' + fcounter + ')';
theimg.style.filter = ieop;
if(fcounter>0){
t = setTimeout('fadedown()',15);
}
else{
nextimg();
}
}

function nextimg(){
curimg++;
if(curimg == imgcount){
curimg = 0;
}
document.getElementById('mainsource').src = imnamarr[curimg];
document.getElementById('mainsource').height = imhgtarr[curimg];
document.getElementById('mainsource').width = imwidarr[curimg];
document.getElementById('maindesc').innerHTML = imrlnarr[curimg];
t = setTimeout('fadeup()',100);
}

function fadeup(){
fcounter++;
newop = fcounter/100;
theimg.style.opacity = newop;
ieop = 'alpha(opacity=' + fcounter + ')';
theimg.style.filter = ieop;
if(fcounter<100){
t = setTimeout('fadeup()',15);
}
else{
t = setTimeout('fadedown()',2500);
}
}

