
//Macromedia functions for Rollovers and Show/Hide Layers and open window
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function initMouseStuff() {
	if (document.layers) { // Netscape
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = captureMousePosition;
	} else if (document.all) { // Internet Explorer
	//    document.onmousemove = captureMousePosition;
	} else if (document.getElementById) { // Gecko
		document.onmousemove = captureMousePosition;
	}
}

function captureMousePosition(e) {
    if (document.layers) {
        mouseLocation.x = e.pageX;
        mouseLocation.y = e.pageY;
        MaxMouseLocation.x = window.innerWidth+window.pageXOffset;
        MaxMouseLocation.y = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        mouseLocation.x = window.event.x+document.body.scrollLeft;
        mouseLocation.y = window.event.y+document.body.scrollTop;
        MaxMouseLocation.x = document.body.clientWidth+document.body.scrollLeft;
        MaxMouseLocation.y = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        mouseLocation.x = e.pageX;
        mouseLocation.y = e.pageY;
        MaxMouseLocation.x = window.innerWidth+window.pageXOffset;
        MaxMouseLocation.y = window.innerHeight+window.pageYOffset;
    }
}

function moveLayerToMouseLoc(theLayer, offsetH, offsetV)
{
  var obj;
  var r;
  var c = 0;
  if ((MM_findObj(theLayer))!=null)
  {

	if (document.layers)  //NS
    {
      document.onmousemove = captureMousePosition;
	  mLoc = mouseLocation;
      obj = document.layers[theLayer];
      obj.left = mLoc.x +offsetH;
      obj.top  = mLoc.y +offsetV;
    }
    else if (document.all)//IE
    {
      captureMousePosition();
  	  mLoc = mouseLocation;
      obj = document.all[theLayer].style;
	  r = (parseInt(obj.width)+mLoc.x +offsetH)
	  if (r > MaxMouseLocation.x)
	  {
		c = (r - MaxMouseLocation.x);
	  }
      obj.pixelLeft = mLoc.x +offsetH - c;
      obj.pixelTop  = mLoc.y +offsetV;
    }
    else if (document.getElementById)
	{
        document.onmousemove = captureMousePosition;
		mLoc = mouseLocation;
		obj = document.getElementById(theLayer);
	  r = (parseInt(obj.style.width)+mLoc.x +offsetH)
	  if (r > MaxMouseLocation.x)
	  {
		c = (r - MaxMouseLocation.x);
	  }
		obj.style.left = (mLoc.x+offsetH - c) + "px";
		obj.style.top  = (mLoc.y+offsetV) + "px";
	}

	MM_showHideLayers(theLayer,'','show');
  }
}

function moveLayerTopToMouseLoc(theLayer, offsetV)
{
  var obj;
  var r;
  var c = 0;
  if ((MM_findObj(theLayer))!=null)
  {

	if (document.layers)  //NS
    {
      document.onmousemove = captureMousePosition;
	  mLoc = mouseLocation;
      obj = document.layers[theLayer];
//      obj.left = mLoc.x +offsetH;
      obj.top  = mLoc.y +offsetV;
    }
    else if (document.all)//IE
    {
      captureMousePosition();
  	  mLoc = mouseLocation;
      obj = document.all[theLayer].style;
	  r = (parseInt(obj.height)+mLoc.y+offsetV)
		  if (r >  MaxMouseLocation.y)
		  {
			c = (r -  MaxMouseLocation.y)
		  }
	
      obj.pixelTop  = mLoc.y +offsetV - c;
    }
    else if (document.getElementById)
	{
        document.onmousemove = captureMousePosition;
		mLoc = mouseLocation;
		obj = document.getElementById(theLayer);
	  r = (parseInt(obj.style.height)+mLoc.y+offsetV)
		  if (r >  MaxMouseLocation.y)
		  {
			c = (r -  MaxMouseLocation.y)
		  }
		obj.style.top  = (mLoc.y+offsetV-c-50) + "px";
	}

	MM_showHideLayers(theLayer,'','show');
  }
}

function moveLayerTopToPosition(theLayer, positionV)
{
  var obj;
  var r;
  var c = 0;
  if ((MM_findObj(theLayer))!=null)
  {

	if (document.layers)  //NS
    {
      obj = document.layers[theLayer];
//      obj.left = mLoc.x +offsetH;
      obj.top  = positionV;
    }
    else if (document.all)//IE
    {
     obj = document.all[theLayer].style;
      obj.pixelTop  = positionV;
    }
    else if (document.getElementById)
	{
		obj = document.getElementById(theLayer);
		obj.style.top  = positionV + "px";
	}

	MM_showHideLayers(theLayer,'','show');
  }
}

function MM_Point(x,y) {  this.x = x; this.y = y; }

//Print page
function printThis(){
	if(navigator.platform.indexOf("Mac")!=-1){
	alert("Attention Mac users:\nTo print, click 'OK', go to the file menu and select 'Print'");
	}else{
	window.print();
	}
  }
  
//open URL in Opener window
function goBack(url) {
opener.location.href = url;
window.close();
}

//clear text fiels
function clearfield(obj){
	if (obj.value != "") 
		obj.value = "";
	}
	
//clear text fiels
function ClearNotesField(obj){
	if (obj.value == "type notes here") 
		obj.value = "";
	}
	
//Close pop up window and refresh opener
function closeWinRefresh() {
	self.close();
	opener.location.reload(true);
}

//name pretty much says it
function confirmDelete() {
	var agree=confirm("Are you sure you want to delete this record?\n------------------------------------------------------\nThis cannot be undone");
	if (agree)
	return true ;
		else
	return false ;
	}
	
function confirmCheck(form) {
	if(form.selectedIndex == 2){
		var agree=confirm("Are you sure you want to mail in a check?\nPaying for \"10,000 Steps\" online is fast, easy, and secure.");
			if (agree){
			return true;
				}
				else
				{
			return false;
			}
		}
	}

function GP_AdvOpenStandardWindow(theURL, winName) {
	GP_AdvOpenWindow(theURL,winName,'fullscreen=no,toolbar=yes,location=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes',700,500,'center','ignoreLink','',0,'')
}


function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}

function P7_JumpMenu(selObj,restore){ //v1.3 by Project Seven
	var theFullString = selObj.options[selObj.selectedIndex].value;
	if (restore) selObj.selectedIndex=0;
	var theLength = theFullString.length;
	var endPos = theFullString.lastIndexOf("~");
	var theUrl, theTarget, theParent;
	if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
	else {theUrl = theFullString;}
	endPos++
	if (endPos < theLength) {theTarget = theFullString.substring(endPos,theLength)}
	else {theTarget = "window:Main";}
	if (theTarget == "window:New") {window.open(theUrl);}
	else if (theTarget == "window:Main") {eval("parent.location='"+theUrl+"'");}
	else {eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}

//functions for auto tabbing

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

if(input.value.length >= len && !containsElement(filter,keyCode)) {
	input.value = input.value.slice(0, len);
	input.form[(getIndex(input)+1) % input.form.length].focus();
}

function containsElement(arr, ele) {
	var found = false, index = 0;
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
			return found;
		}

function getIndex(input) {
	var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)index = i;
			else i++;
			return index;
				}
			return true;
			}

