function tryLogin() {
	if (document.frmLogin.tbLogin.value.length==0) {
		window.alert('Indique por favor o seu nome de utilizador!');
		document.frmLogin.tbLogin.focus();
	} else if (document.frmLogin.tbPwd.value.length==0) {
		window.alert('Indique por favor a sua senha secreta!');
		document.frmLogin.tbPwd.focus();
	} else document.frmLogin.submit();
}
function goTo(x) {
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=x;
	document.frmParameters.submit();
}
function setTask(task) {
	document.frmParameters.task.value=task;
	document.frmParameters.submit();
}
function setId(id, pageIndex) {
	document.frmParameters.task.value='goto';
	document.frmParameters.id.value=id;
	document.frmParameters.pageIndex.value=pageIndex;
	document.frmParameters.submit();
}
function openWindow(url, width, height, wndName, scroll, resize, menu, toolbar)

{

	var x, y, wnd;

	x=(window.screen.width-width)/2;

	y=(window.screen.height-height)/2;

	if (wndName==null) wndName='myChildWindow';

	if (scroll==null) scroll=0;

	if (resize==null) resize=0;
	if (menu==null) menu=0;
	if (toolbar==null) toolbar=0;

	wnd=window.open(url, wndName, 'left=' + x + ', top=' + y + ', width=' + width + ', height=' + height + ', status=0, toolbar=' + toolbar + ', menubar=' + menu + ', scrollbars=' + scroll + ', resizable=' + resize + ', location=0');

	wnd.focus();

}

function setCombinedClass(x) {
	document.frmClass.combinedClass.value=x;
	document.frmClass.submit();
}
function showCalendar() {
	openWindow('calendar.php', 300, 220, 'wndCal', true, true);
}
function setDate(day, month, year) {
	window.opener.document.frmCalendar.Day.value=day;
	window.opener.document.frmCalendar.Month.value=month;
	window.opener.document.frmCalendar.Year.value=year;
	window.opener.document.frmCalendar.submit();
	window.close();
}
function showVisita(idStd) {
	document.frmParameters.idStd.value=idStd;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=1210;
	document.frmParameters.submit();
}

function showStudentAbsences(idStd, idDis) {
	document.frmParameters.idStd.value=idStd;
	document.frmParameters.idDis.value=idDis;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=250;
	document.frmParameters.submit();
}

//Alunos verem as suas faltas
function showStudentAbsencesStu(idStd,idDis) {
	document.frmParameters.idStd.value=idStd;
	document.frmParameters.idDis.value=idDis;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=263;
	document.frmParameters.submit();
}
//Alunos verem a sua classificação
function showStudentClass(idStd,idPer) {
	document.frmParameters.idStd.value=idStd;
	document.frmParameters.idPer.value=idPer;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=264;
	document.frmParameters.submit();
}



function showStudentAbsencesMap(idStd, mode) {
	document.frmParameters.idStd.value=idStd;
	document.frmParameters.task.value='goto';
	if (mode==1) document.frmParameters.pageIndex.value=260;
	else if (mode==2) document.frmParameters.pageIndex.value=261;
	document.frmParameters.submit();
}

function showStudentAbsencesMapCiclo(idStd, mode) {
	document.frmParameters.idStd.value=idStd;
	document.frmParameters.task.value='goto';
	if (mode==1) document.frmParameters.pageIndex.value=265;
	else if (mode==2) document.frmParameters.pageIndex.value=266;
	document.frmParameters.submit();
}


function showNewsFile(id) {
	document.frmParameters.id.value=id;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=1;
	document.frmParameters.submit();
}
function validateInt(ctrl, min, max) {
	x=parseInt(ctrl.value);
	ctrl.value=(((x>=min) && (x<=max))? x:'');
}
function validateFloat(ctrl, min, max) {
	x=parseFloat(ctrl.value);
	ctrl.value=(((x>=min) && (x<=max))? x:'');
}
function validateChar(ctrl) {
	ctrl.value=((((ctrl.value>='a') && (ctrl.value<='z')) || ((ctrl.value>='A') && (ctrl.value<='Z')))? ctrl.value:'');
}
function submitProfile() {
	if ((document.frmProfile.emailLogin) && (((document.frmProfile.emailLogin.value!='') && (document.frmProfile.emailDomain.value=='')) || ((document.frmProfile.emailLogin.value=='') && (document.frmProfile.emailDomain.value!='')))) window.alert('Email invalido - corrija, por favor!');
	else if (document.frmProfile.pwd1.value!=document.frmProfile.pwd2.value) window.alert('Senha secreta errada - corrija, por favor!');
	else if ((document.frmProfile.pwd1.value.length>0) && (document.frmProfile.pwd1.value.length<6)) window.alert('A senha secreta deve ter pelo menos 6 caracteres - corrija, por favor!');
	else document.frmProfile.submit();
}
function submitEspacoPre() {
	if ((document.frmEspacoPre.titulo.value=='')) window.alert('Os campos Título e Descrição sao obrigatórios!');
	else document.frmEspacoPre.submit();
}
function submitEspaco1() {
	if ((document.frmEspaco1.titulo.value=='')) window.alert('Os campos Título e Descrição sao obrigatórios!');
	else document.frmEspaco1.submit();
}
function classAction(argument, action) {
if (action=="delete") {
	var x=window.confirm("Tem a certeza que deseja eliminar esta aula?")
	if (x) {
		document.frmParameters.Argument.value=argument;
		document.frmParameters.Action.value=action;
		document.frmParameters.task.value='goto';
		document.frmParameters.pageIndex.value=270;
		document.frmParameters.submit();
		}
	} else {
		document.frmParameters.Argument.value=argument;
		document.frmParameters.Action.value=action;
		document.frmParameters.task.value='goto';
		document.frmParameters.pageIndex.value=270;
		document.frmParameters.submit();
	}
}

function classPre(argument, action) {
	var x=window.confirm("Tem a certeza que deseja eliminar esta entrada?")
	if (x)
	{
		document.frmParameters.Argument.value=argument;
		document.frmParameters.Action.value=action;
		document.frmParameters.task.value='goto';
		document.frmParameters.pageIndex.value=273;
		document.frmParameters.submit();
	}
}

function classActionCiclo(argument, action) {
	if(action=="delete_esp")
	{
		var x=window.confirm("Tem a certeza que deseja eliminar esta entrada?")
		if (x)
		{
			document.frmParameters.Argument.value=argument;
			document.frmParameters.Action.value=action;
			document.frmParameters.task.value='goto';
			document.frmParameters.pageIndex.value=271;
			document.frmParameters.submit();
		}
	}
	document.frmParameters.Argument.value=argument;
	document.frmParameters.Action.value=action;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=271;
	document.frmParameters.submit();
}

function classActionPopup(argument, action) {
	document.frmParameters.Argument.value=argument;
	document.frmParameters.Action.value=action;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=272;
	document.frmParameters.submit();
}


function classAction1(argument, action) {
	document.frmParameters.Argument.value=argument;
	document.frmParameters.Action.value=action;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=800;
	document.frmParameters.submit();
}



function testNewCommentForm() {
	if (document.frmNewComment.caption.value.length>0) {
		if (document.frmNewComment.comment.value.length>0) document.frmNewComment.submit();
		else window.alert('Por favor escreva o seu comentario.');
	} else window.alert('Por favor declare um titulo para o seu comentario.');
}
function testEditCommentForm() {
	if (document.frmComment.caption.value.length>0) {
		if (document.frmComment.comment.value.length>0) document.frmComment.submit();
		else window.alert('Por favor escreva o texto do comentario.');
	} else window.alert('Por favor declare um titulo para o seu comentario.');
}
function showGrades(showAll) {
	document.frmParameters.Argument.value=showAll;
	document.frmParameters.pageIndex.value=500;
	document.frmParameters.submit();
}


//inventado show declaraçao
function showdeclaracao(showAll) {
	document.frmParameters.Argument.value=showAll;
	document.frmParameters.pageIndex.value=1000;
	document.frmParameters.submit();
}




function showLivroPonto(id) {
	document.frmParameters.id.value=id;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=800;
	document.frmParameters.submit();
}

function showGradesBoard(id) {
	document.frmParameters.id.value=id;
	document.frmParameters.task.value='goto';
	document.frmParameters.pageIndex.value=510;
	document.frmParameters.submit();
}
function printGradesBoard(id) {
	openWindow('/sie/board_temp.php?id=' + id, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}

function printPlanoAnual(year) {
	openWindow('/sie/plano_anual.php?year=' + year, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}

function printPlanocrea(ano) {
	openWindow('/sie/plano_crea.php?ano=' + ano, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}

function printPlanoUnesco(ano) {
	openWindow('/sie/plano_unesco.php?ano=' + ano, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}

function printPlanoEco(ano) {
	openWindow('/sie/plano_eco.php?ano=' + ano, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}

function printVisitaPre(id) {
	openWindow('/sie/visita_pre.php?id=' + id, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}

function printVisita2(id) {
	openWindow('/sie/visita_2.php?id=' + id, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}


function printRegistos(id) {
	openWindow('/sie/registos.php?id=' + id, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}



function printTurmaDT(id) {
	openWindow('/sie/turmadt.php?id=' + id, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}

function printCamionetas(id) {
	openWindow('/sie/camionetas.php?id=' + id, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}

function printjustificacao(id) {
	openWindow('/sie/justificacao.php?id=' + id, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}

function printrelaux(id) {
	openWindow('/sie/relaux.php?id=' + id, 1000, 700, 'wndBoard', 1, 1, 1, 1);
}



function testLockerForm() {
	var frm=document.frmLocker;
	if (frm.cbStatus.value=='null') window.alert('Por favor indique o novo estado do cacifo.');
	else if ((frm.cbStatus.value==2) && (frm.cbStudent.value=='null')) window.alert('Por favor indique o novo propeitario do cacifo.');
	else if (frm.tbValue.value=='') window.alert('Por favor indique o valor do aluguer do cacifo este ano lectivo.');
	else frm.submit();
}
function showPrint(path) {
	openWindow(path, 1000, 700, 'wndPrint', 1, 1, 1, 1);
}

function registerClassPopup() {
	var cnt=0;
	var n;
	if (document.frmClassEditorPopUp.elements['chkTeacher[]'].length>0) {
		for (n=0; n<document.frmClassEditorPopup.elements['chkTeacher[]'].length; n++)
			if (document.frmClassEditorPopup.elements['chkTeacher[]'][n].checked) cnt++;
	} else cnt=(document.frmClassEditorPopup.elements['chkTeacher[]'].checked? 1:0);
	/*if (document.frmClassEditor.cbClassRoom.value=='') window.alert('Escolha por favor uma sala!');
	else*/ if (cnt<1) window.alert('Indique por favor o(s) docente(s) presente(s) na aula!');
	else if (document.frmClassEditorPopup.tbSummary.value.length==0) window.alert('Escreva por favor o sumario da aula.');
	else document.frmClassEditorPopup.submit();
}

function registerClassCiclo() {
	var cnt=0;
	var n;
	if (document.frmClassEditorCiclo.elements['chkTeacher[]'].length>0) {
		for (n=0; n<document.frmClassEditorCiclo.elements['chkTeacher[]'].length; n++)
			if (document.frmClassEditorCiclo.elements['chkTeacher[]'][n].checked) cnt++;
	} else cnt=(document.frmClassEditorCiclo.elements['chkTeacher[]'].checked? 1:0);
	/*if (document.frmClassEditor.cbClassRoom.value=='') window.alert('Escolha por favor uma sala!');
	else*/ if (cnt<1) window.alert('Indique por favor o(s) docente(s) presente(s) na aula!');
	//else if (document.frmClassEditor.tbSummary.value.length==0) window.alert('Escreva por favor o sumario da aula.');
	else document.frmClassEditorCiclo.submit();
}


function registerClass() {
	var cnt=0;
	var n;
	if (document.frmClassEditor.elements['chkTeacher[]'].length>0) {
		for (n=0; n<document.frmClassEditor.elements['chkTeacher[]'].length; n++)
			if (document.frmClassEditor.elements['chkTeacher[]'][n].checked) cnt++;
	} else cnt=(document.frmClassEditor.elements['chkTeacher[]'].checked? 1:0);
	/*if (document.frmClassEditor.cbClassRoom.value=='') window.alert('Escolha por favor uma sala!');
	else*/ if (cnt<1) window.alert('Indique por favor o(s) docente(s) presente(s) na aula!');
	else if (document.frmClassEditor.tbSummary.value.length==0) window.alert('Escreva por favor o sumario da aula.');
	else document.frmClassEditor.submit();
}
function classExtraAction(argument, action) { 
   document.frmParameters.Argument.value=argument; 
   document.frmParameters.Action.value=action; 
   document.frmParameters.task.value='goto'; 
   document.frmParameters.pageIndex.value=280; 
   document.frmParameters.submit(); 
} 
function classSubsAction(argument, action) { 
   document.frmParameters.Argument.value=argument; 
   document.frmParameters.Action.value=action; 
   document.frmParameters.task.value='goto'; 
   document.frmParameters.pageIndex.value=290; 
   document.frmParameters.submit(); 
} 

function testNewNewsForm() {
	var x=document.frmNewNews;
	if (x.title.value.length==0) {
		window.alert('Indique por favor o titulo da noticia.');
		x.title.focus();
	} else if (x.text.value.length==0) {
		window.alert('Indique por favor o texto da noticia.');
		x.text.focus();
	} else x.submit();
}
function testEditNewsForm() {
	var x=document.frmEditNews;
	if (x.title.value.length==0) {
		window.alert('Indique por favor o titulo da noticia.');
		x.title.focus();
	} else if (x.text.value.length==0) {
		window.alert('Indique por favor o texto da noticia.');
		x.text.focus();
	} else x.submit();
}


//Acrescentado
