// http://www.codeproject.com/aspnet/spambot.asp
// encoding and decoding of e-mail to get around spam-harvesters
// The use of a C# backend to encode the string is as follows:
//
// string EncodeEmailAddress(string email)
// {
//  return BitConverter.ToString(ASCIIEncoding.ASCII.GetBytes(email)).Replace("-", "");
// }
// 

function sendEmail(encodedEmail)
{
  // do the mailto: link
  location.href = "mailto:" + decodeEmail(encodedEmail);
}

// return the decoded email address
function decodeEmail(encodedEmail)
{
  // holds the decoded email address
  var email = "";

  // go through and decode the email address
  for (i=0; i < encodedEmail.length;)
  {
    // holds each letter (2 digits)
    var letter = "";
    letter = encodedEmail.charAt(i) + encodedEmail.charAt(i+1)

    // build the real email address
    email += String.fromCharCode(parseInt(letter,16));
    i += 2;
  }
  
  return email;
}

// display the email address in the statusbar
function displayStatus(encodedEmail)
{
  window.status = "mailto:" + decodeEmail(encodedEmail);
}

// clear the statusbar message
function clearStatus()
{
  window.status = "";
}

// Author: Nitesh Naveen (http://www.jguru.com/guru/viewbio.jsp?EID=515443), Jul 29, 2003
// Here is a custom modal dialog which is cross browser compatible. Tested with IE, Netscape 6+ and Netscape 4.7x.
var paramspassed = new Array();

function openModalWindow(url,width,height)
{
	if(arguments.length>3)
		for(i=3;i<arguments.length;i++)
		paramspassed[paramspassed.length] = arguments[i];

	if(window.showModalDialog)
	{
		var return_value = window.showModalDialog(url,paramspassed,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;status:no;help:no;");
		//returnValueFromModal(return_value);
	}
	else
	{
		var modalWin = window.open(url,"","width="+width+"px,height="+height+"px;");
		window.onfocus = function() {
			if(modalWin && !modalWin.closed)
				modalWin.focus();
		}
		window.paramspassed = paramspassed;
	}
}


// toggles visibility of a given DIV object.
function toggle(object) {
  if (document.getElementById) {
    if ( document.getElementById(object).style.visibility == 'visible')
      document.getElementById(object).style.visibility = 'hidden';
    else
      document.getElementById(object).style.visibility = 'visible';
  }

  else if (document.layers && document.layers[object] != null) {
    if (document.layers[object].visibility == 'visible')
      document.layers[object].visibility = 'hidden';
    else
      document.layers[object].visibility = 'visible';
  }

  else if (document.all) {
    if (document.all[object].style.visibility == 'visible')
      document.all[object].style.visibility = 'hidden';
    else
      document.all[object].style.visibility = 'visible';
  }

  return false;
}

