var ACTION = 'webAction';
var USER = 'webUser';

// Created 02.08.2000

// Functions
// Name					Descript
// ------------------------------------------------------------------------------------
// closeFooterFrame     Change the height of the footer frame to 0 pixels
// openFooterFrame      Change the height of the footer frame to 20 pixels
// openWindow			Open a window in the center of the screen and sets focus to it.
// openWindowMenu		Same as openWindow, but the window will have the menu bars (so users can save, etc.)

// Function: closeFooterFrame
// Changes the height of the footer frame to 0

function closeFooterFrame()
{
	if ( !document.layers )
	{
		top.belowheader.rightside.rows = "*,0";
	}
}

// Function: openFooterFrame
// Changes the height of the footer frame to the specified height

function openFooterFrame()
{
	if ( !document.layers )
	{
		top.belowheader.rightside.rows = "*,20";
	}
}

// Function: openWindow
// Centers the window in the center of the screen.
var theNewWindow = null;

var chasm = screen.availWidth;
var mount = screen.availHeight;

var nWidth  = 0;
var nHeight = 0;

function openWindow(cLocation, cWindowName, nWidth, nHeight)
{
	return openWindowWithOpts( cLocation, cWindowName, nWidth, nHeight, 'status,scrollbars,dependent,resizable' );
}

function openWindowMenu(cLocation, cWindowName, nWidth, nHeight)
{
	return openWindowWithOpts( cLocation, cWindowName, nWidth, nHeight, 'menubar,status,scrollbars,dependent,resizable' );
}

function openWindowWithOpts(cLocation, cWindowName, nWidth, nHeight, cOpts)
{
	theNewWindow = window.open(cLocation,cWindowName, cOpts + ',width=' + nWidth + ',height=' + nHeight + ',left=' + ((chasm - nWidth - 10) * .5) + ',top=' + ((mount - nHeight - 30) * .5));
	if ( theNewWindow == null )
	{
		alert( 'A pop-up window was blocked.  To use this application correctly, please disable pop-up blockers for this site.');
	}
	else
	{
		if ( top.spawnedWindows )
		{
			//add spawned window to collection, so that when application is exited, they can be closed as well
			top.spawnedWindows[ top.spawnedWindows.length ] = theNewWindow;
		}

		theNewWindow.focus();
	}

	return theNewWindow;
}

function processRequest()
{
   top.processingRequest = true;
}

function doneProcessingRequest()
{
   top.processingRequest = false;
}

function canProcess( clearStatus )
{
   canProcessResult = false;

   if ( !top.processingRequest )
   {
      //not currently processing a request
      //set flag that now we are (by processRequest())
      processRequest();

      if ( clearStatus )
      {
         //clear window status of message
         window.status='';
      }
      //return result that an item may indeed be added to cart
      canProcessResult = true;
   }

   return canProcessResult;
}

function handleOnSubmit( form )
{
	appendDebugInfo( form );
}

function appendDebugInfo( form )
{	
	if ( form.action != null )
	{
		if ( document.getElementById( ACTION ) != null )
		{
			form.action = form.action + getParameterDelimiter( form.action ) + ACTION + '=' + document.getElementById( ACTION ).value;
		}
		
		if ( document.getElementById( USER ) != null )
		{
			form.action = form.action + getParameterDelimiter( form.action ) + USER + '=' + document.getElementById( USER ).value;			
		}		
	}
}

function getParameterDelimiter( url )
{
	if ( url.indexOf( '?' ) == -1 )
	{
		return '?';
	}

	return '&';
}
