	//MyrsolObserver Class.. 
	//
	//
	// aOptions.. are controls for this object
	//
	function MyrsolObserver(aOptions)
	{
		var m_thisobject = this;
		var m_Options = aOptions;
		var m_list = [];
		
		//Options for this Object
		var m_watchgroupid = aOptions.watchgroupid || 1;
		var m_valueforall = aOptions.valueforall || 0;
		var m_watchname = aOptions.watchname || 0;
		var m_inputtype = aOptions.inputtype || 'checkbox';
		
	
		MO_Init();

		//-----------------------------------------
		//Access Functions
		//-----------------------------------------
		//MB_FindById
		//////////////////////////////	
		this.MO_FindById = MO_FindById;
		function MO_FindById(locateId)
		{
			for (i=0;i<m_list.length;i++)
			{
				if (m_list[i].eid == locateId)
					return i;
			}
				
			return -1;	
		} //End MB_FindById()

		this.MO_GetListSelectCheckBox = MO_GetListSelectCheckBox;
		function MO_GetListSelectCheckBox(szname,bvalue)
		{	var alist = Array();
			var olist = $$('input');
			var icount = 0;
			for (var i = 0; i <olist.length; i++)
			{
				 if (olist[i].type == m_inputtype && olist[i].name == szname)
				 {
					el = olist[i];
					if (el.checked == bvalue)
					{
						alist.push(el.value);
					}
				 }
			}
			
			return alist;
		}

		//Init
		//////////////////////////////	
		this.MO_Init = MO_Init;
		function MO_Init()
		{
			
//			if ($(m_watchgroupid))
//				Event.observe($(m_watchgroupid), 'change', function(event){MO_Observer();});
//			else
//				alert('Unable to locate element with id of '+m_watchgroupid);
		} //End Init()
		
		//MO_Add
		//////////////////////////////	
		this.MO_Add= MO_Add;
		function MO_Add(aItemInfo)
		{
			var oItem = new Object;
			
			oItem.eid = aItemInfo.elemid || 1;
			oItem.valuelist = aItemInfo.valuelist || [];
			
			if (MO_FindById(oItem.eid) != -1)
				return false;
				
			m_list.push(oItem);
			return true;
		}
		
		
		//MO_Observer
		//////////////////////////////	
		this.MO_Observer= MO_Observer;
		function MO_Observer()
		{
			var avalue = MO_GetListSelectCheckBox(m_watchname,true);
			var icount = 0;
			
			for (var i=0; i < m_list.length;i++)
			{
				var oitem = m_list[i];
				var bfound = MO_ArrayInArrayFind(oitem.valuelist,avalue);
				if (bfound && $(oitem.eid))
				{
					$("p_"+oitem.eid).show();
					$(oitem.eid).enable();
					icount++;
				} 
				else if ($(oitem.eid)) 
				{
					$("p_"+oitem.eid).hide();
					$(oitem.eid).disable();
				}
			}
			
			if (!icount)
			{
				$('adv_ftr_when_empty').show();
			}
			else
			{
				$('adv_ftr_when_empty').hide();
			}
		}
		

		//MO_ArrayInArrayFind
		//////////////////////////////	
		this.MO_ArrayInArrayFind= MO_ArrayInArrayFind;
		function MO_ArrayInArrayFind(alist,avalue)
		{	
			var nrmatches = avalue.length;
			
			for (var l=0; l < alist.length;l++)
			{
				var id = alist[l];
				
				if (id==m_valueforall) //is the value for all
					return true;
				
				for (var v=0; v < avalue.length;v++)
				{
					if (id == avalue[v])
					{
						nrmatches--;
						if (!nrmatches)
							return true;
					}
				}	
			}
		
		return false;
		}
	

	} //End MM_Validation
