// POU Association Web Site Main JavaScript library
// Copyright (c) 2001 Aaron Collegeman, Petrick Outsourcing Unlimited, Inc.  All Rights Reserved.
// Published work.

function printer() {
/*
	opens print.pl for printer friendly formatting
*/


	var path = document.location.pathname;
	
	// make sure there is a file reference
	if (path.indexOf('.html') < 0 && path.indexOf('.shtml') < 0) {
		path += 'index.shtml';
	}
	
	var href = '/cgi-bin/print.pl?f=' + path;
	window.open(href,'printer','width=250,height=250,resizeable=no,toolbars=no,status=no,scrollbars=no');
	
}

function mouseIn(tlX, tlY, brX, brY, evt) {
/*
	given an event (evt) and a box defined by two points (tlx, ...) returns true is mouse
	point is within function
	ONLY WORKS IN NETSCAPE>4
	tlX: top-left-x
	tlY: top-left-y
	brX: bottom-right-x
	brY: bottom-right-y
*/

	if (evt == null) {
		return -1;
	}

	if (isIE || !isNET) {
		return -1;
	}
	
	if (evt.pageX >= tlX && evt.pageX <= brX && evt.pageY >= tlY && evt.pageY <= brY) {
		return true;
	}
	
	else {
		return false;
	}
}		

/*
	determine browser software and version
*/
var isIE; var isIE4; var isIE5; var isIE6;
var isNET; var isNET4; var isNET6;
var navVer = parseInt(navigator.appVersion);

// is IE?
if (navigator.appName.indexOf('MSIE') > -1 || navigator.appName.indexOf('Microsoft Internet Explorer') > -1) {
	isIE = true;
	if (navVer >= 4 && navVer < 5) { isIE4 = true; }
}
else if (navigator.appName.indexOf('Netscape') > -1) {
	isNET = true;
	if (navVer >= 4 && navVer < 5) { isNET4 = true; }
	else if (navVer >= 5) { isNET6 = true; }
}



function Help(ref) {

/*
	displays help in accordance with variable ref
*/

	var references = new Array();
	references['gateway'] = 'http://petrickoutsourcing.com/thenewpou/help/gateway.html';

	if (references[ref]) {
		window.open(references[ref],'help','height=480,width=320,resize=0,resizeable=0,noresize,toolbar=0,scrollbars=yes');
	}
	else {
		return 0; // null return
	}
}

function WM_preloadImages(imageReq) {

/*
WM_preloadImages()
Loads images into the browser's cache for later use.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
Author Email: nadav@wired.com
Modified by: Aaron Collegeman, acollege@shentel.net

// modified usage: WM_preloadedImages(imageArray[])
Usage: WM_preloadImages('image 1 URL', 'image 2 URL', 'image 3 URL', ...);
*/

  // Don't bother if there's no document.images
  if (document.images) {
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
	  document.WM.loadedImages = new Array();
    }
    
    /*
	:: MODIFICATION
        wanted to pass array of images to WM_preloadImages, instead of
		using multiple calls to the method
		then i decided i still wanted to allow multiple calls to the method, but using an array
    */	

	// load arguments
	var currentLength = document.WM.loadedImages.length;
	
	for (i=0;i<imageReq.length;i++) {
		document.WM.loadedImages[i+currentLength] = new Image();
		document.WM.loadedImages[i+currentLength].src = imageReq[i];
	}
    

    /*
    // Loop through all the arguments.
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      // For each arg, create a new image.
      document.WM.loadedImages[arg] = new Image();
      // Then set the source of that image to the current argument.
      document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
    }
	:: END MODIFICATION
    */
  }
}

function WM_imageSwap(daImage, daSrc){
  var objStr,obj;
  /*
    WM_imageSwap()
    Changes the source of an image.

    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)

    Author: Shvatz
    Author Email: shvatz@wired.com

    Usage: WM_imageSwap(originalImage, 'newSourceUrl');

    Requires: WM_preloadImages() (optional, but recommended)
    Thanks to Ken Sundermeyer (ksundermeyer@macromedia.com) for his help
    with variables in ie3 for the mac. 
    */

  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}



