function displayBlock(itemid) {
    var obj = document.getElementById(itemid);
    if (obj != null) {
        obj.style.display = 'block';
    }
}

function displayNone(itemId) {
    var obj = document.getElementById(itemId);
    if (obj != null)
        obj.style.display = 'none';
}

function toggle(itemId) {
    var obj = document.getElementById(itemId);
    if (obj == null)
        return false;

    if (obj.style.display == "none")
        obj.style.display = "block";
    else
        obj.style.display = "none";

    return true;
}

var lastVisible = null;

function menuDinamico(objId) {

    var el = document.getElementById(objId);
    if (lastVisible != null) {
        lastVisible.style.display = "none";
        lastVisible = null;
    }
    if (el != null) {
        el.style.display = "block";
        lastVisible = el;
    }
}

window.setTimeout("lastVisible = document.getElementById('subTabela01')", 2000);

function increaseFontSize(itemId, amount) {
    var obj = document.getElementById(itemId);
    if (obj != null) {
        var newAmount = parseInt(obj.style.fontSize);

        if (isNaN(newAmount))
            newAmount = 12;

        newAmount += amount;

        if (!isNaN(newAmount))
            obj.style.fontSize = newAmount + "Px";
        else
            obj.style.fontSize = "";
    }
}

function displayChildUl(elem) {
    var children = elem.getElementsByTagName("ul");
    for (var i = 0; i < children.length; i++)
        children[i].style.display = 'block';
}

function hideChildUl(elem) {
    var children = elem.getElementsByTagName("ul");
    for (var i = 0; i < children.length; i++)
        children[i].style.display = 'none';
}

function FavoriteBox(siteName) {
    this.m_Favorites = [];
    this.m_SiteName = siteName;
    
    this.readCookie = function() {
        var currentItemNumber = 0;
        var currentItemKey = "Fav_" + this.m_SiteName + "_" + currentItemNumber;
        var currentItemValue = readCookieValue(currentItemKey);
        while (currentItemValue != null) {
            this.m_Favorites[currentItemNumber] = currentItemValue;
            currentItemNumber++;
            currentItemKey = "Fav_" + this.m_SiteName + "_" + currentItemNumber;
            currentItemValue = readCookieValue(currentItemKey);
        }
        this.writeItems();
    }

    this.writeCookie = function() {
        var date = new Date();
        date.setFullYear(
            date.getFullYear() + 1,
            date.getMonth(),
            date.getDate());

        for (var i = 0; i < this.m_Favorites.length; i++) {
            if (this.m_Favorites[i] != null) {
                createCookie("Fav_" + this.m_SiteName + "_" + i, this.m_Favorites[i], date);
            }
        }
    }

    this.clearCookie = function() {
        for (var i = 0; i < this.m_Favorites.length; i++) {
            createCookie("Fav_" + this.m_SiteName + "_" + i, "", null);
            var currentItemContainer = document.getElementById("FavoritesBox_Item" + (i + 1));
            if (currentItemContainer != null) {
                currentItemContainer.innerHTML = "";
                currentItemContainer.style.display = 'none';
            }
        }
        var arr = [];
        this.m_Favorites = arr;
        document.getElementById("FavoritesBoxLabelEmpty").style.display = 'block';

    }


    this.writeItems = function() {

        var itemCount = 0;

        for (var i = 0; i < this.m_Favorites.length; i++) {
            if (this.m_Favorites[i] != null) {
                var spl = this.m_Favorites[i].split("||");
                if (this.setFavorite(i + 1, spl[0], spl[1]))
                    itemCount++;
            }
        }

        if (itemCount > 0)
            document.getElementById("FavoritesBoxLabelEmpty").style.display = 'none';
    }

    this.setFavorite = function(itemIndex, title, url) {

        if (title == null || url == null)
            return false;

        var currentItemContainer = document.getElementById("FavoritesBox_Item" + itemIndex);
        if (currentItemContainer == null)
            return false;

        currentItemContainer.innerHTML = "<a href=\"" + url + "\">" + title + "</a>";
        currentItemContainer.style.display = 'block';

        return true;
    }


    this.add = function(title, url) {

        var newValue = title + "||" + url;

        if (this.m_Favorites[0] == newValue)
            return;

        for (var i = this.m_Favorites.length; i > 0; i--) {
            if (this.m_Favorites[i] == newValue)
                return false;
            this.m_Favorites[i] = this.m_Favorites[i - 1];
        }
        this.m_Favorites[0] = newValue;

        this.writeItems();
        this.writeCookie();
        return true;
    }
}

function readCookieValue(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ')
            c = c.substring(1, c.length);

        if (c.indexOf(nameEQ) == 0)
            return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function createCookie(name, value, expiration) {
    var expires = "";
    if (expiration != null)
        expires = "; expires=" + expiration.toGMTString();
    document.cookie = name + "=" + value + expires + "; domain=mzweb.com.br";
}


$(document).ready(function() {

    $(".FAQ h3").toggle(function() {
        $(this).addClass("active");
    }, function() {
        $(this).removeClass("active");
    });

    $(".FAQ h3").click(function() {
        $(this).next(".FAQ_Container").slideToggle("slow");
    });

    $(".FAQ h4").toggle(function() {
        $(this).addClass("active");
    }, function() {
        $(this).removeClass("active");
    });

    $(".FAQ h4").click(function() {
        $(this).next(".FAQ_Container").slideToggle("slow");
    });

});

	
