Filereference download extension

Hi there,
i’ve got a pic gallery from kirupa which i modified a bit.
I’ve added a download button with filereference. The thing is everthing works when the download button is pressed.
But if somebody wants to download a picture and wants to change the name the file isn’t recognised because the extension is lost.
Flash doesnt read after the dot (example .jpg). If you dont change the name of the file which you save it keeps its extension.
here’s my code for the download and the link


/////////////////////////////////////
//    DOWNLOAD CODE
import flash.net.FileReference;
var fileRef:FileReference = new FileReference();
var listener:Object = new Object();   
fileRef.addListener(listener);
listener.onCancel = function(file:FileReference):Void {
   trace(file.removeListener(this)); // GEANNULEERD
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
    downloaded = Math.round(bytesLoaded  / bytesTotal *100)+"%";
    if (bytesLoaded == bytesTotal){
        downloaded_mc._visible = true;
        downloaded_mc.play();
        downloaded = "";
    }
}

function downloadPICT(){
    fileRef.download(url+download[p]);
}

ive tried to put it like this but it doesnt work


function downloadPICT(){
    fileRef.download(url+download[p]+".jpg");
}

PS download[p] is read from an XML file its the link to the downloadfile, which looks like this


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images titel="DJ CHUCKIE" omschrijving="HEINEKEN FULL MOON PARTY" datum="VRIJDAG 5 JANUARI">
    <pic>
        <image>djchuckie/dd001.jpg</image>
        <thumbnail>djchuckie/THUMBS/dd001.jpg</thumbnail>
        <download>djchuckie/DOWNLOAD/dd001.jpg</download>
    </pic>