var acess = new Array('acessibilidade', 'acessibilidade2', 'acessibilidade3');	
var janela = null;

function gT(tag) {
	return document.getElementsByTagName(tag);
}

function gE(id) {
	return document.getElementById(id);
}

function checaNavegador() {	 
	if (gE('acessibilidade')) {
		if (navigator.appName == "Microsoft Internet Explorer") {		
			gE('acessibilidade').className = "acessIE";
		} else {
			gE('acessibilidade').className = "acess";
		}
	}	
}

function mostrar(id)  {
	gE(id).style.display = '';
}
function ocultar(id) {
	gE(id).style.display = 'none';
}

function acessibilidade() {
	if (gE('acessibilidade')) {
		gE('acessibilidade').onmouseover = gE('contato').getElementsByTagName('img')[0].onmouseover = function() {
			mostrar('acessibilidade');
		}
		gE('acessibilidade').onmouseout = gE('contato').getElementsByTagName('img')[0].onmouseout = function() {
			ocultar('acessibilidade');
		}
	}
}

function limparBusca() {	
	if (gE('q')) {
		gE('q').onfocus = function() {
			if (gE('q').value == 'Buscar na USJT') {
				gE('q').value = '';
			}
		}
		gE('q').onblur = function() {
			if (gE('q').value == '') {
				gE('q').value = 'Buscar na USJT';
			}
		}
	}		  
}

function focoCampos() {
	if (gE("p_wpessoa_rgrne")) {		
		gE("p_wpessoa_rgrne").focus();
	}
	if (gE("docente")) {
		gE("docente").focus();
	}
}


function abreJanela(endereco, nome, largura, altura, rol) {	
	var x, y, propriedades;	
	x = (screen.width - largura) / 2;
	y = (screen.height - altura) / 2;	
	if (largura != 0 && altura != 0) {
		propriedades = "height =" + altura + ",width =" + largura + ",top =" + y + ",left =" + x + ",scrollbars =" + rol + ",resizable";
		window.open(endereco, nome, propriedades);
		if (janela == null) {
			janela = window.open(endereco, nome, propriedades);
			janela.window.focus();
		} else {
			janela.close();
			janela = window.open(endereco, nome, propriedades);
			janela.window.focus();
		}
	} else {
		window.open(endereco);
	}
}

function shadowbox() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		Shadowbox.init({
			 language: "en",
			 players:  ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv']			
		});	
	}
}

function pngTransparente() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		for(var i=0; i< document.images.length; i++) {
			var img = document.images[i]
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
				img.outerHTML = strNewHTML
				i = i-1
			}      	
		}
	}
}

function f() {
	if (gE("popup")) {
		gE("popup").style.display = "none";		
	}
}
function cliqueFechar() {
	if (gE("fechar")) {
		gE("fechar").onclick = function() {
			f();
		}
	}
}
function verificarNavegador() {
	if (window.navigator.appName == "Microsoft Internet Explorer") {
		return true;
	} else {
		return false;
	}
}
function criarPlayer(el, titulo, l, a, url) {	
 	var c = "";
	if (verificarNavegador()) {
		c = "<object classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" name=\"MediaPlayer\"  width=\""+l+"\" height=\""+a+"\" id=\"MediaPlayer\">";
	} else {
		c = "<object type=\"audio/x-ms-wma\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" name=\"MediaPlayer\"  width=\""+l+"\" height=\""+a+"\" id=\"MediaPlayer\" >";
    }
    c += "<param name=\"filename\" value=\""+url+"\">";
    c += "<param name=\"autostart\" value=\"false\">";
    c += "<param name=\"controller\" value=\"true\">"; 
	c += "</object>";
    gE(el) ? gE(el).innerHTML = titulo + "<br />" + c : "";
}
window.onload = function() {	
	pngTransparente();
	limparBusca();
	checaNavegador();
	acessibilidade();
	focoCampos();
	shadowbox();
	cliqueFechar();	
	slide();
}