/* Show and hide divs - from http://cross-browser.com/toys/dsds.html */
// if js is disabled we want app elements to be visible
// so they are visible by default in the CSS
document.write("<" + "style type='text/css'>.app{display:none;}<" + "/" + "style>");
function dsds_onload() {
	var ln=1, // lnk number
			lo=1; // lnk object
	for (; lo; ++ln) {
		lo = document.getElementById('lnk' + ln);
		if (lo) {
			lo.appId = 'app' + ln;
			lo.onclick = dsds_onclick;
		}
	}
	window.currentAppId = null; // global
}

/* Image Cross Fade Redux Version 1.0. Last revision: 02.15.2006. steve@slayeroffice.com Please leave this notice intact. Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/xfade2.html */
// window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
function so_init(str) {
	if(!d.getElementById || !d.createElement)return;
	css = d.createElement("link");
	// css.setAttribute("href","xfade2.css");
	// css.setAttribute("rel","stylesheet");
	// css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);
	imgs = d.getElementById("fadeImg" + str).getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = .99;
	setTimeout(so_xfade,5000);
}
function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;
	cOpacity-=.05; 
	nOpacity+=.05;
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	setOpacity(imgs[current]); 
	setOpacity(imgs[nIndex]);
	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,5000);
	} else {
		setTimeout(so_xfade,50);
	}
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
}

function showHide(str) {
	var ln=1, // lnk number
			lo=1; // lnk object
	for (; lo; ++ln) {
		if (ln == str) {
			var e;
			appId = 'app' + ln;
			e = document.getElementById(appId);
			e.style.display = 'block';
			so_init(str);
		} else {
			var e;
			lnkId = ln;
			appId = 'app' + ln;
			e = document.getElementById(appId);
			e.style.display = 'none';
		}
	}
}

// assumes app elements have display:none initially
function dsds_onclick() {
	var e;
	if (currentAppId && currentAppId != this.appId) {
		e = document.getElementById(currentAppId);
		e.style.display = 'none';
	}
	e = document.getElementById(this.appId);
	if (e.style.display == 'block') {
		e.style.display = 'none';
		currentAppId = null;
	} else {
		e.style.display = 'block';
		so_init(this.lnkId);
		currentAppId = this.appId;
	}
	return false;
}
function dsds2_onload() {
	var ln=1, // lnk number
			lo=1; // lnk object
	for (; lo; ++ln) {
		lo = document.getElementById('lnkb' + ln);
		lo1 = document.getElementById('appb1');
		if (lo) {
			first = 1;
			lo1.style.display = 'block';
			lo.appbId = 'appb' + ln;
			lo.onclick = dsds2_onclick;
		}
	}
	window.currentAppbId = null; // global
}
// assumes app elements have display:none initially
function dsds2_onclick() {
	var e;
	if (first == 1) {
		lo1.style.display = 'none';
		first = 0;
	}
	if (currentAppbId && currentAppbId != this.appbId) {
		e = document.getElementById(currentAppbId);
		e.style.display = 'none';
	}
	e = document.getElementById(this.appbId);
	if (e.style.display == 'block') {
		e.style.display = 'none';
		currentAppbId = null;
	} else {
		e.style.display = 'block';
		currentAppbId = this.appbId;
	}
	return false;
}
/* End hide divs */