if (typeof Optametra === 'undefined' || !Optametra) {
	var Optametra = {};
}
if (!Optametra.addListener) {
	Optametra.addListener = (function() {
		if (window.addEventListener) { return function(o, t, f) { o.addEventListener(t, f, false); }; }
		else if (window.attachEvent) { return function(o, t, f) { o.attachEvent('on' + t, f); }; }
		else { return function() { }; }
	} ());
}
if (!Optametra.removeListener) {
	Optametra.removeListener = (function() {
		if (window.removeEventListener) { return function(o, t, f) { o.removeEventListener(t, f, false); }; }
		else if (window.detachEvent) { return function(o, t, f) { o.detachEvent('on' + t, f); }; }
		else { return function() { }; }
	} ());
}
if (!Optametra.homeAlt) {
	Optametra.homeAlt = (function() {
		var contentAlt = [];
		contentAlt[0] = 'Explosive growth of bandwidth';
		contentAlt[1] = 'Constellation diagrams';
		contentAlt[2] = 'Eye diagrams';
		contentAlt[3] = 'Bit Error Rate';
		contentAlt[4] = 'Poincare Sphere';
		contentAlt[5] = 'Q plots and more!';
		function setSrc(o, src) { return function() { if (o && o.className !== 'active') { o.src = src; } }; }
		function setupImageRollover(id) {
			var img, imgSrc, overSrc;
			img = document.getElementById(id);
			if (img && (imgSrc = img.src)) {
				overSrc = imgSrc.replace('up.', 'dn.');
				(new Image()).src = overSrc;
				Optametra.addListener(img, 'mouseout', setSrc(img, imgSrc));
				Optametra.addListener(img, 'mouseover', setSrc(img, overSrc));
			}
		}
		function swapContent(index) {
			if (index >= 0 && index < 6) {
				var content, mediaAlt, nodes, i;
				content = document.getElementById('homeSwfContent');
				mediaAlt = document.getElementById('mediaAlt');
				if (content && mediaAlt) {
					nodes = mediaAlt.getElementsByTagName('img');
					if (nodes && nodes.length >= 6) {
						for (i = 0; i < 6; i++) {
							if (i !== index) {
								nodes[i].className = '';
								nodes[i].src = nodes[i].src.replace('Over.', 'Out.');
							}
						}
						nodes[index].className = 'active';
						nodes[index].src = nodes[index].src.replace('Out.', 'Over.');
						content.src = '2009/swfAlt/home' + index + '.jpg';
						content.alt = contentAlt[index];
					}
				}
			}
		}
		function callSwapContent(index) { return function() { swapContent(index); }; }
		function setupAltContent(img, index) {
			var imgSrc, overSrc;
			if ((imgSrc = img.src)) {
				imgSrc = imgSrc.replace('Over.', 'Out.');
				overSrc = imgSrc.replace('Out.', 'Over.');
				(new Image()).src = overSrc;
				Optametra.addListener(img, 'click', callSwapContent(index));
				Optametra.addListener(img, 'mouseout', setSrc(img, imgSrc));
				Optametra.addListener(img, 'mouseover', setSrc(img, overSrc));
			}
		}
		function windowLoad() {
			var i, mediaAlt, nodes;
			Optametra.removeListener(window, 'load', windowLoad);
			setupImageRollover('topNav2');
			setupImageRollover('topNav3');
			setupImageRollover('topNav4');
			setupImageRollover('topNav5');
			setupImageRollover('topNav6');
			mediaAlt = document.getElementById('mediaAlt');
			if (mediaAlt && mediaAlt.clientHeight > 10) {
				nodes = mediaAlt.getElementsByTagName('img');
				if (nodes && nodes.length >= 6) {
					nodes[0].className = 'active';
					for (i = 0; i < 6; i++) {
						setupAltContent(nodes[i], i);
					}
					for (i = 1; i < 6; i++) {
						(new Image()).src = '2009/swfAlt/home' + i + '.jpg';
					}
				}
			}
		}
		Optametra.addListener(window, 'load', windowLoad);
		return true;
	} ());
}
if (!Optametra.homeScroll) {
	Optametra.homeScroll = (function() {
		function calculateHeight(vp) {
			var parent, children, child, totalHeight = 9, i, l;
			parent = vp.parentNode;
			children = parent.childNodes;
			for (i = 0, l = children.length; i < l; i++) {
				child = children[i];
				if (child !== vp && 1 === child.nodeType) {
					totalHeight += child.offsetHeight;
				}
			}
			vp.style.height = (parent.offsetHeight - totalHeight) + 'px';
		}
		function initViews(vp) {
			var views = [], children, child, i, l;
			children = vp.childNodes;
			for (i = 0, l = children.length; i < l; i++) {
				child = children[i];
				if (1 === child.nodeType) {
					views[views.length] = child;
				}
			}
			return views;
		}
		function scrollViews(vp, views) {
			var index = 0, view0 = views[0], view1, vTop = 0, vMaxHt = vp.offsetHeight + 20, pause;
			vp.onmouseout = function() { pause = false; };
			vp.onmouseover = function() { pause = true; };
			function s() {
				var delay = 40;
				if (!pause) {
					if (vTop === 0) {
						if (view1) {
							view1.style.top = vMaxHt + 'px';
						}
						view1 = view0;
						index = (index + 1) % views.length;
						view0 = views[index];
						vTop = vMaxHt;
						delay = 3000;
					}
					else {
						vTop -= 1;
						view0.style.top = vTop + 'px';
						if (view1) {
							view1.style.top = (vTop - vMaxHt) + 'px';
						}
					}
				}
				setTimeout(s, delay);
			}
			s();
		}
		function load() {
			var vp, views;
			Optametra.removeListener(window, 'load', load);
			vp = document.getElementById('tab2VP');
			if (vp) {
				calculateHeight(vp);
				views = initViews(vp);
				if (views.length > 1) {
					views[0].style.position = 'absolute';
					scrollViews(vp, views);
				}
			}
		}
		Optametra.addListener(window, 'load', load);
		return true;
	} ());
}