
var gallery;

function Gallery(){
    this.container = $("#carousel");
    this.friend = $("#friend");
    this.setup();
}


Gallery.prototype = {
    setup: function(){
        var self = this;
        this.container.find('a').click(function() { self.showImage(this); return false; })
    },
    showImage: function(link) {
        var self = this;
        if (link) {
            var friend_id = link.href.split('?')[1].split('=')[1];
            if(friend_id){
                var fd = $("#fd-load");
                fd.css({display:"block",width: fd.get(0).parentNode.offsetWidth+"px",
                                        height: fd.get(0).parentNode.offsetHeight+"px"});
                fd.css("opacity","0.8");
                var ajaxParams = {object: 'friend',
                                   friend_id: friend_id};
                $.post('/xData/',ajaxParams,function(data){self.parse(data);},"xml");
            }
        }
    },
    parse: function(xml){
      var self = this;
        
        var content = xml.getElementsByTagName('content')[0];
        if(content){
            self.friend.find("div.friend").html(textContent(content));
        }
        $("#fd-load").css({display:"none"});
    }
}


