function openWindow(URL, width, height)
{
	if (!height)
		height = 400;
	if (!width)
		width = 325;
	window.open(URL, 'apps', 'width=' + width + ',height=' + height + ',scrollbars=yes,dependent=yes');
}

function openInParent(URL)
{
	window.opener.location.href=URL;
}

function isLeap(year)
{
	return (((year%4) == 0 && (year%100)!=0) || (year%400)==0);
}

function isValidDate(day, month, year)
{
	if (day <= lastMonthDay(month, year))
		return true;
	return false;
}

function lastMonthDay(month, year)
{
	if (isLeap(year))
		leap = 1;
	else
		leap = 0;
	day_tab = [ [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ];
	return day_tab[leap][month-1];
}

function moveMember(source, dest)
{
	for (i=source.options.length-1 ; i>=0 ; i--)
	{
		if (source.options[i].selected)
		{
			dest.options[dest.length] = new Option(source.options[i].text, source.options[i].value);
			source.options[i]=null;
			i=source.options.length;
		}
	}
}

function fillList(source, dest)
{
	dest.value="";
	for (i=0 ; i<source.options.length ; i++)
	{
		dest.value = dest.value + source.options[i].value + ";";
	}
}

function checkEmailAddr(email)
{
	tmp1=email.replace(/ /g, "");
	var email_pattern = new RegExp('^' +
                                 '[^()<>@,;:\\\\".[\\]\\s]+' +
                                 '(\.[^()<>@,;:\\\\".[\\]\\s]+)*' +
                                 '@' +
                                 '[^()<>@,;:\\\\".[\\]\\s]+' +
                                 '(\.[^()<>@,;:\\\\".[\\]\\s]+)*' +
                                 '$');
	email_result = email_pattern.exec(tmp1);
	if (!email_result && tmp1 != '')
	{
		return false;
	}
	document.forms[0].email.value=tmp1;
	return true;
}

function getObj(name)
{
	if (document.all)
	{
		this.obj = document.all[name];
		if (this.obj)
			this.style = document.all[name].style;
		else
			return null;
	}
	else if (document.layers)
	{
		this.obj = document.layers[name];
		if (this.obj)
			this.style = document.layers[name];
		else
			return null;
	}
	else if (document.getElementById)
	{
		this.obj = document.getElementById(name);
		if (this.obj)
			this.style = document.getElementById(name).style;
		else
			return null;
	}
}

function getObjText(obj)
{
	if (obj.text)
		return obj.text;
	if (obj.innerText)
		return obj.innerText;
}

function setObjText(obj, val)
{
	if(obj.firstChild.data)
		obj.firstChild.data=val;
}

function setObjHTML(obj, val)
{
	if (obj.innerHTML)
		obj.innerHTML=val;
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function toggleBox(boxName)
{
	var row=new getObj(boxName);
	sib=row.obj;
	if (sib.style)
		sib.style.display=(sib.style.display=='none')?'':'none';
	var ancher=new getObj('a'+boxName);
	if (ancher.obj)
		ancher.obj.firstChild.nodeValue = ancher.obj.firstChild.nodeValue=="X"?"+":"X";
}
