Index: trunk/src/scriptbuilder/structures/ScriptIncident.java
===================================================================
--- trunk/src/scriptbuilder/structures/ScriptIncident.java	(revision 167)
+++ trunk/src/scriptbuilder/structures/ScriptIncident.java	(revision 168)
@@ -263,4 +263,35 @@
     }
     /**
+     * Adds an event to the correct timeslice when imported from an XML file.
+     * @param ev Event to be added to the timeslice.
+     * @param start Time when event needs to be added.
+     */
+    public void addNewEventFromXML(I_ScriptEvent ev, int start)
+    {
+        TimeSlice t = slices.get(start);
+        if(t==null)
+        {
+            t = new TimeSlice(start,this);
+            slices.put(start,t); 
+        }
+        t.addEvent(ev);
+        eventCount++;
+
+        //If this is the latest start time in the incident, update that number
+        if (start > latestStart)
+        {
+            latestStart = start;
+        }
+        //If this event is earlier than all previous events, or if there are 
+        //no other events, the offset is equal to this event's start time
+        if (start < offset || eventCount == 1)
+        {
+            offset = start;
+            //System.out.println("Offset: " + offset);
+        }
+        updateLength();
+        
+    }
+    /**
      * Add a new script event to this incident.
      *
@@ -271,20 +302,5 @@
     public void addNewEvent(I_ScriptEvent ev, int start)
     {
-        /*
-        int leftoverSeconds = start % 60;
-        
-        //round start time to the nearest minute
-        if(leftoverSeconds != 0)
-        {
-            if(leftoverSeconds > 30)
-            {
-                start += (60 - leftoverSeconds);
-            }
-            else
-            {
-                start -= leftoverSeconds;
-            }
-        }
-        */
+        
         
         //Check to see if there's already a timeslice here
@@ -300,12 +316,11 @@
         
         //checks if event to add is an I_AudioEvent and if the I_AudioEvent already has an AudioEvent to connect with it
-        if(ev instanceof I_AudioEvent && t.getCorrespondingAudioEvent((I_AudioEvent)ev)==null){
-            
-            AudioEvent audio = (AudioEvent) ScriptEvent.factoryByType(ScriptEventType.AUDIO_EVENT);
+        if(ev instanceof I_AudioEvent){
+            
             
             //checks to see if there is already a filename in the I_AudioEvent, if so, set the AudioEvent ID. This is because the ID is not stored within the Script itself.
             if(!((I_AudioEvent) ev).getFileName().equals(""))
             {
-                ((I_AudioEvent) ev).setID(((I_AudioEvent) ev).getFileName());
+                ((I_AudioEvent) ev).setID(((I_AudioEvent) ev).getFileName().replaceAll(".mp3",""));
             }
             // checks to see if the I_AudioEvent already has an ID or not, if not, set one based on the audioEventCount. 
@@ -315,12 +330,18 @@
                 audioEventCount++;
             }
-            //sets AudioEvent id to id of I_AudioEvent
-            audio.id = ((I_AudioEvent) ev).getID();
-            //sets I_AudioEvent filename to the AudioEvent id
-            ((I_AudioEvent) ev).setFileName(audio.id);
-            //sets the file path of the AudioEvent based on its internal id
-            audio.setAudioFilePathRelative();
-            //adds AudioEvent to the timeslice
-            t.addEvent(audio);
+            if(t.getCorrespondingAudioEvent((I_AudioEvent)ev)==null)
+            {
+                AudioEvent audio = (AudioEvent) ScriptEvent.factoryByType(ScriptEventType.AUDIO_EVENT);
+
+                //sets AudioEvent id to id of I_AudioEvent
+                audio.id = ((I_AudioEvent) ev).getID();
+                //sets I_AudioEvent filename to the AudioEvent id
+                ((I_AudioEvent) ev).setFileName(audio.id+ ".mp3");
+                //sets the file path of the AudioEvent based on its internal id
+                audio.setAudioFilePathRelative();
+                //adds AudioEvent to the timeslice
+                t.addEvent(audio);
+            }
+            
             
         }
