how to save gif in photoshop code example

Example: photoshop script: save as gif

function savefile(name,path,saveExt){

		path = path+"Save_File/"
		var f = new Folder(path);
		if(!f.exists)
		{
			f.create();
			$.writeln("created on ");
			$.writeln(path);
		}
		if(saveExt == "gif")
		{
			
			path = path+saveExt+"/";
			var fgif = new Folder(path);
			if(!fgif.exists){fgif.create();}
			var savePath = path+ name+"."+saveExt;
			$.writeln(path);
			if(!documents.length) return;
			
			var saveFile= new File(savePath);
			
			SaveForWeb(saveFile);
       }
 }
 function SaveForWeb(saveFile) {
	var sfwOptions = new ExportOptionsSaveForWeb();
		sfwOptions.format = SaveDocumentType.COMPUSERVEGIF;
		sfwOptions.includeProfile = false;
		sfwOptions.interlaced = 1;
		sfwOptions.optimized = true;
		sfwOptions.transparency = 1;
		sfwOptions.ColorReductionType = ColorReductionType.SELECTIVE;
		sfwOptions.dither = Dither.NONE; 
		sfwOptions.ditherAmount = 80;
		sfwOptions.webSnap = 0;
		sfwOptions.colors = 128;
	activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
}