// *****************************************************************************************
// *****************************************************************************************
// Filename: gbcs.js
//
// *****************************************************************************************
// *****************************************************************************************


 
// =========================================================================================
// dispEmail()
//
// Description:
//		Displays an email address.  Obfuscates mail addresses from screen scrapers, harvester
// 	robots, etc. by preventing the email address from ever appearing in clear text.
//
// Input:
// 	Parameter	Type			Description
// 	uname			String		The username part of the email address.  Example: 'jane.doe'
// 	domain		String		The domain part of the email address.  Example: 'ufl.edu'
// 	disptype		Integer		The type of link to display.  Valid values:
//										1 - The email address (jane.doe @ ufl.edu)
//										2 - The text string supplied in the 'disptext' parameter
//										3 - An image whose path is supplied in the 'disptext' parameter
//		disptext		String		The text of the link if 'disptype' of 2 was specified.
//											- OR -
//										The path to the image file if 'disptype' of 3 was specified.
//										Ignored for any other value of 'disptype'.
//		hovertext	String		The text to display on the link 'onHover' event.
//										Specify the null string ('')for no onHover text.
// 	subject		String		The text to display in the subject line of the message.
//										Specify the null string ('')for no subject.
// 	classname	String		The CSS class for the link.
//										Specify the null string ('')for no class disignation.
//
// Usage:
//		Include the following script block on the page:
//
//		<script type="text/javascript">
//			//<![CDATA[
//			document.write(dispEmail('jane.doe', 'ufl.edu', 1, '', '', '', ''));
//			//]]>
//		</script>
//==========================================================================================

function dispEmail(uname, domain, disptype, disptext, hovertext, subject, classname) {
	
	// Determine display type
	switch (disptype) {
		
		// Display email address
		case 1:
			displayName = uname+' '+'@'+' '+domain;
			break;
		
		// Display supplied text string
		case 2:
			if (disptext == '') displayName = 'ERROR: Display text option selected, no string supplied';
			else displayName = disptext;
			break;
		
		// Display an image
		case 3:
			if (disptext == '') displayName = 'ERROR: Display image option selected, no path supplied';
			else displayName = '<img src="'+disptext+'" border="0" />';
			break;
			
		// Display an error msg
		default:
			displayName = 'Invalid disptype supplied';
	}
	
	// Select the onHover pop-up text
	if (hovertext == '') linkOnHover = 'Send email';
	else linkOnHover = hovertext;
	
	// Build the subject string
	if (subject == '') strDispSubject = '';
	else strDispSubject = '?subject=' + subject;
	
	// Build the class string
	if (classname == '') strClass = '';
	else strClass = 'class="'+classname+'" ';
	
	// Finally, write out the link
	return('<a '+strClass+'href="mail'+'to:'+uname+''+'@'+''+domain+strDispSubject+'" title="'+linkOnHover+'">'+displayName+'</'+'a>')

}	// end dispEmail()
