﻿function getServerDateTime()
{
frameHour = document.getElementById("iframeCurrentDate").contentWindow.document;

if(frameHour.getElementById("hdCurrentDate") != null)
  return frameHour.getElementById("hdCurrentDate").value;
setTimeout ( "getServerDateTime()", 2500 );

}

function verificarDataIntervaloCampanha(dataInicio, dataFinal)
		{
			var varDataServer = null;
			var varDataInicio = null;
			var varDataFinal = null;
				
			if(getServerDateTime() != null)	varDataServer = getDateObj(getServerDateTime());
			if(dataInicio != null)	varDataInicio = getDateObj(dataInicio);
			if(dataFinal != null)	varDataFinal = getDateObj(dataFinal);	

			return ( 
						(varDataInicio == null || varDataInicio <= varDataServer)   
					&&	(varDataFinal == null || varDataFinal >= varDataServer)   
			       );
					
		}

		function getDateObj(strDate)
		{
			var arrData = strDate.split(' ')[0];
			var arrHora = strDate.split(' ')[1];
			
			var ano = arrData.split('/')[2];
			var mes = arrData.split('/')[1];
			var dia = arrData.split('/')[0];

			var hora = arrHora.split(':')[0];
			var minuto = arrHora.split(':')[1];
			var segundo = arrHora.split(':')[2];
			var milesegundo = 0;

			return new Date(ano, mes, dia, hora, minuto, segundo, milesegundo);
		}


function addWordInDocumentTitle(word)
{
document.title += (' - ' + word );
}


function showDivLn2(n){
	var num = 2;
	for (i=0; i <= num; i++){
		if (document.getElementById("aba" + i)){
			document.getElementById("aba" + i).style.backgroundImage = "url(img/ico_azul.gif)";
			document.getElementById("link" + i).style.border = "solid 1px #426a92";
			document.getElementById("link" + i).style.color = "#426a92";
			document.getElementById("box" + i).style.display = 'none';
			if (i == n) {
				document.getElementById("aba" + n).style.backgroundImage = "url(img/ico_laranja.gif)";
				document.getElementById("link" + n).style.border = "solid 1px #f47921";
				document.getElementById("link" + n).style.color = "#f47921";
				document.getElementById("box" + n).style.display = "block";
			}
		}
	}
}

function showDivLn3(n){
	var num = 3;
	var elem = "";
	for (i=0; i <= num; i++){
		if (document.getElementById("bt" + i)){
			//document.getElementById("bt" + i).style.backgroundImage = "url(img/bt_0"+ i +"_off.gif)";
			document.getElementById("div" + i).style.display = 'none';
			if (i == n) {
				//document.getElementById("bt" + n).style.backgroundImage = "url(img/bt_0"+ n +"_on.gif)";
				document.getElementById("div" + n).style.display = "block";
			}
		}
	}
	
	removeClass(document.getElementById("bt1"), "selected");
	removeClass(document.getElementById("bt2"), "selected");
	removeClass(document.getElementById("bt3"), "selected");
	
	switch(n){
		case 1:
			elem = document.getElementById("bt1");
			break;
		case 2:
			elem = document.getElementById("bt2");
			break;
		case 3:
			elem = document.getElementById("bt3");
			break;
	}
	
	addClass(elem, "selected");
}

function showBoxGrad(n){
	var num = 3;
	for (i=0; i <= num; i++){
		if (document.getElementById("bt0" + i)){
			document.getElementById("bt0" + i).style.fontWeight = "normal";
			document.getElementById("box0" + i).style.display = 'none';
			if (i == n) {
				document.getElementById("bt0" + n).style.fontWeight = "bold";
				document.getElementById("box0" + n).style.display = "block";
			}
		}
	}
}

function showDivCurso(n){
	var num = 2;
	for (i=0; i <= num; i++){
		if (document.getElementById("link" + i)){
			document.getElementById("aba" + i).style.backgroundImage = "url(img/ico_azul.gif)";
			document.getElementById("link" + i).style.color = "#426a92";
			document.getElementById("box" + i).style.display = 'none';
			if (i == n) {
				document.getElementById("aba" + n).style.backgroundImage = "url(img/ico_laranja.gif)";
				document.getElementById("link" + n).style.color = "#f47921";
				document.getElementById("box" + n).style.display = "block";
			}
		}
	}
}

function showBoxManual(n){
	document.getElementById("l" + n).style.backgroundImage = "url(img/espaco_aluno/ico_seta_bottom.gif)";
	document.getElementById("b" + n).style.display = 'block';
}

function hideBoxManual(n){
	document.getElementById("l" + n).style.backgroundImage = "url(img/espaco_aluno/ico_seta_branca.gif)";
	document.getElementById("b" + n).style.display = 'none';
}

/* abre a aba corretamente no manual do aluno */
function getVar(){
	nAbas = 25;
	for(i=1; i<=nAbas; i++){
		url = window.location.search;
		if (url == "?aba"+ i){
			showBoxManual(i);
			window.location.replace("#l"+i);
		}			
	}	
}

function showDivBoxSemestres(n){
	var num = 6;
	for (i=1; i <= num; i++){
		if (document.getElementById('box' + i)){
			document.getElementById('mnSem').getElementsByTagName('li')[i-1].className = 'bt0'+i;
			document.getElementById('box' + i).style.display = 'none';
			if (i == n) {
				//alert(n)
				document.getElementById('mnSem').getElementsByTagName('li')[n-1].className = 'bt0'+n+'-on';
				document.getElementById('box' + n).style.display = 'block';
			}
		}
	}
}

//função que pega o box com maior altura e aplica a mesma altura nos demais
function equalHeight(){
	var maior_altura = 0; 
	var n_elementos = 8;
	
	for(i=1; i<=n_elementos; i++){
		var getaltura = document.getElementById('b' + i).offsetHeight;
		if(getaltura > maior_altura){
			maior_altura = getaltura;
		}
	}
	//alert(maior_altura)
	
	for(i=1; i<=n_elementos; i++){
		document.getElementById('b' + i).style.height = maior_altura + "px";
	}
}

function InsertCssClassByObjectId(obj, cssClassName)
{
    obj.className = cssClassName;
}

function setValueInElement(elementID, htmlValue)
{
   document.getElementById(elementID).innerHTML = htmlValue;
}

function showDivForm(n){
			var num = 3;
			for (i=1; i <= num; i++){
				if (document.getElementById("item" + i)){
					document.getElementById("item" + i).style.display = 'none';
					if (i == n) {
						document.getElementById("item" + n).style.display = "block";
					}
				}
			}
		}
		
function showPasso(n){
			var num = 9;
			for (i=1; i <= num; i++){
				if (document.getElementById("p" + i)){
					document.getElementById("p" + i).style.display = 'none';
					if (i == n) {
						document.getElementById("p" + n).style.display = "block";
					}
				}
			}
		}


function showBoxManualFaqs(n){
	var numAbas = 25;
	for (i=0; i <= numAbas; i++){
		if(document.getElementById("t" + i)){
			document.getElementById("t" + i).style.display = 'none';
			document.getElementById("i" + i).style.background = 'url(img/espaco_aluno/ico_seta_laranja.gif) 10px 7px no-repeat';
			
			if (i == n) {
				document.getElementById("t" + n).style.display = "block";
				document.getElementById("i" + n).style.background = 'url(img/espaco_aluno/ico_seta_laranja_down.gif) 8px 7px no-repeat';
			}
		}
	}
}


function PreVisualizar() 
{
	try 
	{
		 //Utilizando o componente WebBrowser1 registrado no MS Windows Server 2000/2003 ou XP/Vista
		 var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
		 document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
		 WebBrowser1.ExecWB( 7, 1 ); 
		 WebBrowser1.outerHTML = ""; 
	} 
	catch(e) 
	{
		alert("Para visualizar a impressão você precisa habilitar o uso de controles ActiveX na página.");
		return;
	}
}

function linkPrint(){
	/*
	tagLink = document.createElement("link");
	tagLink.setAttribute("href","css/print.css");
	tagLink.setAttribute("media","print");
	
	tagHead = document.getElementsByTagName("head")[0];
	tagHead.appendChild(tagLink);
	*/
	
	
	//for(i=0;i<=5;i++){
		//links = document.getElementsByTagName("link")[i].media;
		//if(links != "print"){
			//alert(document.getElementsByTagName("link")[i].href);
			//alert(
			document.getElementsByTagName("link")[0].media = "screen"
			document.getElementsByTagName("link")[1].media = "screen"
			//);
		//}
	//}
}


function modal_inline(id){
	
	var match_cookie = document.cookie.match("intervencao")// busca o cookie

	if(!match_cookie){// se o cookie não existe
	
		/* VARIAVEIS */	
		var div_background = document.createElement('div');	
		var div_modal = document.createElement('div');			
		var bt_close = document.createElement('a');
		var bt_closeTxt = document.createTextNode('fechar')
		var div_content = document.getElementById(id);
		var flash = document.getElementById('box_flash');
		var flash2 = document.getElementById('vestibular');
			
		
		/*CLASS*/
		div_background.className = 'modal_box';
		div_modal.className = 'modal';
		bt_close.className = 'close';


		/* ID */
		div_background.id = 'modalBox';
		div_modal.id = 'Modal';


		flash.style.display = 'none';
		flash2.style.display = 'none';
		div_content.style.display = 'block'


		div_background.style.height = document.body.offsetHeight + 'px'
		div_background.style.width = document.body.offsetWidth + 'px'

		div_background.style.opacity = 0.7;
		div_background.style.filter = "alpha(opacity=" + 70 + ")";

		bt_close.href="#";

		for(var i = 0; i < document.getElementsByTagName('select').length; i++){
			document.getElementsByTagName('select')[i].style.display = 'none'	
		}

			
		document.body.appendChild(div_background)
		bt_close.appendChild(bt_closeTxt)
		div_modal.appendChild(bt_close)
		document.body.appendChild(div_modal)
		div_modal.appendChild(div_content)				


		div_background.onclick = function(){			

			document.body.removeChild(this);
			document.body.removeChild(div_modal);	
			flash.style.display = 'block';
			flash2.style.display = 'block';
			for(var i = 0; i < document.getElementsByTagName('select').length; i++){
				document.getElementsByTagName('select')[i].style.display = 'block'	
			}
						
		}

		bt_close.onclick = function(){
			document.body.removeChild(div_modal);			
			document.body.removeChild(div_background);
			flash.style.display = 'block';
			flash2.style.display = 'block';
			for(var i = 0; i < document.getElementsByTagName('select').length; i++){
				document.getElementsByTagName('select')[i].style.display = 'block'	
			}
		}

		var t = setTimeout("document.getElementById('modalBox').style.display = 'none'; " +
			"document.getElementById('Modal').style.display = 'none'; " +
			"document.getElementById('box_flash').style.display = 'block';" +
			"document.getElementById('vestibular').style.display = 'block';" +
			"for(var i = 0; i < document.getElementsByTagName('select').length; i++){" +
			"document.getElementsByTagName('select')[i].style.display = 'block'}",10000);
	}

	/* GRAVAÇÃO DO COOKIE */
	document.cookie = "intervencao=1";
}


function init(){
	linkPrint();
	getVar();


	//equalHeight();
}

window.onload = init;

function showDest(n){
	for(i=0; i<=3; i++){
		if(document.getElementById('mn' + i)){
			document.getElementById('mn' + i).className = '';
			document.getElementById('b' + i).style.display = 'none';
			
			if(i == n){									
				document.getElementById('mn' + n).className = 'on';
				document.getElementById('b' + n).style.display = 'block';
			}
		}
	}
}

function abreConviteColacaoDeGrau2010(){
window.open("/content/formados2010.html", "formados", "height = 550, width = 807, scrollbars = yes");
}

function hasClass(el, name) {
   return new RegExp('(\\s|^)'+name+'(\\s|$)').test(el.className);
}

function addClass(el, name){
   if (!hasClass(el, name)) { el.className += (el.className ? ' ' : '') +name; }
}

function removeClass(el, name){
   if (hasClass(el, name)) {
      el.className=el.className.replace(new RegExp('(\\s|^)'+name+'(\\s|$)'),' ').replace(/^\s+|\s+$/g, '');
   }
}


