
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 = "pause slideshow";
		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 = "start slideshow";
		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 gotoNews(obj, n) {
	var links = obj.parentNode.parentNode.getElementsByTagName("li");
	for(var q = 0; q < links.length - 1; q++) {links[q].className = "";}
	obj.parentNode.className = "active";
	var news = document.getElementById("n");
	if(news.style.marginLeft != 0) {var x = parseInt(news.style.marginLeft.replace(/px/g, "")); x = -x;}
	else {var x = 0;}
	--n;
	var newx = n*650;
	slideIt(x, newx);
}
function slideIt(x, newx) { //inspired by Jeremy Keith - www.adactio.com
	if (newx > x) {x += Math.ceil((newx-x)/2);}
	else if (newx < x) {x += Math.floor((newx-x)/2);}
	else if (newx == x) {return true;}
	var obj = document.getElementById("n");
	obj.style.marginLeft = -x + 'px';
	var time = setTimeout('slideIt('+x+', '+newx+')', 75);
}
function doEffects() {
	var links = document.getElementById("portfolio").getElementsByTagName("a");
	for(var q = 0; q < links.length; q++) {
		links[q].onmouseover = function() {this.getElementsByTagName("img")[0].src = this.getElementsByTagName("img")[0].src.replace(/_off/g, "_over");}
		links[q].onmouseout = function() {this.getElementsByTagName("img")[0].src = this.getElementsByTagName("img")[0].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 @*/ 
	
}
function startFeatured() {
	if (http.readyState == 4) {
		if (http.responseText.indexOf('invalid') == -1) {
			var xmlDocument = http.responseXML;
			items = xmlDocument.getElementsByTagName("workitem");
			var preloads = new Object();
			for(var w = 0; w < items.length; w++) {
				preloads[w] = new Image();
				preloads[w].src = items[w].getAttribute("imghref") + "00_off.jpg";
			}
			randomNo = Math.floor(Math.random()*items.length);
			t1 = new featured("t1", 0);
			t2 = new featured("t2", 1);
			t3 = new featured("t3", 2);
			for(var q = 0; q < 3; q++) {
				if(randomNo < items.length-1) {++randomNo;}
				else{randomNo = 0;}
				t1.add_slide(randomNo);
				if(randomNo < items.length-1) {++randomNo;}
				else{randomNo = 0;}
				t2.add_slide(randomNo);
				if(randomNo < items.length-1) {++randomNo;}
				else{randomNo = 0;}
				t3.add_slide(randomNo);
			}
			document.getElementById("portfolio").onmouseover = featuredOn;
			document.getElementById("portfolio").onmouseout = featuredOff;
			playFeatured(1);
		}
	}
}
function featuredOff(e) {
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	var tg = (window.event) ? e.srcElement : e.target;
	try {
		var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
		while (reltg.id != "portfolio" && reltg.nodeName != 'BODY') {reltg = reltg.parentNode;}
		if (reltg.id == "portfolio") {return;}
	} catch(d) {}
	playFeatured();
}
function featuredOn(e) {
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	pauseFeatured();
}
function playFeatured(begin) {
	setTimeout('t1.play('+begin+')', 0);
	setTimeout('t2.play('+begin+')', 250);
	setTimeout('t3.play('+begin+')', 500);
}
function pauseFeatured() {
	t1.pause(); t2.pause(); t3.pause();
}
function featured(fname, pos) {
	this.name = fname;
	this.pos = pos;
	this.slides = new Array();
	this.timeoutid = 0;
	this.current = 0;
	this.prev = -1;
	this.stopped = false;
	this.opct = 1;
	this.add_slide = function(slide) {
		var i = this.slides.length;
		this.slides[i] = slide;
	}
	this.pause = function() {
		if(this.timeoutid != 0) {
			clearTimeout(this.timeoutid);
			this.timeoutid = 0;
		}
	}
	this.play = function(i) {
		this.pause();
		this.stopped = false;
		if(typeof i != 'undefined') {this.timeoutid = setTimeout(this.name + ".loop()", 0);}
		else{this.timeoutid = setTimeout(this.name + ".loop()", 7500);}
	}
	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.update = function() {
		var newImg = document.createElement('img');
		newImg.src = items[this.slides[this.current]].getAttribute("imghref") + "00_off.jpg";
		newImg.alt = items[this.slides[this.current]].getAttribute("title");
		newImg.className = "hidden";
		newImg.onmouseover = function(){
			this.src = this.src.replace(/_off/g, "_over");
			/*this.parentNode.parentNode.getElementsByTagName("span")[0].style.display = "block";*/
		}
		newImg.onmouseout = function(){
			this.src = this.src.replace(/_over/g, "_off");
			/*this.parentNode.parentNode.getElementsByTagName("span")[0].style.display = "none";*/
		}
		var newLink = document.createElement('a');
		newLink.href = items[this.slides[this.current]].getAttribute("href");
		var newTxt = document.createTextNode(items[this.slides[this.current]].getAttribute("title"));

	
	}
}
