
/*****************~ Start of 'home' product ~*****************/
speed = 5;
t = 10;
function $(e) {
	return document.getElementById(e);
}
function getDivByClass(name, node) {
	var e = new Array();
	var divs = node.getElementsByTagName('div');
	var cn = new RegExp("(^|\\s)" + name + "(\\s|$)");
	for (d = 0, c = 0; d < divs.length; d++) {
		if (cn.test(divs[d].className)) {
			e[c] = divs[d];
			c++;
		}
	}
	return e;
}
function getFeatures() {
	var a = document.getElementById('featureaccordion');
	if (a != null) {
		return a.getElementsByTagName('li');
	} else {
		return false;
	}
}
function setActiveImage(content) {
	e = document.getElementById('activeimage');
	if (e != null) {
		if (e.style.display != 'inline') {
			e.style.display = 'inline';
		}
		if (content != undefined) {
			e.innerHTML = content;
		} else {
			e.innerHTML = '';
		}
	}
}
function divDisplay(div, value) {
	if (value == undefined) {
		return div.style.display;
	} else {
		div.style.display = value;
	}
}
function divHeight(div, value) {
	if (value == undefined) {
		if (divDisplay(div) != 'none' && divDisplay(div) != '') {
			return div.offsetHeight;
		}
		viz = div.style.visibility;
		div.style.visibility = 'hidden';
		o = divDisplay(div);
		divDisplay(div, 'block');
		r = parseInt(div.offsetHeight);
		divDisplay(div, o);
		div.style.visibility = viz;
		return r;
	} else {
		div.style.height = value;
	}
}
function ct(d) {
	d = $(d);
	if (divHeight(d) > 0) {
		v = Math.round(divHeight(d) / speed);
		v = (v < 1) ? 1 : v;
		v = (divHeight(d) - v);
		divHeight(d, v + 'px');
		d.style.opacity = (v / d.maxh);
		d.style.filter = 'alpha(opacity=' + (v * 100 / d.maxh) + ');';
	} else {
		divHeight(d, 0);
		divDisplay(d, 'none');
		clearInterval(d.t);
	}
}
function et(d) {
	d = $(d);
	if (divHeight(d) < d.maxh) {
		v = Math.round((d.maxh - divHeight(d)) / speed);
		v = (v < 1) ? 1 : v;
		v = (divHeight(d) + v);
		divHeight(d, v + 'px');
		d.style.opacity = (v / d.maxh);
		d.style.filter = 'alpha(opacity=' + (v * 100 / d.maxh) + ');';
	} else {
		divHeight(d, 'auto');
		d.style.opacity = 100;
		d.style.filter = 'alpha(opacity=100);';
		clearInterval(d.t);
	}
}
function collapse(d) {
	if (divDisplay(d) == 'block') {
		d.maxh = divHeight(d);
		clearInterval(d.t);
		d.t = setInterval('ct("' + d.id + '")', t);
	}
}
function expand(d) {
	if (divDisplay(d) == 'none') {
		divDisplay(d, 'block');
		d.style.height = '0px';
		clearInterval(d.t);
		d.t = setInterval('et("' + d.id + '")', t);
	}
}
function featureClick() {
	if (lis = getFeatures()) {
		for (l = 0; l < lis.length; l++) {
			var title = getDivByClass('title', lis[l]);
			var selectedfeature = false;
			for (i = 0; i < title.length; i++) {
				if (this == title[i]) {
					//This is the feature we're on so set the flag to true
					title[i].onclick = null;
					title[i].className = 'title';
					selectedfeature = true;
				} else {
					title[i].onclick = featureClick;
					title[i].className = 'title clickable';
				}
			}
			if (selectedfeature == true) {
				var bodytext = getDivByClass('text', lis[l]);
				for (i = 0; i < bodytext.length; i++) {
					expand(bodytext[i]);
				}
				var image = getDivByClass('image', lis[l]);
				for (i = 0; i < image.length; i++) {
					setActiveImage(image[i].innerHTML);
				}
				if (image.length == 0) {
					document.getElementById('activeimage').innerHTML = '';
				}
			} else {
				var bodytext = getDivByClass('text', lis[l]);
				for (i = 0; i < bodytext.length; i++) {
					collapse(bodytext[i]);
				}
			}
		}
	}
}
function initFeatureAccordion() {
	if (lis = getFeatures()) {
		//Setup contents of individual features, excluding the first
		for (l = 0; l < lis.length; l++) {
			lis[l].className = 'scripted';
			var bodytext = getDivByClass('text', lis[l]);
			var image = getDivByClass('image', lis[l]);
			for (i = 0; i < image.length; i++) {
				image[i].style.display = 'none';
			}
			if (l == 1) {
				for (i = 0; i < bodytext.length; i++) {
					bodytext[i].style.display = 'block';
					bodytext[i].style.overflow = 'hidden';
					bodytext[i].maxh = divHeight(bodytext[i]);
				}
				for (i = 0; i < image.length; i++) {
					setActiveImage(image[i].innerHTML);
				}
			} else {
				var title = getDivByClass('title', lis[l]);
				for (i = 0; i < title.length; i++) {
					title[i].onclick = featureClick;
					title[i].className = 'title clickable';
				}
				for (i = 0; i < bodytext.length; i++) {
					bodytext[i].style.display = 'none';
					bodytext[i].style.overflow = 'hidden';
					bodytext[i].maxh = divHeight(bodytext[i]);
				}
			}
		}
	}
}
/*****************~ End of 'home' product ~*****************/


