var oFCKeditor = null;
var wysiwyg = null;
var oFCKactivated = false;

function showElement(x)
{
	if (document.getElementById(x))
		document.getElementById(x).style.display = '';
}

function hideElement(x)
{
	if (document.getElementById(x))
		document.getElementById(x).style.display = 'none';
}

function toggleDisplayElement(x)
{
	if (document.getElementById(x))
		document.getElementById(x).style.display = document.getElementById(x).style.display == 'none' ? '' : 'none';
}

function centerElement(id)
{
	if (document.getElementById)
	{
		var el = document.getElementById(id);
		if (el.style.display != "block")
		{
			var box = getRelativeDimension(el,'container');
			el.style.left = '' + ( ( document.body.offsetWidth - box.w ) / 2 ) + 'px';
			el.style.top = '' + ( ( document.body.offsetHeight - box.h ) / 2 ) + 'px';
		}
	}
}

function centerElementHoriz(id)
{
	if (document.getElementById)
	{
		var el = document.getElementById(id);
		if (el.style.display != "block")
		{
			var box = getRelativeDimension(el,'container');
			el.style.left = '' + ( ( document.body.offsetWidth - box.w ) / 2 ) + 'px';
		}
	}
}

function showAndTrackElement (el, div, alignX, alignY)
{
	if (document.getElementById)
	{
		var i = document.getElementById(el);
		var c = document.getElementById(div);
		if (c.style.display != "block")
		{
			var box = getRelativeDimension(i,'');
			var left = box.x, top = box.y;
			c.style.visibility = 'hidden';
			c.style.display = "block";
//alert(""+left+","+top)
			if(alignX == 'left')
				left -= c.offsetWidth;
			else
				left += i.offsetWidth;
			if(alignY == 'top')
				top -= c.offsetHeight;
			else
				top += i.offsetHeight;
//alert(""+c.offsetWidth+","+i.offsetHeight)
			if(top<10)
				top = 10;
			if(left<0)
				left = 10;
			//if(gClientIsIE5)
			if(false)
			{
				left += document.body.scrollLeft;
				top += document.body.scrollTop;
			}
			c.style.left = left+'px';
			c.style.top = top+'px';
			c.style.visibility = 'visible';
		}
		else
		{
			c.style.display="none";
		}
	}
}

function activateFck(areaId,areaWidth,areaHeight,toolbarSet)
{
	if ( !oFCKactivated )
	{
		oFCKeditor = new FCKeditor(areaId);
		oFCKeditor.BasePath = "/javascript/fckeditor/";
		oFCKeditor.Width = areaWidth;
		oFCKeditor.Height = areaHeight;
		oFCKeditor.Config["ToolbarStartExpanded"] = true;
		oFCKeditor.ToolbarSet=toolbarSet;
		//oFCKeditor.Config["SkinPath"] = "/editor/fck/editor/skins/default/";
		oFCKeditor.ReplaceTextarea()
		wysiwyg = oFCKeditor._IsCompatibleBrowser();

		oFCKactivated = true;
	}
}

function transposeAddress(userid,domainName,domainExt,subject)
{
	var email = domainName + '.' + domainExt +'@' + userid;
	var TempBefore = '';
	var TempAfter = '';
	var NewString = '';
	var Start = 0;

	var WhereHash = email.indexOf ('@');
	for (Count = 1; Count <= WhereHash; Count ++)
	{
		TempBefore += email.substring (Start, Count);
		Start++
	}
	Start = WhereHash;
	Start ++
	WhereHash +=2;
	for (Count = WhereHash; Count <=email.length; Count++)
	{
		TempAfter +=email.substring (Start, Count)
		Start++
	}
	NewString = TempAfter +'@' + TempBefore;
	parent.location = 'mailto:'+NewString+'?subject='+subject;
}

function chiocciola()
{
	document.write('@');
}

function urldecode(str)
{
	var unescaped = unescape(str);
	return unescaped.replace(/\+/g,' ');
}
