function startList() {
	if (document.getElementById("primary")) {
		navRoot = document.getElementById("primary");
		for (i=0; i < navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				if(document.all) {
					node.onmouseover=function() {
						this.className += " over";
					}
					node.onmouseout=function() {
						this.className = this.className.replace(" over", "");
					}
				}
			}
		}
	}
}

function checkMenu() {
	if(document.getElementById("sidebar")) {
		var x = document.getElementById("sidebar");
		var y = x.getElementsByTagName("LI");
		for(i=0;i<y.length;i++) {
			if(y[i].getElementsByTagName("A")[0] && y[i].getElementsByTagName("A")[0].href == document.location.href) {
				y[i].className = "current";
			}
		}
	}
}

function validateForm() {
	var f = document.forms['demorequest'];
	var missing = new Array();
	var msg = "Please be sure to fill out all of the fields marked in red.";
	for(i=0;i<f.elements.length;i++) {
		if(f.elements[i].className == "required" && f.elements[i].value.length < 1) {
			missing.push(f.elements[i].name);
		}
		if(f.elements[i].name == "email") {
			if(!validateEmail(f.elements[i].value)) {
				missing.push(f.elements[i].name);
				missing.length > 1 ? msg += "\nAlso, please make sure you have entered a valid email address." : msg = "Please make sure you have entered a valid email address.";
			}
		}
	}
	if (missing.length > 0) {
		labels = document.getElementsByTagName("LABEL");
		for(h=0;h<labels.length;h++) {
			labels[h].className = "";
		}
		for(j=0;j<missing.length;j++) {
			document.getElementById(missing[j]).className = "required";
		}
		alert(msg);
		return false;
	}
	else {
		return true;
	}
}

function validateEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

$(document).ready(function() {
	startList();
	checkMenu();
	if(document.body.className == "home") {
		var so = new SWFObject("banner/pixel-velocity_home.swf", "pixelvelocity", "880", "280", "6", "#FFFFFF");
		so.useExpressInstall('expressinstall.swf');
		so.addParam("wmode", "transparent");
		so.addParam('menu', 'false');
	    so.write("banner");
	}
});