var obj;
var xPos;
var yPos;
var photo = 0;

function getObj(id)
{
	return document.getElementById(id);
}

function getInnerWidth(win) {
  var winWidth;
  if (win.innerWidth) {
    winWidth = win.innerWidth;
  }
  else if (win.document.documentElement && win.document.documentElement.clientWidth) {
    winWidth = win.document.documentElement.clientWidth;
  }
  else if (document.body) {
    winWidth = win.document.body.clientWidth;
  }
  return winWidth;
}

function getInnerHeight(win) {
  var winHeight;
  if (win.innerHeight) {
    winHeight = win.innerHeight;
  }
  else if (win.document.documentElement && win.document.documentElement.clientHeight) {
    winHeight = win.document.documentElement.clientHeight;
  }
  else if (win.document.body) {
    winHeight = win.document.body.clientHeight;
  }
  return winHeight;
}


function popupLogin(win)
{
	obj = getObj('loginBox');
	yPos = (getInnerHeight(win)/2) - 60;
	xPos = (getInnerWidth(win)/2) - 150;
	obj.style.display = 'block';
	obj.style.top = yPos + 'px';
	obj.style.left = xPos + 'px';
}

function closeLogin()
{
	obj = getObj('loginBox');

	getObj('username').value = '';
	getObj('password').value = '';

	obj.style.display = 'none';
}

function popupHelp(win)
{
	obj = getObj('helpBox');
	yPos = (getInnerHeight(win)/2) - 200;
	xPos = (getInnerWidth(win)/2) - 150;
	obj.style.display = 'block';
	obj.style.top = yPos + 'px';
	obj.style.left = xPos + 'px';
}

function closeHelp()
{
	obj = getObj('helpBox');
	obj.style.display = 'none';
}

function repositionLogin(win)
{
	obj = getObj("loginBox");

	if (obj.style.display == 'block')
	{
		yPos = (getInnerHeight(win)/2) - 60;
		xPos = (getInnerWidth(win)/2) - 150;
		obj.style.display = 'block';
		obj.style.top = yPos + 'px';
		obj.style.left = xPos + 'px';
	}
	return;
}

function repositionHelp(win)
{
	obj = getObj("helpBox");

	if (obj.style.display == 'block')
	{
		yPos = (getInnerHeight(win)/2) - 200;
		xPos = (getInnerWidth(win)/2) - 150;
		obj.style.display = 'block';
		obj.style.top = yPos + 'px';
		obj.style.left = xPos + 'px';
	}
	return;
}

function reposition(browserWin)
{
	if (getObj("loginBox"))
	{
		repositionLogin(browserWin);
	}
	if (getObj("helpBox"))
	{
		repositionHelp(browserWin);
	}
}

function checkLogin()
{
	username = getObj('username').value;
	password = getObj('password').value;

	if (username == '')
	{
		getObj('userLabel').style.color = '#f00'
	}

	if (password == '')
	{
		getObj('passLabel').style.color = '#f00'
	}
}


function popPhoto(image)
{
	var left = (screen.width-500)/2;
	var top = (screen.height-530)/2;;

	if (!photo.closed && photo.location)
	{
		photo.location.href = '/html/popupPhoto.php?photo=' + image;
	}
	else
	{
		photo=window.open('/html/popupPhoto.php?photo=' + image, 'photoPopup','resizable=no,width=500,height=530,scrollbars=0,top=' + top + ',left=' + left + '');
		if (!photo.opener) photo.opener = self;
	}
	if (window.focus)
	{
		photo.focus();
	}
}



function mail(first, last)
{
	document.write('<a href="mail' + 'to:' + first + '@' + last + '">' + first + '@' + last + '</a>');
}
