// JavaScript Document
function doAlertClose(){
	document.getElementById('popalert').style.display = 'none';	
	document.getElementById('popalertshadow').style.display = 'none';	
}
function doAuth(f){
	var us = document.getElementById('us');	
	var pw = document.getElementById('pw');	
	if (us.value == '' || pw.value == ''){
		alert('Informe corretamente os dados de login.');
		us.focus();
		return false
	} else {
		document.getElementById('authbtn').disabled = true;
		return true;	
	}
}
function doSendPw(f){
	var us = document.getElementById('us');	
	if (us.value == ''){
		alert('Informe corretamente o CRM.');
		us.focus();
		return false
	} else {
		document.getElementById('authbtn').disabled = true;
		return true;	
	}
}
function doMenu(mn){
	var sm = document.getElementById('sm'+mn);
	var mm = document.getElementById('mm'+mn);
	if (sm.className == 'menu-open'){
		sm.className = 'menu-close';
		mm.style.display = 'none';
	} else {
		sm.className = 'menu-open';
		mm.style.display = '';
	}
}
function number_format( number, decimals, dec_point, thousands_sep ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57     
 
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}
function DoPop(popWin,instName,w,h,scrll,resz,side){
	var t = 0;
	var l = 0;
	if (!side){
		if(window.screen.Width<=800){
			l = (window.screen.Width-w)/2;
		} else {
			l = (window.screen.Width-w)/2;
			t = (window.screen.Width-h)/4;
		}
	} else {
		if(window.screen.Width<=800){
			l = (window.screen.Width-w)-20;
		} else {
			l = (window.screen.Width-w)-20;
			t = 10;
		}
	}
	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/','selomedico',768,420,'yes','yes');
		} 
	}
}
document.onkeydown = callCNS;

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 doModulo(m){
	if (confirm("Você estará acessando o ambiênte de estudo para este módulo a partir deste momento.\nClique em 'OK' para prosseguir ou 'Cancelar' para permanecer nesta página.")){
		doAjax('container_body','modulos.ajax.php','mod='+m);
	}
}
function doBloqueio(tipo,tries){
	alert("Você ultrapassou o limite de "+tries+" tentativas para realização da prova.\nEntre em contato com a ABRAMET para realizar o desbloqueio.")	
}

function loadVideo(v,tr){
	doTabsheet("tab2");
	doArea(2);
	document.getElementById('playerframe').src = 'videoplayer.ajax.php?v='+v;
	doVideo(tr);
}
