function url_encode(str) { 
        var hex_chars = "0123456789ABCDEF"; 
        var noEncode = /^([a-zA-Z0-9\_\-\.])$/; 
        var n, strCode, hex1, hex2, strEncode = ""; 

        for(n = 0; n < str.length; n++) { 
            if (noEncode.test(str.charAt(n))) { 
                strEncode += str.charAt(n); 
            } else { 
                strCode = str.charCodeAt(n); 
                hex1 = hex_chars.charAt(Math.floor(strCode / 16)); 
                hex2 = hex_chars.charAt(strCode % 16); 
                strEncode += "%" + (hex1 + hex2); 
            } 
        } 
        return strEncode; 
    } 

    // url_decode version 1.0 
    function url_decode(str) { 
        var n, strCode, strDecode = ""; 

        for (n = 0; n < str.length; n++) { 
            if (str.charAt(n) == "%") { 
                strCode = str.charAt(n + 1) + str.charAt(n + 2); 
                strDecode += String.fromCharCode(parseInt(strCode, 16)); 
                n += 2; 
            } else { 
                strDecode += str.charAt(n); 
            } 
        } 

        return strDecode; 
    }  


function makeHttpRequest(url, callback_function, return_xml)
{
    var http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Unfortunatelly you browser doesn\'t support this feature.');
        return false;
    }
    http_request.onreadystatechange = function() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                if (return_xml) {
                    eval(callback_function + '(http_request.responseXML)');
                } else {
                    eval(callback_function + '(http_request.responseText)');
                }
            } else {
                alert('There was a problem with the request.(Code: ' + http_request.status + ')');
            }
        }
    }
    http_request.open('GET', url, true);
    http_request.send(null);
}

function LoadBlock(url,bloco) {
    if(bloco == 'blog') {
        makeHttpRequest(url, 'CarregaBlog');
    } else if (bloco == 'forum') {
        makeHttpRequest(url, 'CarregaForum');
    }

}

function CarregaBlog(text) {


document.getElementById('resblog').innerHTML = url_decode(text.replace(/\+/g, " "));

}

function CarregaForum(text) {


document.getElementById('resforum').innerHTML = url_decode(text.replace(/\+/g, " "));

}