<!--//
// ----------------------------------- //
// General JavaScript for All Points Pioneer //
// ----------------------------------- //

//calls current year in footer
var date = new Date();
var year = date.getYear();
if (year < 1000) year += 1900;

//simplifiy object calls
var df = document.forms;
var di = document.images;


function changeImage(imgID,imgURL)
{
   if (document.images)
   {
	 document.images[imgID].src = imgURL;
   }else{
	document.getElementById( imgID).src = imgURL;
  }
}

function jsnull () 
	{ /* prevents browser screen jumps that href="#" can cause */ }
	
	
	
// ------------------------------- //
//       Window Popup Function     //
// ------------------------------- //

var w;
function popup(target, width, height, scrollbars, hidemenus){
 	var settings;
 	var menus;
 	var scrolls;
	
 	if (hidemenus) { menus = ",status=yes,toolbar=no,menubar=no,location=no"; }else{ menus = ",status=yes,toolbar=yes,menubar=yes,location=yes"; }
	
 	if (scrollbars) { scrolls = ",scrollbars=yes"; }else{ scrolls = ""; }
	
 	settings = 'width=' + width + ',height=' + height + ',resizable=yes' + scrolls + menus;
	
 	w = window.open(target,'bearpop',settings);
 	w.focus();
}


// ----------------------------------- //
//   Display and Visibility Functions  //
// ----------------------------------- //
function toggleDisplay(divID)
{
	if (document.layers)
		{
		var thisDiv = document.layers[divID];
		var newValue = (thisDiv.display != 'block') ? 'block' : 'none';
		thisDiv.display = newValue;
		}
	else if (document.all)
		{
		var thisDiv = document.all[divID];
		var newValue = (thisDiv.style.display != 'block') ? 'block' : 'none';
		thisDiv.style.display = newValue;
		}
	else if (document.getElementById)
		{
		var thisDiv = document.getElementById(divID);
		var newValue = (thisDiv.style.display != 'block') ? 'block' : 'none';
		thisDiv.style.display = newValue;
		}
}

function toggleVisible(divID)
{
	if (document.layers)
		{
		var thisDiv = document.layers[divID];
		var newValue = (thisDiv.visibility != 'show') ? 'show' : 'hide'
		thisDiv.visibility = newValue;
		}
	else if (document.all)
		{
		var thisDiv = document.all[divID];
		var newValue = (thisDiv.style.visibility != 'visible') ? 'visible'	: 'hidden';
		thisDiv.style.visibility = newValue;
		}
	else if (document.getElementById)
		{
		var thisDiv = document.getElementById(divID);
		var newValue = (thisDiv.style.visibility != 'visible') ? 'visible' : 'hidden';
		thisDiv.style.visibility = newValue;
		}
}

function setDisplay(divID,setType){
	if (document.layers){
		document.layers[divID].display = setType;
		}
	else if (document.all){
		document.all[divID].style.display = setType;
		}
	else if (document.getElementById){
		document.getElementById(divID).style.display = setType;
		}
}

function showCallout(calloutIndex,lnksArray,wndwsArray){
	if (document.getElementById){
		var i;
		var thisLnk = document.getElementById(lnksArray[calloutIndex]);
		var thisWndw;
		var currentState = thisLnk.className;
		
		//turn all links and windows off//
		for (i in lnksArray){
			thisLnk = document.getElementById(lnksArray[i]);
			thisWndw = document.getElementById(wndwsArray[i]);
			thisLnk.className = 'expand';
			setDisplay(thisWndw.id,'none');
		}
		
		//turn this one on, if not already//
		thisLnk = document.getElementById(lnksArray[calloutIndex]);
		thisWndw = document.getElementById(wndwsArray[calloutIndex]);
		
		if(currentState == 'expand'){
			thisLnk.className = 'activeftr';
			setDisplay(thisWndw.id,'block');	
		}else{
			thisLnk.className = 'expand';
			setDisplay(thisWndw.id,'none');
		}
		
	}else{
		//no getElementById//
		// TODO - consider writing code for these browsers //
	}
}


// ------------------------------- //
//   Email Addy Hiding Functions   //
// ------------------------------- //
at = '@';
mailer = 'mailto:';

function getmail(name, domain, suffix, text){ //user supplied email parts and alt text
		hiddenMail=(name + at + domain + '.' + suffix);
		if (! text){ //if no alt text then use full email address
			text = hiddenMail;
		}
		email = '<a href="' + mailer + hiddenMail + '" onClick="javascript:pageTracker._trackPageview(\'/mailto/' + hiddenMail + '\');">' + text + '</a>';
		return email;
}


// ------------------------------- //
//     Image Rollover Functions    //
// ------------------------------- //
// XHTML Transitional Valid Image Rollovers //
// This script runs on any images with the proper ending to their filename (foo_nm.jpg, foo_hv.jpg, foo_md.jpg, foo_ou.jpg, foo_mu.jpg) //

// Non-Obtrusive Image Swap Script V1.1 by Hesido.com //
// Attribution required on all accounts //

// If the browser is W3 DOM compliant, execute setImageSwaps function
if (document.getElementsByTagName && document.getElementById) 
{
	if (window.addEventListener) window.addEventListener('load', setImageSwaps, false);
	else if (window.attachEvent) window.attachEvent('onload', setImageSwaps);
}

// When document loads, apply the prepareImageSwap function to various images with our desired settings
function setImageSwaps() 
{
	// ---Mousedown, restore - for images in container with ID=example2
	// prepareImageSwap('example2',true,true,true,true);
	// ---Hover, mousedown, no restore - for images in container with ID=example3
	// prepareImageSwap('example3',true,false,true,false);
	// ---Hover with restore, most basic usage - for any image in document.body that are not yet processed (function accepts elements,too)
	prepareImageSwap(document.body);
	// ---Note that once an image is processed, it won't be processed again, so you should set more specific images first, e.g. document.body, as it is the grand
	// ---container, has to be processed last.
}

function prepareImageSwap(elem,mouseOver,mouseOutRestore,mouseDown,mouseUpRestore,mouseOut,mouseUp) 
{ 
    if (typeof(elem) == 'string') elem = document.getElementById(elem); 
    if (elem == null) return; 
    var regg = /(.*)(_nm\.)([^\.]{3,4})$/ 
    var prel = new Array(), img, imgList, imgsrc, mtchd; 
    imgList = elem.getElementsByTagName('img'); 
    for (var i=0; img = imgList[i]; i++) 
	{ 
        if (!img.rolloverSet && img.src.match(regg)) 
		{ 
            mtchd = img.src.match(regg); 
            img.hoverSRC = mtchd[1]+'_hv.'+ mtchd[3]; 
            img.outSRC = img.src; 
            if (typeof(mouseOver) != 'undefined') 
			{ 
                img.hoverSRC = (mouseOver) ? mtchd[1]+'_hv.'+ mtchd[3] : false; 
                img.outSRC = (mouseOut) ? mtchd[1]+'_ou.'+ mtchd[3] : (mouseOver && mouseOutRestore) ? img.src : false; 
                img.mdownSRC = (mouseDown) ? mtchd[1]+'_md.' + mtchd[3] : false; 
                img.mupSRC = (mouseUp) ? mtchd[1]+'_mu.' + mtchd[3] : (mouseOver && mouseDown && mouseUpRestore) ? img.hoverSRC : (mouseDown && mouseUpRestore) ? img.src : false; 
          	} 
            if (img.hoverSRC) {preLoadImg(img.hoverSRC); img.onmouseover = imgHoverSwap;} 
            if (img.outSRC) {preLoadImg(img.outSRC); img.onmouseout = imgOutSwap;} 
            if (img.mdownSRC) {preLoadImg(img.mdownSRC); img.onmousedown = imgMouseDownSwap;} 
            if (img.mupSRC) {preLoadImg(img.mupSRC); img.onmouseup = imgMouseUpSwap;} 
            img.rolloverSet = true; 
     	} 
	} 
    function preLoadImg(imgSrc) 
		{ 
        prel[prel.length] = new Image(); prel[prel.length-1].src = imgSrc; 
		} 
} 
function imgHoverSwap() {this.src = this.hoverSRC;} 
function imgOutSwap() {this.src = this.outSRC;} 
function imgMouseDownSwap() {this.src = this.mdownSRC;} 
function imgMouseUpSwap() {this.src = this.mupSRC;}

function hideAllSelectBoxes(){
	// Hide select boxes as they will 'peek' through the image in IE
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {selects[i].style.visibility = "hidden";}
}

function showAllSelectBoxes(){
	// reveal select boxes that were hidden from IE	
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {selects[i].style.visibility = "visible";}	
}

//-->
