﻿$(document).ready(function () {

    //comentado para não aparecer colapsado
    ////versao alternativa para procurar elemento através da classe na linha abaixo
    ////jQuery(this).find('div .contentRight').find('.accordion tr').each(
    /*jQuery(this).find('div .contentRight').find('#tableRight').each(
    function () {
    //$("#tableRight tr").first().nextAll("tr").hide();
    jQuery(this).find("tr").first().nextAll("tr").hide();
    });


    ////versao alternativa para procurar elemento através da classe na linha abaixo
    ////jQuery(this).find('div .contentRight').find('.accordion tr').each(
    jQuery(this).find('div .contentRight').find('#tableRight').each(
    function () {

    jQuery(this).find("tr").first().click(function () {
    $(this).nextAll("tr").toggle();
    });
    });*/



    ////Code to collapse/expand content div clicking a title div
    ////title divs must begin with: "clickDiv", content divs must have the following id: bodyof_+<idoftitlediv>
    ////an image is added to the title div with the +/- icon
    ////content divs are displayed collapsed on first render

    jQuery("div[id^='clickDiv']").append('<img style="padding-left: 5px;cursor: pointer;" src="/Style Library/FMS.Images/bullet_mais.png" alt="">');
    jQuery("div[id^='bodyof_']").hide();

    jQuery("div[id^='clickDiv']").css('cursor', 'pointer');

    jQuery("div[id^='clickDiv']").click(function () {

        var target = $(this).attr("id");
        var src = jQuery(this).children("img").first().attr("src");
        //jQuery(this).children("img").first().attr("src", src == "/Style Library/FMS.Images/bullet_mais.png" ? "/Style Library/FMS.Images/bullet_menos.png" : "/Style Library/FMS.Images/bullet_mais.png");
        jQuery(this).children("img").first().attr("src", src.indexOf("bullet_mais.png") != -1 ? "/Style Library/FMS.Images/bullet_menos.png" : "/Style Library/FMS.Images/bullet_mais.png");

        jQuery("#bodyof_" + target).toggle();
    });

});
