/*-------------------------------------------------------------------------------------------
 *   iM JavaScript Functions
 *  (c) 2006 Interactive Multimedia Brazil
 *
 *  iM JavaScript Functions is freely distributable under the terms of an GNU-GPL license.
 *  For details, see the iM web site at http://www.interactivemultimedia.com.br/
 *
/*------------------------------------------------------------------------------------------*/

var callbacksGlobais = {
	onCreate: function(){
		Element.show('carregando');
	},
	onComplete: function() {
		if(Ajax.activeRequestCount == 0){
			Element.hide('carregando');
		}
	}
};
Ajax.Responders.register(callbacksGlobais);

function verificaIntegridade(formulario,acao){
	var url="ajax.php";
	var pars="verifica="+acao+"&"+Form.serialize(formulario);
	var myAjax = new Ajax.Request(url,{method: 'get',parameters: pars,onComplete: retornaResposta});
	function retornaResposta(resposta){
		var resposta = resposta.responseText.split("|");
		if(resposta[0]==''){
			formulario.submit();
			return false;
		}else{
	 		document.getElementById("alerta").innerHTML = resposta[0];
			document.getElementById(resposta[1]).select();
			window.scrollTo(0,280);
		}
	}
	return false;
}

function verificaIntrAcao(formulario,acao){
	formulario.action.value=acao;
	var url="ajax.php";
	var pars="modulo="+acao+"&"+Form.serialize(formulario);
	var myAjax = new Ajax.Request(url,{method: 'post',parameters: pars,onComplete: retornaResposta});
	function retornaResposta(resposta){
		var resposta = resposta.responseText.split("|");
		if(resposta[0]==''){
;			cm('central','intranet','pt-BR');
			return false;
		}else{
	 		document.getElementById("alerta").innerHTML = resposta[0];
			document.getElementById(resposta[1]).select();
			window.scrollTo(0,280);
		}
	}
	return false;
}

function lm(div,modulo,linguagem){
	cmn('menu',modulo,linguagem);
	cm(div,modulo,linguagem);
	return false;
}

function cm(div,modulo,linguagem){
 	var url = 'ajax.php';
 	var pars = 'modulo=loadModule&im='+modulo+'&ln='+linguagem;
 	var myAjax = new Ajax.Updater(div, url, { asynchronous:true, evalScripts:true, method: 'get', parameters: pars });
	return false;
}

function cmm(div,modulo,nv,c,linguagem){
 	var url = 'ajax.php';
 	var pars = 'modulo=loadModule&im='+modulo+'&'+nv+'='+c+'&ln='+linguagem;
 	var myAjax = new Ajax.Updater(div, url, { asynchronous:true, evalScripts:true, method: 'get', parameters: pars });
	return false;
}

function cmmd(div,modulo,nv,c,nvd,cvd,linguagem){
 	var url = 'ajax.php';
 	var pars = 'modulo=loadModule&im='+modulo+'&'+nv+'='+c+'&'+nvd+'='+cvd+'&ln='+linguagem;
 	var myAjax = new Ajax.Updater(div, url, { asynchronous:true, evalScripts:true, method: 'get', parameters: pars });
	return false;
}

function cmd(div,modulo,nv,c,nvd,cvd,nvt,cvt,linguagem){
 	var url = 'ajax.php';
 	var pars = 'modulo=loadModule&im='+modulo+'&'+nv+'='+c+'&'+nvd+'='+cvd+'&'+nvt+'='+cvt+'&ln='+linguagem;
 	var myAjax = new Ajax.Updater(div, url, { asynchronous:true, evalScripts:true, method: 'get', parameters: pars });
	return false;
}
function confirmaUsPw(){
	if(document.getElementById('email').value==''){
		alert('Por Favor Informe o Email do Usuário');
		document.getElementById('email').focus();
		return false;
	}
	if(document.getElementById('login').value==''){
		alert('Por Favor Informe o Login do Usuário');
		document.getElementById('login').focus();
		return false;
	}
	if(document.getElementById('admPw').value!=''){
		if(document.getElementById('admPw').value!=document.getElementById('admPwCf').value){
			alert('Senhas não Conferem, por Favor, informe novamente Senha e Confirmação');
			document.getElementById('admPw').value='';
			document.getElementById('admPwCf').value='';
			document.getElementById('admPw').focus();
			return false;
		}
	}else{
		alert('Por favor informe uma senha para o usuário');
		document.getElementById('admPw').focus();
		return false;
	}
	return true;
}

function confirmaAtUsPw(){
	if(document.getElementById('email').value==''){
		alert('Por Favor Informe o Email do Usuário');
		document.getElementById('email').focus();
		return false;
	}
	if(document.getElementById('login').value==''){
		alert('Por Favor Informe o Login do Usuário');
		document.getElementById('login').focus();
		return false;
	}
	if(document.getElementById('admPw').value!=''){
		if(document.getElementById('admPw').value!=document.getElementById('admPwCf').value){
			alert('Senhas não Conferem, por Favor, informe novamente Senha e Confirmação');
			document.getElementById('admPw').value='';
			document.getElementById('admPwCf').value='';
			document.getElementById('admPw').focus();
			return false;
		}
	}
	return true;
}

function iMPop(pagina,altura,largura){
	window.open(pagina,'iMpop','width='+altura+',height='+largura+',resizable=no');
}

function acao(formulario,action){
        formulario.action.value=action;
}

function acaoConfirma(formulario,action,mensagem){
	if(confirm(mensagem)){
        	formulario.action.value=action;
		return true;
	}else return false;
}

function enviaFormulario(form,tecla,ordem){
	if(tecla==13){
		acao(form,ordem);
		form.submit();
		return false;
	}else{
		return true;
	}
}

function SlideShow(slideList, image, speed, name){
         this.slideList = slideList;
         this.image = image;
         this.speed = speed;
         this.name = name;
         this.current = 0;
         this.timer = 0;
 }

function SlideShow_play(){
         with(this){
                 if(current++ == slideList.length-1) current = 0;
                 switchImage(image, slideList[current]);
                 clearTimeout(timer);
                 timer = setTimeout(name+'.play()', speed);
         }
 }

 function SlideShow_stop(){
         with(this){
                 clearTimeout(timer);
         }
 }

 function switchImage(imgName, imgSrc){
         if (document.images){
                 if (imgSrc != "none"){
                         document.images[imgName].src = imgSrc;
                 }
         }
 }


