// JavaScript Document

$(document).ready(function () {

    $('.submenu_top li:first-child').find('span.ico_left').hide();
    $('.submenu_top li:last-child').find('span.ico_right').hide();

    var ulSize = 0;
    //MENU
    $('.menu_top li').hover(function () {

        // Save the Objects -- .menu_top li |.menu_top li ul|.menu_top li ul li;

        var liPrincipal = $(this);
        var ulSecundary = $(this).find('ul');
        var liSecundary = $(this).find('li');

        // Get the Size of Menu and the Offset + Calculate both;
        var menuSize = $('.menu_top').width();
        var menuOffs = $('.menu_top').offset();
        menuOffs = menuOffs.left;
        var menuBoth = menuOffs + menuSize;

        // Show ul to Start Calculate the Li's
        ulSecundary.show();

        // Add Class hover to set "position:relative" into LI(this)
        $(this).addClass('hover');


        if ($(this).attr("checking") != "true") {
            // Doing For to get Size of all LiSecundary to set Width of ulSecundary
            var qtdLi = liSecundary.size();
            var liSize = 0;
            var i;
            for (i = 0; i < qtdLi; i++) {
                liSize = liSize + liSecundary.eq(i).width()+5;
            }
            ulSecundary.width(liSize);

            // Now let's move the Menu to their place
            //   //First get Offset liSecundary, then sum Offset + width of liSecundary(liSize)
            var liOffs = liSecundary.offset();
            liOffs = liOffs.left;
            var liBoth = liOffs + liSize;

            //Do This to set LiSecundary in their place if necessary.
            var finalSum = 0;
            if (liBoth > menuBoth) {
                finalSum = menuBoth - liBoth;
                ulSecundary.css("left", finalSum);
            }
            $(this).attr("checking", "true");
        }


    }, function () {

        $(this).find('ul').hide();

        $(this).removeClass('hover');
    });
    



    $('#email_text').focus(
		function () {
		    if ($(this).val() == 'seu email') {
		        $(this).val('');
		    }
		});
    $('#email_text').blur(
		function () {
		    if ($(this).val() == '') {
		        $(this).val('seu email')
		    }
		});

});

(function ($) {
    $(function () { //on DOM ready
        $("#scroller").simplyScroll({
            autoMode: 'loop'
        });
    });
})(jQuery);



(function ($) {
    $(document).ready(
		function () {
		    $(".ImagemLateral").css("height", $("#neo_conteudo").height() - 960);
		}
	);
})(jQuery);


$(function () {

    // Accordion
    $("#accordion").accordion({ header: "h3", autoHeight: false });

    $('#accordion').bind('accordionchange', function (event, ui) {
          
    });

    //hover states on the static widgets
    $('#dialog_link, ul#icons li').hover(
					function () { $(this).addClass('ui-state-hover'); },
					function () { $(this).removeClass('ui-state-hover'); }
				);

});

