function silence() { return true; }
function initGlobals() {
	delay_tier2Profs = null;
	delay_tier2Patients = null;
	delay_tier3Profs = null;
	delay_tier3Patients = null;
	hideOk = new Array();
	hideOk[2] = true;
	hideOk[3] = true;
}

function showCopyright() {
	var currentYear = new Date();
	document.write("Copyright &copy; " + currentYear.getFullYear() + " Young Dental Laboratory, Inc. All Rights Reserved.");
}

function hiLite1(cell) {
	cell.style.background = "#B38065";
	cell.style.cursor = "pointer";
}

function action(url) {
  location.href = url;
}

function delite(cell) {
	cell.style.background = "#990100";
}

function hiLite2(cell) {
	cell.style.background = "#FF0000";
}

function showMenu(currentMenu) {
	currentMenu.style.visibility = "visible";
	currentMenu.style.zIndex = "100";
	var pageDropMenus = document.getElementsByTagName("select");
	if (pageDropMenus.length >= 2 && currentMenu.id == "tier2Profs") {
		pageDropMenus[1].style.visibility = "hidden";
	}
}

// ----------------------------------------------------------------------------
// DHTML Menu
// ----------------------------------------------------------------------------

// Quick-Hide functions - no delay
function qh_tier2Profs() {
	document.getElementById("tier2Profs").style.visibility = "hidden";
	document.getElementById("tier2Profs").style.zIndex = "0";
	var pageDropMenus = document.getElementsByTagName("select");
	if (pageDropMenus.length >= 2) {
		pageDropMenus[1].style.visibility = "visible";
	}
}
function qh_tier2Patients() {
	document.getElementById("tier2Patients").style.visibility = "hidden";
	document.getElementById("tier2Patients").style.zIndex = "0";
}
function qh_tier3Profs() {
	document.getElementById("tier3Profs").style.visibility = "hidden";
	document.getElementById("tier3Profs").style.zIndex = "0";
}
function qh_tier3Patients() {
	document.getElementById("tier3Patients").style.visibility = "hidden";
	document.getElementById("tier3Patients").style.zIndex = "0";
}
// end Quick-Hide functions

// Hide functions - delay = .5 seconds
function hide_tier2Profs() {
	if (hideOk[2]) {
		document.getElementById("tier2Profs").style.visibility = "hidden";
		document.getElementById("tier2Profs").style.zIndex = "0";
		var pageDropMenus = document.getElementsByTagName("select");
		if (pageDropMenus.length >= 2) {
			pageDropMenus[1].style.visibility = "visible";
		}
		// ensure tier3 menu is closed.
		qh_tier3Profs();
	}
}
function hide_tier2Patients() {
	if (hideOk[2]) {
		document.getElementById("tier2Patients").style.visibility = "hidden";
		document.getElementById("tier2Patients").style.zIndex = "0";
		// ensure tier3 menu is closed.
		qh_tier3Patients();
	}
}
function hide_tier3Profs() {
	if (hideOk[3]) {
		document.getElementById("tier3Profs").style.visibility = "hidden";
		document.getElementById("tier3Profs").style.zIndex = "0";
	}
}
function hide_tier3Patients() {
	if (hideOk[3]) {
		document.getElementById("tier3Patients").style.visibility = "hidden";
		document.getElementById("tier3Patients").style.zIndex = "0";
	}
}
// end hide functions

function hideMenu(currentMenu) {
	var delayTime = 500;
	switch (currentMenu.id) {
		case "tier2Profs":
			delay_tier2Profs = setTimeout("hide_tier2Profs()", delayTime);
		break;
		case "tier2Patients":
			delay_tier2Patients = setTimeout("hide_tier2Patients()", delayTime);
		break;
		case "tier3Profs":
			delay_tier3Profs = setTimeout("hide_tier3Profs()", delayTime);
		break;
		case "tier3Patients":
			delay_tier3Patients = setTimeout("hide_tier3Patients()", delayTime);
		break;
	}
}

function stopDelay(tierA, tierB) {
	hideOk[tierA] = false;
	if (tierB) {
		hideOk[tierB] = false;
	}
}
function startDelay(tierA, tierB) {
	hideOk[tierA] = true;
	if (tierB) {
		hideOk[tierB] = true;
	}
}

// end DHTML Menu
// ----------------------------------------------------------------------------

function newWin(url) {
  window.open(url);
}

function jumpTo(menu) {
	location.href = menu.options[menu.selectedIndex].value;
}

function showCoupon() {
	window.open("/downloads/coupon.html", "promo", "width=520,height=310,toolbar");
}

function showPrescriptions() {
	window.open("/downloads/prescript.html", "promo", "width=465,height=700,toolbar,scrollbars");
}

function showCustomDesignerWksh() {
	window.open("/downloads/custom_design.html", "promo", "width=665,height=700,toolbar,scrollbars");
}

function showAcrylicColorChart() {
	window.open("/downloads/acrylic.html", "promo", "width=665,height=700,toolbar,scrollbars");
}

function showCareOfNightGuard() {
	window.open("/downloads/night_guard.html", "promo", "width=550,height=600,toolbar,scrollbars");
}

function showCareOfTalon() {
	window.open("/downloads/talon.html", "promo", "width=665,height=700,toolbar,scrollbars");
}

function quickGet(promo) {
  switch (promo.options[promo.selectedIndex].value) {
		case "coupon":
			showCoupon();
		break;
		case "pres":
			showPrescriptions();
		break;
		case "wksh":
			showCustomDesignerWksh();
		break;
		case "chart":
			showAcrylicColorChart();
		break;
		case "ng":
			showCareOfNightGuard();
		break;
		case "talon":
			showCareOfTalon();
		break;
	}
}

function validate(submission) {
	var i = 0;
	var fieldsOk = true;
	while ((i < submission.elements.length) && (fieldsOk != false) && (i < 20)) {
		if (submission.elements[i].value == "") {
			window.alert("Please complete your submission and then press \"Submit.\"");
			submission.elements[i].focus();
			fieldsOk = false;
		}
		i++;
	}
	// check email format
	if (fieldsOk) {
		if (submission.Visitor_Email.value.indexOf("@") == -1 || submission.Visitor_Email.value.indexOf(".") == -1) {
			window.alert("Please enter a valid email address and then press \"Submit.\"");
			submission.Visitor_Email.focus();
			fieldsOk = false;
		}
	}
	
	return fieldsOk;
}

window.onerror = silence;
initGlobals();
