
function spamGuard(email, text, image) {

  //alert('email=' + email);
  
	var a = document.createElement("a");
	a.setAttribute("href", "mailto:" + email);

	if (arguments.length == 1)
		a.appendChild(document.createTextNode(email));
	else if (arguments.length < 3)
		a.appendChild(document.createTextNode(text));
	else {
		var img = document.createElement("img");
		img.setAttribute("id", image);
		img.setAttribute("src", "/images/" + image + ".png");
		img.setAttribute("alt", "");
		img.setAttribute("align", "middle");
		a.appendChild(img);
	}

	var p = document.createElement("p");
	p.appendChild(a);
	document.write(p.innerHTML);
}

function openPictureWindow(imageName, imageWidth, imageHeight, alt, posLeft, posTop) {
	newWindow = window.open("", "newWindow", "width=" + imageWidth + ",height=" + imageHeight + ",scrollbars=no,status=no,resizable=no,left=" + posLeft + ",top=" + posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>' + alt + '</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
	newWindow.document.write('<img src="' + imageName + '" width="' + imageWidth + '" height="' + imageHeight + '" alt="' + alt + '">');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function formatCurrency(num) {

	num = num.toString().replace(/\$|\,/g,'');
	if (isNaN(parseFloat(num)))
		num = "0";

	var sign = (num == (num = Math.abs(num)));
	num = Math.floor(num * 100 + 0.50000000001);

	var cents = num % 100;
	num = Math.floor(num/100).toString();
	if (cents < 10)
		cents = "0" + cents;

	for (var i = 0; i < Math.floor((num.length - (1 + i))/3); i++)
		num = num.substring(0, num.length - (4 * i + 3)) + "," + num.substring(num.length - (4 * i + 3));

	return ((sign ? "" : "-") + "$" + num + "." + cents);
}
