/*
	File: site.js
	Common JS for anywhere on the site.
*/

/* --- generic utility functions ---------------------------------- */

function getElement(elemId) {
	if (document.getElementById && document.getElementById(elemId))
		return document.getElementById(elemId);
	else if (document.all && document.all(elemId))
		return document.all(elemId);
	else
		return false;
}

function getStyleObject(elemId) {
	var elem = getElement(elemId);

	return (elem) ? elem.style : false;
}

function setDisplay(elemId, value) {
	var styleObj = getStyleObject(elemId);
	if (styleObj)
		styleObj.display = value;
}

/* --- e-mail "disguising" ---------------------------------------- */

//
// Optional third argument is text to show instead of address
//

function courriel(user, abbr) {
	var domain = '';

	switch (abbr) {
		case 'ffc':
			domain = 'fontfont.com';
			break;
		case 'ffd':
			domain = 'fontfont.de';
			break;
		case 'fsc':
			domain = 'fontshop.com';
			break;
	}

	if (domain.length > 0) {
		var male = user + '@' + domain;
		var male2 = 'mailto:' + male;
		var text = (arguments.length == 3) ? arguments[2] : male;
		document.write('<a href="' + male2 + '">' + text + '</a>');
	}
}

// OBSOLETE
function printEmail(user, lastPart) {
	var male = user + "@fontfont." + lastPart;
	var male2 = "mailto:" + male;
	document.write('<a href="' + male2 + '">' + male + '</a>');
}

/* --- other... --------------------------------------------------- */

function installwin() {
	window.open("/shop/install.ep", 'inst',
		'height=400,width=700,menubar=no,scrollbars=yes,toolbar=no,status=no,resizable=yes');
}

function infoWin(url) {
	var args = 'height=600,width=400,menubar=no,scrollbars=yes,toolbar=no,status=no,resizable=yes';
	var window_ = window.open(url, 'popup', args);
	window_.focus();
}

function linktothisWin(type, idOrProdNo) {
	var url = "linktothis.ep?t=" + type + "&id=" + idOrProdNo;
	var args = 'height=170,width=500,menubar=no,scrollbars=yes,toolbar=no,status=no,resizable=yes';
	window.open(url, 'linktothis', args);
}
