window.addEvent("domready", function () {

    // MAIN MENU
    $$('#main_menu .main_menu_item').each(function(li, i) {
        var el = li.getChildren("a")[0],
            submenu = li.getChildren('.submenu'),
            x_start = el.getPosition($('main_menu')).x,
            x_size = el.getSize().x;
            
        if (submenu.length > 0) {
            if (x_size < 180)
                submenu[0].setStyle('left', x_start - (180 - x_size) / 2);
            else
                submenu[0].setStyle('left', x_start + (x_size - 180) / 2);
            
            
/*
    	   	li.addEvents({
    	   	   'mouseenter': function() {
                    submenu[0].fade(1);
                },
                'mouseleave': function() {
                    submenu[0].fade(0);
                }
            });
*/
    	}
    });


    // BULLETS
    var image_bullets = Array(
		"template/images/bullets/bullet-cobra.png",
		"template/images/bullets/bullet-iguana.png",
		"template/images/bullets/bullet-macaco.png",
		"template/images/bullets/bullet-passaro1.png",
		"template/images/bullets/bullet-passaro2.png",
		"template/images/bullets/bullet-pica_pau.png",
		"template/images/bullets/bullet-pinguim.png",
		"template/images/bullets/bullet-suricatas.png"
    );
    $$('.bullets li').each(function(el,i) {
      el.setStyle('list-style-image', 'url(' + image_bullets[Math.floor(Math.random()*image_bullets.length)] + ')');
    });
  
    
    // MOLDURAS COLORIDAS
    var colors = Array("#E0007A", "#00A7E9", "#6CB434", "#F6F600", "#FFFFFF")
    $$('.photo_frame').each(function(el,i) {
        el.setStyle("border-color", colors[Math.round(i%colors.length)]);
    });
    
    
    // ROTATIONS
/*
    $$('.photo_frame').each(function(el,i) {
    	var rotation = new Fx.Rotate(el, { duration: 300, transition: Fx.Transitions.Quad.easeInOut });
    	if (i%2) {
        	rotation.set(Math.floor(Math.random()*10));
        } else {
        	rotation.set(Math.floor(Math.random()*10)-10);
        }
    });
*/
});
