/*
Potential Improvements....
1) better semi-colon processing... strip beginning semi-colon, remove any double semicolons in text area.

*/

			function ImportFromAddressBook(oSetThis)	
			{
				var strXMLContacts = "";
			
				//Verify that the Sharepoint Address Book (Contact) Import components are installed and available
				if (typeof EnsureImport == "undefined")
				{
				alert('Outlook services are not accessible from this browser.');
				}
				else
				{
				if (EnsureImport() != 0)	
				{
				alert('Outlook services are not accessible.');
				}
				else
				{
					//Now prompt the user to select Address Book Entries and conver their selections into an XML structure
					strXMLContacts = DoImportFromAddressBook();
						
					if (strXMLContacts.length > 0)	        
					{  
						//Convert the < and > to their equivalent HTML encoded characters, so we 
						//...can pass the ASP.NET page request validation.
						//strXMLContacts = strXMLContacts.replace(/</g, "&lt;");
						//strXMLContacts = strXMLContacts.replace(/>/g, "&gt;");

						strXMLContacts = sw(strXMLContacts,' ','');
						strXMLContacts = sw(strXMLContacts,',','\n');
						strXMLContacts = sw(strXMLContacts,';','\n');
						if(oSetThis.value!=''){if(oSetThis.value.substr(oSetThis.value.length-1)!='\n'){oSetThis.value+='\n'};};
						//if it's a text field overwrite... otherwise append.
						if(oSetThis.type=='text'){oSetThis.value = strXMLContacts;}
						else{oSetThis.value += strXMLContacts;}
						//Put the XML data for the selected contacts into the hidden HTML input element
						//Form1.xmlContacts.value = strXMLContacts;
						
						//Auto-submit the form to send the XML data to the server
						//Form1.submit();
					}
				}
				}
			}
			
			function DoImportFromAddressBook()	
			{
				//Simple call the OpenABW (ABW - Address Book Wrapper) and return the XML data string containing all of 
				//...the data for the selected Address Book Entries (contacts)		
				return OpenABW();			
			}

				
			function ProcessContacts(col)	
			{
				try 
				{
					//define the member variables for this method
					var strXML='';
							
					//Get a new Enumerator object for working with the passed collection of Address Book Entries (contacts)		

					var e = new Enumerator(col);


					//If there were no items selected, then simply return
					if (e.atEnd())
					{			
						return "";
					}
					
					for (; !e.atEnd(); e.moveNext())
					{
						//Get the current Address Book (contact) item into a variable
						objContactItem = e.item();

						
						//Can access properties of the Contact, like...
						//objContactItem.FirstName;			
						//strXML += objContactItem.FirstName +' '+ objContactItem.LastName +' <'+ objContactItem.SMTPAddress +'>\n' ;
						strXML += objContactItem.SMTPAddress +'\n';
					}
					
					//Return the XML data for the selected Address Book Entries (Contacts)
					return strXML;				
				}		
				catch (excp) 
				{
					window.alert("An error occured processing the list of selected Address Book Entries (contacts).");
					return null;
				}		
			}
