/**
 * Copyright (C) 2004, CodeHouse.com. All rights reserved.
 * CodeHouse(TM) is a registered trademark.
 *
 * THIS SOURCE CODE MAY BE USED FREELY PROVIDED THAT
 * IT IS NOT MODIFIED OR DISTRIBUTED, AND IT IS USED
 * ON A PUBLICLY ACCESSIBLE INTERNET WEB SITE.
 *
 * Script Name: E-mail Hider
 *
 * You can obtain this script at http://www.codehouse.com
 */

//chk if an object is an array or not.
//returns true is it is an array

// Object typefunction isObject(o) {  return (typeof(o)=="object");}function isArray(o) {  return (isObject(o) && (o.length) &&(!isString(o)));}function isFunction(o) {  return (typeof(o)=="function");}function isString(o) {  return (typeof(o)=="string");}

//Opens an email instance with the following settings.
//name:		the user name at the front of the email address. 
//domain:	the domain name eg. yahoo
//suffix:	suffix to use eg. org or com
//text:		the text displayed in the link to this.
//bcc:		the user name of the recipient of a blind carbon copy.  
//			Can be an array of user names. Must be in the same domain/suffix.
//subject:	What to put in the subject line of the message.
			
function email(name, domain, suffix, text, bcc, subject)
{
   var address = name + "\u0040" + domain + "." + suffix;
   var url = "mailto:" + address;

   if(bcc)
   {
	  if(isArray(bcc))
	  {
		url = url + "\u003f" + "bcc" + "=" + bcc[0] + "\u0040" + domain + "." + suffix;
		for(i=1; i<bcc.length; i++)
			url = url + "," + bcc[i] + "\u0040" + domain + "." + suffix;
	  }
	  else
		url = url + "\u003f" + "bcc" + "=" + bcc + "\u0040" + domain + "." + suffix;
   }
   
   if(subject)
   {
		if(bcc)
			url = url + "\u0026";
		else
			url = url + "\u003f";
		url = url + "subject" + "\u003d" + subject;		
   }
   
   if( ! text )
   {
      text = address;
   }

   document.write("<a href=\"" + url + "\">" + text + "</a>");
}