function getObj(name)
{
	if (document.getElementById)
	{
  		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers)
	{
		this.obj = getObjNN4(document,name);
		this.style = this.obj;
	}
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

var key1 = "yJzdeB4CcDnmEFbZtvuHlI1hA8SiLo9MwfN3O6Y5QaRqKTjUpxVk2WgXrP7Gs0";
var key2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

function DecrypteMailTo()
{
	var hrefs = document.getElementsByTagName('A');
    for (i in hrefs)
    {
		if (hrefs[i] == null)
			continue;
        
        var href = hrefs[i].toString().toLowerCase();
		if (href.indexOf('mailto:') == 0)
		{
			var mailto = hrefs[i].getAttribute('href').substring(7);
			var newmailto = new String();
			var len = mailto.length;
			for (c = 0; c < len; c++)
			{
				var pos = key1.indexOf(mailto.charAt(c));
				if (pos != -1)
					newmailto += key2.charAt(pos);
				else
					newmailto += mailto.charAt(c);
			}
			hrefs[i].setAttribute('href', 'mailto:' + newmailto);
		}
    }
	
	var elem = document.getElementById('email');
	if (elem != null)
	{
		var newmailto = new String();
		var len = elem.innerHTML.length;
		for (c = 0; c < len; c++)
		{
			var pos = key1.indexOf(elem.innerHTML.charAt(c));
			if (pos != -1)
				newmailto += key2.charAt(pos);
			else
				newmailto += mailto.charAt(c);
		}
		elem.innerHTML = newmailto;
    }
}

function OnPageLoad()
{
	DecrypteMailTo();
	DesactiveEnterForTextArea();
}

var enter = true;

function OnFocus()
{
	enter = false;
}
function OnBlur()
{
	enter = true;
}

function DesactiveEnterForTextArea()
{
	if (document.all)
	{
		var input = document.all.tags('textarea');
		for (i = 0; i < input.length ; i++)
		{
			input[i].onfocus = OnFocus;
			input[i].onblur = OnBlur;
		}
	}
}

function EnterKeyDown(elem)
{
	if (document.all)
	{
		if (enter == true && event.keyCode == 13)
		{
			event.returnValue = false;
			event.cancel = true;
			elem.click();
		}
	}
}

function Galerie(image, w, h)
{
	h = h + 12;
	w = w + 36;
	handle=window.open(image,
	'Image','menubar=1,toolbar=0,status=0,scrollbars=1,location=0,resizable=1,' + 
	'height=' +	h + ',width=' + w);
	if (handle.focus) handle.focus();
	return false;
}

function NewMember(url, ctrl)
{
	url += '?nom=' + ctrl[ctrl.value].text + "&create=1";
	handle=window.open(url,'Membre','menubar=1,toolbar=1,status=1,scrollbars=1,location=1,resizable=1');
	handle.focus();
	return false;
}
