function OpenPopupWindow(url, title, width, height)
{
	x = (screen.width - width) / 2;
	y = (screen.height - height) / 2;
	w = "scrollbars,resizable,height=" + height + ",width=" + width;
	
	win = window.open(url, title, w);
	win.focus();
	win.moveTo(x, y)
}

function ClickButtonOnEnter(e, buttonId)
{
	if (!e) 
		e = window.event								
	
	if (e.keyCode) 
		code = e.keyCode;
	else if (e.which) 
		code = e.which;
		
		
	
	if (code == 13)
	{
		button = document.getElementById(buttonId);
		
		window.status = buttonId;
		
		if (button)
			button.click();
		
		return false;
	}
	
	return true;
}

function FocusFieldOnEnter(e, fieldId)
{
	if (!e) 
		e = window.event								
	
	if (e.keyCode) 
		code = e.keyCode;
	else if (e.which) 
		code = e.which;
		
	
	
	if (code == 13)
	{
		field = document.getElementById(fieldId);
		
		window.status = fieldId;		
		if (field)
			field.focus();
		
		return false;
	}
	
	return true;
}

function GetAge(dob)
{
	now = new Date();
	
	age = now.getFullYear() - dob.getFullYear();
	if ((now.getMonth() > dob.getMonth()) || (now.getMonth() == dob.getMonth() && now.getDay() >= dob.getDay()))
		age+= 1;
	
	return age;		
}

// Used in Page header.
function swap(element, cssclass)
{
	element.parentNode.className = cssclass;
}

