function initPage()
{

}

function PositionX(elementid) {
    var iReturnValue = 0;
    while( elementid != $('content') )
    {
        iReturnValue += elementid.offsetLeft;
        if (isNaN(iReturnValue)) { iReturnValue = 0; }
        elementid = elementid.offsetParent;
    }
    return iReturnValue;
};
   
function PositionY (elementid) {
    var iReturnValue = 0;
    while( elementid != $('content') )
    {
        iReturnValue += elementid.offsetTop;
        if (isNaN(iReturnValue)) { iReturnValue = 0; }
        elementid = elementid.offsetParent;
    }
    return iReturnValue;
};
   
function getPositionX(element) {
	if (IsIE(navigator)) {
		return PositionX(element);
	} else {
		return element.getPosition().x;
	}
}
function getPositionY(element) {
	if (IsIE(navigator)) {
		return PositionY(element);
	} else {
		return element.getPosition().y;
	}
}

function IsIE (navigator) {
   if (navigator.appName == 'Microsoft Internet Explorer') { return true; } else { return false; }
}
  
function openPopup(button)
{
	var popup =  document.getElementById('popup01');
	var fader = document.getElementById('fader');
	fader.style.display = "block";
	popup.style.display = "block";
	fader.style.height = document.documentElement.scrollHeight+'px';
	positionPopup(button,popup);
}

function hide () {
	document.getElementById('popup01').style.display='none';
	document.getElementById('fader').style.display='none';
}

jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
	if(($(window).width() - this.width()) > 0) //added for mobile if width of device is tiny
	{
		this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
	}
    return this;
}

function positionPopup(button,popup) {
	$(popup).center();
}

// The following was created to work with mootools, but was replaced by the above cleaner function for jQuery.
function positionPopupOld(button,popup) {
	// determine verticial positioning limits
	var positionY = getPositionY(button); //button.getPosition().y;
	var scrollY = window.getScroll().y;
	var clientHeight = popup.clientHeight;
	var top = positionY - clientHeight;
	if ((positionY - scrollY) < clientHeight) { top = scrollY; }

	// determine horizontal positioning limits
	var positionX = getPositionX(button) //button.getPosition().x;
	var scrollX = window.getScroll().x;
	var popupWidth = popup.clientWidth;
	var windowWidth = window.getSize().x;
	var rightLimit = windowWidth - scrollX;

	// initialize positioning
	var left = (windowWidth / 2) - (popupWidth / 2);
	var right = (left + popupWidth);

	// adjust position for scrolling
	if (right > rightLimit)  { left = rightLimit - popupWidth; }
	if (left < 0) { left = 0; }
	if (left < scrollX) { left = scrollX; }
	
    if (isNaN(left)) { left = 0; }
    if (isNaN(top)) { top = 0; }
 	
	//position popup
	popup.style.marginLeft = left + 'px';			
	popup.style.marginTop =  top + 'px';	
}



function displayNamedDivs(name) {
 var divs = document.getElementsByName(name);
 for (var i in divs) {
  var div = divs[i];
  if (div.name == name) { div.style.display='block'; } else { div.style.display='none'; }
  }
 }
 
 function isEmpty(aTextField) {
   if ((aTextField.value.length==0) ||
   (aTextField.value==null)) {
      return true;
   }
   else { return false; }
}	

 


