// JavaScript Document

// JavaScript Document
function opacity(id, opacStart, opacEnd, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

var portfolioRunning = false;
var portfolioAutoRun = true;
var portfolioCurrentId = 0;
var portfolioBuffer = 0;
function portfolioStart() {
	if(portfolioAutoRun) {
		portfolioNext(false);
		setTimeout("portfolioStart()", 4000);
	}
}
function portfolioNext(killAuto) {
	if(killAuto) {
		portfolioAutoRun = false;
	}
	if(portfolioCurrentId >= portofilioTotal) {
		portfolioSwitch(1);
	} else {
		portfolioSwitch(portfolioCurrentId + 1);
	}
}
function portfolioBack(killAuto) {
	if(killAuto) {
		portfolioAutoRun = false;
	}
	if(portfolioCurrentId == 1) {
		portfolioSwitch(portofilioTotal);
	} else {
		portfolioSwitch(portfolioCurrentId - 1);
	}
}
function portfolioClick(id) {
	portfolioAutoRun = false;
	portfolioSwitch(id)
}
function portfolioSwitch(id) {
	
	if(portfolioBuffer && portfolioBuffer != id) {
		return false;
	}
	if(portfolioBuffer) {
		portfolioBuffer = 0;
	}
	if(portfolioCurrentId == id) {
		return false;
	}
	if(portfolioRunning) {
		portfolioBuffer = id;
		setTimeout("portfolioSwitch("+id+")", 300);
		return false;
	}
	for (var i = 1; i <= portofilioTotal; i++) {
		document.getElementById('miSlideShowButton'+i).className = 'miSlideShowButton';
		document.getElementById('miSlideShowButton'+i).style.color = '#000';
	}
	document.getElementById('miSlideShowButton'+id).className = 'miSlideShowButtonOn';
	portfolioCurrentId = id;
	portfolioRunning = true;
	opacity('ImgImage', 100, 0, 500);
	portfolioFadeOutText(1, id);
}
function portfolioFadeOutText(color, id) {
	/*
	var colorCode = '000';
	switch(color) {
		case 2:
			document.getElementById('ImgContent').style.color = '#1e1d19';
			document.getElementById('ImgName').style.color = '#1e1d19';
			break;
		case 5:
			document.getElementById('ImgContent').style.color = '#4a473c';
			document.getElementById('ImgName').style.color = '#4a473c';
			break;
		case 8:
			document.getElementById('ImgContent').style.color = '#7e7764';
			document.getElementById('ImgName').style.color = '#7e7764';
			break;
		case 10:
			document.getElementById('ImgContent').style.color = '#b1a78d';
			document.getElementById('ImgName').style.color = '#b1a78d';
			break;
		case 12:
			document.getElementById('ImgContent').style.color = '#ddd1b0';
			document.getElementById('ImgName').style.color = '#ddd1b0';
			break;
		case 15:
			document.getElementById('ImgContent').style.color = '#fceec9';
			document.getElementById('ImgName').style.color = '#fceec9';
			break;
	}
	*/
	color++;
	if(color <= 15) {
		setTimeout("portfolioFadeOutText("+color+","+id+")", 33);
	} else {
		portfolioShow(id);
	}
}
function portfolioFadeInText(color) {
	/*
	var colorCode = 'fceec9';
	switch(color) {
		case 2:
			//document.getElementById('ImgContent').style.color = '#1e1d19';
			//document.getElementById('ImgName').style.color = '#1e1d19';
			break;
		case 5:
			//document.getElementById('ImgContent').style.color = '#4a473c';
			document.getElementById('ImgName').style.color = '#4a473c';
			break;
		case 8:
			//document.getElementById('ImgContent').style.color = '#7e7764';
			document.getElementById('ImgName').style.color = '#7e7764';
			break;
		case 10:
			//document.getElementById('ImgContent').style.color = '#b1a78d';
			document.getElementById('ImgName').style.color = '#b1a78d';
			break;
		case 12:
			//document.getElementById('ImgContent').style.color = '#ddd1b0';
			document.getElementById('ImgName').style.color = '#ddd1b0';
			break;
		case 15:
			//document.getElementById('ImgContent').style.color = '#fceec9';
			document.getElementById('ImgName').style.color = '#fceec9';
			break;
	}*/
	color--;
	if(color >= 0) {
		setTimeout("portfolioFadeInText("+color+")", 33);
	} else {
		portfolioRunning = false;
	}
}
function portfolioShow(id) {
	document.getElementById('slideShowURL').href = document.getElementById('ImgURL'+id).innerHTML;
	//load up new image
	document.getElementById('ImgImage').src = document.getElementById('ImgImage'+id).src;
	document.getElementById('ImgImage').alt = document.getElementById('ImgImage'+id).alt;
	opacity('ImgImage', 0, 100, 500);
	portfolioFadeInText(14);
}