
/**
 * menu.js
 *
 * Log:
 * - v0.0.1 2011-11-03 first version
 *
 * @package PG
 * @version 0.0.1
 * @date 2011-11-03
 * @author Michal Luberda <michal.luberda@appcom.it>
 */

if (aMenu.length == 1)
{
    
    Menu = function (o)
    {
        
        this.id = "#" + o.id;
        
        this.init = function ()
        {
            
            var o = this;
            
            var sLang = $ (o.id).find ("span.l").text ();
            
            // home
            $ (o.id).find ("a.home").hover (
                function () {o.hover ($ (this), "home", true);},
                function () {o.hover ($ (this), "home", false);}
            );
            
            // masks
            $ (o.id).find ("a.masks").hover (
                function () {o.hover ($ (this), "masks", true);},
                function () {o.hover ($ (this), "masks", false);}
            );
            
            // wines
            $ (o.id).find ("a.wines").hover (
                function () {o.hover ($ (this), "wines", true);},
                function () {o.hover ($ (this), "wines", false);}
            );
            
            // bus-tickets
            $ (o.id).find ("a.bus-tickets").hover (
                function () {o.hover ($ (this), "bus-tickets", true);},
                function () {o.hover ($ (this), "bus-tickets", false);}
            );
            
        };
        
        this.hover = function (oA, sPage, isSelected) 
        {
            
            var oMenu = this;
            if (isSelected)
                oA.find ("img").attr ("src", $ (oMenu.id).find ("span.selected").find ("." + sPage).text ());
            else
                oA.find ("img").attr ("src", $ (oMenu.id).find ("span.normal").find ("." + sPage).text ());
            
        };
        
    };
    
}

$ (document).ready (function ()
{
    
    var o = null;
    for (var i in Page.aMenu) {
        if (Page.aMenu[i].id == "#" + sId) {
            o = Page.aMenu[i];
        }
    }
    
    if (! o) {
        for (var i in aMenu) {
            o = new Menu ({
                id: aMenu[i]
            });
            
            Page.aMenu = Page.aMenu || [];
            Page.aMenu.push (o);
        }
    }
    
    o.init ();
    
});

