﻿var photoselect =
{
    photosall: new Array(),
    photosselected: new Array(),
    photosunselected: new Array(),
    dataset: function (json)
    {
        if (typeof (json) == "string")
        {
            this.photosall = JSON.parse(json);
        }
        else
        {
            this.photosall = json;
        }
        if (this.photosall == null)
        {
            foundError("^JSON failed^", "not going to work, facebook fatal error!", true);
            return;
        }
        this.photosunselected = new Array();
        for (var i = 0; i < this.photosall.length; i++)
        {
            this.photosall[i].selected = false;
            var found = false;
            for (var a = 0; a < this.photosselected.length; a++)
            {
                if (this.photosall[i].pid == this.photosselected[a].pid)
                {
                    this.photosall[i].selected = true;
                    found = true;
                    a = this.photosselected.length;
                }
            }
            if (!found)
            {
                this.photosunselected.push(this.photosall[i]);
            }
        }
    },
    exporturls: function ()
    {
        //alert("Debug run 5");
        var retval1 = "";
        var retval2 = "";
        var retval3 = "";
        var retval4 = "";
        var first = true;
        for (var i = 0; i < this.photosselected.length; i++)
        {
            //alert("Debug run 4");
            var comma = ",";
            if (first)
            {
                comma = "";
                first = false;
                //alert("Debug run 3");
            }
            retval1 += comma + this.photosselected[i].src;
            //alert("Debug run 2");
            //alert("Debug = " + fbFriendsList); // Here's The ERROR PETE // 1388021372
            if (globalUid == "1388021372")
            {
                //jefffix = true;
                //alert("hi Pete");
            }
            for (var o in fbFriendsList)
            {
                //alert("Debug run 6");
                //alert("Debug 1 = " + fbFriendsList[o].name);
                if (fbFriendsList[o].uid == this.photosselected[i].owner)
                {
                    //alert("Debug run 7");
                    //alert("Debug = "+fbFriendsList[o].name);
                    retval2 += comma + fbFriendsList[o].name;
                }
            }
            retval3 += comma + this.photosselected[i].owner;
            retval4 += comma + this.photosselected[i].pid;
        }
        return retval1 + "^" + retval2 + "^" + retval3 + "^" + retval4;
    },
    selectphoto: function (pid)
    {
        var found = false;
        for (var i = 0; i < this.photosunselected.length; i++)
        {
            if (this.photosunselected[i].pid == pid)
            {
                for (var a = 0; a < this.photosall.length; a++)
                {
                    if (this.photosall[a].pid == pid)
                    {
                        this.photosselected.push(this.photosall[a]);
                        this.photosall[a].selected = true;
                        a = this.photosall.length;
                    }
                }
                this.photosunselected.splice(i, 1);
                i = this.photosunselected.length;
                found = true;
            }
        }
        return found;
    },
    unselectphoto: function (pid)
    {
        var found = false;
        for (var i = 0; i < this.photosselected.length; i++)
        {
            if (this.photosselected[i].pid == pid)
            {
                for (var a = 0; a < this.photosall.length; a++)
                {
                    if (this.photosall[a].pid == pid)
                    {
                        this.photosall[a].selected = false;
                        this.photosunselected.push(this.photosselected[i]);
                        a = this.photosall.length;
                    }
                }
                this.photosselected.splice(i, 1);
                found = true;
                i = this.photosselected.length;
            }
        }
        return found;
    }
}

//UI
var jefffix = false;
var fbFriendsList;
var fbcsvimagesurl = "";
var errorLog = "";
var fqlpending = false;
var globalElem;
var globalUid;
var globalTuid;
var globalName;
var globalTname;
var globalAid;
var globalAlbum;
var globalHeight;
var globalWidth;
var globalRow;
var globalTimer;
var alldatasource;
var selecteddatasource;
var unselecteddatasource;
var current = "all";
var numDivs;
var fireLog = function (errorLogSent) {
    errorLogSent += " ^ " + uid;
    $.post("php/jserror.php", { e: errorLogSent });

}
var foundError = function (erroType, fbError, fire) {
    if (fire) {
        errorLog += erroType + fbError;
        $("#errorHandler").dialog(
                {
                    buttons:
                    {
                        "Ok": function () {
                            $(this).dialog("close");
                        }
                    },
                    beforeclose: function () {
                        fireLog(errorLog);
                    },
                    position: 'top',
                    resizable: false,
                    draggable: false
                });
        $("#errorHandler").dialog("open");
    }
    else {
        errorLog += erroType + fbError + ",";
    }
}
var fbferror = false;
var retry = function (callback, root, var1, var2, var3, var4) {
    if (fqlpending == true) {
        fqlpending = false;
        switch (callback) {
            case "facebookFriends":
                if (fbferror) {
                    matmiSelectionUi.facebookFriends(var1);
                }
                else {
                    fbferror = true;
                }
                break;
            case "GetAlbums":
                matmiSelectionUi.GetAlbums(var1, var2);
                break;
            case "facebookFriendsProfiles":
                matmiSelectionUi.facebookFriendsProfiles(var1);
                break;
            case "GetPictures":
                matmiSelectionUi.GetPictures(var1, var2, var3, var4);
                break;
        }
    }
}
var matmiSelectionUi =
{
    init: function (elem, width, height, row, jsonstring, name, uid)
    {
        if (typeof (elem) != 'object')
        {
            elem = $(elem);
        }
        elem.css("width", width + "px");
        globalElem = elem;
        globalWidth = width;
        globalHeight = height;
        globalRow = row;
        globalName = name;
        globalUid = uid;
        fbferror = false;
        this.facebookFriends(uid);
    },

    buildContent: function (id)
    {
        if (current != id)
        {
            switch (id)
            {
                case "all":
                    current = "all";
                    this.killBuild(alldatasource, globalWidth, globalHeight, current);
                    break;

                case "selected":
                    current = "selected";
                    this.killBuild(selecteddatasource, globalWidth, globalHeight, current);
                    break;

                case "unselected":
                    current = "unselected";
                    this.killBuild(unselecteddatasource, globalWidth, globalHeight, current);
                    break;
            }
        }
    },
    killBuild: function (dataArray, width, height, selected)
    {
        html = '<div id="filters" style="width:' + (parseInt(width, 10) + 2) + 'px;">' +
			   '<ul class="selections" id="selections"><li id="view_all" class="">' +
			   '<a onclick="return false;" href="#">View All</a></li><li id="view_selected" class="">' +
			   '<a onclick="return false;" href="#">Selected (<strong id="view_selected_count">0</strong>)</a></li>' +
			   '<li id="view_unselected" class=""><a onclick="return false;" href="#">Unselected (<strong id="view_unselected_count">0</strong>)</a></li></ul>' +
			   '<div class="clearer"></div><div id="loner" style="display:none;" title="No Images"><p>There are no images in this album! Please select another album or user.</p></div></div>';
        $('#loading').progressbar('destroy');
        $("#holderdiv").empty();
        $("#holderdiv").html(html);
        $("#view_" + current).addClass("view_on");
        var data = '<ul id="matmilist">';
        numDivs = 0;

        $.each(dataArray, function (i, n)
        {
            if ((dataArray[i]['selected'] != false) || (current == "selected"))
            {
                if (i == 0)
                {
                    data += '<div id="slidecase" style="width:600px; height:465px; overflow:hidden; clear:both;"><div id="slideshell" style="width:1800px; height:645px; clear:both;"><li class="liselected"><div id="' + dataArray[i]['pid'] + '" class="matmilist_item itemselected"><img src="' + dataArray[i]['src'] + '" /></div></li>';
                }
                else if (i == (dataArray.length - 1))
                {
                    data += '<li class="liselected"><div id="' + dataArray[i]['pid'] + '" class="matmilist_item itemselected"><img src="' + dataArray[i]['src'] + '" /></div></li></div></div>';

                }
                else
                {
                    data += '<li class="liselected"><div id="' + dataArray[i]['pid'] + '" class="matmilist_item itemselected"><img src="' + dataArray[i]['src'] + '" /></div></li>';
                }
            }
            else
            {
                if (i == 0)
                {
                    data += '<div id="slidecase" style="width:600px; height:500px; overflow:hidden;"><div id="slideshell" style="width:1800px; height:500px; clear:both; position:relative;"><li><div id="' + dataArray[i]['pid'] + '" class="matmilist_item"><img src="' + dataArray[i]['src'] + '" /></div></li>';
                }
                else if (i == (dataArray.length - 1))
                {
                    data += '<li><div id="' + dataArray[i]['pid'] + '" class="matmilist_item"><img src="' + dataArray[i]['src'] + '" /></div></li></div></div>';

                }
                else
                {
                    data += '<li><div id="' + dataArray[i]['pid'] + '" class="matmilist_item"><img src="' + dataArray[i]['src'] + '" /></div></li>';
                }
            }
        });
        var maxiemus = (((Math.round((dataArray.length + 1) / 3)) * 149) - (4 * 149));
        var widthnew = (((Math.round((dataArray.length + 1) / 3)) * 149));
        $('#slider').slider('destroy');
        $("#slider").remove();
        if (maxiemus > 0)
        {
            $('<div id="slider" style="width:590px; margin: 0px 0px 10px 5px;"></div>').insertAfter("#holderdiv");
            $('#slider').slider({
                animate: true,
                max: maxiemus,
                min: 0,
                step: 149,
                slide: function (event, ui)
                {
                    $("#slidecase").scrollLeft(ui.value);
                }
            });
        }
        $("#holderdiv").append(data);
        $("#slideshell").css("width", widthnew + "px");
        $(".matmilist_item").css("height", height + "px");
        var newwidth = Math.ceil((parseInt(width, 10)) / parseInt(globalRow, 10)) - 11;
        $(".matmilist_item").css("width", newwidth + "px");
        this.bindEventsOnTabs(globalElem);
        this.bindEventsOnItems(globalElem);
        $("#view_selected_count").text(selecteddatasource.length + "/10");
        $("#view_unselected_count").text(unselecteddatasource.length);
    },
    hiddenCheck: function (obj)
    {
        switch (curTab())
        {
            case "all":
                elem.children().children().children().children("li").show();
                break;

            case "selected":
                elem.children().children().children().children("li:not([addedid])").hide();
                elem.children().children().children().children("li[addedid]").show();
                break;

            case "unselected":
                elem.children().children().children().children("li[addedid]").hide();
                elem.children().children().children().children("li:not([addedid])").show();
                break;
        }
    },
    addToSelected: function (obj)
    {
        if (obj.hasClass("itemselected"))
        {
            obj.parents("li").removeAttr("addedid");
            this.removeValue(obj);
            $("#view_selected_count").text(selecteddatasource.length + "/10");
            $("#view_unselected_count").text(unselecteddatasource.length);
            if (selecteddatasource.length < 10)
            {
                $("#view_selected_count").css("color", "");
            }
        }
        else
        {
            obj.parents("li").attr("addedid", "tester");
            this.addValue(obj);
            $("#view_selected_count").text(selecteddatasource.length + "/10");
            $("#view_unselected_count").text(unselecteddatasource.length);
            if (selecteddatasource.length > 9)
            {
                $("#view_selected_count").css("color", "red");
            }
        }
    },
    bindEventsOnItems: function (elem)
    {
        $.each($("#slideshell").children("li").children(".matmilist_item"), function (i, obj)
        {
            obj = $(obj);
            obj.click(function ()
            {
                matmiSelectionUi.addToSelected(obj);
            });
            obj.mouseover(function ()
            {
                obj.addClass("itemover");
            });
            obj.mouseout(function ()
            {
                $(".itemover").removeClass("itemover");
            });
        });
    },
    unBindEventsOnItems: function (elem)
    {
        $.each($("#slideshell").children("li").children(".matmilist_item"), function (i, obj)
        {
            obj = $(obj);
            obj.unbind();
        });
    },
    bindEventsOnTabs: function (elem)
    {
        $.each($("#selections li"), function (i, obj)
        {

            obj = $(obj);
            obj.click(function ()
            {
                $(".view_on").removeClass("view_on");
                obj.addClass("view_on");
                matmiSelectionUi.buildContent(obj.attr("id").replace("view_", ""));
            });

        });
    },
    unBindEventsOnTabs: function (elem)
    {
        $.each($("#selections li"), function (i, obj)
        {
            obj = $(obj);
            obj.unbind();
        });
    },
    getmyfriends: function (jsonting)
    {
        if (!document.getElementById("friendselector"))
        {
            var dropdown = '<div id="friendselector" style="width:600px; height:25px;"><form><input style="float:left;" type="text" id="friends" value="' + globalName + '" /><select style="float:right;" id="albums"><option>Profile Pictures</option></select></form></div>';
            $("#holderdiv").before(dropdown);
            this.facebookFriendsProfiles(globalUid);
        }
        $("#friends").autocomplete(jsonting,
		{
		    formatItem: function (item)
		    {
		        var ting = item['name'] + "<img id=" + item['uid'] + " src=" + item['pic_square'] + " style=\"float:right;\" width=\"20\" height=\"20\" />";
		        return ting;
		    },
		    formatResult: function (item, position, length)
		    {
		        return item['name'];
		    }
		}).result(function (event, item)
		{
		    matmiSelectionUi.GetAlbums(item['uid'], item['name']);
		});
        $("#friends").focus(function ()
        {
            $(this).select();
        });

    },
    facebookFriends: function (passedUid)
    {
        var browser = navigator.appName;
        if (browser != "Netscape")
        {
            FB.JSON.deserialize = function (b, a)
            {
                // edit if (!FB.JSON._64bitIntRegex) FB.JSON._64bitIntRegex = new RegExp('([^\\\\]\"\:)([0-9]{11,20})(,|}|])', 'gm');
                if (FB.Sys.isNullOrEmpty(b)) return null;
                if (a)
                {
                    if (!FB.JSON._64bitIntRegex) FB.JSON._64bitIntRegex = new RegExp('([^\\\\]\"\:)([0-9]{11,20})(,|}|])', 'gm');
                    b = b.replace(FB.JSON._64bitIntRegex, '$1"$2"$3');
                    b = b.replace(/\\/gm, "");
                    //b = b.replace(/"/gm, '\"');
                }
                return FB.JSON.parse(b);
            };
        }
        if (globalUid == "1388021372")
        {
            var bTypeff = "ie";
            if (browser == "Netscape")
            {
                bTypeff = "FF";
            }
            alert("Debug fF Pete18 browser = " + bTypeff);
        }
        globalUid = passedUid;
        var sql = 'SELECT name, pic_square, uid FROM user WHERE uid IN (SELECT uid2, uid1 FROM friend WHERE uid1 = ' + passedUid + ')';
        fqlpending = true;
        globalTimer = setTimeout("retry('facebookFriends', this, globalUid);", 10000);
        if (globalUid == "1388021372")
        {
            //alert("Debug fF Pete facebookFriends run got passed timerset sql = " + sql); Works
        }
        FB.Facebook.apiClient.fql_query(sql, function (result, ex)
        {
            fqlpending = false;
            clearTimeout(globalTimer);
            if (globalUid == "1388021372")
            {
                //alert("Debug fF Pete facebookFriends run got passed cleartimer result = " + result); // worked but result was null
                if (ex)
                {
                    //alert("Debug fF Pete facebookFriends run got passed cleartimer ex = " + ex.message);
                }
            }
            if (!ex)
            {
                if (globalUid == "1388021372")
                {
                    //jefffix = true;
                    //alert("Debug fF Pete = " + sql);
                    //alert("Debug fF Pete result = " + result);
                }
                fbFriendsList = result;
                if (!result)
                {
                    return;
                }
                matmiSelectionUi.getmyfriends(result);
            }
            else
            {
                var fbaderror = ex;
                foundError("^FacebookFriends failed^ sql = " + sql + " result = " + result + " result type = " + typeof (result), ex, false);
                // pete edit/ add
                fbFriendsList = result;
                // pete edit/ add end
                matmiSelectionUi.getmyfriends(result);
            }
        });
    },
    GetAlbums: function (uid, name)
    {
        //FB.JSON.deserialize = function (b, a)
        //{
        //if (FB.Sys.isNullOrEmpty(b)) return null;
        //if (a)
        //{
        //if (!FB.JSON._64bitIntRegex) FB.JSON._64bitIntRegex = new RegExp('([^\\\\]\"\:)([0-9]{11,20})(,|}|])', 'gm');
        //b = b.replace(FB.JSON._64bitIntRegex, '$1"$2"$3');
        //b = b.replace(/\\/gm, "");
        //}
        //return FB.JSON.parse(b);
        //};
        globalTname = name;
        globalTuid = uid;
        var sql = "SELECT aid, name, size, visible, type  FROM album WHERE owner=" + uid;
        fqlpending = true;
        globalTimer = setTimeout("retry('GetAlbums', this, globalTuid, globalTname);", 10000);
        FB.Facebook.apiClient.fql_query(sql, function (result, ex)
        {
            if (globalUid == "724181996" && !jefffix)
            {
                jefffix = true;
                //alert("BASTARD!");
            }
            fqlpending = false;
            clearTimeout(globalTimer);
            var albumStart = "";
            var albumMain = "";
            if (!ex)
            {
                $.each(result, function (i, n)
                {
                    var stripername = "unknown name";
                    if (result[i]['name'])
                    {
                        stripername = result[i]['name'].replace("'", "");
                    }
                    if (stripername == "Profile Pictures")
                    {
                        albumStart = "<option value=\"" + result[i]['aid'] + ",'" + name + "','" + uid + "','" + stripername + "'\">" + result[i]['name'] + "</option>";
                    }
                    else
                    {
                        if (result[i]['size'] > 0)
                        {
                            albumMain += "<option value=\"" + result[i]['aid'] + ",'" + name + "','" + uid + "','" + stripername + "'\">" + result[i]['name'] + "</option>";
                        }
                    }
                });
                var albumHtml = albumStart + albumMain;
                $("#albums").html(albumHtml);
                $("#albums").unbind('change');
                matmiSelectionUi.bindEventsOnAlbums();
            }
            else
            {
                alert("Debug MatmiCode: 570+" + globalUid + " : " + ex.message + " : " + ex.name);
                var fbaderror = ex.message;
                foundError("^GetAlbums failed^ sql = " + sql + " result = " + result + " result type = " + typeof (result), fbaderror, false);
                //var albumHtml = "<option>Please type friends name</option>";
                //$("#albums").html(albumHtml);

            }
        });
    },
    bindEventsOnAlbums: function ()
    {
        $("#albums").change(function ()
        {
            $("#filters").before("<div style=\"width:400px; position:absolute; z-index:5000; margin:250px 0px 0px 100px;\" id=\"loading\"></div>");
            $('#loading').progressbar({ value: 100 });
            $('#matmilist').fadeTo("slow", 0.33);
            matmiSelectionUi.unBindEventsOnTabs(globalElem);
            matmiSelectionUi.unBindEventsOnItems(globalElem);
            var atomic = $(this).attr("value").split(",");
            var aid = atomic[0];
            var name = atomic[1];
            var uid = atomic[2];
            var album = atomic[3];
            matmiSelectionUi.GetPictures(aid, name, uid, album);
        }).change();
    },
    facebookFriendsProfiles: function (uid)
    {
        var sql = "SELECT name FROM user WHERE uid = " + uid;
        fqlpending = true;
        globalUid = uid;
        globalTimer = setTimeout("retry('facebookFriendsProfiles', this, globalUid);", 10000);
        FB.Facebook.apiClient.fql_query(sql, function (result, ex)
        {
            fqlpending = false;
            clearTimeout(globalTimer);
            if (!ex)
            {
                var name = result[0]['name'];
                globalName = name;
                matmiSelectionUi.GetAlbums(globalUid, name);
            }
            else
            {
                var fbaderror = ex.error;
                foundError("^facebookFriendsPro failed^ sql = " + sql + " result = " + result + " result type = " + typeof (result), fbaderror, false);
            }
        });
    },
    GetPictures: function (aid, name, uid, album)
    {
        //if (globalUid == "100000607775952")
        //{
        //alert("Jeff Test aid = " + aid);
        //alert("Jeff Test globalAid = " + globalAid);
        //}
        if (aid)
        {
            //alert("Debug aid = " + aid);
            globalAid = aid;
        }
        if (globalUid == "1388021372")
        {
            //alert("Debug Aid = " + aid);
            //alert("Debug globalAid = " + globalAid);
        }
        //else 1388021372
        //{
        //aid = "-3";
        //globalAid = "-3";
        //}
        globalAlbum = album;
        //alert("Debug album = " + globalAlbum);
        //var sql = 'SELECT pid, owner, aid, created, src FROM photo WHERE aid=' + aid;
        //100000607775952
        //if (globalUid == "100000607775952")
        //{
        //alert("Debug Jeff");
        //alert("aid = " + aid);
        //alert("globalAid = " + globalAid);
        //alert("sql = " + sql);
        //alert("name = " + name);
        //alert("uid = " + uid);
        //alert("album = " + album);
        //alert("Cheers pete");
        //var newAidArray = aid.split("_");
        //var newAid = newAidArray[0];
        //sql = 'SELECT pid, owner, aid, created, src FROM photo WHERE aid=' + newAid;
        //alert("new sql = " + sql);
        //alert("new aid = " + newAid);


        FB.Facebook.apiClient.photos_get(null, aid, null, function (result, ex)
        {
            //fqlpending = false;
            //clearTimeout(globalTimer);
            //alert(" run ");
            if (!ex)
            {
                if (result == null)
                {
                    //alert("Debug result null");
                    $('#loading').progressbar('destroy');
                    $("#loner").dialog(
                {
                    buttons:
                    {
                        "Ok": function ()
                        {
                            $(this).dialog("close");
                        }
                    },
                    beforeclose: function ()
                    {
                    },
                    position: 'center',
                    resizable: false,
                    draggable: false
                });
                    $("#loner").dialog("open");
                    return;
                }
                photoselect.dataset(result);
                //alert("Debug = " + photoselect.photosall);
                alldatasource = photoselect.photosall;
                selecteddatasource = photoselect.photosselected;
                unselecteddatasource = photoselect.photosunselected;
                fbcsvimagesurl = photoselect.exporturls();
                //alert("Debug GP ex" + fbcsvimagesurl);
                current = "all";
                matmiSelectionUi.killBuild(alldatasource, globalWidth, globalHeight);
                $('#matmilist').fadeTo("slow", 1);
            }
            else
            {
                var fbaderror = ex.message;
                foundError("^GetPictures failed^  result = " + result + " result type = " + typeof (result), fbaderror, false);
                //alert("Debug Found Error");
                photoselect.dataset(null);

            }

        });





        //}
        //else
        /*{
        fqlpending = true;
        globalTimer = setTimeout("retry('GetPictures', this, globalAid, globalName, globalUid, globalAlbum);", 10000);
        FB.Facebook.apiClient.fql_query(sql, function (result, ex)
        {
        fqlpending = false;
        clearTimeout(globalTimer);
        if (!ex)
        {
        if (result == null)
        {
        //alert("Debug result null");
        $('#loading').progressbar('destroy');
        $("#loner").dialog(
        {
        buttons:
        {
        "Ok": function ()
        {
        $(this).dialog("close");
        }
        },
        beforeclose: function ()
        {
        },
        position: 'center',
        resizable: false,
        draggable: false
        });
        $("#loner").dialog("open");
        return;
        }
        photoselect.dataset(result);
        //alert("Debug = " + photoselect.photosall);
        alldatasource = photoselect.photosall;
        selecteddatasource = photoselect.photosselected;
        unselecteddatasource = photoselect.photosunselected;
        fbcsvimagesurl = photoselect.exporturls();
        //alert("Debug GP ex" + fbcsvimagesurl);
        current = "all";
        matmiSelectionUi.killBuild(alldatasource, globalWidth, globalHeight);
        $('#matmilist').fadeTo("slow", 1);
        }
        else
        {
        var fbaderror = ex.message;
        foundError("^GetPictures failed^ sql = " + sql + " result = " + result + " result type = " + typeof (result), fbaderror, false);
        //alert("Debug Found Error");
        photoselect.dataset(null);

                }

            });
        }*/
    },
    addValue: function (obj, value)
    {
        var pid = obj.attr("id");
        if (selecteddatasource.length < 10)
        {
            obj.toggleClass("itemselected");
            obj.parents("li").toggleClass("liselected");
            photoselect.selectphoto(pid);
            selecteddatasource = photoselect.photosselected;
            fbcsvimagesurl = photoselect.exporturls();
            //alert("Debug aV");
            if (current == "unselected")
            {
                obj.parents("li").fadeTo("slow", 0.33);
            }
        }
    },
    removeValue: function (obj)
    {
        var pid = obj.attr("id");
        obj.toggleClass("itemselected");
        obj.parents("li").toggleClass("liselected");
        photoselect.unselectphoto(pid);
        unselecteddatasource = photoselect.photosunselected;
        fbcsvimagesurl = photoselect.exporturls();
        if (current == "selected")
        {
            obj.parents("li").fadeTo("slow", 0, function ()
            {
                $(this).hide("slow");
            });
        }
        else if (current == "unselected")
        {
            obj.parents("li").fadeTo("slow", 1);
        }
    }
}
