function FunctionsInclude_CheckAll(checkboxList){
	for(var i=0; i < checkboxList.length; i++){
		checkboxList[i].checked = true;
	} //end for
} //end FunctionsInclude_CheckAll

function FunctionsInclude_UncheckAll(checkboxList){
	for(var i=0; i < checkboxList.length; i++){
		checkboxList[i].checked = false;
	} //end for
} //end FunctionsInclude_UncheckAll




function FunctionsInclude_RequiredTags(tags_array){
	regex = / /g;
	var formTagObj;
	var textText;
	
	for (var i=0; i < tags_array.length; i++){
		
		//var textObj = tags_array[i][0];
		formTagObj = tags_array[i][0];
		textText = tags_array[i][1];
		
	//	alert(textText + ": " + formTagObj.type);
		
		switch (formTagObj.type)
		{
			case "password":
			case "text":
			case "textarea":
				if (formTagObj.value.replace(regex,'') == ''){
					window.alert("Please fill in " + textText);
					formTagObj.focus();
					return false;
				} 
				break;
			
			case "select-one":
				if( formTagObj.selectedIndex == 0)
				{
					window.alert("Please select a " + textText);
					formTagObj.focus();
					return false;
				}
				break;
			
		} //end switch
		
		
	} //end for
	
	return true;

} //end FunctionsInclude_RequireText()

function FunctionsInclude_IsChecked(checkboxList)
{
	//alert(checkboxList.length);
	//alert(checkboxList.length == undefined);
	
	
	var is_checked = false;
	
	if( checkboxList.length != undefined)
	{
		for(var i=0; i < checkboxList.length; i++)
		{
			if(checkboxList[i].checked)
			{
					is_checked = true;
					return is_checked;
			}
		} //end for
	} //end if( checkboxList.length != undefined)
	else{
		return checkboxList.checked;
	}
	
	return is_checked;
} //end FunctionsInclude_IsChecked



function FunctionsInclude_IsSpanVisible(SpanName){
	if(document.all){
		var SpanObj = document.all[SpanName];		
	}
	else if(document.getElementById){
		var SpanObj = document.getElementById(SpanName);
	}
	
	return SpanObj.style.display == 'block';
} //end FunctionsInclude_isSpanVisible(SpanName)


function FunctionsInclude_ShowSpan(SpanName){
	if(document.all){
		var SpanObj = document.all[SpanName];		
	}
	else if(document.getElementById){
		var SpanObj = document.getElementById(SpanName);
	}
	
	SpanObj.style.display = 'block';
} //end FunctionsInclude_ShowSpan(Span_name)

function FunctionsInclude_HideSpan(SpanName){
	if(document.all){
		var SpanObj = document.all[SpanName];		
	}
	else if(document.getElementById){
		var SpanObj = document.getElementById(SpanName);
	}
	
	SpanObj.style.display = 'none';
} //end FunctionsInclude_HideSpan(Span_name)


function FunctionsInclude_ToggleSpan(SpanName)
{
	if(document.all){
		var SpanObj = document.all[SpanName];		
	}
	else if(document.getElementById){
		var SpanObj = document.getElementById(SpanName);
	}
	
	if(SpanObj.style.display == "block")
	{
		FunctionsInclude_HideSpan(SpanName);
	}
	else
	{
		FunctionsInclude_ShowSpan(SpanName);
	}
} //end FunctionsInclude_ToggleSpan(SpanName)



function FunctionsInclude_ArrayContainsString(arrayObj, valuestr)
{
	var containsElement = false;
	
	for(var i=0; i < arrayObj.length; i++)
	{
		if(arrayObj[i] == valuestr)
		{
			containsElement = true;
			return containsElement;
		}
	} //end for
	
	return containsElement;
} // end FunctionsInclude_ArrayContainsString(arrayObj, valuestr)

function FunctionsInclude_ArrayContainsNumber(arrayObj, valuenum)
{
	var containsElement = false;
	for(var i=0; i < arrayObj.length; i++)
	{
		if(arrayObj[i] == valuenum ){
			containsElement = true;
			return containsElement;
		}
	}
	return containsElement;
} /// end FunctionsInclude_ArrayContainsNumber(arrayObj, valuenum)

function FunctionsInclude_GetMatchedSelectedIndex(selectObj, strInput)
{
	var myselectedIndex = -1;
	
	for(var i=0; i < selectObj.options.length; i++)
	{
		if(selectObj.options[i].value == strInput)
		{
			myselectedIndex = i;
		}
	}
	return myselectedIndex;
} //end FunctionsInclude_GetMatchedSelectedIndex


//returns true/false if valid or not. if valid sets the value of textfield. if not valid displays alert error box. if user enters 6141231234, this method will put in the dashes
function FunctionsInclude_ValidatePhone(oTxt, dspName){
		//xxx-xxx-xxxx
		var myvalue = oTxt.value;
		myvalue = myvalue.replace(/ /g, '');
		myvalue = myvalue.replace(/-/g, "");
		myvalue = myvalue.replace(/\(/g, "");
		myvalue = myvalue.replace(/\)/g, "");
		

		if(myvalue.length != 10){
			alert("The format for " + dspName + " should be 'xxx-xxx-xxxx'. There should be 10 numbers entered.");
			oTxt.focus();
			return false;
		}

		var oRe = /[a-zA-Z0-9]{10}/;
		var matchA = oRe.exec(myvalue);
		if(matchA == null){
			alert("The format for " + dspName + " should be 'xxx-xxx-xxxx'. There should only be numbers or letters entered.");
			oTxt.focus();
			return false;
		}
		
		var format_value = myvalue.substring(0, 3) + "-" + myvalue.substring(3, 6) + "-" + myvalue.substring(6,10);

		oTxt.value = format_value;
		return true;
}
