function valDownloadv2() {
var fFirst     = document.downloadform.firstname.value;
var fLast      = document.downloadform.lastname.value;
var fRole      = document.downloadform.role.options[document.downloadform.role.selectedIndex].value;
var fCompany   = document.downloadform.company.value;
var fCity      = document.downloadform.city.value;
var fState     = document.downloadform.state_province.options[document.downloadform.state_province.selectedIndex].value;
//var fCountry   = document.downloadform.country.options[document.downloadform.country.selectedIndex].value;
var fPhone     = document.downloadform.phone.value;
var fEmail     = document.downloadform.email.value;

// -- ADD vars for MSDS format, language and  ID for building URL  July 20, 2007-- //
//var fMSDSformat  =  document.downloadform.msdsformat.options[document.downloadform.msdsformat.selectedIndex].value;
//var fLanguage  =  document.downloadform.language.options[document.downloadform.language.selectedIndex].value;
//var fID  =  document.downloadform.id.value;

// -- ADD var for building URL July 20, 2007-- //
//var url  =  "http://sachem.thewercs.com/WV.ASP?A=LIST&F_PRODUCT="+fID+"&F_LANGUAGE="+fLanguage+"&F_FORMAT=MTR&F_SUBFORMAT="+fMSDSformat+"";

var themessage = "You are required to complete the following fields: ";

	if (fFirst=="") {
		themessage = themessage + "\n - First Name";
	}
	if (fLast=="") {
		themessage = themessage + "\n - Last Name";
	}
	if (fRole=="") {
		themessage = themessage + "\n - Role";
	}
	if (fCompany=="") {
		themessage = themessage + "\n - Company";
	}
	if (fCity=="") {
		themessage = themessage + "\n - City";
	}
	if (fState=="") {
		themessage = themessage + "\n - State/Province";
	}
	/*if (fCountry=="") {
		themessage = themessage + "\n - Country";
	}*/
	if (fPhone=="") {
		themessage = themessage + "\n - Phone";
	}
	if (fEmail=="") {
		themessage = themessage + "\n - Email";
	}
	if (themessage == "You are required to complete the following fields: ") {
		if (fEmail.indexOf('@', 0) == -1 || fEmail.indexOf('.', 0) == -1){ 
			alert("Please enter a valid e-mail address.");
			return false;
		} else {
			return true;
		}
	} else {
		alert(themessage);
		return false;
	}
}

function valDownload() {
var fFirst     = document.downloadform.fname.value;
var fLast      = document.downloadform.lname.value;
var fCompany   = document.downloadform.company.value;
var fState     = document.downloadform.state.value;
var fCountry   = document.downloadform.country.options[document.downloadform.country.selectedIndex].value;
var fPhone     = document.downloadform.phone.value;
var fEmail     = document.downloadform.email.value;

// -- ADD vars for MSDS format, language and  ID for building URL  July 20, 2007-- //
var fMSDSformat  =  document.downloadform.msdsformat.options[document.downloadform.msdsformat.selectedIndex].value;
var fLanguage  =  document.downloadform.language.options[document.downloadform.language.selectedIndex].value;
var fID  =  document.downloadform.id.value;

// -- ADD var for building URL July 20, 2007-- //
var url  =  "http://sachem.thewercs.com/WV.ASP?A=LIST&F_PRODUCT="+fID+"&F_LANGUAGE="+fLanguage+"&F_FORMAT=MTR&F_SUBFORMAT="+fMSDSformat+"";

var themessage = "You are required to complete the following fields: ";

	if (fFirst=="") {
		themessage = themessage + "\n - First Name";
	}
	if (fLast=="") {
		themessage = themessage + "\n - Last Name";
	}
	if (fCompany=="") {
		themessage = themessage + "\n - Company";
	}
	if (fState=="") {
		themessage = themessage + "\n - State/Province";
	}
	if (fCountry=="") {
		themessage = themessage + "\n - Country";
	}
	if (fPhone=="") {
		themessage = themessage + "\n - Phone";
	}
	if (fEmail=="") {
		themessage = themessage + "\n - Email";
	}
	if (themessage == "You are required to complete the following fields: ") {
		if (fEmail != "") {
			if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(fEmail)) {
				return true;
			} else {
				alert("You must enter a valid email address.");
				return false;
			}
		} else {
			return true;
		}
	} else {
		alert(themessage);
		return false;
	}
}

function valContact() {
var fFirst     = document.contactform.fname.value;
var fLast      = document.contactform.lname.value;
var fPhone     = document.contactform.phone.value;
var fEmail     = document.contactform.email.value;
var fIndustry  = document.contactform.industry.options[document.contactform.industry.selectedIndex].value;
var fSubject   = document.contactform.subject.value;
var themessage = "You are required to complete the following fields: ";

	if (fFirst=="") {
		themessage = themessage + "\n - First Name";
	}
	if (fLast=="") {
		themessage = themessage + "\n - Last Name";
	}
	if (fPhone=="") {
		themessage = themessage + "\n - Phone";
	}
	if (fEmail=="") {
		themessage = themessage + "\n - Email";
	}
	if (fIndustry=="") {
		themessage = themessage + "\n - Industry of Interest";
	}
	if (fSubject=="") {
		themessage = themessage + "\n - Subject of Request";
	}
	if (themessage == "You are required to complete the following fields: ") {
		if (fEmail != "") {
			if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(fEmail)) {
				return true;
			} else {
				alert("You must enter a valid email address.");
				return false;
			}
		} else {
			return true;
		}
	} else {
		alert(themessage);
		return false;
	}
}

// -- AJAX calls -- //

//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("We are attempting to give you a better search experience. Upgrade your browser to enjoy it.");
	}
}

//Our XmlHttpRequest object to get the auto suggest
var searchReq = getXmlHttpRequestObject();

//Called from keyup on the search textbox.
//Starts the AJAX request.
function searchSuggest() {
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		var str = escape(document.getElementById('mod_search_searchword').value);
		searchReq.open("GET", 'searchSuggest.php?search=' + str, true);
		searchReq.onreadystatechange = handleSearchSuggest;
		searchReq.send(null);
	}
}

function closeSuggest() {
	document.getElementById('search_suggest').innerHTML = '';
	document.getElementById('search_suggest').className = 'off';
}

//Called when the AJAX response is returned.
function handleSearchSuggest() {
	if (searchReq.readyState == 4) {
		var ss = document.getElementById('search_suggest')
		ss.innerHTML = '';
		var str = searchReq.responseText.split("\n");
		for(i=0; i < str.length - 1; i++) {
			//Build our element string.  This is cleaner using the DOM, but
			//IE doesn't support dynamically added attributes.
			/*var suggest = '<div onmouseover="javascript:suggestOver(this);" ';
			suggest += 'onmouseout="javascript:suggestOut(this);" ';
			suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';
			suggest += 'class="suggest_link">' + str[i] + '</div>';
			ss.innerHTML += suggest;*/
			var suggest = '<a href="#" onmouseover="javascript:suggestOver(this);" ';
			suggest += 'onmouseout="javascript:suggestOut(this);" ';
			suggest += 'onclick="javascript:setSearch(this.innerHTML); return false" ';
			suggest += 'class="suggest_link">' + str[i] + '</a>';
			ss.innerHTML += suggest;
			document.getElementById('search_suggest').className = 'on';
		}
	}
}

//Mouse over function
function suggestOver(div_value) {
	div_value.className = 'suggest_link_over';
}
//Mouse out function
function suggestOut(div_value) {
	div_value.className = 'suggest_link';
}

//Click function
function setSearch(value) {
	document.getElementById('mod_search_searchword').value = value;
	document.getElementById('search_suggest').innerHTML = '';
	document.getElementById('search_suggest').className = 'off';
}

//Popup window function for Displacement Chromatography Demos
function popwin(url, swfWidth, swfHeight) {
	var leftMargin = (screen.availWidth - swfWidth)/2;
	var topMargin = (screen.availHeight - swfHeight)/2;
   	var w = screen.availWidth;
	var h = screen.availHeight;
   	var windowFeatures = "width=" + swfWidth + ",height=" + swfHeight + ",";
	windowFeatures += "left=" + leftMargin + ",top=" + topMargin + ",";
   	windowFeatures += "location=no,";
	windowFeatures += "menubar=no,";
   	windowFeatures += "resizable=no,";
	windowFeatures += "scrollbars=no,";
	windowFeatures += "status=no,";
 	windowFeatures += "toolbar=no";
	window.open(url, "dc", windowFeatures);
}
