// JavaScript Document

function doAjax(xtarget,xfile,xparam){ // ACIONA O AJAX

	var ajax = new JAjax();
	
	ajax.CallBack(null);	

	ajax.Request();
	ajax.SetFile(xfile);
	ajax.SetMetodo('POST');
	ajax.SetTarget(xtarget,false);
	ajax.SetStrLoading("Aguarde... Conectando ao Servidor,Aguarde... Enviando Dados,Aguarde... Recebendo Resposta,Operação Efetuada.");
	ajax.SetMouseEFX(false);
	ajax.SetParam(xparam);
	ajax.Open();
		
	
}

function doValidaAuth(){
	var us = document.getElementById('us');
	var pw = document.getElementById('pw');
	if(us.value == '' || pw.value == ''){
		alert('Insira corretamente os dados de autenticação');	
	} else {
		document.getElementById('status_auth').innerHTML = '<b style="color:gray">Aguarde. Validando daodos...</b>';
		doAjax('extranet_div','extranet.auth.php','us='+us.value+'&pw='+pw.value+'&action=auth');
	}
}

function DoPop(popWin,instName,w,h,scrll,resz){
	//var site_w = 750;
	//var site_h = 500;
	var t = 0;
	var l = 0;
		if(window.screen.Width<=800){
			l = (window.screen.Width-w)/2;
		} else {
			l = (window.screen.Width-w)/2;
			t = (window.screen.Width-h)/4;
		}
	win = window.open(popWin,instName,'top='+t+',left='+l+',height='+h+',width='+w+',resizable='+resz+',scrollbars='+scrll+',toolbar=no,location=no,directories=no,status=yes,menubar=no,fullscreen=no');
}
function callCNS(){
if(event.ctrlKey)
	if (event.keyCode == 89){
		DoPop('apps/scp/','publix',768,420,'yes','yes');
	} 
}
document.onkeydown = callCNS;
var link_clicked = null;
function testaExpand(it){
	var mylink = document.getElementById('link'+it);
	var myitem = document.getElementById('item'+it);
	if (myitem.style.display == 'none'){
		myitem.style.display = '';
		mylink.className = 'level_open';
	} else {
		myitem.style.display = 'none';
		mylink.className = 'level_close';
	}
}
function expandItens(it){
	if (link_clicked == null){
		testaExpand(it);
		link_clicked = it;
	} else {
		if (it != link_clicked){
			//testaExpand(link_clicked);
		}
		testaExpand(it);
		link_clicked = it;
	}
	return false;
}

