﻿function WriteMailLink(addr, text)
{
	document.write("<a href=\"");
	for(i = addr.length - 2; i >= 0; i--)
	{
		document.write(addr.substr(i, 1));
	}
	document.write(addr.substr(addr.length - 1, 1));
	document.write("\">");
	if(text.length == 0)
	{
		for(i = addr.length - 2; i >= 0; i--)
		{
			document.write(addr.substr(i, 1));
		}
		document.write(addr.substr(addr.length - 1, 1));
	}
	else
	{
		for(i = text.length - 2; i >= 0; i--)
		{
			document.write(text.substr(i, 1));
		}
		document.write(text.substr(text.length - 1, 1));
	}
	document.write("</a>");
}

// #region Dictionary

function Lookup(key) 
{
  return(this[key]);
}

function Delete() 
{
  for (c=0; c < Delete.arguments.length; c++) 
  {
    this[Delete.arguments[c]] = null;
  }
  // Adjust the keys (not terribly efficient)
  var keys = new Array()
  for (var i=0; i<this.Keys.length; i++)
  {
    if(this[this.Keys[i]] != null)
      keys[keys.length] = this.Keys[i];
  }
  this.Keys = keys;
}

function Add() 
{
  for (c=0; c < Add.arguments.length; c+=2) 
  {
    // Add the property
    this[Add.arguments[c]] = Add.arguments[c+1];
    // And add it to the keys array
    this.Keys[this.Keys.length] = Add.arguments[c];
  }
}

function Dictionary() 
{
  this.Add = Add;
  this.Lookup = Lookup;
  this.Delete = Delete;
  this.Keys = new Array();
}

// #endregion

var maxHeightDict = new Dictionary();

function toggleMaxHeight(obj)
{
	if(obj.style.maxHeight == "100%") obj.style.maxHeight = maxHeightDict.Lookup(obj);
	else
	{
		maxHeightDict.Add(obj, obj.style.maxHeight);
		obj.style.maxHeight = "100%";
	}
}



