function popup(url)
{
 width  = 460;
 height = 410;

 x = (640 - width )/2;
 y = (480 - height)/2;

 if(screen)
 {
  y = (screen.availHeight - height)/2;
  x = (screen.availWidth  - width )/2;
 }

 window.open(url, 'arteseapopup', 'scrollbars,status,width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
}

function closePopup(url)
{
 window.opener.location = window.opener.location;
 setTimeout('window.close();',1000);
}

function login()
{
 popup('/popup/login.php');
}

function logout()
{
 popup('/popup/logout.php');
}

function register()
{
 popup('/popup/register.php');
}

function add_panels()
{
 popup('/add/index.php');
}

function add_new(type)
{
 url = '/add/next.php?cat=' + type;
 popup(url);
}

function close_panel(col,row)
{
 url = '/popup/close.php?c=' + col + '&r=' + row;
 popup(url);
}

function edit_panel(col,row)
{
 url = '/edit/index.php?c=' + col + '&r=' + row;
 popup(url);
}

function add_alert(type)
{
 url = '/alerts/add/' + type + '.php';
 popup(url);
}

function edit_alert(type, id)
{
 url = '/alerts/edit/' + type + '.php?alert=' + id;
 popup(url);
}

function pda_demo()
{
 window.open("http://www.artesea.co.uk/pda/example/",
             "my_new_window",
             "toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=405, height=630");
}

function decem(emailAddress, messageText)
{
 decoded = emailAddress.replace('www.pants.','');
 decoded = decoded.replace('.yep.yay.','@');
 decoded = decoded.replace('.pointless.ohdear.com','');
 if(messageText == undefined)
 {
  document.write('<a href="mailto:' + decoded + '">' + decoded + '</a>');
 }
 else
 {
  document.write('<a href="mailto:' + decoded + '">' + messageText + '</a>');
 }
}