var links; var pics; var slides; var opacity = 1; var stopShow; var items = new Array(); var http = getHTTPObject(); var t1; var t2; var t3;
window.onload = init;
function init() {
	if(!document.getElementById) {return false;}
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
	if(document.getElementsByTagName("body")[0].className == "project") {stopShow = document.getElementById("stopShow"); startShow();}
}
function startShow() {
	slides = new slideshow("slides");
	if(document.getElementById("screenshots")){links = document.getElementById("screenshots").getElementsByTagName("a");
	pics = document.getElementById("photo").getElementsByTagName("li");
	for(var q = 0; q < links.length - 1; q++) {slides.add_slide(new slide(links[q].src));}
	slides.transition(1);
	if(links.length > 1) {slides.play();}}
}
function slide(src) {this.src = src;}
function slideshow(ssname) { //inspired by Patrick Fitzgerald - www.barelyfitz.com
	this.name = ssname;
	this.slides = new Array();
	this.current = 0;
	this.prev = -1;
	this.timeoutid = 0;
	this.stopped = false;
	this.add_slide = function(slide) {
		var i = this.slides.length;
		this.slides[i] = slide;
	}
	this.play = function() {
		this.pause();
		this.stopped = false;
		stopShow.innerHTML = "<img src='images/pause.jpg'>";
		stopShow.onclick = function() {slides.fullStop();}
		stopShow.onmouseover = function() {window.status = "pause slideshow"; return true;}
		this.timeoutid = setTimeout(this.name + ".loop()", 6000);
	}
	this.pause = function() {
		if(this.timeoutid != 0) {
			clearTimeout(this.timeoutid);
			this.timeoutid = 0;
		}
	}
	this.fullStop = function() {
		this.pause();
		this.stopped = true;
		stopShow.innerHTML = "<img src='images/play.jpg'>";
		stopShow.onmouseover = function() {window.status = "start slideshow"; return true;}
		stopShow.onclick = function() {slides.transition(1); slides.play();}
	}
	this.update = function() {
		links[this.current].parentNode.className = "active";
		pics[this.current].className = "active";
		if(!this.stopped) {
			if(this.current > 0) {this.prev = this.current - 1;}
			else {this.prev = this.slides.length - 1;}
		}
		if(this.prev != -1) {links[this.prev].parentNode.className = "";}
		this.transition(1);
	}
	this.transition = function(i) {
		if (typeof i != 'undefined') {opacity = i;}
		if(opacity <= 10) {
			if(this.prev != -1) {pics[this.prev].style.opacity = ((10-opacity)*10)/100; pics[this.prev].style.filter = "alpha(opacity=" + (10-opacity)*10 + ")";}
			else if(this.prev == -1) {pics[this.current].className = "active";}
			pics[this.current].style.opacity = (opacity*10)/100; pics[this.current].style.filter = "alpha(opacity=" + opacity*10 + ")";
			++opacity;
			setTimeout(this.name + ".transition()", 75);
		}
		else {
			if(this.prev != -1) {pics[this.prev].className = "";}
			return true;
		}
	}
	this.next = function(n) {
		if(n < this.slides.length && n >= 0) {this.current = n;}
		this.update();
	}
	this.loop = function() {
		if(this.current < this.slides.length - 1) {next_slide = ++this.current;}
		else {next_slide = 0;}
		this.next(next_slide);
		this.play();
	}
	this.gotoSlide = function(n) {
		if((n < this.slides.length) && (n >= 0)) {
			this.fullStop();
			if(n != this.current) {
				this.prev = this.current;
				this.current = n;
			}
		}
		this.update();
	}
}
function doRollovers() {
	var images = document.getElementsByTagName("img");
	var buttons = document.getElementsByTagName("input");
	preloads = new Object();
	for(var i = 0; i < images.length; i++) {
		var imageOffSrc = images[i].src + "";
		if(imageOffSrc.indexOf("_off") != -1){
			var imageOverSrc = imageOffSrc.replace(/_off/g, "_over");
			preloads['imageOff_' + i] = new Image();
			preloads['imageOff_' + i].src = imageOffSrc;
			preloads['imageOver_' + i] = new Image();
			preloads['imageOver_' + i].src = imageOverSrc;
			images[i].onmouseover = function(){this.src = this.src.replace(/_off/g, "_over");}
			images[i].onmouseout = function(){this.src = this.src.replace(/_over/g, "_off");}
		}
	}
	for (var i = 0; i < buttons.length; i++){
		if(buttons[i].src){
			var imageOffSrc = buttons[i].src + "";
			if(imageOffSrc.indexOf("_off") != -1){
				var imageOverSrc = imageOffSrc.replace(/_off/g, "_over");
				preloads['imageOff_' + i] = new Image();
				preloads['imageOff_' + i].src = imageOffSrc;
				preloads['imageOver_' + i] = new Image();
				preloads['imageOver_' + i].src = imageOverSrc;
				buttons[i].onmouseover = function(){this.src = this.src.replace(/_off/g, "_over");}
				buttons[i].onmouseout = function(){this.src = this.src.replace(/_over/g, "_off");}
			}
		}
	}
}

function getHTTPObject() { 
	var xmlhttp; 
	/*@cc_on 
	@if (@_jscript_version >= 5) 
	try { 
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
	} catch (e) { 
		try { 
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
		} catch (E) {
			xmlhttp = false; 
		} 
	} 
	@else 
	xmlhttp = false; 
	@end @*/ 
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { 
		try { 
			xmlhttp = new XMLHttpRequest();
				xmlhttp.overrideMimeType("text/xml");
		} catch (e) { 
			xmlhttp = false; 
		} 
	} 
	return xmlhttp; 
}










