// Create spider proof email addresses
// Use this code in the body:
// <SCRIPT language=javascript>generateAntiSpiderEmail('user', 'domain', 'tld', 'display_text');</SCRIPT>
function generateAntiSpiderEmail(Username, DomainName, TLD, Text) {
	Address = Username + "&#64;" + DomainName + "." + TLD;

	if (!(Text)) {DisplayText = Address}
	else {DisplayText = Text};

	document.write("<a href=\"mailto:" + Address + "\">" + DisplayText + "</a>");
}


// Is this MSIE?
IsCrappyMicroshaftBrowser = navigator.appVersion.indexOf('MSIE') != -1;

// ASSIGNS A JAVASCRIPT EVENT TO A SPECIFIED OBJECT ACCORDING TO THE BROWSER
function setEvent(Obj, Event, Action) {

	// For IE, use attachEvent
	if (IsCrappyMicroshaftBrowser) {
		eval("Obj.attachEvent('" + Event.toLowerCase() + "', function() { " + Action + " });");
	}

	// For proper browsers, simply use setAttribute
	else
		Obj.setAttribute(Event, Action);
}


// Function to create image overlay
function enlargeImg(ImgSrc, ImgLabel) {

	with (document) {
		NewContainerDiv	= createElement('div');
		NewDisableDiv	= createElement('div');
		NewImg		= createElement('img');
		NewXImg		= createElement('img');
	}

	with (NewImg) {
		src		= ImgSrc;
		style.margin	= '15px';
		style.cursor	= 'pointer';
		style.display	= 'block';

		TmpLabel = ImgLabel + ' [click to close]';
		setAttribute('alt', TmpLabel);
		setAttribute('title', TmpLabel);
		setAttribute('id', 'MainImg');
	}

	with (NewXImg) {
		src = 'images/x.gif';

		style.position	= 'absolute';
		style.cursor	= 'pointer';
		
		if (IsCrappyMicroshaftBrowser)
			style.margin = '-30px 10px 0px ' + (NewImg.width-0) + 'px';
		else
			style.margin	= '-15px 10px 0px ' + (NewImg.width+15) + 'px';

		setAttribute('width', '30');
		setAttribute('height', '35');
		setAttribute('alt', 'close');
		setAttribute('title', 'close');
		setAttribute('id', 'XImg');
	}

	setEvent(NewImg, 'onClick', 'closeMainImg()');
	setEvent(NewXImg, 'onClick', 'closeMainImg()');

	if (NewImg.width == 0) {
		setTimeout('enlargeImg("' + ImgSrc + '", "' + ImgLabel + '")', 500);
		return;
	}

	setLeft = (Math.round(document.body.clientWidth / 2)*1)/1 - ((NewImg.width + 10) / 2);
	setLeft = (String(setLeft).lastIndexOf('.') != '-1')
		  ?String(setLeft).substr(0, String(setLeft).lastIndexOf('.')):String(setLeft) + 'px';

	setTop = String(document.body.scrollTop + 35) + 'px';

	with (NewContainerDiv) {
		setAttribute('id', 'MainImgContainer');

		style.position	= 'absolute';
		style.top	= setTop;
		style.left	= setLeft;
		style.zIndex	= '2';
		style.background= '#FFFFFF';
		
		if (IsCrappyMicroshaftBrowser)
			style.paddingTop= '15px';
	}

	with (NewDisableDiv.style) {
		top        = '0px';
		left       = '0px';
		width      = '100%';
		position   = 'absolute';
		height     = String(document.body.scrollHeight) + 'px';
		background = '#204052';
		zIndex     = '1';

		if (IsCrappyMicroshaftBrowser) {
			//toggleSelectMenuVisibility(true, 'hidden');
			filter = 'alpha(opacity=75)';
		}
		else {
			setProperty('-moz-opacity', '.75', '');
			setProperty('opacity', '.75', '');
		}
	}

	NewDisableDiv.setAttribute('id', 'DisableDiv');

	with (document.body) {
		appendChild(NewDisableDiv);
		appendChild(NewContainerDiv);
	}

	NewContainerDiv.appendChild(NewXImg);
	NewContainerDiv.appendChild(NewImg);
}


// Function to close overlay
function closeMainImg() {
	with (NewContainerDiv) {
		removeChild(document.getElementById('MainImg'));
		removeChild(document.getElementById('XImg'));
	}

	with (document.body) {
		removeChild(document.getElementById('DisableDiv'));
		removeChild(document.getElementById('MainImgContainer'));
	}
}

