var Portfolio = {

    pCurrent:null,
    
    init: function() 
    {
        $("div.pf div.pl").each(function() 
        {                    
            $(this).mouseover(function(e)
            {
                Portfolio.showTitle($(this));    
            });
        });
    },
    
    showTitle: function(pItem) 
    {
        if(pItem.children().children().css('opacity') == 1)
        {          
            Portfolio.hideTitle();      
            Portfolio.pCurrent = pItem;
            pItem.each( function() 
            { 
                $(this).children().each( function() 
                { 
                    if ($(this).is("a")) 
                    { 
                        $(this).children().animate({"opacity": "0.5"}, 500); 
                    }

                    if ($(this).is("div")) 
                    { 
                        $(this).animate({"top": "50"}, 500); 
                    }

                }); 
            });
        }    
    },
    
    hideTitle: function() 
    {
        // alert(e.pageX +', '+ e.pageY);
        // alert( "left: " + pItem.position().left + ", top: " + pItem.position().top );
        /*
        var nMouseX = e.pageX;
        var nMouseY = e.pageY;
        var nItemX = pItem.position().left;
        var nItemY = pItem.position().top;
        var nItemWidth = 100;
        
        if(!(nMouseX-11 < nItemX || nMouseX-9 > nItemX + nItemWidth || nMouseY-11 < nItemY || nMouseY-9 > nItemY + nItemWidth))
        {
            return false;
        }
        */    
        pItem = Portfolio.pCurrent;
        if(pItem)
        {
            pItem.each( function() 
            { 
                $(this).children().each( function() 
                { 
                    if ($(this).is("a")) 
                    { 
                        $(this).children().animate({"opacity": "1.0"}, 500); 
                    }
                    
                    if ($(this).is("div")) 
                    { 
                        $(this).animate({"top": "100"}, 500); 
                    }
                
                }); 
            });
            
            Portfolio.pCurrent = null;
        }
    }    
    
};

$(document).ready(function() { Portfolio.init(); });
