function change_box_display(ids, id, n) {
	for (var i = 1; i <= n; i++) {
		if (i != id) {
			document.getElementById(ids + i).style.display = 'none';
		} else {
			document.getElementById(ids + i).style.display = 'block';
		}
	}
}

//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/geral/utf-8 [v1.0]

UTF8 = {
        encode: function(s){
                for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
                        s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
                );
                return s.join("");
        },
        decode: function(s){
                for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
                        ((a = s[i][c](0)) & 0x80) &&
                        (s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
                        o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
                );
                return s.join("");
        }
};

function startSlide(id, parent) {
        allItems = document.getElementById('mainNav').childNodes;
        var menuItems = new Array();
        for (i=0; i<allItems.length; i++) {
                if (allItems[i].nodeName=='LI') {
                        menuItems.push(allItems[i]);
                }
        }
        activeItem = 0;
        for (i=1; i<=menuItems.length; i++) {
                menuItem = document.getElementById('sub' + i);
                if ((menuItem!=null)&&(menuItem.style.display=='block')) {
                        activeItem = i;
                        break;
                }
        }
        if (activeItem!=0) {
                document.getElementById('sub' + activeItem).style.display='none';
                document.getElementById(id).style.display='block';
        }
        else {
                doSlide(id);
        }

        for (i=0; i<menuItems.length; i++) {
                menuItems[i].firstChild.className='off';
                document.getElementById('mainmenu'+i).setAttribute('class', 'off');
        }
        parent.className='on';
}

function doSlide(id){
        timeToSlide = 7; // in milliseconds
        obj = document.getElementById(id);
        if(obj.style.display == "none"){
                obj.style.visibility = "hidden";
                obj.style.display = "block";
                height = obj.offsetHeight;
                obj.style.height="0px";
                obj.style.visibility = "visible";
                pxPerLoop = height/timeToSlide;
                slide(obj,0,height,pxPerLoop);
        } else {
                obj.style.display = "none";
        }
}

function slide(obj,offset,full,px){
        obj.style.height = "auto";
/*
        if(offset < full){
                obj.style.height = offset+"px";
                offset=offset+px;
                setTimeout((function(){slide(obj,offset,full,px);}),1);
        } else {
                obj.style.height = "auto"; //Can be usefull in updated divs otherwise just use full+"px"
        }
*/
}


