
function tripInfo() {
	var tripID;
	var tripSelect = document.tripForm.tripID;
	for (var i = 0; i < tripSelect.length; i++)
		if (tripSelect[i].selected == true)
			{
			tripID = tripSelect[i].value
			}
	for (var i = 1; i < tripSelect.length; i++)
		{
		//alert(tripSelect[i].value);
		eval("document.getElementById('s" + tripSelect[i].value + "').style.display = 'none'");
		eval("document.getElementById('sp" + tripSelect[i].value + "').style.display = 'none'");
		eval("document.getElementById('c" + tripSelect[i].value + "').style.display = 'none'");
		}
	if (eval("document.getElementById('s" + tripID + "')"))
		{
			eval("document.getElementById('s" + tripID + "').style.display = ''");
			eval("document.getElementById('sp" + tripID + "').style.display = ''");
			eval("document.getElementById('c" + tripID + "').style.display = ''");
			if (eval("document.getElementById('s" + tripID + "').firstChild.data == 'Open'"))
				{
				eval("document.getElementById('applyButton').style.display = ''");
				eval("document.getElementById('inquireLink').style.display = ''");
				eval("document.getElementById('noMoreAppText').style.display = 'none'");
				}
			else
				{
				eval("document.getElementById('applyButton').style.display = 'none'");
				eval("document.getElementById('inquireLink').style.display = 'none'");
				eval("document.getElementById('noMoreAppText').style.display = ''");
				}
			if (eval("document.getElementById('sSelect')"))
				{
				eval("document.getElementById('sSelect').style.display = 'none'");
				}
			if (eval("document.getElementById('spSelect')"))
				{
				eval("document.getElementById('spSelect').style.display = 'none'");
				}
			if (eval("document.getElementById('cSelect')"))
				{
				eval("document.getElementById('cSelect').style.display = 'none'");
				}
		}
	else
		{
			if (eval("document.getElementById('applyButton')"))
				{
				eval("document.getElementById('applyButton').style.display = 'none'");
				}
			if (eval("document.getElementById('inquireLink')"))
				{
				eval("document.getElementById('inquireLink').style.display = ''");
				}
			if (eval("document.getElementById('noMoreAppText')"))
				{
				eval("document.getElementById('noMoreAppText').style.display = 'none'");
				}
		}

}



function getCookieData(label) 
{
	var labelLen = label.length;
	var cLen = document.cookie.length;
	var cEnd;
	for (var i = 0; i < cLen; i++)
	{
		var j = i + labelLen;
		if (document.cookie.substring(i, j) == label)
		{
			cEnd = document.cookie.indexOf(";",j);
			if (cEnd == -1)
			{
				cEnd = document.cookie.length;
			}
			return unescape(document.cookie.substring(j + 1,cEnd))
		}
	}
		return "";
}


function checkImages() {
	var doSubmit = true;
	for (var x = 0; x < 7; x++)
	{
		if ((eval("document.getElementById('amount" + x + "').value") != 0) && (eval("document.getElementById('uploadImage" + x + "').value") == ''))
			{
			alert('You must upload an image for each item with a value greater than 0.');
			document.getElementById('amount' + x).focus();
			doSubmit = false;
			return false;
			break;
			}
	}
	if (doSubmit)
		{
		reimbForm.submit();
		}
}



function checkImages2() {
	var doSubmit = true;
		if ((eval("document.getElementById('amount1').value") != 0) && (eval("document.getElementById('uploadImage1').value") == ''))
			{
			alert('You must upload an image for each item with a value greater than 0.');
			document.getElementById('amount1').focus();
			doSubmit = false;
			return false;
			}
		if ((eval("document.getElementById('amount1').value") == 0) && (eval("document.getElementById('uploadImage1').value") == ''))
			{
			alert('You must enter a total for the receipts you are uploading.');
			document.getElementById('amount1').focus();
			doSubmit = false;
			return false;
			}
	if (doSubmit)
		{
		return true;
		}
}


function checkImages3() {
	var theTotal = 0;
	for (var x = 0; x < 7; x++)
		{
			theTotal += eval("document.getElementById('amount" + x + "').value")
		}
	if (theTotal == 0)
		{
			alert('You must enter a total for at least one category.');
			document.getElementById('amount0').focus();
			return false;
		}
	else
		{
		document.reimbForm.submit();
		}
}


function checkImages5() {
	var theTotal = 0;
	for (var x = 0; x < 7; x++)
		{
			theTotal += eval("document.getElementById('amount" + x + "').value")
		}
	if (theTotal == 0)
		{
			alert('You must enter a total for at least one category.');
			document.getElementById('amount0').focus();
			return false;
		}
	else
		{
			return true;
		}
}


function checkImages4() {
	var doSubmit = false;
	for (var x = 1; x < 16; x++)
		{
			if (eval("document.getElementById('uploadImage" + x + "')"))
				{
				if (eval("document.getElementById('uploadImage" + x + "').value") != '')
					{
					doSubmit = true;
					break;
					}
				}
			if (eval("document.getElementById('uploadPDF" + x + "')"))
				{
				if (eval("document.getElementById('uploadPDF" + x + "').value") != '')
					{
					doSubmit = true;
					break;
					}
				}
		}
	if (doSubmit)
		{
			document.reimbForm.submit();
		}
	else
		{
			alert('You must upload at least one file.');
			return false;
		}
}


/*
these functions do a tooltip to anything on the html page.
*/
	
	function showTipz(oEvent, sElement) {
		var oDiv = document.getElementById(sElement);
		oDiv.style.visibility = "visible";
		oDiv.style.left = oEvent.clientX + 5;
		oDiv.style.top = oEvent.clientY + 5;
	}
	function hideTipz(oEvent, sElement) {
		var oDiv = document.getElementById(sElement);
		oDiv.style.visibility = "hidden";
	}

/*

This is an example of a js confirm
if (salaryForm.Delete[1].checked)//this is using another condition to get to the confirm
	{
		if (confirm('Are you sure you want to delete this record?'))//notice that the confirm is, in itself, an if/then statement
			{salaryForm.submit();}
	} 
else 
	checkForm('salaryForm')
*/
function unCheckAll(sForm, sField)
{
	//var newForm = document.getElementById(sForm) + '.' + document.getElementById(sField);
	//5/4/09 I'm not sure why the above line is suddenly not working. However, the line below works fine...??
	var newForm = eval(sForm + '.' + sField);
	var q = 0;
	//alert(newForm.length);
	//alert(newForm[2].checked);
	for (var x = 0; x < newForm.length; x++)
		{
			if (newForm[x].checked == true)
				{
					newForm[x].checked = false;
					q += 1
				}
		}
	if (q == 0)
		{
			for (var x = 0; x < newForm.length; x++)
				{
					//alert(x);
					newForm[x].checked = true;
				}
		}
}


function writeSort()
{
var phred = document.searchForm.phred
var sPhred = document.searchForm.sPhred
var sortBy = document.searchForm.sortBy
var sortChoose = document.searchForm.sortByChoose
var qb = 0
var doClear = false
for (var q = 0; q < sortChoose.length; q++)
	{
	if (sortChoose[q].selected == true)
		{
		qb += 1;
		if (q == 0)
			{
			doClear = true;
			}
		}
	}
if (doClear == true)
	{
	for (var a = 0; a < sortChoose.length; a++)
		{
		if (a > 0)
			{
			sortChoose[a].selected = false;
			}
		phred.value = '';
		sPhred.value = '';
		sortBy.value = '';
		}
	}
else
	{
	for (var z = 0; z < sortChoose.length; z++)
		{
		if (qb == 1)
			{
			if ((sortChoose[z].selected == true ) && (z > 0))
				{
				phred.value = sortChoose.options[z].text;
				sPhred.value = sortChoose.options[z].text;
				sortBy.value = sortChoose.options[z].value;
				}
			}
		else if (qb > 1)
			{
			if (sortChoose[z].selected == false)
				{
				if (phred.value.indexOf(sortChoose.options[z].text) > -1)
					{
					phred.value = phred.value.replace(sortChoose.options[z].text + ',', '');
					phred.value = phred.value.replace(',' + sortChoose.options[z].text, '');
					sPhred.value = phred.value.replace(sortChoose.options[z].text + ',', '');
					sPhred.value = phred.value.replace(',' + sortChoose.options[z].text, '');
					var aArr = sortBy.value.split('||');
					var newI = 0;
					var breakType = '';
			        for (var y = 0; y < aArr.length; y++)
			            {
			            if (sortChoose.options[z].value == aArr[y])
			                {
							//we know the index of the item that matches in the string = y
							newI = y;
							break;
			                }
			             }
					var newSort = '';
					var bArr = sortBy.value.split('||');
					for (var g = 0; g < bArr.length; g++)
						{
						if (g != newI)
							{
							newSort += bArr[g] + '||';
							}
						}
					sortBy.value = newSort.substring(0, newSort.length - 2);
					}
				}
			else
				{
				if (phred.value.indexOf(sortChoose.options[z].text) < 0)
					{
					phred.value += ',' + sortChoose.options[z].text;
					sPhred.value += ',' + sortChoose.options[z].text;
					sortBy.value += '||' + sortChoose.options[z].value;
					}
				}
			}
		}
	}
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function reportSubmit(sValue)
	{
		if (sValue == 'location')
		{
			//document.reportForm.action.value = 'index.asp?switch=searchLocation';
			//alert(document.reportForm.action.value.toString());
			//reportForm.submit();
		}
	}
//====this function turns a div on and off
function toggleDiv(sField, sImg)
	{
		var theF = eval("document.all." + sField);
		if (theF.style.display == 'none')
			{
				theF.style.display = '';
				eval("document.images['" + sImg + "'].src = '../images/dsChildNew.gif'");
			}
		else
			{
				theF.style.display = 'none';
				eval("document.images['" + sImg + "'].src = '../images/dsParentNew.gif'");
			}
	}


function toggleDiv3(sForm, sField)
	{
		var newForm = eval("document." + sForm);
		var theF = eval(sField + "div");
		//alert("document." + sForm);
		//alert(sField);

		var theT = sField.replace("_xz", "text");
		var theList = eval(sForm + "." + sField);
		//alert(eval(sForm + "." + sField + ".value"));
		//alert(eval(sForm + "." & sField + ".length"));
		//alert(sForm.toString());
		//alert(evalForm.sProject_xz.length);
		var theForm = sForm.toString();
		var theField = sField.toString();
		//alert(eval(theForm + "." + theField + ".length"));
		var theLength = eval(theForm + "." + theField + ".length");
		for (var i = 0; i < theLength; i++)
			{
				//alert(theList[i].value);
			if (theList[i].selected == true)
				{
				if ((theList[i].value == 1 || theList[i].value == 2))
				//if (sVal == 1 || sVal ==2)
					{
						theF.style.display = '';
						eval("document." + sForm + "." + theT + ".style.display = ''");
						eval("document." + sForm + "." + theT + ".disabled = false");
						eval("document." + sForm + "." + theT + ".focus()");
						break;
					}
				}
			else
				{
					theF.style.display = 'none';
					eval("document." + sForm + "." + theT + ".style.display = 'none'");
					eval("document." + sForm + "." + theT + ".disabled = true");
				}
			}
	}


function toggleDiv2(sField, sImg)
	{
		var theF = eval("document.all." + sField);
		if (theF.style.display == 'none')
			{
				theF.style.display = '';
				eval("document.images['" + sImg + "'].src = 'images/dsChildNew.gif'");
			}
		else
			{
				theF.style.display = 'none';
				eval("document.images['" + sImg + "'].src = 'images/dsParentNew.gif'");
			}
	}


function toggleDiv4(sField)
	{
		var theF = eval("document.all." + sField);
		if (theF.style.display == 'none')
			{
				theF.style.display = '';
			}
		else
			{
				theF.style.display = 'none';
			}
	}


//==This function enables a submit button when a radiobutton is clicked. Nothing else
function enableButton(sForm, sButton)
	{
	eval("document." + sForm + "." + sButton + ".disabled = false;");
	}

//==This function changes the style of the item fed to it from display:none to display and back again
/*
function showField(sValue, matchValue, itemName)
1/20/06
sValue = the actual selected value (I expect that this will be used most with select boxes)
matchValue = the value that triggers the item to be turned on
itemName = name of the item that is to be turned on or off
	{
	var sItem = eval("document.all." + itemName);
	alert(sItem.);
		if (sValue == matchValue)
			{
			sItem.style.display = '';
			}
		else
			{
			sItem.style.display = 'none';
			}
	}
*/


//==================================== this checks a form for required items and colors them reddish
function reqFields(formName)
	{
	var newForm = eval("document." + formName);
	var isSubmit
	//alert(newForm.elements.length);
		for (var i = 0; i < newForm.elements.length; i++)
			{
				if ((newForm.elements[i].name.indexOf('_xz') < 1) && (newForm.elements[i].value == '') && (newForm.elements[i].type != 'hidden') && (newForm.elements[i].disabled == false) && (newForm.elements[i].name.indexOf('month') < 1) && (newForm.elements[i].name.indexOf('day') < 1) && (newForm.elements[i].name.indexOf('year') < 1))
					{
					if (newForm.elements[i].type == 'text')
						{
						newForm.elements[i].style.background = '#cccccc';
						}
					if (newForm.elements[i].type == 'select-one')
						{
						newForm.elements[i].style.background = '#cccccc';
						}
					if (newForm.elements[i].type == 'select-multiple')
						{
						newForm.elements[i].style.background = '#cccccc';
						}
					if (newForm.elements[i].type == 'password')
						{
						newForm.elements[i].style.background = '#cccccc';
						}
					if (newForm.elements[i].type == 'textarea')
						{
						newForm.elements[i].style.background = '#cccccc';
						}
					if (newForm.elements[i].type == 'checkbox')
						{
						newForm.elements[i].style.background = '#cccccc';
						}
					if (newForm.elements[i].type == 'radio')
						{
						newForm.elements[i].style.background = '#cccccc';
						}
    				}
    			if (newForm.elements[i].type == 'radio')
    			    {
        			    var newName = newForm.elements[i].name;
        			    var newLen = eval("newForm." + newName + ".length");
        			    var isTrue = false
    			        for (var x = 0; x < newLen; x++)
    			            {
                            if (eval("newForm." + newName + "[x].checked") == true)
                                {
                                isTrue = true;
                                }    			             
    			            }
    			            if (isTrue == false)
    			            {
    			            for (var x = 0; x < newLen; x++)
    			                {
                                //alert(eval("newForm." + newName + "[x].checked"));
    			                eval("newForm." + newName + "[x].style.background = '#cccccc'");
    			                }
    			            }
    			    }
    			if (newForm.elements[i].type == 'checkbox')
    			    {
        			    var newName = newForm.elements[i].name;
        			    var newLen = eval("newForm." + newName + ".length");
        			    var isTrue = false
    			        for (var x = 0; x < newLen; x++)
    			            {
                            if (eval("newForm." + newName + "[x].checked") == true)
                                {
                                isTrue = true;
                                }    			             
    			            }
    			            if (isTrue == false)
    			            {
    			            for (var x = 0; x < newLen; x++)
    			                {
                                //alert(eval("newForm." + newName + "[x].checked"));
    			                eval("newForm." + newName + "[x].style.background = '#cccccc'");
    			                }
    			            }
    			    }
			}
	}



//==================================== valid email address tester thingee
/*
Advanced Email Check
By Website Abstraction (http://www.wsabstract.com) and
Java-Scripts.net (http://www.java-scripts.net)
Over 200+ free scripts here!
*/

var testresults

function checkemail(formName, fieldName)
	{
 	var str = eval('document.' + formName + '.' + fieldName + '.value')
 	var filter=/^.+@.+\..{2,3}$/
	
 	if (filter.test(str))
    	testresults=true
 	else {
 	/*
 	OK, here's what I found out; Firefox will not allow you to focus on a field from which you are doing an onBlur.
 	So, the solution is to do the onBlur on the next field and it works fine in both IE and FF.
 	Weird.
 	*/
		alert("Please input a valid email address!");
		document.getElementById(fieldName).focus();
		document.getElementById(fieldName).select();
		//setTimeout("document.getElementById(" + fieldName + ").focus();",1000);
		//setTimeout("document.getElementById(" + fieldName + ").select();",1000);
		//eval('document.' + formName + '.' + fieldName + '.select()');
		//eval('document.' + formName + '.' + fieldName + '.focus()');
		testresults=false
		}
	return (testresults)
	}


function checkbae(){
if (document.layers||document.all)
return checkemail()
else
return true
}


//===================================this changes the background color of a text box based on whether or not it is required and/or empty
function changeBackground(sName, sType)
    {
    var newForm = "form1";
    var newVal = eval("form1." + sName + ".value");
    var newLen = eval("form1." + sName + ".length");
    var newField = eval("form1." + sName);
    
    switch(sType)
        {
        case 'radio':
            for (var x = 0; x < newLen; x++)
                {
                eval("form1." + sName + "[x].style.background = ''");
                }
            break;
        case 'checkbox':
            var isTrue = false;
            var isOther = false;
            for (var x = 0; x < newLen; x++)
                {
                if (eval("form1." + sName + "[x].checked == true"))
                    {
                    //alert(eval("form1." + sName + "[x].checked == true"))
                    isTrue = true;
                    }
                }
            if (isTrue)
                {
                for (var x = 0; x < newLen; x++)
                    {
                    eval("form1." + sName + "[x].style.background = ''");
/*                    if (eval("form1." + sName + "[x].value == 'Other'") && (eval("form1." + sName + "[x].checked == true")))
                        {
                        isOther = true;
                        }
*/                    }
                }
              else
                {
                for (var x = 0; x < newLen; x++)
                    {
                    eval("form1." + sName + "[x].style.background = '#cccccc'");
                    }
                }
            break;
        default:
            if (newVal.length > 0)
                {
                newField.style.background = '#ffffff';
                //alert(newVal.length);
                }
            else
                {
                newField.style.background = '#cccccc';
                //alert(newVal.length);
                }
         }
    }

//===================================this function checks the string and selects the item if the string value = true
function selectCheckBox(sStr, sName)
    {
    /*
    9/28/04 mal
    Because I am using only numeric values, I am doing vb replace(sVar, " ", "") when this function is called to get rid of 
    the spaces that are in the string.
    */
    var aArr = sStr.split(',')
    var z = eval("document.form1." + sName + ".length")
    var sVal = eval("document.form1." + sName)
    for (var x = 0; x < z; x++)
        {
        for (var y = 0; y < aArr.length; y++)
            {
            if (sVal[x].value == aArr[y])
                {
                //alert(aArr[y]);
                sVal[x].checked = true;
                }
             }
        }
    }
//==============does the same as the function above, only lets you feed the form name.
function selectCheckBox2(sForm, sStr, sName)
    {
    /*
	12/20/07 mal
	*/
    var aArr = sStr.split(',')
    var z = eval("document." + sForm + "." + sName + ".length")
    var sVal = eval("document." + sForm + "." + sName)
    for (var x = 0; x < z; x++)
        {
        for (var y = 0; y < aArr.length; y++)
            {
            if (sVal[x].value == aArr[y])
                {
                //alert(aArr[y]);
                sVal[x].checked = true;
                }
             }
        }
    }

//==================================== this function submits the current nextStep form and sets a page number value
function sPage(pageNum)
    {
    var s = form1;
    if (s.thisPage.value == 0)
        {
        if (s.Email_Address1.value == '')
            {
                alert('You must type an email address');
                s.Email_Address1.focus();
            }
        else if (s.Password.value == '')
            {
                alert('You must type a password');
                s.Password.focus();
            }
        else if (checkemail())
            {
            //if (confirm("This will save all of your changes.\n\Are you sure you want to do this?"))
              //  {
                s.nextPage.value = pageNum;
                s.submit();
              //  }
            }
         }
      else
        {
            s.nextPage.value = pageNum;
            if ((pageNum == 7))
                {
                    s.action = "https://www.adventures.org/a/nextstep/apply/_pay_app_fee.asp"
                }

            s.submit();
        }
    }



//===================================== this function is used for the admin drop downs to make them automatically activate the choice that is selected
function leapTo (link)
   {
   var new_url=link;
   if (  (new_url != "")  &&  (new_url != null)  )
      window.location=new_url;
   else
      alert("\nYou must make a selection.");
   }

//===================================== this function is called when using isNumber(a, b) and gives the alert
//===================================== is also uses the next function, isNumber, to do its business...
function numAlert(myStr)
	{
		if (myStr.value.length > 0)
		{
			if (isNumber(myStr) == false)
				{
					alert("You have entered an item that is not at number. Please correct " + myStr.value);
					myStr.focus();
					myStr.select();
					return false;
				}
		}
	}
	
//===================================== this function is supposed to test a string to see if it is a number, but I have had trouble with it.
function isNumber(fvalue) 
	{
	var anum = /\d/;
	var m = true;
	if ((fvalue == null) || (fvalue == ""))
		m = false;
	else
		for (var d = 0; d < fvalue.length; d++) {
			var c = fvalue.charAt(d);
			//alert(c + ' -- ' + anum.test(c));
			if (!anum.test(c))
				m = false;
		}
	return m;
} //isNumber(fvalue)

//===================================== this function tests a string to see if it is a number
//===================================== The thing I like about this one is that it is simple and works - if only because js allows you to make any string into a number
function formatNum(theNum)
	{
	var newNum;
	newNum = Number(theNum.value);
	if ((newNum * 0 == 0))
		return newNum;
	else if (newNum * 0 != 0)
		alert("This is not a number");
		document.getElementById(theNum).focus();
		document.getElementById(theNum).select();
		return theNum.value;
	}


function formatNum2(theNum)
	{
	var newNum;
	newNum = Number(theNum.value);
	if ((newNum * 0 == 0) && (newNum != 0))
		{
		//alert(newNum);
		return newNum;
		}
	else if (newNum * 0 != 0)
		{
		alert("This is not a number");
		theNum.focus();
		theNum.select();
		return false;
		}
	else
		{
		alert("You must enter a number");
		theNum.focus();
		theNum.select();
		return false;
		}
	}

//===================================== this function tests a string (theStr) for the length fed to it (theNum)
function testLength(theStr, theNum)
	{
	if (theStr.value.length > theNum)
		{
		alert("The max character length of this field is " + theNum + ". You are using " + theStr.value.length + " characters.");
		theStr.focus();
		theStr.select();
		}
	else
		return false;
	}

//===== this function forces a certain length - it is intended for phone numbers, 
//but could be used for more
function forceLength(theStr, theNum)
	{
	if (theStr.value.length != theNum)
		{
		alert("You must enter " + theNum + " numbers");
		theStr.focus();
		theStr.select();
		}
	else
		return false;
	}

//==this function does the window open thing, but allows users to feed the dimensions of the window	
function OpenMe(newin, theWidth, theHeight)
	{
		flyout = window.open(newin, "flyout", "resizable=yes, scrollbars=yes, width=" + theWidth + ", height=" + theHeight + ", top=100, left=100");
	}
	
	
//==this is the new, improved function that does the window open thing, 
//but allows users to feed the dimensions of the window AND the top and left positions
function OpenMe2(newin, theWidth, theHeight, theTop, theLeft)
	{
		flyout = window.open(newin, "flyout", "resizable=yes, scrollbars=yes, width=" + theWidth + ", height=" + theHeight + ", top=" + theTop + ", left=" + theLeft);
	}
	
	
//===================================== this function tests for blanks
function testBlank(theForm)
	{
	if ((theForm.SearchBy.value != '') && (theForm.Employee.value.length == 0))
		{
		alert('You cannot select a criteria and not enter an employee number');
		theForm.Employee.focus();
		return false;
		}
	else if ((theForm.SearchBy.value == '') && (theForm.Employee.value.length > 0))
		{
		alert('You cannot enter an employee number and not select a criteria');
		theForm.Employee.focus();
		theForm.Employee.select();
		return false;
		}
	else
		{
		return true;
		}
	}


//===================================== this function is used for the js pop up on search results - currently not used
var iCount = iCount++;
var sWhich
var the_Name = ''
	function theClick(sName, sName2, sName3)
	{
		if (the_Name.indexOf(sName) < 0)
		{
//		alert(the_Name.indexOf(sName.value));
			the_Name = the_Name + "|" + sName + "|"
			eval("document.all."+sName+".style.display='';");
			eval("document.all."+sName2+".style.display='none';");
			eval("document.all."+sName3+".style.display='';");
		}
		else
		{
			the_Name = the_Name.replace("|" + sName + "|", "")
			eval("document.all."+sName+".style.display='none';");
			eval("document.all."+sName2+".style.display='';");
			eval("document.all."+sName3+".style.display='none';");
		}
//		alert(the_Name);
	}


//=== this function tests the search box for ''
//=== there is now another, better, faster, more advanced version of this function called checkForm(formname) in this file
	function TestMe( formObj )
		{
		if (((formObj.SearchStr.value.length == 0)) && ((formObj.ClosedBy.value == '') && (formObj.SubmittedBy.value == '')) && (formObj.wfNum.value.length == 0))
			{
			alert( 'You must type in or select something to search for.');
			formObj.ClosedBy.focus();
			return false;
			}
		if (((formObj.SearchStr.value.length == 0)) && ((formObj.ClosedBy.value == '') && (formObj.SubmittedBy.value == '')) && (formObj.wfNum.value.length > 0))
			{
//			alert( 'You must type in something to search for.');
			if (confirm("Are you sure you want to search for everything in the given date range? This could take a while."))
				{
				formObj.submit();
				}
			else
				{
				formObj.SearchStr.focus();
				return false;
				}
			}
		else if ((formObj.FAQ.checked == false) && (formObj.SR.checked == false) && (formObj.WFOpen.checked == false) && (formObj.WFClosed.checked == false))
			{
			alert( 'You select at least one search area.');
			formObj.FAQ.checked = true;
			return false;
			}
	}
	
	
//======================================= this function turns the advanced search on and off
var isNone;isNone=parseInt(isNone);
if (isNone != 0)
	{
	isNone = 0;
	}
	function changeDisplay()
	{
	if (document.all.Advanced.style.display == '')
		{
		document.all.Advanced.style.display = 'none';
		}
	else
		{
		document.all.Advanced.style.display = '';
		}
	}
	
//==============================================this function clears the values from the 'advanced' fields if the display = 'none'
	function clearFields(theForm)
	{
	if (document.all.Advanced.style.display == 'none')
		{
		theForm.ClosedBy.value = '';
		theForm.SubmittedBy.value = '';
		}
	}
//=============================================this function allows the user to click on the paragraph text of a checkbox and execute the action that one normally expects from a computer...turn the checkbox off/on What a radical.
//============================================put this into the onclick event of whatever you want and feed it the name of the form and the field and watch it work it's magic.
//side note, the kaClick is a tribute to Bun Bun...
	function checkTheBox(formName, fieldName)
	{
	var kaClick = eval(formName + "." + fieldName);
		if (kaClick.type == 'checkbox')
		{
			switch(kaClick.checked)
			{
			case false:
				kaClick.checked = true;
				break;
			case true:
				kaClick.checked = false;
				break;
			default:
				kaClick.checked = true;
			}
		}
	}

//==============================================this function will clear a field of whatever value is fed to it
	function clearValue(theValue) //not to be confused with true value
		{
		if (theValue.defaultValue == theValue.value)
			{
			theValue.value = '';
			}
		}
		
//well, this was a good idea...but it didn't work as is. I was trying to erase the value of a field 
//while the display is set to hide. It did weird things and made the request thingee lose the value. 
//Maybe next time
//Side note. I accomplished this same thing by putting in a javascript string directly into the onSubmit of the form. It is as follows: javascript:if (document.all.Advanced.style.display == ""none""){SearchSR.ClosedBy.value="""";SearchSR.SubmittedBy.value=""""}
//nother side note - could the field be set to disable? form.field.disabled = true?
//yes, 10/16/02
	function isHide()
	{
		if (document.all.Advanced.style.display = 'none')
			{
			SearchSR.ClosedBy.value = '';
			SearchSR.SubmittedBy.value = '';
			return true;
			}
	}



	function checkTheFields()
	{
		if ((SearchSR.ClosedBy.value != '') || (SearchSR.SubmittedBy.value != ''))
			{
			checkFields = true;
			}
	}


//===========================this function selects a radio button when the text of the button is clicked
		//First, must do <p style='cursor:hand' onClick='return selectMe(formName, value)'><input type=radio name=phred value=no>Choose Phred</p>
		//This can be used two different ways:
		//1. if the values of the radio buttons are all the same, as in the example above, you must feed a number into iMe that corresponds 
		//with z. (If the radio buttons are in an array, just use the array index) Then, you must compare the value of z to the value of iMe
		//	a. if the values are integers, it will assign it to the first available item that meets the criteria
		//		- this means, if the value of the item is 1 and the index is 2, it will select item 1 in the index
		//		- it might be better to just have a switch for whichever one you want. More later.
		//		- how scary, the comments are longer than the function...
		//2. If the values of the radio buttons are different, compare the selected value with iMe (if (theForm.theField[z].value == iMe))
		//selectMe(1, 2) is the first version of this function and has a specific field name in it, topic
		//selectRadio(myForm, theField, iMe) is the real version
function selectMe(myForm, aMe, rdoName)
	{
	//alert(eval(myForm + "." + rdoName + ".length"));
	for (var z = 0; z < eval(myForm + '.' + rdoName + '.length'); z++)
		{
		if ((z == aMe) || (aMe == eval(myForm + '.' + rdoName + '[z].value')))
			{
			if (eval(myForm + '.' + rdoName + '[z].checked') == false)
				{
					eval(myForm + '.' + rdoName + '[z].checked = true');
					break;
				}
			else
				{
					eval(myForm + '.' + rdoName + '[z].checked = false');
					break;
				}
			}
		}
	}
	
	
function selectRadio(myForm, theField, iMe)
	{
	var newForm
	newForm = eval(myForm + "." + theField)
//	alert(iMe);
//	alert(newForm.length);
	for (var z = 0; z < newForm.length; z++)
		{
		if (newForm[z].value == iMe)
			{
//			alert(z);
			newForm[z].checked = true;
			break;
			}
		}
	}
	

function selectBox(myForm, sMe)
	{
		var newForm
		newForm = eval(myForm + '.' + sMe)
		if (newForm.checked == true)
			{
				newForm.checked = false;
			}
		else
			{
				newForm.checked = true;
			}
	}


//====================================this function checks a string to see if it is blank
//	it does assume the field name, but this could be easily adapted to any field
function checkStr(theForm)
	{
//	alert(theForm.SubOrder.length)
	for (var z = 0; z < theForm.SubOrder.length; z++)
		{
		if (theForm.SubOrder[z].length = 0)
			{
			alert("One of the order fields is empty");
			theForm.SubOrder[z].focus();
			break;
			}
		}
	return false;
	}

	

//====================================this function will focus the cursor on the first selectable item in the given form - (formName)
//IMPORTANT!!!!! you must call this function AFTER the form loads.
function doFocus(formName)
	{
	if (eval("document.forms." + formName))
	var newForm = eval("document.forms." + formName + ".name");
	var dobreak
		for (var i = 0; i < eval(newForm + ".elements.length"); i++)
			{
				if (((eval(newForm + ".elements[i].value") == '') || (eval(newForm + ".elements[i].value") == 0)) && (eval(newForm + ".elements[i].name") != 'Header1:LoginSearch1:txbSearch') && (eval(newForm + ".elements[i].type") != 'hidden') && (eval(newForm + ".elements[i].disabled") != true))
					{
					if (document.all.tags("div") && document.all.tags("div").length > 0)
						{
//						alert(document.all.tags("div").length);
//						alert(eval(newForm + ".elements[i].name"));
						for (var q = 0; q < document.all.tags("div").length; q++)
							{
							if ((document.all.tags("div")[q].style.display == ''))
								{
//								alert(eval(newForm + ".elements[i].name"));
								eval(newForm + ".elements[i].focus()");
								dobreak = true;
								break;
								}
							}
						}
					else
						{
//						alert(eval(newForm + ".elements[i].name"));
						eval(newForm + ".elements[i].focus()");
						dobreak = true;
						}
					if (dobreak = true)
						{
						break;
						}
					}
			}
	}


//===================================this does the fancy css button rollover thing. You know, the thing...	
function buttonChange(obj, new_Class)
	{
		obj.className = new_Class;
	}

//==============================this checks the form fed to it for any empty fields that need to be filled in.
//It doesn't check fields that have the following criteria:
// 1 - hidden fields
// 2 - disabled fields
// 3 - fields that have '_xz' in the name - this is how to "turn off" the checker
// 4 - I also turned off fields with the word 'Date' in them in the original code. 
//		I was using Vinh's dateDrop.js and was getting some weird errors if I checked them. 
//		Here is the condition that was taken out -  && (newForm.elements[i].name.indexOf('Date') < 1)
function checkForm(formName)
	{
	var newForm = eval("document." + formName);
	var isSubmit
		for (var i = 0; i < newForm.elements.length; i++)
			{
				if ((newForm.elements[i].name.indexOf('_xz') < 1) && (newForm.elements[i].value == '') && (newForm.elements[i].type != 'hidden') && (newForm.elements[i].disabled == false) && (newForm.elements[i].name.indexOf('month') < 1) && (newForm.elements[i].name.indexOf('day') < 1) && (newForm.elements[i].name.indexOf('year') < 1))
					{
					if (newForm.elements[i].type == 'text')
						{
						alert("You cannot leave this field blank.");
						}
					if (newForm.elements[i].type == 'select-one')
						{
						alert("You must select something.");
						}
					if (newForm.elements[i].type == 'select-multiple')
						{
						alert("You must select something.");
						}
					if (newForm.elements[i].type == 'password')
						{
						alert("You must enter a password.");
						}
					if (newForm.elements[i].type == 'textarea')
						{
						alert("You must enter some text.");
						}
					if (newForm.elements[i].type == 'file')
						{
						alert("You must select a file.");
						}
					newForm.elements[i].focus();
					isSubmit = false;
					return false;
					break;
					}
				if (((newForm.elements[i].type == 'radio') || (newForm.elements[i].type == 'checkbox')) && (newForm.elements[i].name.indexOf('_xz') < 1))
					{
					var theName = newForm.elements[i].name
					var radioCheck = false
					//alert(eval('newForm.' + theName + '.length'));
					for (var y = 0; y < eval('newForm.' + theName + '.length'); y++)
						{
							//alert(eval('newForm.' + theName + '[y].checked'));
							if (eval('newForm.' + theName + '[y].checked') == true)
							{
								radioCheck = true;
								isSubmit = true;
							}
						}
					if (radioCheck == false)
						{
							alert("You must choose an option.");
							isSubmit = false;
							return false;
							break;
						}
					}
			}
	if (isSubmit != false)
			{
			if (newForm.theButton)
				{
				newForm.theButton.disabled = true;
				}
			newForm.submit();
			}
	}

	
//========================this will select the given value of a form.select when loaded after the select
function doSelect(sForm, sField, sValue)
	{
	var myForm = eval(sForm + "." + sField)
	//alert(sValue);
	if (sValue.length != 0)
		{
		if (sValue.indexOf(',') < 0)
			{
			for (var z = 0; z < myForm.length; z++)
				{
				//alert(sValue);
				if (myForm[z].value == sValue)
					{
					myForm[z].selected = true;
					break;
					}
				}
			}
		else
			{
	//==this particularly brilliant move allows for a multiple select to be fed to this function and have all the selected items highlighted
	//==it must be comma delimited
	//==must remove the spaces between the commas - ex. 1,2,3,4 or My,Name,is,Mark Lindberg,hi
	//==it is ok to have spaces inside the value, just not between the commas
				//alert(sValue);
			var theSplit = sValue.split(',');
			for (var z = 0; z < myForm.length; z++)
				{
				for (var x = 0; x < theSplit.length; x++)
					{
					if (myForm[z].value == theSplit[x])
						{
//					alert(theSplit[x]);
						myForm[z].selected = true;
						}
					}
				}
			}
		}
	}

function doSelectRadio(sForm, sField, sValue)
	{
	var newVar = eval(sForm + "." + sField);
	for (var x = 0; x < newVar.length; x++)
		{
		if (newVar[x].value == sValue)
			{
			newVar[x].checked = true;
	/*		if (newVar[x].value == 'Other')
				document.all.otherRow.style.display = '';
	*/
			}
		}
	}

//========================this writes a cookie. 1 or 0, depending on what it is now... and returns true if 1 and false if 0
//=========ok, this was a really good idea, but, as it exists, doesn't really do me much good.
//=========I think I need to separate out the boolean and the 1/0 stuff and make them different functions. That way, if it's false, I can write the number, if not, I can leave it alone
	function writeCookie()
		{
		var iVisit
		if (document.cookie.indexOf("visit=1;") > -1)
			{
			iVisit = 0;
			}
		else
			{
			iVisit = 1;
			}
		document.cookie = "visit=" + iVisit
		}


//=====================this clears the original value of a field onfocus. It should be put into onfocus...
//=====================this is so you can label a field with its contents. For instance, zip, city, etc.
function clearField(firstName, sOriginalValue)
	{
	var newName = eval(firstName)
	if (newName.value == sOriginalValue)
		{
		newName.value = '';
		}
	}


//=======================this function allows you to feed a value and have the item selected or checked
//=======================I did this rather than do multiple if/then statements in a dead select list. I get the value in a db hit, then feed it to this function after the select has loaded. Voila!
function selectList(theForm, theField, theValue)
	{
	var	newForm = eval("document." + theForm + "." + theField);
	if (newForm)
		{
		for (var d = 0; d < newForm.length; d++)
			{
			if (newForm[d].value == theValue)
				{
				alert(newForm.length);
				if (newForm.type == 'select-one')
					{
					newForm[d].selected = true;
					}
				//there are two different types of if/then for checkboxes. I am assuming that some will have the same name, and some will not
				if (newForm.type == 'checkbox')
					{
					newForm[d].selected = true;
					}
				if (newForm[d].type == 'checkbox')
					{
					newForm[d].selected = true;
					}
				if (newForm[d].type == 'radio')
					{
					newForm[d].checked = true;
					}
				}
			}
		}
	}
	

	
//this function selects the first item of the list for the select 1418 in the 600 wf.
//the reason it appears to be so complicated is that the select name is a number - a no no in javascript
//I am using the for loop to write what I need and not using the name outside of the indexOf function
//woo hoo
function selectTheItem()
	{	
	var theName
		if (document.all.myform)
			{
			for (var d = 0; d < myform.length; d++)
				{
				theName = myform.elements[d].name;
				if ((theName.indexOf(1418) == 0) || (theName.indexOf(1420) == 0))
					{
					myform.elements[d].options[0].selected = true;
					myform.choiceTaken[0].checked = true;
					}
				}
			}
		}

		
//this function builds an array for the fiscal month (or period), which, for some bizarre reason known only to accountants, starts in October
function dotheMonths(daMonth)
	{
	var theMonths = new Array('October', 'November', 'December', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September');
		document.writeln('<select name=' + daMonth + 'Month class=tiny>');
		for (var d = 0; d < 12; d++)
			{
			document.writeln('<option value=' + (d + 1) + '>' + (d+1) + ' - ' + theMonths[d]);
			}
		document.writeln('</select>');
	}

//html color selector writer thingee
	function CloseSubmit(ColorNum)
		{
	//	alert(EmpNum)
		opener.document.Page.pageColor.value = ColorNum;
		opener.document.Page.submit()
		window.close()
		}


function openRow(rowID)
	{
	if (eval("document.all." + rowID + ".style.display == ''"))
		{
		eval("document.all." + rowID + ".style.display = 'none'");
		}
	else
		{
		eval("document.all." + rowID + ".style.display = ''");
		}
	}
	

function openRow2(rowID)
	{
	if (document.getElementById(rowID).style.display == '')
		{
		document.getElementById(rowID).style.display = 'none';
		}
	else
		{
		document.getElementById(rowID).style.display = '';
		}
	}
	

