// JavaScript Document

function init() 
{
	fieldFocus();
}

function setOpacity(obj, opacity) 
{
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function getObj(elementID)
{
	if (typeof elementID == "string") 
	{
		return document.getElementById(elementID);
	}
	else
	{
		return elementID;
	}
}

//Focus first field
function fieldFocus() 
{
   // var textElements = 0;
	var focusField = -1;
	
	if(document.forms[0])
	{
		for (i = 0; i < document.forms[0].elements.length; i++)
		{
			if (document.forms[0].elements[i].type == "text" || document.forms[0].elements[i].type == "password") 
			{
				if (focusField < 0) 
				{
						focusField = i;
				}
			}
		}
		//put focus in first text or password field
		if(focusField > -1)
		{
			document.forms[0].elements[focusField].focus();
		}
	}
}

function popup(URL, width, height) 
{
	width = parseInt(width);	
	heigth = parseInt(height);
	
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ width +",height=" + heigth + ",left = 100,top = 100');");
}


function insertEmo(emo)
{
	getObj("message").value = getObj("message").value+" "+emo+ " ";
	getObj("message").focus();
}
