function $($id){
	return document.getElementById($id);
}

function $$($id){
	return document.getElementById($id).value;
}

function isIE(){
	return (document.all&&document.getElementById);
}

String.prototype.trim = function(){
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

function startList() {

	try{
		if ( isIE() ) {

			var navRoot = $('nav');

			if(!navRoot){
				navRoot = $('menu-geral');
			}

			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
					  this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}catch(e){
/*		if(e.number!=-2146827864){
			for($i in e){
				prompt('', $i+'='+eval('e.'+$i));
			}
		}*/
	}
	
}

window.onload = function() {
	startList();

	if( (typeof internalFunction) == 'function' ){
		internalFunction();
	}
}


/*Daniel San Functions*/
function daniel_opn(s, w, h){

	alert(this);

	dats_con  = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'+
				'<html xmlns="http://www.w3.org/1999/xhtml">\n'+
				'<head>\n<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\n'+
				'<title>Col&eacute;gio Santo Agostinho, H&aacute; mais de 70 anos educando gera&ccedil;&otilde;es</title></head>\n'+
				'<style type="text/css" media="screen">body{padding:0; margin:0;background-color:#badefa;}</style>'+
				'<body><div class="imagex"><a href="javascript:;" onclick="window.close();"><img src="imgs/' + s + '.jpg" alt="Clique para fechar" border="0" /></a></div></body>\n</html>';

	dats_wnm = 'WindowName';
	dats_cfg = 'width=' + w + ', height=' + h + ', scroll=false';

	dats_win = window.open('about:blank', dats_wnm, dats_cfg);
	dats_win.focus();

    sw = screen.width;
    sh = screen.height;

    tp = ((sw - w)/2);
    lf = ((sh - h)/2);

    dats_win.moveTo(tp, lf);
	
	dats_win.document.write(dats_con);
}




function daniel_foto(Imagem){

	UltimaPosicaoDaBarra = Imagem.src.lastIndexOf('/');
	NomeDoArquivoImagem  = Imagem.src.substr(UltimaPosicaoDaBarra + 1);

	NomeDaJanela          = 'WindowName';
	ConfiguracoesDaJanela = 'width=640, height=480, scroll=false';
	URLParaAbrir          = '/v.php?foto=' + NomeDoArquivoImagem + '&' + 'ref=' + location.href;

	JanelaAberta = window.open(URLParaAbrir, NomeDaJanela, ConfiguracoesDaJanela);
	JanelaAberta.focus();

	return false;

}

function daniel_pict(TagA){

	NomeDoArquivoImagem   = TagA.href;//TagA.childNodes[0].src;
	$AltDaImagem          = TagA.childNodes[0].alt;
	

	NomeDaJanela          = 'WindowName';
	ConfiguracoesDaJanela = 'width=640, height=480, scroll=false';
	URLParaAbrir          = '/v.php?foto=' + NomeDoArquivoImagem + '&alt=' + $AltDaImagem;


	JanelaAberta = window.open(URLParaAbrir, NomeDaJanela, ConfiguracoesDaJanela);
	JanelaAberta.focus();

	return false;
}

function daniel_picts(TagA){

	UltimaPosicaoDaBarra = TagA.childNodes[0].src.lastIndexOf('/');
	NomeDoArquivoImagem  = TagA.childNodes[0].src.substr(UltimaPosicaoDaBarra + 1);

	NomeDaJanela          = 'WindowName';
	ConfiguracoesDaJanela = 'width=640, height=480, scroll=false';
	URLParaAbrir          = '/v.php?foto=' + NomeDoArquivoImagem + '&' + 'ref=' + location.href;

	JanelaAberta = window.open(URLParaAbrir, NomeDaJanela, ConfiguracoesDaJanela);
	JanelaAberta.focus();

	return false;
}

function reajustar(imagem){

	LarguraDaJanela = imagem.width + 5;
	AlturaDaJanela  = imagem.height + 25;

	window.resizeTo(LarguraDaJanela, AlturaDaJanela);

	LarguraDaResolucao = screen.width;
	AlturaDaResolucao  = screen.height;

	DistanciaDoTopo     = ((LarguraDaResolucao - LarguraDaJanela) / 2);
	DistanciaDaEsquerda = ((AlturaDaResolucao  - AlturaDaJanela) / 2);

	window.moveTo(DistanciaDoTopo, DistanciaDaEsquerda);

}

/**************/

function openWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore){
			selObj.selectedIndex=0;
	}
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
	var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_validateForm() { //v4.0
	var i, p, q, nm, test, num, min, max, errors='', args=MM_validateForm.arguments;
	for (i=0; i < (args.length-2); i+=3){
		test = args[i+2];
		val = MM_findObj(args[i]);
		if (val){
			nm = val.name;
			if ((val = val.value)!=""){
				if (test.indexOf('isEmail')!=-1) {
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)){
						errors+='- '+nm+' must contain an e-mail address.\n';
					}
      			} else if (test!='R') {
					num = parseFloat(val);
					if (isNaN(val)){
						errors+='- '+nm+' must contain a number.\n';
					}
					if (test.indexOf('inRange') != -1) {
						p=test.indexOf(':</label>');
						min=test.substring(8,p); max=test.substring(p+1);
						if ( (num<min) || (max<num) ){
							errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
						}
					}
				}
			} else if (test.charAt(0) == 'R'){
				errors += '- '+nm+' é um campo obrigatório.\n';
			}
		}
	}

	if (errors){
		alert('Ocorreram os seguinte erros no preenchimento:\n' + errors);
	}

	document.MM_returnValue = (errors == '');
}