// JavaScript Document
function Expande(obj)
{
	if (obj.style.visibility == "visible")
	{
	    obj.style.visibility = "hidden";
		obj.style.display = "none";
	}
	else
	{
    	obj.style.visibility = "visible";
		obj.style.display = "block";
	}
}

function Editar(vLink, vJanela, vAlt, vLarg)
{
    var objWindow=window.open(vLink, vJanela, 'width='+vLarg+',height='+vAlt+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
}

function WindowOpen(vLink, vJanela, vAlt, vLarg)
{
    var objWindow=window.open(vLink, vJanela, 'width='+vLarg+',height='+vAlt+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
}

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 goAjax(url, metodo, modo, tagRetorno, parametros)
{
	document.getElementById(tagRetorno).innerHTML='<br/><br/><center><div class="carregando"><img src="images/carregando.gif"><br/><br/>carregando...<br/><br/></div>';

    if(metodo == "GET")
        xmlhttp.open("GET", url, modo);
    else
    {
        xmlhttp.open("POST", url, modo);
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
        xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        xmlhttp.setRequestHeader("Pragma", "no-cache");
    }

    xmlhttp.onreadystatechange = function()
    {
        if(xmlhttp.readyState == 4)
        {
            retorno=xmlhttp.responseText;
            document.getElementById(tagRetorno).innerHTML = retorno;
            //findScript(retorno)
        }
    }

    if(metodo == "GET")
        xmlhttp.send(null);
    else
        xmlhttp.send(parametros);
}

function OffMenu(menu)
{
	document.getElementById("m" + menu).style.color = "#FFFFFF";
	document.getElementById("m" + menu).style.background ="background-image: url(images/menu_center_off.jpg)";
	document.getElementById("ml" + menu).style.background ="background-image: url(images/menu_left_off.jpg)";
	document.getElementById("mr" + menu).style.background ="background-image: url(images/menu_right_off.jpg)";
}
function OnMenu(menu)
{
	document.getElementById("m" + menu).style.color = "#000000";
	document.getElementById("m" + menu).style.background ="background-image: url(images/menu_center.jpg)";
	document.getElementById("ml" + menu).style.background ="background-image: url(images/menu_left.jpg)";
	document.getElementById("mr" + menu).style.background ="background-image: url(images/menu_right.jpg)";
}

function enviaPage(url, metodo, modo, tagId, parametros)
{
    if (parametros != "")
        goAjax( url+"?"+parametros+"&rnd"+ Math.random() , metodo, modo , "retMenu", "");
    else
        goAjax( url + "?rnd"+ Math.random() , metodo, modo , "retMenu", "");
    Menu(tagId);
}

function SendPage(url, metodo, modo, tagId, parametros)
{
    if (parametros != "")
        goAjax( url+"?"+parametros+"&rnd"+ Math.random() , metodo, modo , tagId, "");
    else
        goAjax( url + "?rnd"+ Math.random() , metodo, modo , tagId, "");
}

