// ===========================================
// Formata URL para querystring da busca
// ===========================================
function URLEncode(clearString) {
    var output = '';
    var x = 0;
    clearString = clearString.toString();
    var regex = /(^[a-zA-Z0-9_.]*)/;
    while (x < clearString.length) {
        var match = regex.exec(clearString.substr(x));
        if (match != null && match.length > 1 && match[1] != '') {
            output += match[1];
            x += match[1].length;
        } else {
            if (clearString[x] == ' ')
                output += '+';
            else {
                var charCode = clearString.charCodeAt(x);
                var hexVal = charCode.toString(16);
                output += '%' + (hexVal.length < 2 ? '0' : '') + hexVal.toUpperCase();
            }
            x++;
        }
    }
    return output;
}

// ===========================================
// Envia formul�rio de busca pela tecla ENTER
// ===========================================
function submitOnEnter(myfield, e) {
    var keycode;
    if (window.event)
        keycode = window.event.keyCode;
    else if (e)
        keycode = e.which;
    else
        return true;
    if (keycode == 13) {
        searchSite();
        return false;
    }
    else
        return true;
}

// ========================================
// Efetua busca no Google
// ========================================
function searchSite(){
    document.location = 'home.php?Fuseaction=busca&cx=008466561216812971964:wdxr2cpneem&cof=FORID%3A11&ie=UTF-8&q=' + URLEncode(document.getElementById('q').value);
}


// ========================================
// cursos
// ========================================
function abreDiv(qualDiv) {
	if (document.getElementById(qualDiv).style.display == "block") {
             document.getElementById(qualDiv).style.display = "none"}
        else
        {document.getElementById(qualDiv).style.display = "block"}

}


function fechaDiv(qualDiv) {
document.getElementById(qualDiv).style.display = "none"}

// ========================================
// noticias 
// ========================================
function trocarDiv(esconde,mostra) {
document.getElementById(esconde).style.display = "none";
document.getElementById(mostra).style.display = "block";
}

// ========================================
// quem ja fez 

function abreFrame(qualDiv) {
	if (document.getElementById(qualDiv).style.display == "block") {
document.getElementById(qualDiv).style.display = "none"}
else 
{document.getElementById(qualDiv).style.display = "block"}

}

function mudaAno(novoAno) {
window.location.href=novoAno;
}

// abrir janela
function abre(pagina,nome,caracter)  {window.open (pagina,nome,caracter)}

function abreVideo(qualVideo) {
document.getElementById('nomeVideo').value="caminhoVideo=videos/" + qualVideo + ".flv"
document.getElementById('nomeVideo2').flashVars="caminhoVideo=videos/" + qualVideo + ".flv"
}



