			function SelectedItems(housingControl, idControl, controlType, validate, checked)
			{
				//store selected ids in a pipe delimited string
				var ids = "";
				var msg = "";
				
				var oHousingControl = document.getElementById(housingControl);
				
				var oControls;
				
				var oControl;
				
				if(controlType != "select")
				{
					oControls = oHousingControl.getElementsByTagName("input");	
				}
				else
				{
					oControls = oHousingControl.getElementsByTagName("select");
				}
				
				for(var i=0; i<oControls.length; i++)
				{
					
					if (controlType == "checkbox" && oControls[i].type == "checkbox")
					{
						if (oControls[i].id != "chkSelectAll")

						{
							if (oControls[i].checked == checked)
							{
								ids += oControls[i].id + "|";
							}
						}
					}
					
					if (controlType == "select" && (oControls[i].type == "select" || oControls[i].type == "select-multiple"))
					{
						oControl = oControls[i];
						
						for(var j = 0; j < oControl.length; j++)
						{
							if (oControl[j].selected == checked)
							{
								ids += oControl[j].value + "|";
							}
						}
					}	
					
				}

				if (ids == "" && validate == true && checked == true)
				{
					if (controlType == "checkbox")
					{
						msg = "Please select an item from the list";
					}
					
					if (controlType == "select")
					{
						msg = "Please select an item from the select list";
					}
			
				}	
				
				if (msg == "" || validate == false)
				{
					document.getElementById(idControl).value = ids;
		
					return true;
				}
				else
				{
					alert(msg);
					return false;
				}

			}						
			
			function SelectItems(housingControl, idControl, validate)
			{
				//store selected ids in a pipe delimited string
				var ids = "";
				var msg = "";
				var oRadios = document.getElementsByTagName("input");
				
				for(var i=0;i<oRadios.length;i++)
				{

					if ((oRadios[i].type == "checkbox"))
					{
						if (oRadios[i].id != "chkSelectAll")
						{
							if (oRadios[i].checked == true)
							{
								ids += oRadios[i].id + "|";
							}
						}
					}
				}

				if (ids == "" && validate == true)
				{
					msg = "Please select an item from the list";
				}	
				
				if (msg == "" || validate == false)
				{
					document.getElementById(idControl).value = ids;
					return true;
				}
				else
				{
					alert(msg);
					return false;
				}

			}
			
			function SelectAllItems(housingControl, idControl, checkboxindex)
			{
				//store selected ids in a pipe delimited string
				var ids = "";
                
				var table = document.getElementById(housingControl);
				var rows = table.rows;

				for(i = 0; i < rows.length; i++)
				{
					var checkbox = rows[i].cells[checkboxindex].childNodes[0];
					
					if ((checkbox.type == "checkbox"))
					{
						if (checkbox.id != "chkSelectAll")
						{
						ids += checkbox.id + "|";
						}
					}
				}
				
				document.getElementById(idControl).value = ids;
				
			}
			
			function SelectItem(housingControl, idControl)
			{
                
				var id = "";
				var msg = "";

				var oRadios = document.getElementsByTagName("input");
				
				for(var i=0;i<oRadios.length;i++){

					if ((oRadios[i].type == "checkbox"))
					{
						if (oRadios[i].checked == true)
						{
							if (id == "")
							{
								id = oRadios[i].id;
							}
							else
							{
								msg = "Please select only one item from the list";
							}
						}
					}
				}
	
				if (id == "")
				{
					msg = "Please select an item from the list";
				}	
				
				if (msg == "")
				{
					document.getElementById(idControl).value = id;
					return true;
				}
				else
				{
					alert(msg);
					return false;
				}

			}
						
			function ConfirmDelete()
			{
				var i = confirm("Are you sure you want to delete the item/s?");
				
				return i;
			}

			function TabClick(control, header, index)
			{
				var tabControl = document.getElementById(control);
				var tabControlHeader = document.getElementById(header);
				var tabButtons = tabControlHeader.rows[0].cells;
				var tab = tabControl.rows[1].cells[0];
				var activetab = document.getElementById("activetab");
				
				activetab.value = index;

				for(i = 0; i < tabButtons.length; i++)
				{
					if(tabButtons[i].className != 'tabbuttonempty')
					{
						if (i == index)
						{
							tabButtons[index].className='tabbuttonopen';
							tab.childNodes[index].className='panelopen';
						}
						else
						{
							tabButtons[i].className='tabbutton';
							tab.childNodes[i].className='panelclosed';

						}
					}
				}
				
			}

			function TabMouseIn(tabButtonControl)
			{
				tabButtonControl.style.cursor='default';
			}

			function TabMouseOut(tabButtonControl)
			{
				tabButtonControl.style.cursor='auto';
			}
			
			function RemoveItems(housingControl, checkboxindex)
			{

				var table = document.getElementById(housingControl);
				var rows = table.rows;
                
				for(var i = 1; i < rows.length; i++)
				{
					var checkbox = rows[i].cells[checkboxindex].childNodes[0];
					
					if ((checkbox.type == "checkbox"))
					{
						if (checkbox.id != "chkSelectAll")

						{
							if (checkbox.checked == true)
							{
								table.deleteRow(i);
								i -= 1;
							}
						}
					}
				}
				
			}
			
			function Validate()
			{
				var MANDATORY = "M";
                
				var msg = "";

				var oInputs = document.getElementsByTagName("input");
				
				var oSelects = document.getElementsByTagName("select");
				
				document.getElementById("lblErrorMessage").innerText = "";	
				
				for(var i=0;i<oInputs.length;i++){
					
					//reset the color to white
					if (oInputs[i].type == "checkbox" || oInputs[i].type == "text" )
					{
						{
						oInputs[i].className = "";
						}
					}
						
					if (oInputs[i].getAttribute("validation") != null && oInputs[i].getAttribute("validation") != "")
					{

						var validation = oInputs[i].getAttribute("validation").split("|");
						var code = validation[0];
						var rule = validation[1];
						var label = validation[2];						
												
						switch (oInputs[i].type) 
						{
							case "checkbox":
								break;
							
							case "text":
								if (code == MANDATORY && oInputs[i].value.replace(" ", "") == "")
								{
									oInputs[i].className = "inputerror";
									msg += label + " is a required field \n";
								}
								break;

						}
					}
				}
				
				
				for(var i=0;i<oSelects.length;i++)
				{
					//reset the color to white
					oSelects[i].className = "";
						
					if (oSelects[i].getAttribute("validation") != null && oSelects[i].getAttribute("validation") != "")
					{

						var validation = oSelects[i].getAttribute("validation").split("|");
						var code = validation[0];
						var rule = validation[1];
						var label = validation[2];						

						if (code == MANDATORY && oSelects[i].selectedIndex < rule)
						{
							oSelects[i].className = "inputerror";
							msg += label + " is required field \n";
						}
					}
				}
									
				if (msg == "")
				{
					return true;
				}
				else
				{
					document.getElementById("lblErrorMessage").innerText = msg;
					return false;
				}
			}
			
			function Toggle(hide, show, data)
			{
				try
				{
					document.getElementById(hide).style.display = "none";
					
					document.getElementById(show).value = "";
						
					if(data == true)
					{
						var newValue = document.getElementById(hide).value;
						
						if (newValue.length > 0)
						{
							var select = document.getElementById(show).childNodes[0];
							
							var option = document.createElement('option');
							
							var optionText = document.createTextNode(newValue);
							
							option.appendChild(optionText);
							
							option.value = newValue;
							
							select.appendChild(option);
							
							option.selected = true;
						}
						
					}
				
					document.getElementById(show).style.display = "block";
					
					if (document.getElementById(show).type == 'text')
					{
						document.getElementById(show).focus();
					}
					
				}
				catch(e)
				{
					alert(e.message);
				}
			}
			
			function SelectValues(housingControl, idControl, valueControl, validate)
			{
				var ids = "";
				var values = "";
				var msg = "";
				
				var oHousingControl = document.getElementById(housingControl);
				
				var oControls = oHousingControl.getElementsByTagName("input");
				
				for(var i=0; i<oControls.length; i++)
				{

					if(oControls[i].type == "text")
					{
						ids += oControls[i].id + "|";
						values += oControls[i].value + "|";


					}
					
				}

				if (msg == "" || validate == false)
				{
					document.getElementById(idControl).value = ids;
					document.getElementById(valueControl).value = values;					
					return true;
				}
				else
				{
					alert(msg);
					return false;
				}

			}
			
		function SelectAll(checked)
		{
//		alert (checked);
				var oInput = document.getElementsByTagName("input");
				
				for(var i=0;i<oInput.length;i++)
				{

					if ((oInput[i].type == "checkbox"))
					{
						if (oInput[i].id != "chkSelectAll")
						{
						
							oInput[i].checked = checked;
						}

					}
				}
		
		}
		
		function ConfirmTag()
		{
			var i = confirm("Are you sure you want to set member as tag issued?");
				
			return i;
		}
		
		function ConfirmBill(action)
		{
		    var i;
		    
		    if(action == "start")
		    {
			    i = confirm("Are you sure you want to " + action + " billing?");
			}
			
			if(action == "resume")
		    {
			    i = confirm("Are you sure you want to " + action + " billing?");
			}
			
			if(action == "end")
		    {
			    i = confirm("Are you sure you want to " + action + " billing?");
			}
				
			return i;
		}