/* MENU
-------------------------------------------------------------------------*/
	var cssOn			= 'sub-on';	// cor qdo submenu aberto
	var cssOff			= '';	// cor qdo submenu aberto
	var timeout         = 500;
	var closetimer		= 0;
	var ddmenuitem      = 0;
	var prnt			= 0;
	
	// abre bloco submenu
	function mopen(id)
	{	
		// cancela fechamento
		mcancelclosetime();	
		// fecha submenu anterior
		if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
		if(prnt) prnt.className = cssOff; prnt = 0;
		prnt = document.getElementById("_"+id);
		// exibe novo submenu
		ddmenuitem = document.getElementById(id);
		ddmenuitem.style.visibility = 'visible';
		prnt.className = cssOn;
	
	}
	// oculta submenu
	function mclose()
	{
		if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
		if(prnt) prnt.className = cssOff; 
	}
	// fecha submenu
	function mclosetime()
	{
		closetimer = window.setTimeout(mclose, timeout);
	}
	// cancela fechamento submenu
	function mcancelclosetime()
	{
		if(closetimer)
		{
			window.clearTimeout(closetimer);
			closetimer = null;
		}
	}
	// ao clicar fora
	document.onclick = mclose; 



/* ajax
-------------------------------------------------------------------------*/
	function ajax(url, destino)
	{
		  var obj = document.getElementById(destino);
		
		switch (destino)
		{
		  default:
			obj.innerHTML = 'Processando...';
			break;
		}
	
		var http; // referência ao objeto XMLHttpRequest
	
		if(window.XMLHttpRequest && navigator.appVersion.indexOf('MSIE') < 0){
			http = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){
			http = new ActiveXObject("Msxml2.XMLHTTP");
			if(!http)
				http = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else{
			http = null;
			alert('Seu navegador nao possui o recurso necessário.');
		}	
	
		http.onreadystatechange = function(){
			if(http.readyState < 4)
			{
				//obj.className = (destino=='frame'?"loading":"loading2");
				obj.innerHTML = "Processando...";
			}
			else if(http.readyState == 4)
			{
				obj.innerHTML = http.responseText ;//'Cadastrado com sucesso!';
			}
		}
		
		http.open("GET",url,true);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
		http.send(null); // variaveis de post
	 }


/* POPUP GENERICA
-------------------------------------------------------------------------*/

function AbreJanela(url, width, height)
{
    if (width == '0')
        width = screen.availWidth;
    if (height == '0')
        height = screen.availHeight - 80;

    var left = (screen.availWidth - width)/2;
    var top  = (screen.availHeight - height - 80)/2;
    window.open(url,'frame','width='+width+',height='+height+',top='+top+',left='+left+',resizable=yes,scrollbars=yes,directories=no,location=no,menubar=no,status=yes,titlebar=no,toolbar=no');
 }
