var IMG_DIR = "/img";

var CGS_DIR = "/php";
var CORP_DIR = "/corporativo";


function goMCEmitirCertificado(id){
	
	var w = 800;
	var h = 600;
	var l;
	var t;
	var no=0;
	
	l = (screen.width) ? (screen.width-w)/2 : 0;
	t = (screen.height) ? (screen.height-h)/2 : 0;

	window.open(CGS_DIR+"/mc_certificados.php?id="+id, 'emitir_certificado', 'top='+t+', left='+l+', width='+w+', height='+h+', status=no, tollbar=no, menubar=no, resizable=no');

}
function goBanners(){
	
	window.open(document.getElementById('ban_id').value);

}
function goMCCadastro() {
		
	ajaxpage(CGS_DIR+"/mc_cadastro.php", "mostrar_opcoes");
	
}
function goMCMensagens() {
		
	ajaxpage(CGS_DIR+"/mc_mensagens.php", "mostrar_opcoes");
	
}
function goMCMensagensCorp() {

	ajaxpage(CGS_DIR+"/mc_mensagens.php", "mostrar_opcoes");

}
function goMCNovaMensagem() {
		
	ajaxpage(CGS_DIR+"/mc_novamensagem.php", "mostrar_opcoes");
	
}
function goMCLerMensagem(id) {
	
	ajaxpage(CGS_DIR+"/mc_lermensagem.php?msgId="+id, "mostrar_opcoes");
	
}
function goMCReply() {
	
	ajaxpage(CGS_DIR+"/mc_novamensagem.php?action=reply&msgId="+document.getElementById("msgId").value, "mostrar_opcoes");
	
}
function goMCForward() {

	ajaxpage(CGS_DIR+"/mc_novamensagem.php?action=forward&msgId="+document.getElementById("msgId").value, "mostrar_opcoes");
	
}
function goMCExcluirMensagens() {

	var strMsgId = "";
	var form = document.getElementById("ajaxpost");
	form.action = CGS_DIR+"/mc_mensagens_excluir.php";

	with ( form ) {
		for( i=0; i < elements.length; i++ ) {
			if ( elements[i].type == "checkbox" ) {
				if( elements[i].checked == true ) {
					strMsgId += elements[i].value+",";
				}
			}
		}
	
		strMsgId = strMsgId.substr(0, strMsgId.length - 1);

		msgId.value = strMsgId;
		
		lightconfirm(form.id,'mostrar_opcoes',"Confirmação","Confirma a exclusão das mensagens selecionadas?");
	}
}
function goMCExcluirMensagem() {
	
	var form = document.getElementById("ajaxpost");
	form.action = CGS_DIR+"/mc_mensagens_excluir.php";

	lightconfirm(form.id,'mostrar_opcoes',"Confirmação","Confirma a exclusão desta mensagem?");

}
function goEnviarMCCadastro() {

	var form = document.getElementById("ajaxpost");
	form.action = CGS_DIR+"/mc_cadastro_gravar.php";

	if ( trim(document.getElementById("cad_nome").value) == "" ) {
		lightbox("Mensagem","Preencha o seu Nome!","cad_nome");
		return false;
	}
	if ( trim(document.getElementById("cad_email").value) == "" ) {
		lightbox("Mensagem","Preencha o seu E-Mail!","cad_email");
		return false;
	} else {
		if ( check_email(document.getElementById("cad_email")) == false ) {
			return false;
		}		
	}
	if( document.getElementById("emailok").value == 0 ) {
		lightbox("Mensagem","Informe um E-Mail válido!","cad_email");
		return false;		
	}
	if ( document.getElementById("cad_cpf").value == "" ) {
		lightbox("Mensagem","Preencha o seu CPF!","cad_cpf");
		return false;
	} else {
		if ( check_cpf(document.getElementById("cad_cpf")) == false ) {
			return false;
		}
	}	
	if ( trim(document.getElementById("cad_dia").value) == "" ) {
		lightbox("Mensagem","Selecione o Dia do seu Aniversário!","cad_dia");
		return false;
	}
	if ( trim(document.getElementById("cad_mes").value) == "" ) {
		lightbox("Mensagem","Selecione o Mês do seu Aniversário!","cad_mes");
		return false;
	}
	
	if ( trim(document.getElementById("cad_dddtel").value) == "" ) {
		lightbox("Mensagem","Preencha o campo DDD do Telefone!","cad_dddtel");
		return false;
	} else {
		if ( isNaN(trim(document.getElementById("cad_dddtel").value))) {
			lightbox("Mensagem","O campo DDD do Telefone deve conter apenas números!","cad_dddtel");
			return false;
		}
	}
	if ( trim(document.getElementById("cad_telefone").value) == "" ) {
		lightbox("Mensagem","Preencha o campo Telefone!","cad_telefone");
		return false;
	} else {
		if ( isNaN(trim(document.getElementById("cad_telefone").value))) {
			lightbox("Mensagem","O campo Telefone deve conter apenas números!","cad_telefone");
			return false;
		}
	}
	
	if ( trim(document.getElementById("cad_area").value) == "" ) {
		lightbox("Mensagem","Selecione a Área de Atividade!","cad_area");
		return false;
	}
	if ( trim(document.getElementById("cad_atividade").value) == "" ) {
		lightbox("Mensagem","Selecione a Atividade!","cad_atividade");
		return false;
	}
	
	if ( trim(document.getElementById("cad_senhaatual").value) != "" ) {

		if ( trim(document.getElementById("cad_senha").value) == "" ) {
			lightbox("Mensagem","Preencha o campo Nova Senha!","cad_senha");
			return false;
		}
		if ( trim(document.getElementById("cad_csenha").value) == "" ) {
			lightbox("Mensagem","Confirme a sua Nova Senha!","cad_csenha");
			return false;
		}
		if ( trim(document.getElementById("cad_senha").value) != trim(document.getElementById("cad_csenha").value) ) {
			lightbox("Mensagem","As Novas Senhas informadas não conferem!","cad_senha");
			return false;
		}	
	}
	
	if ( trim(document.getElementById("cad_cep").value) == "" ) {
		lightbox("Mensagem","Preencha o campo Cep!","cad_cep");
		return false;
	} else {
		if ( isNaN(trim(document.getElementById("cad_cep").value))) {
			lightbox("Mensagem","O campo Cep deve conter apenas números!","cad_cep");
			return false;
		}
	}
	if ( trim(document.getElementById("cad_endereco").value) == "" ) {
		lightbox("Mensagem","Preencha o campo Endereço!","cad_endereco");
		return false;
	}
	
	if ( trim(document.getElementById("cad_numero").value) == "" ) {
		lightbox("Mensagem","Preencha o campo Número!","cad_numero");
		return false;
	} else {
		if ( isNaN(trim(document.getElementById("cad_numero").value))) {
			lightbox("Mensagem","O campo Número deve conter apenas números!","cad_numero");
			return false;
		}
	}
	
	if ( trim(document.getElementById("cad_bairro").value) == "" ) {
		lightbox("Mensagem","Preencha o campo Bairro!","cad_bairro");
		return false;
	}
	if ( trim(document.getElementById("cad_cidade").value) == "" ) {
		lightbox("Mensagem","Preencha o campo Cidade!","cad_cidade");
		return false;
	}
	if ( trim(document.getElementById("cad_uf").value) == "" ) {
		lightbox("Mensagem","Selecione o campo Uf!","cad_uf");
		return false;
	}
	if ( trim(document.getElementById("cad_como").value) == "" ) {
		lightbox("Mensagem","Indique como tomou conhecimento do Portal CGS!","cad_como");
		return false;
	}
	
	lightconfirm(form.id,'mostrar_opcoes',"Confirmação",document.getElementById("cad_nome").value+", você deseja gravar as alterações efetuadas no seu cadastro?<br><br>Clique no botão OK para confirmar o processo.");

	return false;

}

function goEnviarMCMensagem() {

	var form = document.getElementById("ajaxpost");
	form.action = CGS_DIR+"/mc_mensagem_enviar.php";

	if ( trim(document.getElementById("mc_usuarios").value) == "" ) {
		lightbox("Mensagem","Selecione o usuário destinatário!","mc_usuarios");
		return ;
	}
	if ( trim(document.getElementById("mc_assunto").value) == "" ) {
		lightbox("Mensagem","Informe o assunto da mensagem!","mc_assunto");
		return ;
	}
	if ( trim(document.getElementById("mc_mensagem").value) == "" ) {
		lightbox("Mensagem","Informe o conteúdo da mensagem!","mc_mensagem");
		return ;
	}
	
	lightconfirm(form.id,'mostrar_opcoes',"Confirmação"," Confirma o envio da mensagem?");

}


function goVerificaMCEmail() {
	
	var form = document.getElementById("mc_cadastro");

	if ( trim(document.getElementById("cad_email").value) == "" ) {
		lightbox("Mensagem","Preencha o seu E-Mail!","cad_email");
		return false;
	} else {
		if ( check_email(document.getElementById("cad_email")) == false ) {
			return false;
		}		
	}
	
	ajaxpage(CGS_DIR+'/mc_cadastro_verificar.php?cad_email='+document.getElementById("cad_email").value, 'verEmail','GET');
	
}
function goMCPrint() {

	var w = 800;
	var h = 600;
	var l;
	var t;
	var no=0;
	
	l = (screen.width) ? (screen.width-w)/2 : 0;
	t = (screen.height) ? (screen.height-h)/2 : 0;

	window.open(CGS_DIR+'/mc_imprimirmensagem.php?msgId='+document.getElementById("msgId").value, 'msgprint', 'top='+t+', left='+l+', width='+w+', height='+h+', status=no, tollbar=no, menubar=no, resizable=no');

}

function goMCImprimirBoleto(pedido) {
	
	document.getElementById("boleto_"+pedido).submit();
	
}

function goMCAjuda() {

	ajaxpage(CGS_DIR+"/mc_ajuda.php", "mostrar_opcoes");

}
function goMCExtratoFidelidade() {

	ajaxpage(CGS_DIR+"/mc_extrato.php", "mostrar_opcoes");

}
function goMCCursosAbertos() {

	ajaxpage(CGS_DIR+"/mc_cursos_abertos.php", "mostrar_opcoes");

}
function goMCEncaminhaTutor() {

	window.open("http://www.portalcgs.com.br/corporativo/?tutores");

}
function goMCCursosAbertosCorp() {

	ajaxpage(CORP_DIR+"/mc_cursos_abertosCorp.php", "mostrar_opcoes");

}
function goMCCertificados() {

	ajaxpage(CGS_DIR+"/mc_certificados.php", "mostrar_opcoes");

}
function goMCCertificadosCorp() {

	ajaxpage(CORP_DIR+"/mc_certificadosCorp.php", "mostrar_opcoes");

}

function goMCExpandirCurso(curso){
	
	if( document.getElementById("cur_"+curso) ){
		document.getElementById("fset_"+curso).style.height = "190px";
		document.getElementById("cur_"+curso).style.display = "block";
		document.getElementById("img_"+curso).innerHTML = "<a href='javascript:goMCReduzirCurso("+curso+")'><img src='"+IMG_DIR+"/botao_menos.gif' border='0' /></a>";
	}
	
}
function goMCReduzirCurso(curso){
	
	if( document.getElementById("cur_"+curso) ){
		document.getElementById("fset_"+curso).style.height = "20px";
		document.getElementById("cur_"+curso).style.display = "none";
		document.getElementById("img_"+curso).innerHTML = "<a href='javascript:goMCExpandirCurso("+curso+")'><img src='"+IMG_DIR+"/botao_mais.gif' border='0' /></a>";
	}
	
}

function goMCExpandirCertificado(curso){
	
	if( document.getElementById("cur_"+curso) ){

		document.getElementById("cer_"+curso).style.display = "block";
		document.getElementById("cimg_"+curso).innerHTML = "<a href='javascript:goMCReduzirCertificado("+curso+")'><img src='"+IMG_DIR+"/botao_menos.gif' border='0' /></a>";
	}
	
}
function goMCReduzirCertificado(curso){
	
	if( document.getElementById("cur_"+curso) ){

		document.getElementById("cer_"+curso).style.display = "none";
		document.getElementById("cimg_"+curso).innerHTML = "<a href='javascript:goMCExpandirCertificado("+curso+")'><img src='"+IMG_DIR+"/botao_mais.gif' border='0' /></a>";
	}
	
}

function goMCExpandirDesempenho(curso){
	
	if( document.getElementById("gra_des_"+curso) ){
		document.getElementById("gra_des_"+curso).style.display = "block";
		document.getElementById("gra_con_"+curso).style.display = "none";
	}
	
}
function goMCExpandirConcluido(curso){
	
	if( document.getElementById("gra_con_"+curso) ){
		document.getElementById("gra_con_"+curso).style.display = "block";
		document.getElementById("gra_des_"+curso).style.display = "none";
	}
	
}

function goMCIniciarCurso(curso) {

	var w = 800;
	var h = 600;
	var l;
	var t;

	
	l = (screen.width) ? (screen.width-w)/2 : 0;
	t = (screen.height) ? (screen.height-h)/2 : 0;

	window.open(CGS_DIR+'/ac_cursos_iniciar.php?curso='+curso, 'curso_'+curso, 'top='+t+', left='+l+', width='+w+', height='+h+', status=no, tollbar=no, menubar=no, resizable=no, scrollbars=no');

}

function goMCDadosPedido(id) {

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	var left = ((arrayPageSize[0] - 20 - 600) / 2);


	goPed=dhtmlwindow.open("goMCPedidos", "ajax", CGS_DIR+"/mc_pedidos_listar.php?pId="+id, "Dados do Pedido", "width=600,height=300,resize=1,scrolling=1,left="+left);


}