/****
 *
 * filename      : js_script.js
 * project       : mp-network.de 2006
 *
 * copyright     : (c) 2005 by pokepika
 * author        : Patrick Westerhoff
 *                 pokepika
 * email         : projects@pokepika.com
 *
 */

function toggleForm ( pId )
{
	var form = document.getElementById( pId );

	if ( form.style.display == 'block' )
		form.style.display = 'none';
	else
		form.style.display = 'block';
}

/** overlay Method **/
var overlayId  = null;
var overlayDiv = null;

function toggleOverlay ( pId )
{
	pStatus = 1;

	if ( overlayId != null )
	{
		if ( pId == overlayId )
			pStatus = 0;

		overlayDiv.style.display = 'none';
		overlayDiv               = null;
		overlayId                = null;
	}

	if ( pStatus == 1 )
	{
		overlayId  = pId;
		overlayDiv = document.getElementById( overlayId );

		overlayDiv.style.display = 'block';
		overlayDiv.style.left    = ( mouseX + 10 ) + 'px';
		overlayDiv.style.top     = ( mouseY + 10 ) + 'px';
	}
}


/** Mouse Positions **/
document.onmousedown = getMousePositions;
var mouseX;
var mouseY;

function getMousePositions ( eventObj )
{
	var nMouseX;
	var nMouseY;
	var nDocumentWidth;
	var nDocumentHeight;
	var nBodyWidth  = 500;
	var nBodyHeight = 600;

	if ( navigator.appName == 'Microsoft Internet Explorer' )
	{
		nMouseX         = event.x;
		nMouseY         = event.y;
		nDocumentWidth  = document.documentElement.clientWidth;
		nDocumentHeight = document.documentElement.clientHeight;
	}
	else
	{
		nMouseX         = eventObj.pageX;
		nMouseY         = eventObj.pageY;
		nDocumentWidth  = window.innerWidth;
		nDocumentHeight = window.innerHeight;
	}

	// calculate relative mouse positions
	mouseX = nMouseX - ( nDocumentWidth  - nBodyWidth  ) / 2;
	mouseY = nMouseY - ( nDocumentHeight - nBodyHeight ) / 2;
}


/** PopUp Function **/
function popUp( pName, pUrl, pWidth, pHeight )
{
	pWidth  += 20;
	pHeight += 20;
	
	// position
	var posX   = ( screen.width  - pWidth  ) / 2;
	var posY   = ( screen.height - pHeight ) / 2;

	// set parameter
	var params = 'width=' + pWidth + ',height=' + pHeight;
	params    += ',left=' + posX + ',top=' + posY;
	params    += ',menubar=no,location=no,toolbar=no';
	params    += ',status=no,resizable=no,scrollbars=yes';

	var popWin  = window.open( pUrl, pName, params );

	popWin.moveTo( posX, posY );pName, pUrl, pWidth, pHeight
	popWin.focus();
}

