window.defaultStatus="Faculdade Interativa COC";

function AbreDiv(obj){
	var div;
	div = obj;

	if (document.getElementById(div).style.display == "none"){
		document.getElementById(div).style.display = "block";
		}
	else{
		document.getElementById(div).style.display = "none";
    	}
}


function AbreJanela(arq,alt,lag,res,barra){
	if(barra=='')
		barra = 0;
	if(navigator.appName=="Microsoft Internet Explorer")
		window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+ barra +',resizable=' + res + ',width=' + lag + ',height=' + alt + ',top=100,left=100');
	else
		window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=0,status=0,screenX=100,screenY=100,scrollbars='+ barra +',resizable=1,width=' + lag + ',height=' + alt);
}

function mask(str,textbox,loc,delim,event){
var locs = loc.split(',');
var c = event.keycode;

for (var i = 0; i <= locs.length; i++){
	for (var k = 0; k <= str.length; k++){
	 if (k == locs[i]){
	  if (str.substring(k, k+1) != delim){
	   if (c != 8){ //backspace
	    str = str.substring(0,k) + delim + str.substring(k,str.length);
       }
	  }
	 }
	}
 }
textbox.value = str
}


function AbreDivCidadePolo(obj, ancora, controle, param, estado){
	var div;
	div = obj;
	
	if (document.getElementById(div).style.display == "none"){
		document.getElementById(div).style.display = "block";
		}
	else{
		document.getElementById(div).style.display = "none";
    	}
    	document.location = "http://www.estudeadistancia.com/polos.asp?NomeCidade="+ ancora +"&controle=" + controle + "&param=" + param + "&estado=" + estado;

}



function AbreDivCidadePoloPos(obj, ancora, controle, param, estado, codCurso){
	var div;
	div = obj;
	
	if (document.getElementById(div).style.display == "none"){
		document.getElementById(div).style.display = "block";
		}
	else{
		document.getElementById(div).style.display = "none";
    	}
    	document.location = "PosGraduacaoNossosPolos.asp?NomeCidade="+ ancora +"&controle=" + controle + "&param=" + param + "&estado=" + estado +"&codCurso="+ codCurso;

}



function AbreDivCidade(obj, id, ancora)
{
	
	for(i=1;i<=29;i++)
	{
		div = obj + i;
		
		if (document.getElementById(div).style.display == "block")
		{
			document.getElementById(div).style.display = "none";
			document.location = "#"+ ancora;
		}

	}

	document.getElementById(obj + id).style.display = "block";
	document.location = "#"+ ancora;
	
}


/*function redim(iframe){	
	var altura = document.getElementById('uic').offsetHeight;
	parent.document.getElementById(iframe).style.height = altura + "px";
	clearInterval(s)
}*/

function redim(iframe)
{
	if(navigator.appName=="Microsoft Internet Explorer")
		var altura = parseInt(document.body.scrollHeight);
	else
		var altura = parseInt(document.body.offsetHeight);

	parent.document.getElementById(iframe).style.height = altura + 'px';
}


function abreGaleria(arq,alt,lag){
	if(navigator.appName=="Microsoft Internet Explorer")
		window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=' + alt + ',height=' + lag + ',top=100,left=100');
    else
    	window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=0,status=0,screenX=100,screenY=100,resizable=0,scrollbars=1,width=' + alt + ',height=' + lag);
}

function AbreMidia(Midia, Tipo){
	if (Tipo == 1){
		window.open('http://www.jornal.coc.com.br/fotos/'+ Midia,'wind','toolbar=no,width=628,height=504,scrollbars=yes,resizable=no');
		return
	}
	if (Tipo == 2){
		//window.open('http://www.jornal.coc.com.br/EventosVideoXML.asp?Video=' + Midia,'video','width=325,height=300,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no')
		window.location.href = 'http://www.jornal.coc.com.br/Fotos/' + Midia;
		return
	}
}

function Conta(formulario){
	var form = document.forms[formulario];
	total = form.mensagem.value.length;
	form.mensagem.focus();
	if(total <= 3000){
		form.total.value = 'Máximo de 3000 caracteres. '+ total +' caracteres já digitados'
	}
	else{
		form.total.value = 'Máximo de 3000 caracteres. 3000 caracteres já digitados'
		form.mensagem.value = form.msg.value.substring(0,3000);
		alert('Excedido o número máximo de caracteres.');
		return;
	}
}


function ValidaFaleConosco(){
	var form = document.forms['faleConosco']
	
	if (form.nome.value == '' || form.nome.value.length < 5){
		alert('Preencha corretamente o campo nome.');
		form.nome.focus();
		return;
	}
	if (form.email.value == '' || form.email.value.indexOf(".") < 2 || form.email.value.indexOf("@") < 2){
		alert('Preencha corretamente o campo e-mail.');
		form.email.focus();
		return;
	}
	if (form.assunto.value == ''){
		alert('Preencha corretamente o campo assunto.');
		form.assunto.focus();
		return;
	}
	 if (form.mensagem.value == ''){
		alert('Preencha corretamente o campo mensagem.');
		form.mensagem.focus();
		return;
	}
	
	form.target = 'corpo';
	form.action = 'includes/faleConosco.asp';
	form.submit();

}


function ValidaCadastro(){
	var form = document.forms['cadastro']
	
	if (form.nome.value == '' || form.nome.value.length < 5){
		alert('Preencha corretamente o campo nome.');
		form.nome.focus();
		return;
	}
	if (form.email.value == '' || form.email.value.indexOf(".") < 2 || form.email.value.indexOf("@") < 2){
		alert('Preencha corretamente o campo e-mail.');
		form.email.focus();
		return;
	}
	if (form.telefone.value == ''){
		alert('Preencha corretamente o campo telefone.');
		form.telefone.focus();
		return;
	}
	if (form.cidade.value == ''){
		alert('Preencha corretamente o campo cidade.');
		form.cidade.focus();
		return;
	}
	if (form.assunto.value == ''){
		alert('Preencha corretamente o campo assunto.');
		form.assunto.focus();
		return;
	}
	if (form.curso.value == ''){
		alert('Preencha corretamente o campo curso(s) desejado(s).');
		form.curso.focus();
		return;
	}	
	 if (form.mensagem.value == ''){
		alert('Preencha corretamente o campo mensagem.');
		form.mensagem.focus();
		return;
	}
	
	form.target = 'corpo';
	form.action = 'includes/cadastro.asp';
	form.submit();

}


function ValidaPolo(){
	var form = document.forms['cadPolo']
	
	if (form.nome.value == '' || form.nome.value.length < 5){
		alert('Preencha corretamente o campo nome.');
		form.nome.focus();
		return;
	}
	if (form.email.value == '' || form.email.value.indexOf(".") < 2 || form.email.value.indexOf("@") < 2){
		alert('Preencha corretamente o campo e-mail.');
		form.email.focus();
		return;
	}
	if (form.ddd.value == ''){
		alert('Preencha corretamente o campo telefone.');
		form.ddd.focus();
		return;
	}
	if (form.telefone.value == ''){
		alert('Preencha corretamente o campo telefone.');
		form.telefone.focus();
		return;
	}		
	if (form.assunto.value == ''){
		alert('Preencha corretamente o campo assunto.');
		form.assunto.focus();
		return;
	}
	 if (form.mensagem.value == ''){
		alert('Preencha corretamente o campo mensagem.');
		form.mensagem.focus();
		return;
	}
	
	form.target = 'corpo';
	form.action = 'includes/cadPolo.asp';
	form.submit();

}



function ValidaPolo2(){
	var form = document.forms['cadPolo']
	
	if (form.nome.value == '' || form.nome.value.length < 5){
		alert('Preencha corretamente o campo nome.');
		form.nome.focus();
		return;
	}
	if (form.email.value == '' || form.email.value.indexOf(".") < 2 || form.email.value.indexOf("@") < 2){
		alert('Preencha corretamente o campo e-mail.');
		form.email.focus();
		return;
	}
	if (form.cidade.value == ''){
		alert('Preencha corretamente o campo cidade.');
		form.cidade.focus();
		return;
	}
	if (form.fone1.value == '' || form.fone1.value.length < 2){
		alert('Preencha corretamente o campo telefone.');
		form.fone1.focus();
		return;
	}
	if (form.fone2.value == '' || form.fone2.value.length < 8){
		alert('Preencha corretamente o campo telefone.');
		form.fone2.focus();
		return;
	}
	if (form.material2.checked == true) {
		if (form.txtSistema.value == '' || form.txtSistema.value.length < 3){
			alert('Preencha qual seria o material didático.');
			form.txtSistema.focus();
			return;
		}
	} 
	if (form.sabendo.value == 'yes') {
		if (form.qualSistema.value == '' || form.qualSistema.value.length < 3){
			alert('Preencha corretamente o qual ?');
			form.qualSistema.focus();
			return;
		}
	}
	if (form.info.value == '') {
		alert("Escolha sim ou não, para receber informações sobre como se tornar um pólo Unicoc para Ensino a Distância.")
		form.info.focus();
		return;
    }	
	
	
	form.target = 'corpo';
	form.action = 'includes/cadPolo.asp';
	form.submit();

}


function DesabilitaCampo(){
	var form = document.forms['cadPolo'];
	if (form.material2.checked == true) {
		form.txtSistema.disabled = false;
	}
	else {
		form.txtSistema.disabled = true;
		form.txtSistema.value = '';
	}
		
	if (form.sabendo.value == 'yes') {
		form.qualSistema.disabled = false;
	}
	else {
		form.qualSistema.disabled = true;
		form.qualSistema.value = '';
	}

}


function ValidaRecomenda(){
	var form = document.forms['recomede']
	
	if (form.nome.value == '' || form.nome.value.length < 5){
		alert('Preencha corretamente o campo Nome do amigo.');
		form.nome.focus();
		return;
	}
	if (form.email.value == '' || form.email.value.indexOf(".") < 2 || form.email.value.indexOf("@") < 2){
		alert('Preencha corretamente o campo E-mail do amigo.');
		form.email.focus();
		return;
	}
	if (form.seunome.value == ''){
		alert('Preencha corretamente o campo Seu nome.');
		form.seunome.focus();
		return;
	}
	 if (form.mensagem.value == ''){
		alert('Preencha corretamente o campo Mensagem.');
		form.mensagem.focus();
		return;
	}
	
	form.target = 'corpo';
	form.action = 'includes/Recomenda.asp';
	form.submit();

}

function ValidaEnqueteJornal(){
	
	var f    = document.forms['EnqueteSite']
	f.action = 'EnqueteFuncs.asp'
	f.submit();	

}

function EnqueteResultado(){
	window.location.href= 'enquete.asp?bt=1&IdSiteEnquete=9';
}

function addfav(){
	if(navigator.appName == "Microsoft Internet Explorer") {
		window.external.AddFavorite("http://www.faculdadescoc.com.br","Universidade Interativa COC");
	}
	else {
		alert("Seu browser não suporta essa função \n Para adicionar aos favoritos, pressiona a tecla Ctrl + D")
	}
}

function MudaData(obj)
{
	var f = document.forms[obj];
	
	if(obj=='periodo')
	{
		if(verificaData(f.DataInicial.value) == false)
		{
			f.DataInicial.focus();
			return;
		}
		if(verificaData(f.DataFinal.value) == false)
		{
			f.DataFinal.focus();		
			return;			
		}
		if(DateDiff(f.DataInicial.value, f.DataFinal.value) == false)
		{
			f.DataInicial.focus();
			return;
		}		
			
	}
	else
	{
		if(verificaData(f.data.value) == false)
		{
			f.data.focus();
			return;
		}
	}
	
	f.action="AgendaDetalhe.asp";
	f.submit();
	
}

function MudaDataCalendario()
{
	var f = document.forms['data'];
	
	if(verificaData(f.data.value) == false)
	{
		f.data.focus();
		return;
	}
	
	f.action="agenda.asp";
	f.submit();
	
}

function DateDiff(Data1, Data2){
	
	if(Data1=='')
		return false;
		
	if(Data2=='')
		return false;		
		
	var s  = Data1;
	var s1 = Data2;
	
	Data1 = s.split('/');
	Data2 = s1.split('/');
	
	dia1 = parseFloat(Data1[0]);
	mes1 = parseFloat(Data1[1]);
	ano1 = parseFloat(Data1[2]);
	
	dia2 = parseFloat(Data2[0]);
	mes2 = parseFloat(Data2[1]);
	ano2 = parseFloat(Data2[2]);
	
	if (ano2 < ano1){
		alert('Data final menor que data inicial!');
		return false;
	}
	else{
		if (ano1 == ano2){
			if (mes1 > mes2){
				alert('Data final menor que data inicial!');
				return false;
			}
			else{
				if (mes2 == mes1){
					if (dia2 < dia1){
						alert('Data final menor que data inicial!');
						return false;
					}
				}
			}
		}
	}
	
}

function verificaData(Data){
	
	var s = Data;
	var MesDia = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	Data     = s.split('/');

	if (Data.length > 3 || Data.length < 3){
		alert('Data Incorreta!');
		return false;
	}

	dia = Data[0];
	mes = Data[1];
	ano = Data[2];
	
	// Verifica se o mês é valido
	if (mes < 1 || mes > 12 || mes.length < 2){
		alert('Digite corretamente a data');
		return false;
	}
		
	// Verifica se o ano é valido
	if (ano < 2000 || ano > 2100){
		alert('Digite corretamente a data');
		return false;
	}

	QtDiaMes = MesDia[mes - 1];

	if (dia > QtDiaMes || dia.length < 2){
		alert('Digite corretamente a data');
		return false;
	}
	
}

function CarregarPagina(){

	var f    = document.forms['Dados']
	f.action = 'http://www.coc.com.br/default.asp'
	f.target = 'blank_'
	f.submit();
}

function MascaraData(str, textbox, loc, delim)
{
	var locs = loc.split(',');
	
	for (var i = 0; i <= locs.length; i++)
	{
		for (var k = 0; k <= str.length; k++)
		{
			if (k == locs[i])
			{
		  		if (str.substring(k, k+1) != delim)
		  		{
		   			if (event.keyCode != 8)
		   			{
		    			str = str.substring(0,k) + delim + str.substring(k,str.length);
	       			}
		  		}
		 	}
	 	}
	}
	textbox.value = str
}

function numero(event)
{

	var ValidChar = "#0;#9;#8;#48;#49;#50;#51;#52;#53;#54;#55;#56;#57;";
	
	if(navigator.appName.indexOf("Netscape")!= -1)
		tecla = event.which; 
	else
		tecla = event.keyCode;
		
	if (ValidChar.indexOf("#" + String(tecla + ";")) == -1)
		return false;
	else	
		return true;
	
}

function mudaFundo(div,obj){
	document.getElementById(div).className=obj;
}

function AOLMudaImgNew(pImg) {
	document.getElementById(pImg).src = '../images/faculdade/AOLMsgLida.gif';
}

function AOLContaReq(pNome,pContador) {
	
	document.getElementById(pContador).value = document.getElementById(pNome).value.length;	
	
	if(document.getElementById(pNome).value.length>300) {
		alert('O Número Máximo de 300 Caracteres foi Excedido!');
		document.getElementById(pNome).value = document.getElementById(pNome).value.substr(0,2999);
	}	
}

function AOLContaMsg(pNome,pContador) {
	
	document.getElementById(pContador).value = document.getElementById(pNome).value.length;	
	
	if(document.getElementById(pNome).value.length>3000) {
		alert('O Número Máximo de 3000 Caracteres foi Excedido!');
		document.getElementById(pNome).value = document.getElementById(pNome).value.substr(0,2999);
	}	
}

function ValidaDataRequerimento(pData) {
	
	var form = document.forms['frmAOLReq'];
	
	var Data1,Data2,Dif;
	
	//Faltas...132 = Requerimento de FALTAS...
	if(form.cboRequer.value == 132) {
		//if(form.Ano.value == "" || form.Mes.value == "" || form.Dia.value == "") {
		//	form.Dia.focus;
		//	return;
		//}
		
		Data1 = new Date(pData);
		Data2 = new Date(form.Ano.value+"/"+form.Mes.value+"/"+form.Dia.value);
	
		Dif = Data1 - Data2;
		
		Dif = Dif / 1000 / 60 / 60 / 24;
			
		if(Dif < 2)
			{
				StatusDiv('DivMsg',1);
		}
		else {
			
			StatusDiv('DivMsg',0);
		}
	}
}

function AOLdrawAlert(cb){
		opts = cb.options
		val = opts[opts.selectedIndex].value
		//comentado por Estevão Vilas Boas  11/03/2004
		if(val == 132){
			document.getElementById('DIVData').style.display = "block";
		}
		else{
			document.getElementById('DIVData').style.display = "none";
		}
}

function StatusDiv(obj,pStatus){	
	
	var div;
	
	div = obj;
	
	Status = pStatus;
	
	if(Status == 0) {
		document.getElementById(div).style.display = "none";
		document.getElementById('txtDetalhe').style.display = "block";
		document.getElementById('DVCont').style.display = "block";
		document.getElementById('btEnviar').style.display = "block";
		}
	else{
		document.getElementById(div).style.display = "block";
		document.getElementById('txtDetalhe').style.display = "none";
		document.getElementById('DVCont').style.display = "none";
		document.getElementById('btEnviar').style.display = "none";
    	}

}

function abre_scroll(arq,alt,lag,res){
	if(navigator.appName=="Microsoft Internet Explorer")
		window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=' + res + ',width=' + lag + ',height=' + alt + ',top=100,left=100');
	else 
		window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=0,status=0, scrollbars=1, screenX=100,screenY=100,resizable=' + res + ',width=' + lag + ',height=' + alt);
}