// --------------------------------------
//  This file is emhide2.js version 2.0
// --------------------------------------


// Replace c1 in s with c2
// (c) Michael Watson 2002 
function replaceChars(s, c1, c2)
{
  text = "";
  for (i = 0; i <= s.length; i++)
	{
	  if (s.substring(i, i+1)==c1) 
		{
		  text=s.substring(0, i);
			text=text+c2;
			text=text+s.substring(i+1, s.length);
		}
	}
	// if c1 is not present - return the original string
	// else return the new string
  if(text=="")
  	return s;
	else
   	return text;
}

// Reverses a string
// Starts at end of string and works backwards - should be faster
// (c) Michael Watson 2002
function revString(inputString)
{
  text = "";
  for (i=inputString.length; i > 0; i-- )
    text = text + inputString.substring(i-1, i);
		
  return text;		
}

// Pass a string in and this function:
// 1) Reverses it
// 2) Changes a "#" to a "@"
// 3) Returns the resultant string
// (c) Michael Watson 2002 
function reverseReplace(inputString)
{
  return replaceChars( revString(inputString), "#", "@");
}

// This function writes a mailto: tag using the address and text passed in.
// The addr should be reversed with the @ replaced with a #
// This is intended to foil e-mail address harvesters
// (c) Michael Watson 2002
function writeMail2(addr, text)
{
  revm2="otliam";
  wrText = "<a href="+  revString(revm2)+":"+reverseReplace(addr)  + ">";
  wrText = wrText+text+"</a>";
  alert("here 1");	  
  return wrText;
}

function writeMail3(addr)
{
  wrText = "<a href=mailto:" + addr + ">";
  wrText = wrText + addr + "</a>";

  return wrText;
}

// This function allows the use of writeMail2 using one parameter only
// (c) Ric Zanelli 2004
function addrWrite(revAddr)
{
  visText = reverseReplace(revAddr);
  outText = writeMail2(revAddr, visText);

  return outText;
}

// This function outputs the string: <INPUT type="hidden" name="business" value="--email address--"> 
// for use with Paypal buttons
function inputWrite(revAddr)
{
  addrString = reverseReplace(revAddr);
  outString = "<INPUT type='hidden' name='business' value='" + addrString + "'>";

  return outString;
}






