﻿/// <reference path="jquery-1.4.1-vsdoc.js" />
$(domReady);
function domReady() {
    // lateral menu left effects
    jQuery(".mainMenu .menuLateralFlash img").live('mouseover', function() {
        ChangeImageOnMouseHover(jQuery(this));
    });
    jQuery(".mainMenu .menuLateralFlash img").live('mouseout', function() {
        ChangeImageOnMouseHover(jQuery(this));
    });
    // lateral menu left effects
    jQuery(".destaqueLateralMainHeader .destaqueLateralMain .menuLateralFlash img").live('mouseover', function() {
        ChangeImageOnMouseHover(jQuery(this));
    });
    jQuery(".destaqueLateralMainHeader .destaqueLateralMain .menuLateralFlash img").live('mouseout', function() {
        ChangeImageOnMouseHover(jQuery(this));
    });

    
    //Caption Sliding (Partially Hidden to Visible)
    jQuery('.boxgrid.caption').hover(function() {
        jQuery(".cover", this).stop().animate({ top: '23px' }, { queue: false, duration: 300 }, "normal", function() {
            jQuery(".cover", this).attr("style", "background: #ffffff");
        });
    }, function() {
        jQuery(".cover", this).stop().animate({ top: '123px' }, { queue: false, duration: 300 }, "normal", function() {
            jQuery(".cover", this).attr("style", "background: #000");
        });
        return false;
    });
    // ver mais destaques homepage
    jQuery(".verMais.bold").live("click", function() {
        if (jQuery("#newsHidden").attr('IsOpen') == "false") {
            jQuery("#newsHidden").animate({ top: -130 + ((-55 * jQuery("#newsHidden .noticiasAreaHidden div").size())), height: 'show' }, { queue: true, duration: 300 }, "normal", function() {
            }).attr('IsOpen', 'true');
            return false;
        }
        else {
            jQuery("#newsHidden").animate({ top: '-130', height: 'hide' }, { queue: true, duration: 300 }, "normal", function() {
            }).attr('IsOpen', 'false');
            return false;
        }
        return false;
    });

    // Competition items slider
    jQuery(".linksVermais li a").live('click', function() {
        var id = jQuery(this).attr("id");
        id = id.split('_')[1];
        jQuery("#ContentArea_" + id).slideToggle("400", function() {
            if (jQuery(this).is(':hidden')) {
                jQuery("#SeeMore_" + id).text("ver mais");

            }
            else {
                jQuery("#SeeMore_" + id).text("fechar");

            }
            return false;
        });

        return false;
    });

    // encapsulating menu first level
    jQuery('#menuElem > li').each(function() {
        var link = jQuery(this).html();

        var cUl = '<div></div>';
        var cA = '<div></div>';
        // get ul (submenu).
        var ul = jQuery(cUl).append(jQuery('> ul', this).clone()).remove().html();
        // get link current menu.
        var a = jQuery(cA).append(jQuery('> a', this).clone()).remove().html();
        // fill again html object width new mwnu item 1 changed.
        jQuery(this).html('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="left">&nbsp;</td><td class="center">' + a + '</td><td class="right">&nbsp;</td></tr></table>' + ul);

        // setup child submenu
        jQuery('ul > li ', this).corner("3px");
        jQuery('ul', this).corner("Bottom 3px");

    });

    // menu drop down
    jQuery('#menuElem li').hover(
		function() {
		    //show its submenu
		    jQuery('ul', this).stop(true, true).slideDown(300);

		},
		function() {
		    //hide its submenu
		    jQuery('ul', this).stop(true, true).slideUp(300);
		}
	);
}


function ChangeImageOnMouseHover($element) {
    if ($element.attr("imghover") != "") {
        var imgHover = jQuery($element).attr("imghover");
        var img = jQuery($element).attr("src");
        jQuery($element).attr("src", imgHover);
        jQuery($element).attr("imghover", img);
    }
}
