// favorites code by Matt Palermo. modified by Dean Laforet for Opera, folder view, validation and XML DOM
// copyright 2007 Dean Laforet, Matt Palermo
// do not use or modify code without permission.
var popularFileTypes = ["bat","lnk","url","exe","txt","html","htm","pdf","mp3","aac","ape","wav","flac","shn","wma","m3u","pls","asx","doc","ppt","xls","mov","avi","mpg","mpeg","mp4","ogg","jpg","jpeg","png","bmp","tif","gif","psd"];
var mediaFileTypes = ["mp3","wav","flac","wma","ogg","shn","aac","ape"];
var notepadExclude = ["lnk","url","exe","pdf","mp3","aac","ape","wav","flac","shn","wma","mov","avi","mpg","mpeg","mp4","ogg","jpg","jpeg","png","bmp","tif","gif","psd","dll","rar","cab","msi","sys","wim"];
var favType = "ff";
var oFSO = new ActiveXObject("Scripting.FileSystemObject");
var oShell = new ActiveXObject("WScript.Shell");
var ie_favDir = oShell.SpecialFolders("Favorites");
var ff_favDir = oShell.SpecialFolders("Appdata")+"\\Mozilla\\Firefox";
var opera_favDir = oShell.SpecialFolders("Appdata")+"\\Opera\\Opera\\profile";
var desktop = oShell.SpecialFolders("Desktop")+"\\";
var winPath = System.Environment.getEnvironmentVariable("windir");
var pfPath = System.Environment.getEnvironmentVariable("PROGRAMFILES");
if (oFSO.FolderExists(pfPath+" (x86)")) {pfPath = pfPath+" (x86)";}
var ffPath = pfPath + "\\Mozilla Firefox\\firefox.exe";
var iePath = pfPath + "\\Internet Explorer\\iexplore.exe";
var operaPath = pfPath + "\\Opera\\Opera.exe";
var gadgetPath = System.Gadget.path;
var validateURL = /^(ht|f)tp(s?):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
var ff_ProfileDir;
var ff_bookmarkFile;
var ffItemsArray;
var favListArea;
var dirCount = 0;
var idCount = 0;
var delConfirmOpen = "no";
var targetLink = null;
var copyLink = null;
var showOnlyPopular = 1; // 1 = yes 0 = no. overwritten from settings page.
var bDebug = oFSO.FileExists(gadgetPath+"\\debugfav.txt");
try{
if (bDebug)
var debugLogFile = oFSO.OpenTextFile(gadgetPath+"\\debugfav.txt", 2);
openArea.innerHTML = "<span onclick=\"System.Shell.execute(folderLocation);\" style=\"cursor:pointer;width:100%;text-align:center;color:blue;\">Click here to open the folder.</span>";
if (copyHere.firstChild.innerText == "empty folder") copyHere.removeChild(copyHere.firstChild); // remove the empty folder text then moving to an empty folder