// Global JavaScript Functions

/*####################################################################################################

	Title:			Dioceseny Application Global Rollover 
	Author:			Adam Sharp - asharp@andera.com
	Date:			8-24-2001
	
	Purpose:		To serve as a global Image Rollover / Preloader function.
	
	How-To-Config:
		Simply define the 2 variables below...Off_Indicator & Over_Indicator
		"Off_Indicator" should reflect how your "off-state" images are named.  For example, if your
		off-state images are suffixed with "_off", such as "AboutUs_off.gif", than _off would be your
		Off_Indicator.  Over_Indicator should reflect how your "over-state" images are named.
		And that's it!  It's that simple!  Now you can start calling this .js file into your HTML.
		
	Rollover-HTML-Usage:
		<a href="#" onMouseOver="SwapOver('Image1')" onMouseOut="SwapOut('Image1')">
			<img border="0" src="MyImage_off.gif" name="Image1">
		</a>
		
	Preloader-HTML-Usage:
		You need to call the "PreloadImgs()" function onLoad in your <body> tag.  (See below)
					
----------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------
  :-: Define Vars :-:
----------------------------------------------------------------------------------------------------*/

Off_Indicator = "_off";
Over_Indicator = "_over";

/*					**DO NOT EDIT BELOW THIS LINE**
####################################################################################################*/
/*--------------------------------------------------------------------------------------------------
	Create the necessary Variables & Structures
----------------------------------------------------------------------------------------------------*/
var PreloadIndex = 0;
ImgNames = new Array();
LoadImgs = new Array();
OffExpression = "/"+Off_Indicator+"/gi";
OverExpression = "/"+Over_Indicator+"/gi";




/*--------------------------------------------------------------------------------------------------
	MouseOver & MouseOut functions
----------------------------------------------------------------------------------------------------*/

function SwapOver() {
	if (arguments[1]){ if(arguments[1]==1) OnArgs(); }
	ImageName = SwapOver.arguments[0];
	if (document.layers && SwapOver.arguments.length > 1) {
		if (arguments[1] != 1){
			LayerName = SwapOver.arguments[1];
			document[LayerName].document.images[ImageName].src = document[LayerName].document.images[ImageName].src.replace(eval(OffExpression), Over_Indicator);
		}
	} else {
		document.images[ImageName].src = document.images[ImageName].src.replace(eval(OffExpression), Over_Indicator);
	}
	if (arguments[1]){ if(arguments[1]==1) OffArgs(); }
}

function SwapOut() {
	if (arguments[1]){ if(arguments[1]==1) OnArgs(); }
	ImageName = SwapOut.arguments[0];
	if (document.layers && SwapOut.arguments.length > 1) {
		if (arguments[1] != 1){
			LayerName = SwapOut.arguments[1];
			document[LayerName].document.images[ImageName].src = document[LayerName].document.images[ImageName].src.replace(eval(OverExpression), Off_Indicator);
		}
	} else {
		document.images[ImageName].src = document.images[ImageName].src.replace(eval(OverExpression), Off_Indicator);
	}
	if (arguments[1]){ if(arguments[1]==1) OffArgs(); }
}

function OnArgs() {
	Off_Indicator = "_on";
	Over_Indicator = "_onover";
	OffExpression = "/"+Off_Indicator+"/gi";
	OverExpression = "/"+Over_Indicator+"/gi";
}

function OffArgs() {
	Off_Indicator = "_off";
	Over_Indicator = "_over";
	OffExpression = "/"+Off_Indicator+"/gi";
	OverExpression = "/"+Over_Indicator+"/gi";
}

/*--------------------------------------------------------------------------------------------------

	The Preload Function
	How it Works:
		This function will iterate through all of the images in the document. While doing that..for each 
		image, it will check if the image contains your Off_Indicator. If it does, it will create a string identical to 
		that image's name, replacing your Off_Indicator with your Over_Indicator. That string is then added to an array 
		called "ImgNames."  When the function is done building the "ImgNames" array, it will loop
		through ImgNames...Pre-Loading all of the contained images into the Browser-Cache.
	
	Usage:
		You must call the PreloadImgs() function onLoad.
	Example:
		<body onLoad="PreloadImgs()">
		
----------------------------------------------------------------------------------------------------*/

function PreloadImgs() {

	// Build the "ImgNames" Array
	
	if (document.layers) {
		for (y=0; y<document.layers.length; y++) {
			for(i=0; i < document.layers[y].document.images.length; i++) {
				if (document.layers[y].document.images[i].src.search(eval(OffExpression)) > -1) {
					ImgNames[PreloadIndex] = document.layers[y].document.images[i].src.replace(eval(OffExpression), Over_Indicator);
					PreloadIndex++;
				}
			}
		}
		
	}else{
		for(i=0; i < document.images.length; i++) {
			
			if (document.images[i].src.search(eval(OffExpression)) > -1) {
				ImgNames[PreloadIndex] = document.images[i].src.replace(eval(OffExpression), Over_Indicator);
				PreloadIndex++;
			}
		}
	}
	
	
	
	// Lock & Load!
	for(i = 0; i < ImgNames.length; i++) {
	  	LoadImgs[i] = new Image;
	  	LoadImgs[i].src = ImgNames[i];
	}
}

// Pop-up
function popUpSR(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=481,height=252');
self.name = "mainWin"; }

function popUpMAPIT(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=573,height=235');
self.name = "mainWin"; }

function popUpSurvey(url) {
sealWin=window.open(url,"console",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=720,height=700');
self.name = "mainWin"; }