// JavaScript Document
	function ObjectCollection()
	{
		this.collection=new Array();
		this.addObject=ObjectCollection_Add;
		this.deleteObject=ObjectCollection_Delete;
		this.populate=ObjectCollection_Populate;
		this.getObject=ObjectCollection_GetObject;
		this.getXML=ObjectCollection_GetXML;
		this.RemoveAll=ObjectCollection_RemoveAll;
		this.Remove=ObjectCollection_Remove;
		this.RemoveItem=ObjectCollection_RemoveItem;
		this.AddOption=ObjectCollection_AddOption;		
	}
	
	function ObjectCollection_Add(roObject)
	{
		var iIndex=this.collection.length;
		this.collection[iIndex]=roObject;
	}
		
	function ObjectCollection_Delete(roObject)
	{                                         
		var iIndex=-1;                        
		var oTempCollection=this.collection;  
		this.collection=new Array();          
		for(var i=0;i<oTempCollection.length;i++)
		{                                     
			if(oTempCollection[i].ID!=roObject.ID)
			{                                 
				iIndex++                      
				this.collection[iIndex]=oTempCollection[i];
			}                                 
		}                                     
	}                                         
	
	function ObjectCollection_Populate(roList)
	{						
		var Len = roList.options.length;
		for(var i=0;i<Len;i++)
		{			
			roList.options.remove(0);
		}				
		for(var i=0;i<this.collection.length;i++)
		{
			var oOption=document.createElement("OPTION");
			roList.options.add(oOption);
			oOption.value=this.collection[i].ID;			
			oOption.text=this.collection[i].Name;			
		}		
	}
	
	function ObjectCollection_GetObject(riID)
	{
		for(var i=0;i<this.collection.length;i++)
		{
			if(this.collection[i].ID==riID)
			{
				return this.collection[i]
			}
		}
		return null;
	}
	
	function ObjectCollection_GetXML()
	{
		var sXML="";
		for(var i=0;i<this.collection.length;i++)
		{
			sXML=sXML+this.collection[i].getXML();
		}
		return sXML;
	}
	
	function ObjectCollection_RemoveAll(roControl)
	{
		var i;
		var iItemCount=roControl.length;
		for(i=0; i<iItemCount; i++)
			roControl.remove(0);
	}	

	function ObjectCollection_Remove(roControl, riID)
	{
		var i;
		for(i=0; i<roControl.length; i++)
			if(roControl(i).value==riID)
				roControl.remove(i);
	}  
	
	function ObjectCollection_AddOption(rsHTMLControl, rOptionValue, rOptionText)
	{		
		var oOption=document.createElement("OPTION");
		rsHTMLControl.options.add(oOption);
		oOption.value=rOptionValue;
		oOption.text=rOptionText;	
	}


	function ObjectCollection_RemoveItem(roControl, riID)
	{
		var iIndex;
		var iLength = roControl.options.length;
		for(iIndex=0; iIndex<iLength ; iIndex++)
			if (roControl.options(iIndex).value == riID)
			{
				roControl.options.remove(iIndex);
				break;
			}
	}
	
		function ValidateForm_Custom(roControl,rsControlName)
	{	
   
		if (roControl.value == '')
		{
		alert (rsControlName + "Field is not entered");
		roControl.focus()
		return false;
		}

		for (index=0;index<roControl.value.length;index++)
		{			
			switch (roControl.value.charAt(index))
			{
			
			case '~':	case '!': case '@':	case '#': case '$':	case '%': case '^':	case '&':
			case '*': case '(':	case ')': case '+':	case '=': case '/':	case '|': case ']':	case '}':
			case '[': case '{':	case "'": case '"':	 case ';':	case '?': case '.':	case '>':
			case ',': case '<':
				alert ("No special characters allowed in " + rsControlName );
				roControl.focus()
				roControl.value="";
				return false;
				break;
			}
		}
	return true;
 }

