
var current_image = 0;

function Previous() {
    if (current_image == 0) {
		current_image = ((slideshow_images.length)-1);
	}
	else {
		current_image--;
	}
	var image = slideshow_images[current_image][0];
	var width = slideshow_images[current_image][1];
	var height = slideshow_images[current_image][2];
	ProjectSetImage(image, width, height);
    return false;
}

function Next() {
    if (current_image == ((slideshow_images.length)-1)) {
		current_image = 0;
	} else {
		current_image++;
	}
	var image = slideshow_images[current_image][0];
	var width = slideshow_images[current_image][1];
	var height = slideshow_images[current_image][2];
	ProjectSetImage(image, width, height);
    return false;
}

function GetCurrent() {
    document.getElementById('mouseoverprojectname').innerHTML = slideshow_images[0];
}

function JSInit() {
    SetCookieColor();
}

function rolloverInit() {
	var imgParent, divImages;
	divImages = document.getElementById('catprojects').getElementsByTagName('img');
	for (var i=0, len=divImages.length; i<len; i++)
	    if ((imgParent=divImages[i].parentNode).tagName == "A" && imgParent.parentNode.id=='catprojects')
	        setupRollover( divImages[i] );
}

function SetColor(color) {
    document.getElementById('wrapper').style.backgroundColor= color;
    var expiredate = new Date();
    expiredate.setMonth(expiredate.getMonth() + 6);
    document.cookie = "BackgroundColor=" + color + ";path=/;expires=" + expiredate.toGMTString();
}

function SetCookieColor() {   
    if(document.cookie != "") {
        var cookiearray = document.cookie.split("; ");
        for(var i=0; i<cookiearray.length; i++) {
            var thiscookie = cookiearray[i].split("=");
            if(thiscookie[0] == "BackgroundColor") {
                cookiecolor = thiscookie[1];
                document.getElementById('wrapper').style.backgroundColor=cookiecolor;
            }
        }  
    }
}

function SetImage(image) {
    document.getElementById('MainImage').src = image;
}

function SetOpacity(value, id) {
  var item = document.getElementById(id);
	item.style.opacity = value/10;
	item.style.filter = 'alpha(opacity=' + value*10 + ')';
}

function CatProjectMouseover(image, thumb, cell) {
    SetImage(image);
	document.getElementById(cell).src = thumb;
}

function CatProjectMouseout(image, cell) {
	document.getElementById(cell).src = image;
}

function ProjectMouseover(div, description) {
    var fixedtext = description.replace(/_/g, " ");
    SetOpacity(10, div);
    document.getElementById('mouseoverprojectname').innerHTML = fixedtext;
}

function ProjectMouseout(div) {
    SetOpacity(4, div);
    SetText("", 'mouseoverprojectname');
}

function ProjectImageMouseover(image, width, height, current) {
    ProjectSetImage(image, width, height);
    current_image = current;
}

function ColorMouseover(id,name) {
	document.getElementById(id).src = "../images/" + name + "_f2.gif";	
}

function ColorMouseout(id,name) {
	document.getElementById(id).src = "../images/" + name + ".gif";	
}

function SetText(text, div) {
    var fixedtext = text.replace(/_/g, " ");
    document.getElementById(div).innerHTML = fixedtext;
}

function ProjectSetImage (image, width, height) {
	document.getElementById('largeimage').innerHTML = '<img src="' + image + '" alt="' + image + '" width="' + width + '" height="' + height + '" border="0" />';
}

