try{
	xmlhttp = new XMLHttpRequest();
}
catch(ee){
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E){
     	 xmlhttp = false;
		}
	}
}
function enviar_enquete() {
    var form = document.votacao;
    var Radio = form.opcao;
    for (var i = 0; i < Radio.length; i++) {
        if (Radio[i].checked) {
            var selecionado = Radio[i].id;
        }
    }
    window.alert(selecionado);

    xmlhttp.open("GET", "votar.php?voto=" + selecionado, true);

    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            var mensagem = xmlhttp.responseText;
            //mensagem        = mensagem.replace(/\+/g," ");
            mensagem = unescape(mensagem);
            document.getElementById('respostas').innerHTML = mensagem;
        }
    }
    xmlhttp.send(null)
    window.alert("falhou!")
    return false;
}
function ChangeProgramming(DayOfWeek) {

    var newProgramming;

    document.getElementById("dvProgramming_1").style.visibility = 'hidden';
    document.getElementById("dvProgramming_1").style.display = 'none';

    document.getElementById("dvProgramming_2").style.visibility = 'hidden';
    document.getElementById("dvProgramming_2").style.display = 'none';

    document.getElementById("dvProgramming_3").style.visibility = 'hidden';
    document.getElementById("dvProgramming_3").style.display = 'none';

    document.getElementById("dvProgramming_4").style.visibility = 'hidden';
    document.getElementById("dvProgramming_4").style.display = 'none';

    document.getElementById("dvProgramming_5").style.visibility = 'hidden';
    document.getElementById("dvProgramming_5").style.display = 'none';

    document.getElementById("dvProgramming_6").style.visibility = 'hidden';
    document.getElementById("dvProgramming_6").style.display = 'none';

    document.getElementById("dvProgramming_7").style.visibility = 'hidden';
    document.getElementById("dvProgramming_7").style.display = 'none';

    newProgramming = "dvProgramming_" + DayOfWeek;

    document.getElementById(newProgramming).style.visibility = 'visible';
    document.getElementById(newProgramming).style.display = 'block';
}
function SetCurrentDayOfWeek() {

    var isOK = document.getElementById("hdnProgramming").value;

    if (isOK == "OK") {

        var date = new Date();

        switch (Number(date.getDay())) {

            case 0:
                ChangeProgramming(7);
                break;
            case 1:
                ChangeProgramming(1);
                break;
            case 2:
                ChangeProgramming(2);
                break;
            case 3:
                ChangeProgramming(3);
                break;
            case 4:
                ChangeProgramming(4);
                break;
            case 5:
                ChangeProgramming(5);
                break;
            case 6:
                ChangeProgramming(6);
                break;
        }
    }
}
function SetBanner(idBanner) {

    var newBanner;

    document.getElementById("banner_1").style.visibility = 'hidden';
    document.getElementById("banner_1").style.display = 'none';

    document.getElementById("banner_2").style.visibility = 'hidden';
    document.getElementById("banner_2").style.display = 'none';

    document.getElementById("banner_3").style.visibility = 'hidden';
    document.getElementById("banner_3").style.display = 'none';

    document.getElementById("banner_4").style.visibility = 'hidden';
    document.getElementById("banner_4").style.display = 'none';

    document.getElementById("banner_5").style.visibility = 'hidden';
    document.getElementById("banner_5").style.display = 'none';

    document.getElementById("banner_6").style.visibility = 'hidden';
    document.getElementById("banner_6").style.display = 'none';

    document.getElementById("banner_7").style.visibility = 'hidden';
    document.getElementById("banner_7").style.display = 'none';

    document.getElementById("banner_8").style.visibility = 'hidden';
    document.getElementById("banner_8").style.display = 'none';

    document.getElementById("banner_9").style.visibility = 'hidden';
    document.getElementById("banner_9").style.display = 'none';

    document.getElementById("banner_10").style.visibility = 'hidden';
    document.getElementById("banner_10").style.display = 'none';

    newBanner = "banner_" + idBanner;

    document.getElementById(newBanner).style.visibility = 'visible';
    document.getElementById(newBanner).style.display = 'block';
    
    document.getElementById("hdnBanner").value = idBanner;
}
function PreviousBanner() {

    var idBanner = Number((document.getElementById("hdnBanner").value)) - 1;

    var newBanner = "banner_" + idBanner;

    if (idBanner > 0) {

        document.getElementById("banner_1").style.visibility = 'hidden';
        document.getElementById("banner_1").style.display = 'none';

        document.getElementById("banner_2").style.visibility = 'hidden';
        document.getElementById("banner_2").style.display = 'none';

        document.getElementById("banner_3").style.visibility = 'hidden';
        document.getElementById("banner_3").style.display = 'none';

        document.getElementById("banner_4").style.visibility = 'hidden';
        document.getElementById("banner_4").style.display = 'none';

        document.getElementById("banner_5").style.visibility = 'hidden';
        document.getElementById("banner_5").style.display = 'none';

        document.getElementById("banner_6").style.visibility = 'hidden';
        document.getElementById("banner_6").style.display = 'none';

        document.getElementById("banner_7").style.visibility = 'hidden';
        document.getElementById("banner_7").style.display = 'none';

        document.getElementById("banner_8").style.visibility = 'hidden';
        document.getElementById("banner_8").style.display = 'none';

        document.getElementById("banner_9").style.visibility = 'hidden';
        document.getElementById("banner_9").style.display = 'none';

        document.getElementById("banner_10").style.visibility = 'hidden';
        document.getElementById("banner_10").style.display = 'none';

        document.getElementById(newBanner).style.visibility = 'visible';
        document.getElementById(newBanner).style.display = 'block';
        document.getElementById("hdnBanner").value = idBanner;
    }
    else
        alert(' Nao ha imagem anterior. \n Voce esta visualizando a primeira imagem.');
}
function NextBanner() {

    var idBanner = Number((document.getElementById("hdnBanner").value)) + 1;

    var newBanner = "banner_" + idBanner;

    if (idBanner < 10) {

        document.getElementById("banner_1").style.visibility = 'hidden';
        document.getElementById("banner_1").style.display = 'none';

        document.getElementById("banner_2").style.visibility = 'hidden';
        document.getElementById("banner_2").style.display = 'none';

        document.getElementById("banner_3").style.visibility = 'hidden';
        document.getElementById("banner_3").style.display = 'none';

        document.getElementById("banner_4").style.visibility = 'hidden';
        document.getElementById("banner_4").style.display = 'none';

        document.getElementById("banner_5").style.visibility = 'hidden';
        document.getElementById("banner_5").style.display = 'none';

        document.getElementById("banner_6").style.visibility = 'hidden';
        document.getElementById("banner_6").style.display = 'none';

        document.getElementById("banner_7").style.visibility = 'hidden';
        document.getElementById("banner_7").style.display = 'none';

        document.getElementById("banner_8").style.visibility = 'hidden';
        document.getElementById("banner_8").style.display = 'none';

        document.getElementById("banner_9").style.visibility = 'hidden';
        document.getElementById("banner_9").style.display = 'none';

        document.getElementById("banner_10").style.visibility = 'hidden';
        document.getElementById("banner_10").style.display = 'none';

        document.getElementById(newBanner).style.visibility = 'visible';
        document.getElementById(newBanner).style.display = 'block';
        document.getElementById("hdnBanner").value = idBanner;
    }
    else
        alert(' Nao ha imagem posterior. \n Voce esta visualizando a ultima imagem.');
}
function OpenPopRadio() {
    window.open("popRadioAME.htm", "RADIO_AME", "toolbar=no,status=no,menubar=no,scrollbars=false,resizeable=false,top=100,left=50,width=520,height=125");
}
function ChangeImage(imagepath, description) {

    document.getElementById("ctl00_ContentPlaceHolder1_imgMain").src = imagepath;
    document.getElementById("comentarioFoto").innerHTML = description;
}
function OpenPopAgenda(date) {

    window.open("PopUpAgenda.aspx?date="+date,"Popup","height=400, width=500;","toolbar=no","menubar=no");
}
function FormatValue(campo, tammax, teclapres) {
    var tecla = teclapres.keyCode;
    vr = campo.value;
    vr = vr.replace("/", "");
    vr = vr.replace("/", "");
    vr = vr.replace(",", "");
    vr = vr.replace(".", "");
    vr = vr.replace(".", "");
    vr = vr.replace(".", "");
    vr = vr.replace(".", "");
    tam = vr.length;

    if (tam < tammax && tecla != 8) { tam = vr.length + 1; }

    if (tecla == 8) { tam = tam - 1; }

    if (tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105) {
        if (tam <= 2) {
            campo.value = vr;
        }
        if ((tam > 2) && (tam <= 5)) {
            campo.value = vr.substr(0, tam - 2) + ',' + vr.substr(tam - 2, tam);
        }
        if ((tam >= 6) && (tam <= 8)) {
            campo.value = vr.substr(0, tam - 5) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
        }
        if ((tam >= 9) && (tam <= 11)) {
            campo.value = vr.substr(0, tam - 8) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
        }
        if ((tam >= 12) && (tam <= 14)) {
            campo.value = vr.substr(0, tam - 11) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
        }
        if ((tam >= 15) && (tam <= 17)) {
            campo.value = vr.substr(0, tam - 14) + '.' + vr.substr(tam - 14, 3) + '.' + vr.substr(tam - 11, 3) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
        }
    }
}
function FormatDate(Campo) {
    var tecla = event.keyCode;
    var tam = Campo.value.length + 1;

    if (tecla != 9 && tecla != 8 && tecla != 45 && tecla != 46 && (tecla < 35 || tecla > 40)) {
        if ((tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105))
            event.returnValue = false;
        else {
            if (tam > 10)
                event.returnValue = false;
            if (tam == 3 || tam == 6)
                Campo.value += '/'
        }
    }
}
function FromatInt(KeyCode) {
    if (KeyCode >= 48 && KeyCode <= 57)
        return true;
    else event.keyCode = false;
}
function GetSelectedItemCombo(combo, text) {
    if (text)
        return combo.options[combo.selectedIndex].text;
    return combo.options[combo.selectedIndex].value;
}
function SelectItemCombo(combo, valor) {
    if (valor == -1) {
        combo.options[0].selected = true;
        return true;
    }
    for (i = 0; i <= combo.options.length - 1; i++) {
        if (combo.options[i].value == valor) {
            combo.options[i].selected = true;
            return true;
        }
    }
    return false;
}
function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g, "");
}
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.Right = function(t) {
    var rt = this;
    if (rt.length < t)
        return rt;
    return rt.substr(rt.length - t, t);
}
String.prototype.LTrim = function(c) {
    if (!c)
        c = ' ';
    var rt = this;
    while (rt.substring(0, 1) == c) {
        rt = rt.substring(1, rt.length);
    }
    return rt;
}

function apresentacao(url) {
    var strHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=\"705\" height=\"564\">";
    strHTML += "<param name=\"movie\" value=\"" + url + "\" />";
    strHTML += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
    strHTML += "<param name=\"quality\" value=\"high\" />";
    strHTML += "<param name=\"allowFullScreen\" value=\"true\" />";
    strHTML += "<param name=\"bgcolor\" value=\"#000000\" />";
    strHTML += "<embed src=\"" + url + "\" quality=\"high\" allowScriptAccess=\"sameDomain\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"720\" height=\"564\"></embed>";
    strHTML += "</object>";
    popupCreate(strHTML, 705, 564);
}

function popupCreate(content, width, height) {

    if (width == 950) { width2 = "width:" + width + "px;"; } else { width2 = ""; }
    if (height == 500) { height2 = "height:" + height + "px;"; } else { height2 = ""; }

    var obj = document.getElementById('boxPOPUP');
    if (!obj) {

        target = document.getElementById("BASE");
        var newElement = document.createElement('div');
        newElement.setAttribute('id', 'boxPOPUP');
        newElement.setAttribute('name', 'boxPOPUP');
        document.body.appendChild(newElement);
        obj = newElement;
    }

    obj.innerHTML = "";
    obj.style.display = "block";

    var posTop = -((height + 18) / 2 - document.documentElement.scrollTop);
    var strHTML = "<div onclick=\"popupRemove('boxPOPUP')\" id=\"lightMASK\" style=\"position:absolute;top:0;left:0;width:100%;height:" + /*$(document).height()*/ getTotalHeigth() + "px;z-index:1500;background-color:#000000;opacity:0.8;filter:alpha(opacity=80);\" ></div>";
    strHTML += "<div id=\"popupPDF\"  style=\" " + width2 + height2 + "position:absolute; z-index:2000; top:50%; left:50%; margin:" + posTop + "px 0px 0px -" + width / 2 + "px; background:none; \">";
    strHTML += "<div class=\"popupTitle\" style=\"text-align:right\"><a href=\"javascript:popupRemove('boxPOPUP');\" title=\"Fechar\"><img src=\"../Content/images/fechar.png\" alt=\"Fechar\" /></a></div>";
    strHTML += "<div style=\" border:1px solid #FFFFFF;\">";
    strHTML += content;
    strHTML += "</div>";
    strHTML += "</div>";
    strHTML += "";

    obj.innerHTML = strHTML;
}
function popupRemove(obj) {
    obj = document.getElementById(obj);
    if (obj) {
        obj.style.display = "none";
        obj.innerHTML = "";
    }
}

function getTotalHeigth()
{
	var /*theWidth,*/ theHeight;/*
	if (window.innerWidth)
		theWidth=window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		theWidth=document.documentElement.clientWidth;
	else if (document.body)
		theWidth=document.body.clientWidth;*/

	if (window.innerHeight)
		theHeight=window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
		theHeight=document.documentElement.clientHeight;
	else if (document.body)
		theHeight=document.body.clientHeight;
	return document.body.parentNode.scrollHeight;

}
