currentopacity = 0;
currentimage = 1;
crossfadespeed = 2500;
fadespeed = 25;
currentlink = this.location;
fades = new Array;
numberofsets = 0;

if (document.images && totalprojectimages > 0) {
for (x = 1; x < (totalprojectimages + 1); x++) {
if (totalprojectimages > 1) {
eval ("select" + x + "on  = new Image()");
eval ("select" + x + "on.src = 'img/project" + x + "_selected_on.gif'");
eval ("select" + x + "off  = new Image()");
eval ("select" + x + "off.src = 'img/project" + x + "_selected_off.gif'");
}
eval ("projectimage1" + x + " = new Image\(\)");
eval ("projectimage1" + x + ".src = 'img/project" + x + "_image1.jpg'");
eval ("projectimage2" + x + " = new Image\(\)");
eval ("projectimage2" + x + ".src = 'img/project" + x + "_image2.jpg'");
}
}

function swapit_old () {
if (document.images) {
eval ("document.project1.src = projectimage1" + currentimage + ".src");
eval ("document.project2.src = projectimage2" + currentimage + ".src");
}
}


function changeprojectimage(location) {
for (x = 1; x < (totalprojectimages + 1); x++) {
eval ("document.select" + x + ".src = select" + x + "off.src");
}
eval ("document.select" + location + ".src = select" + location + "on.src");
currentimage = location;
fadeoutproject();
setTimeout("swapit()", crossfadespeed);
setTimeout("fadeinproject()", crossfadespeed);
}

function swapit () {
for (y=0;y < fades.length; y++) {
clearTimeout(fades[y]);
}
numberofsets = 0;
eval ("document.project1.src = projectimage1" + currentimage + ".src");
eval ("document.project2.src = projectimage2" + currentimage + ".src");
}

function fadeinproject() {
if (currentopacity < 100) {
document.getElementById("projectarea1").style.opacity=(currentopacity/100);
document.getElementById("projectarea2").style.opacity=(currentopacity/100);
currentopacity += 5;
setTimeout("fadeinproject()", fadespeed);
} else {
currentopacity = 99;
document.getElementById("projectarea1").style.opacity=(currentopacity/100);
document.getElementById("projectarea2").style.opacity=(currentopacity/100);
}
}

function fadeoutproject() {
if (currentopacity > 0) {
document.getElementById("projectarea1").style.opacity=(currentopacity/100);
document.getElementById("projectarea2").style.opacity=(currentopacity/100);
currentopacity -= 5;
fades[numberofsets] = setTimeout("fadeoutproject()", fadespeed);
numberofsets++;
} else {
currentopacity = 0;
document.getElementById("projectarea1").style.opacity=(currentopacity/100);
document.getElementById("projectarea2").style.opacity=(currentopacity/100);
}
}

function fadetitles(where,whichway) {
document.getElementById(where).style.opacity=(whichway/100);
}

function fadeboxes(where,whichway) {
projectimageshown = "select" + currentimage;
document.getElementById(projectimageshown).style.opacity=1;
if (where != projectimageshown) {
document.getElementById(where).style.opacity=(whichway/100);
}
}

function exitpage(nextpage) {
currentlink = nextpage;
fadeoutproject();
setTimeout("movepage()", crossfadespeed);
}

function movepage() {
window.location = currentlink;
}
