var testimonials = {


    init: function() {
        markMenu('nav-concept');
        markSubmenuConcept('nav-3');
        this.testimonials();
        this.idealizers();

        $("div#sidebar ul li a").neoHover();

        $('li[rel="mailto"]').css('cursor', 'pointer');
        $('li[rel="mailto"]').click(function() {
            location.href = 'mailto:ideia@maxhaus.com.br';
        });
    },



    idealizers: function() {

        var obj = $('#idealizers ul');
        var duration = 300;
        var easing = 'easeOutQuad';

        $.each(obj, function(i, el) {
            $('li', obj).hover(function() {
                $(this).parent().find('li').animate({ width: 66 }, { queue: false, duration: duration, easing: easing });
                $(this).animate({ width: 304 }, { queue: false, duration: duration, easing: easing });
            },
			function() {
			    $('li', obj).animate({ width: 100 }, { queue: false, duration: duration, easing: easing });
			});
        });

    },



    testimonials: function() {
        var pos = 0;

        var items = $('div#testimonials ul li');
        $(items).fadeTo(0, 0);

        var width = 71;
        var height = 59;

        var x = 0;
        var y = 0;


        $.each(items, function(i, el) {

            if (i == 0) {
                x = width * i;
                y = 0;
            }
            else if (i % 10 == 0) {
                x = 0;
                y += height;
            }
            else {
                x += width;
            }

            el.x = x;
            el.y = y;
            el.last = false;


            if (items.length == i + 1) {
                el.last = true;
            }


            $(el).css('top', Math.random() * 1000);
            $(el).css('left', Math.random() * 1000);

            $(el).animate({ foo: 1 }, { queue: true, duration: 100 + (30 * i), easing: 'easeOutQuad', complete: function() {


                $(this).animate({ opacity: 1, left: el.x, top: el.y }, { queue: false, duration: 600, easing: 'easeOutQuad', complete: function() {
                    if (el.last) {
                        $('<div id="quote">&nbsp;</div>').appendTo('div#testimonials');


                        $('#quote').css('width', 0);
                        $(items).bind('mouseover',
							function() {
							    $this = $(this);

							    $('#quote').html($this.html());
							    $('#quote').attr('class', $this.attr('class'));

							    $('#quote').css({
							        top: $this.css('top'),
							        left: $this.css('left')
							    });

							    if ($('#quote').hasClass('lasts') || $('#quote').hasClass('last-column')) {
							        $('#quote').css('margin-left', '-283px');
							    } else {
							        $('#quote').css('margin-left', '0');
							    }

							    $('#quote').fadeTo(0, 0);
							    $('#quote').css('width', '71px');
							    $('#quote').animate({ opacity: 1, width: '368px' }, { queue: false, duration: 500, easing: 'easeInOutQuad' });
							}
						);
                    }
                }
                });


            }
            });


        });



    }




};
