/** Lution script file **/

// alert( "In lution.js" );

// ___Gloabal State Variables
   var imagesPreloaded = false;

// FUNCTION: removeFrames
function removeFrames()
{
	if (top.location.href != self.location.href)
	{	if (window.parent.frames[0].location.href != self.location.href) 
		{	top.location.replace(self.location.href);
		}
	}
}

// ___FUNCTION: loadStyleSheet
function loadStyleSheet( xPath )
{
	var cssCall;
	
	if( loadStyleSheet.arguments.length > 0 )
	{
		alert( "xPath = " + xPath );
	}
	else
	{
//		alert( "Loading default stylesheet" );

		if (navigator.platform == "Mac68k" || navigator.platform == "MacPPC")
		{	if (navigator.appName == "Netscape")
			{	cssCall = "<link rel=\"stylesheet\" href=\"/_styles/mac_ns.css\" type=\"text/css\">";
			}
			else
			{	cssCall = "<link rel=\"stylesheet\" href=\"/_styles/mac_ie.css\" type=\"text/css\">";
			}		
		}
		else
		{	if (navigator.appName == "Netscape")
			{	cssCall = "<link rel=\"stylesheet\" href=\"/_styles/standard_ns.css\" type=\"text/css\">";
			}
			else
			{	cssCall = "<link rel=\"stylesheet\" href=\"/_styles/standard_ie.css\" type=\"text/css\">";
			}
		}
	}
	document.write(cssCall);

}

// ___FUNCTION: popupWindow
// ___   Note: min size 25x25, defaults to 1/2 screen size
function popupWindow( xPath, xName, xPrefWidth, xPrefHeight, xGrabFocus )
{
	var height;
	var width;
	
   if( (xPrefWidth > 25) && (xPrefWidth < screen.width) )
	{	width = xPrefWidth;
	}
	else
	{	width = (screen.width) ? screen.width - 50 : 600;
	}

   if( (xPrefHeight > 25) && (xPrefHeight < screen.height) )
	{	height = xPrefHeight;
	}
	else
	{	height = (screen.height) ? screen.height - 50 : 440;
	}

	leftPos = (screen.width) ? (screen.width - width)/2 : 0;
	topPos = (screen.height) ? (screen.height - height)/2 : 0;
	
	var winSettings = 'height=' + height + ',width=' + width + ',top=' + topPos + ',left=' + leftPos + ',scrollbars,resizable=yes';
	var win = window.open( xPath, xName, winSettings );
	
	if( xGrabFocus )
	{	win.focus();
	}
}


// ___FUNCTION: preloadImage
function preloadImage( xPath )
{
	if( document.images)
   {  img = new Image();
      img.src = xPath;
      return img;
   }
}

// ___FUNCTION: swapImages
function swapImages( xName, xPath )
{  if (document.images && (imagesPreloaded == true) )
   {  document[ xName ].src = xPath;
   }
}

// ___FUNCTION; swapImagePairs
// ___   This function takes pairs of arguments (imageName, path) so more than one image can be swapped at a time
function swapImagePairs()
{  if (document.images && (imagesPreloaded == true) )
   {  for( var x=0; x < swapImagePairs.arguments.length; x+=2 )
      {  document[ swapImagePairs.arguments[x]].src = swapImagePairs.arguments[x+1];
      }
   }
}
