/* opens language switch box */
function swLang() {
	var layer = document.getElementById('language-switch');
	if (layer.style.display != 'block') {
		layer.style.display = 'block';
	} else {
		layer.style.display = 'none';
	}
}

/* detects flash version */
var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 0;
var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
window.onload = function() {
	var flashobj = document.getElementById('flash-alert');
	var picobj = document.getElementById("no-flash");
	var picswitcherobj = document.getElementById("pic-switcher");
	if (!hasRightVersion) {
		flashobj.style.display = 'block';
		picobj.style.display = 'block';
		picswitcherobj.style.display = 'none';
		}
	
	if (navigator.platform == "Linux") {
		var a = document.getElementById('main-menu-overlap');
		a.style.overflow = "auto";
	}
}
function closeAlert() {document.getElementById('flash-alert').style.display = 'none';}

/* increase/decrease fonts */
var tgs = new Array( 'p');

//specify spectrum of different font sizes:
var szs = new Array( '13px','14px','15px','16px','17px','18px','19px' );
var startSz = 1;
function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0; i < tgs.length; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0; j < cTags.length; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

/* opens news popup */
function openPopUp(urlPage,xWidth,xHeight) {
	var win_w;
	var win_h;
	if (parseInt(navigator.appVersion) > 3) {
		if (navigator.appName=="Netscape") {
			win_w = window.innerWidth;
			win_h = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			win_w = document.body.offsetWidth;
			win_h = document.body.offsetHeight;
		}
	}
	var pop_window = window.open(urlPage,'_blank', 'height='+ xHeight +',width='+xWidth+', menubar=0, statusbar=0, resizable=1, scrollbars=1');
	if	(!pop_window) {
		document.getElementById('warning-container').style.display='block';
		document.getElementById('warning-container').innerHTML = "<div id='pop-warning' style='top: 300px; left: "+ ((win_w/2)-305) + "px;'>Bloqueador de popups detectado. Caso voc&ecirc; n&atilde;o esteja vendo o conte&uacute;do desejado, desabilite seu(s) bloqueador(es) e clique novamente no link.<br /><br /><p align='center' style='font-size: 11px;'>(<a href='javascript:closeWarning();'>fechar este aviso</a>)</p></div>";
		scroll(0,0);
		setTimeout("closeWarning();",8000);
	} else {
		document.getElementById('warning-container').style.display='none';
	}
}

function closeWarning() {
	document.getElementById('warning-container').innerHTML = "";
		
}

/* sets main menu div height */
function setMenuLayerSize(param) {
	var a = document.getElementById('main-menu-overlap');
	if (param == 'open') {
		a.style.height = "260px";
		a.style.overflow = "auto";
	} else if (param == 'close') {
		a.style.height = "37px";
		a.style.overflow = "hidden";
	}
}

function setFastLinksLayerSize(param) {
	var a = document.getElementById('fast-links-overlap');
	var closed_size = "110px";
	if (navigator.appName == "Microsoft Internet Explorer") {
		a.style.height = "330px";
		var closed_size = "330px";
	}
	if (param == 'open') {
		a.style.height = "330px";
	} else if (param == 'close') {
		a.style.height = closed_size;
	}
}

/* sets form blocks display */
function switchFormBlocks(par_id) {
	var divs = document.getElementsByTagName('div');
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].id.indexOf('formblock') != -1) {
			document.getElementById(divs[i].id).style.display = "none";
		}
	}
	document.getElementById('formblock' + par_id).style.display = "block";
}

/* prints current page */
function printPage() {
	window.open('/pucrs/popup_imprimir.htm','','width=610, height=500, menubar=0, statusbar=0, resizable=1, scrollbars=1');
}

function printContent() {
	var content = "";
	var rightcol_array = window.opener.document.getElementsByTagName('div');
	for (var i=0; i < rightcol_array.length; i++) {
		if (rightcol_array[i].id.indexOf('right-col') != -1) {
			content += window.opener.document.getElementById(rightcol_array[i].id).innerHTML;
			if (rightcol_array[i].id.indexOf('right-col-container') != -1) {
				content = window.opener.document.getElementById('right-col-container').innerHTML;
				break;
			}
		}
	}
	document.getElementById('internal-content').innerHTML = content;
	window.print();
}

function MM_jumpMenu(targ,selObj,restore){
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

/* switches video using mini player */
var _selected_videodiv = 'videolink01';
function switchVideo($video, $img, $id) {
	window.document.getElementById('flash-video').innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='300' height='250' id='multimedia_player_mini' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='allowFullScreen' value='false' /><param name='movie' value='http://www3.pucrs.br/pucrs/swf/multimedia_player_mini.swf?filename=" + $video + "&imagename=" + $img + "&autoplay=true' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><embed src='http://www3.pucrs.br/pucrs/swf/multimedia_player_mini.swf?filename=" + $video + "&imagename=" + $img + "&autoplay=true' quality='high' bgcolor='#ffffff' width='300' height='250' name='multimedia_player_mini' align='middle' allowScriptAccess='sameDomain' allowFullScreen='true' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' />";
	document.getElementById(_selected_videodiv).className = "videolink off";
	_selected_videodiv = $id;
	document.getElementById(_selected_videodiv).className = "videolink on";
}