/**
* author Allan Brown
*/
document.observe('dom:loaded', function() {
    $$('.ellipsis').each(function(parent) {
        parent.observe('mouseenter', function(event) {
            // Code to respond to each click goes here
            child = parent.down('span');
            if (child.getWidth() > parent.getWidth()) {
                difference = child.getWidth() - parent.getWidth()
                /* child.setStyle({marginLeft: '-' + difference + 'px'}) */
                Effect.Queues.get('ellipsis' + parent.identify()).invoke('cancel');
                new Effect.Move(child, { x: -difference, mode: 'absolute', queue: { position: 'end', scope: 'ellipsis' + parent.identify() } });
            }
        });
        parent.observe('mouseleave', function(event) {
            // Code to respond to each click goes here
            child = parent.down('span');
            if (child.getWidth() > parent.getWidth()) {
                difference = child.getWidth() - parent.getWidth()
                /* child.setStyle({marginLeft: '0px'}) */
                Effect.Queues.get('ellipsis' + parent.identify()).invoke('cancel');
                new Effect.Move(child, { x: 0, mode: 'absolute', queue: { position: 'end', scope: 'ellipsis' + parent.identify() } });
            }
        });
    });
});

document.observe('dom:loaded', function() {
    $$('.verticalellipsis').each(function(parent) {
        parent.observe('mouseenter', function(event) {
            // Code to respond to each click goes here
            child = parent.down('span');
            if (child.getHeight() > parent.getHeight()) {
                difference = child.getHeight() - parent.getHeight()
                Effect.Queues.get('ellipsis' + parent.identify()).invoke('cancel');
                new Effect.Move(child, { y: -difference, mode: 'absolute', queue: { position: 'end', scope: 'ellipsis' + parent.identify() } });
            }
        });
        parent.observe('mouseleave', function(event) {
            // Code to respond to each click goes here
            child = parent.down('span');
            if (child.getHeight() > parent.getHeight()) {
                difference = child.getHeight() - parent.getHeight()
                Effect.Queues.get('ellipsis' + parent.identify()).invoke('cancel');
                new Effect.Move(child, { y: 0, mode: 'absolute', queue: { position: 'end', scope: 'ellipsis' + parent.identify()} });
            }
        });
    });
});

/*  */
document.observe('dom:loaded', function() {
    $$('.toggleMenu').each(function(parent) {
        parent.observe('mouseenter', function(event) {
            toggleMenu(parent,1);
        });
        parent.observe('mouseleave', function(event) {
           toggleMenu(parent,0);
        });
    });
});
