﻿/*Timeline(Inicio)*/
/**/

/*    MPF 2008/11/27
 var fileref=document.createElement('script');
  fileref.setAttribute("type","text/javascript");
  fileref.setAttribute("src", "/timeline/timeline-api.js");
  document.getElementsByTagName("head")[0].appendChild(fileref);
function onLoad() {
	var currentTime = new Date();

	var myArray = new Array();
	myArray[0] = "Jan";myArray[1] = "Feb";
	myArray[2] = "Mar";myArray[3] = "Mar";
	myArray[4] = "May";myArray[5] = "Jun";
	myArray[6] = "Jul";myArray[7] = "Aug";
	myArray[8] = "Sep";myArray[9] = "Oct";
	myArray[10] = "Nov";myArray[11] = "Dec";
  var eventSource = new Timeline.DefaultEventSource();  
MPF 2008/11/27 */

/*
var bandInfos = [
    Timeline.createBandInfo({
        eventSource:    eventSource,
        date:           myArray[currentTime.getMonth()]+" "+currentTime.getDate()+" "+currentTime.getFullYear()+" 00:00:00 GMT",
        width:          "140px", 
        intervalUnit:   Timeline.DateTime.MONTH, 
        intervalPixels: 350,
    }),
    Timeline.createBandInfo({
        showEventText:  false,
        trackHeight:    0.2,
        trackGap:       0.5,
        eventSource:    eventSource,
        date:           myArray[currentTime.getMonth()]+" "+currentTime.getDate()+" "+currentTime.getFullYear()+" 00:00:00 GMT",
        width:          "15px",
        intervalUnit:   Timeline.DateTime.YEAR, 
        intervalPixels: 600
    })
  ];
  bandInfos[1].syncWith = 0;
  bandInfos[1].highlight = true;
*/
/*
MPF 2008/11/27
var bandInfos = [
    Timeline.createBandInfo({
        eventSource:    eventSource,
        date:           myArray[currentTime.getMonth()]+" "+currentTime.getDate()+" "+currentTime.getFullYear()+" 00:00:00 GMT",
        width:          "100%", 
        intervalUnit:   Timeline.DateTime.MONTH, 
        intervalPixels: 200,
        trackGap:       0.5
    })
  ];
  
  
    tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
    Timeline.loadXML("/Site/XMLAnnouncements.jsf", function(xml, url) { eventSource.loadXML(xml, url); });
	equalSizes();
}

var resizeTimerID = null;
function onResize() {
    if (resizeTimerID == null) {
        resizeTimerID = window.setTimeout(function() {
            resizeTimerID = null;
            tl.layout();
        }, 500);
    }
}
MPF 2008/11/27
*/
/*Timeline(Fim)*/

/*   MPF 2008/11/27 */

function onLoad() 
{
var mytest=1;
mytest =0;
}


function onResize() 
{
var mytest2=1;
mytest2 = 2;
}

/*    MPF 2008/11/27 */

function getElementsByClass(searchClass,node,tag) 
{
	var classElements = new Array();
	if ( node == null )
	node = document;
	if ( tag == null )
	tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) 
	{
		if ( pattern.test(els[i].className) ) 
		{
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
function equalSizes()
{
	if (document.getElementById) 
	{ 
		var groundHeight = document.getElementById('wtbody_centralr_box').clientHeight;
      /* var layer=getElementsByClass('body_centralr_box_site',null,null);
         var groundHeight = document.getElementById(layer[0].id).clientHeight; */
		if (groundHeight < 450) 
		{ 
			var groundElement = document.getElementById('wtbody_centralr_box',null,null); 
			groundElement.style.height = '450px'; 
	   	} 
     } 
}
function setTall(nr)
{
     var y=0;

	if (document.layers)
	{
		y=parseFloat(document.body.clientHeight);
		document.layers[nr].height = y+'px';
	}
	else if (document.all)
	{
		y=parseFloat(document.body.clientHeight);
		document.all[nr].style.height = y+'px';
	}
	else if (document.getElementById)
	{
		y=parseFloat(document.body.clientHeight);
		document.getElementById(nr).style.height = y+'px';
	}
}
function show(nr)
{
	if (document.layers)
	{
		document.layers[nr].visibility = 'show';
	}
	else if (document.all)
	{
		document.all[nr].style.visibility = 'visible';
	}
	else if (document.getElementById)
	{
		document.getElementById(nr).style.visibility = 'visible';
	}
}

function hide(nr)
{
	if (document.layers)
	{
		document.layers[nr].visibility = 'hide';
	}
	else if (document.all)
	{
		document.all[nr].style.visibility = 'hidden';
	}
	else if (document.getElementById)
	{
		document.getElementById(nr).style.visibility = 'hidden';
	}
}


function hideDIV(divId){
		document.getElementById(divId).style.visibility = "hidden";
}

function showDIV(divId){
		document.getElementById(divId).style.visibility = "visible";
}

/*
	------------------------------

	 JScript TreeListControl v3.0
	------------------------------
	author:	Nathan Ridley
	email:	generalgherkin@yahoo.com
	web:	www.extroversity.com (inactive at the moment - September 14 2002)
	
	Legal:
	This control is free for commercial and non-commercial use provided that I am credited and
	this header is not removed or changed in any way. Please email me if you are using it!
	
*/
TreeListControlHandler = {
	nextID					: 0,
	getUniqueID				: function() { return this.nextID++; },
	allTrees				: new Array(),
	preventRowClick			: false,
	callExpand				: function(treeID, nodeID) { this.allTrees[treeID].allNodes[nodeID].expand(); },
	callCollapse			: function(treeID, nodeID) { this.allTrees[treeID].allNodes[nodeID].collapse(); },
	callRowClick			: function(treeID, nodeID) { this.allTrees[treeID].allNodes[nodeID].click(); },
	
	imgConnectMore			: 'connect.more.gif',
	imgConnectEnd			: 'connect.end.gif',
	imgConnectBridge		: 'connect.bridge.gif',
	imgHandleCollapseMore	: 'handle.collapse.more.gif',
	imgHandleCollapseEnd	: 'handle.collapse.end.gif',
	imgHandleExpandMore		: 'handle.expand.more.gif',
	imgHandleExpandEnd		: 'handle.expand.end.gif',
	imgEmpty				: 'empty.gif',
	imgIconDefault			: 'icon.folder.gif',
	imgIconFile			: 'file.png',
	xmlHTTPStateChange		: function(treeID, nodeID) { this.allTrees[treeID].allNodes[nodeID].xmlCallback(); }
}

function TreeListControl(sRootLabel, sIconSrc, hideColumnHeadings, hideRootNode) {
	this.ID						= TreeListControlHandler.getUniqueID();
	TreeListControlHandler.allTrees[this.ID] = this;
	this.all					= new Array(); //user indices
	this.allNodes				= new Array(); //system indices
	this.columns				= new Array();
	this.rootNode				= new TreeListControlNode(true, sIconSrc, null, 1);
	this.rootNode.columnText[0]	= sRootLabel;
	this.rootNode.depth			= 0;
	this.rootNode.bShowHandle	= false;
	this.rootNode.oTree			= this;
	this.allNodes[this.rootNode.ID] = this.rootNode;
	this.rendered				= false;
	this.nLabelColumn			= 0; //this is the column in which the icons and branches are drawn
//	this.iconPath				= 'http://buzz.ipatimup.pt/Utils/img/';
	this.showColumnHeadings		= hideColumnHeadings ? false : true;
	this.showRootNode			= hideRootNode ? false : true;
	this.disableRecalc			= false;
}

TreeListControl.prototype.toString = function() {
	var str, x;
	str = '';
	x = 0;
	for(var i=0; i<this.columns.length; i++) {
		str += '<div class="tlc_columnheading" style="width:' + this.columns[i].width + 'px; left:' + x + 'px; ' +
			   '">' + this.columns[i].name + "</div>";
		x += this.columns[i].width;
	}
	//str = '<div id="treelistcontrol' + this.ID + '" class="body_text_box_site" style="width:' + x +
	//	  'px;"><table cellpadding="0" cellspacing="0" border="0"><tr>' + str +
	//	  '</tr></table>' + this.rootNode + '</div>';
	str = '<div id="treelistcontrol' + this.ID + '" class="body_text_box_site" style="width:' + (x + 4) +
		  'px;"><div class="tlc_headings" style="display:expression(TreeListControlHandler.allTrees[' + this.ID +
			   '].showColumnHeadings ? \'block\' : \'none\');">' + str + '</div>' + this.rootNode + '</div>';
	this.rendered = true;
	return str;
}

TreeListControl.prototype.redraw = function() {
	//redraw all icons in the tree
}

TreeListControl.prototype.add = function(oNode) {
	this.rootNode.add(oNode);
}

TreeListControl.prototype.addColumn = function(oColumn) {
	this.columns[this.columns.length] = oColumn;
}

function TreeListControlColumn(width, name, onclickdisabled) {
	this.name = name;
	this.width = width ? width : '100';
	this.onclickdisabled = onclickdisabled ? true : false;
	



























































}

function TreeListControlNode(bShowChildren, sIconSrc, sXMLSrc, refKey) {
	//refKey is an optional user-specified value which will be matched to this node for easy reference later
	this.columnText			= new Array();
	this.bShowChildren 		= bShowChildren ? true : false;
	this.sIconSrc			= sIconSrc ? sIconSrc : null;
	this.sXMLSrc			= (typeof(sXMLSrc) == 'string') ? sXMLSrc : '';



	this.bDynamicNode		= this.sXMLSrc.length > 0 ? true : false; //set to false once children are loaded to prevent sXMLSrc being used to dynamically load the children
	this.bShowHandle		= true; //this is the + or - icon
	this.refKey				= (refKey || refKey == 0) ? refKey : null;
	this.ID					= TreeListControlHandler.getUniqueID();
	this.sImages			= '';
	this.sHandle			= '';
	this.onclick			= '';
	this.useIcon			= true;

	this.nextSibling		= null;
	this.previousSibling	= null;
	this.firstChild			= null;
	this.lastChild			= null;
	this.parentNode			= null;
	this.oTree				= null;
	this.rendered			= false;
	


	//this.className			= 'tlc_node_row';
	//this.classNameHover		= 'tlc_node_row_hover';
	//this.classNameClick		= 'tlc_node_row_click';		
}

TreeListControlNode.prototype.toString = function() {
	var str = '<div class="tlc_node" id="tlcnode' + this.ID + '">';
//	var str = '<div id="tlcnode' + this.ID + '">';
	if(this.columnText[3]!='T') {
	str += '<div class="tlc_node_row"  style="position:relative; ' +
		   (this.parentNode == null ? 'display:expression(TreeListControlHandler.allTrees[' + this.oTree.ID +
			   '].showRootNode ? \'block\' : \'none\');' : '') + '">';
     }
	else {
	str += '<div class="tlc_node_title_row" style="position:relative; ' +
		   (this.parentNode == null ? 'display:expression(TreeListControlHandler.allTrees[' + this.oTree.ID +
			   '].showRootNode ? \'block\' : \'none\');' : '') + '" onclick="if(!TreeListControlHandler.preventRowClick) { ' + this.onclick + ' }">';
	}
	var c = this.oTree.columns;
	var x = 0;
	for(var i=0; i<c.length-1; i++) {
	    if(this.columnText[3]!='T') {		
		if(i==1){
		str += '<div class="tlc_node_text" style="cursor:default;width:' + c[i].width + 'px; position:absolute; left:' + x + 'px; text-align:center"' + 
				(c[i].onclickdisabled ? ' onmouseenter="TreeListControlHandler.preventRowClick=true;" onmouseleave="TreeListControlHandler.preventRowClick=false;"' : '' )+ '>';
         }
		else
		{
		if(this.columnText[3]!='S'){
		str += '<div class="tlc_node_text" style="width:' + c[i].width + 'px; position:absolute; left:' + x + 'px;"' + 
				(c[i].onclickdisabled ? ' onmouseenter="TreeListControlHandler.preventRowClick=true;" onmouseleave="TreeListControlHandler.preventRowClick=false;"' : '' )+ '>';
		}
		else
		{
		str += '<div class="tlc_node_text" style="font-weight:bold; width:' + c[i].width + 'px; position:absolute; left:' + x + 'px;"' + 
				(c[i].onclickdisabled ? ' onmouseenter="TreeListControlHandler.preventRowClick=true;" onmouseleave="TreeListControlHandler.preventRowClick=false;"' : '' )+ '>';
		}
		}
         }
		else
		{

		str += '<div class="body_text_title_text_site" style="width:' + c[i].width + 'px; position:absolute; left:' + x + 'px; height:24px; overflow:hidden; padding-left:2px; white-space:nowrap;"' +
				(c[i].onclickdisabled ? ' onmouseenter="TreeListControlHandler.preventRowClick=true;" onmouseleave="TreeListControlHandler.preventRowClick=false;"' : '' )+ '>';
		}
		if(this.oTree.nLabelColumn == i) {
			if(!this.oTree.disableRecalc) this.recalcImages();
			str += '<span>'; //handle and images
			if(this.columnText[3]=='F') {
			  	str += this.sImages + this.sHandle + '<img src="' + (this.sIconSrc ? this.sIconSrc : this.oTree.iconPath + TreeListControlHandler.imgIconFile) + 
					'" width="16" height="16" align="absmiddle">';
			}
			else {	    
			if(this.columnText[3]!='R') {
			str += this.sImages + this.sHandle + '<img src="' + (this.sIconSrc ? this.sIconSrc : this.oTree.iconPath + TreeListControlHandler.imgIconDefault) + '" width="16" height="16" align="absmiddle">';

			}

			}

			str += '</span>&nbsp;';
		}
		str += '<span>' + (this.columnText[i] ? this.columnText[i] : '&nbsp;') + '</span></div>';
		x += c[i].width;
	}
	str += '</div><div id="children' + this.ID + '" class="tlc_node_children" style="display:' + ((this.bShowChildren && this.firstChild) ? 'block' : 'none') + '">';
	var node = this.firstChild;
	while(node) {
		str += node;
		node = node.nextSibling;
	}
	str += "</div></div>";
	this.rendered = true
	return str;
}

TreeListControlNode.prototype.recalcImages = function() {
	var h = TreeListControlHandler;
	this.sImages = '';
	if(this.parentNode) {
		if(this.parentNode.parentNode) {
			this.sImages = this.parentNode.sImages;
			this.sImages += '<img src="' + this.oTree.iconPath +
							(this.parentNode.nextSibling ? h.imgConnectBridge : h.imgEmpty) +
							'" width="16" height="16" align="absmiddle">';

		}
		if(this.firstChild || this.bDynamicNode) {
			if(this.bShowChildren && !this.bDynamicNode) {
				this.sHandle = '<img src="' + this.oTree.iconPath +
								(this.nextSibling ? h.imgHandleCollapseMore : h.imgHandleCollapseEnd) +
								 '" style="cursor:hand;"' +
								' width="16" height="16" align="absmiddle" onmouseenter="TreeListControlHandler.preventRowClick=true;" onmouseleave="TreeListControlHandler.preventRowClick=false;"' +
								' onclick="TreeListControlHandler.callCollapse(' +
								this.oTree.ID + ',' + this.ID + ');">';
			} else {
				this.sHandle = '<img src="' + this.oTree.iconPath +
								(this.nextSibling ? h.imgHandleExpandMore : h.imgHandleExpandEnd) +
								 '" style="cursor:hand;"' +
								' width="16" height="16" align="absmiddle"' +
								' onmouseenter="TreeListControlHandler.preventRowClick=true;"' +
								' onmouseleave="TreeListControlHandler.preventRowClick=false;"' +
								' onclick="TreeListControlHandler.callExpand(' +
								this.oTree.ID + ',' + this.ID + ');">';
			}
		} else {
			this.sHandle = '<img src="' + this.oTree.iconPath +
							(this.nextSibling ? h.imgConnectMore : h.imgConnectEnd) +
							'" width="16" height="16" align="absmiddle">';
		}
	}
	if(this.rendered) {
		var o = document.all['tlcnode'+this.ID].firstChild.childNodes[this.oTree.nLabelColumn].firstChild;
		o.innerHTML = this.sImages + this.sHandle + (this.useIcon ? '<img src="' + (this.sIconSrc ? this.sIconSrc : this.oTree.iconPath + TreeListControlHandler.imgIconDefault) + '" width="16" height="16" align="absmiddle">' : '');
	}
}

TreeListControlNode.prototype.recalcChildImages = function() {
	var node = this.firstChild;
	while(node) {
		node.recalcImages();
		node.recalcChildImages();
		node = node.nextSibling;
	}
}



TreeListControlNode.prototype.expand = function() {
	this.bShowChildren = true;
	var o = document.all['tlcnode' + this.ID];
	o.lastChild.style.display = 'block';
	var id1 = this.oTree.ID;
	var id2 = this.ID;
	if(!this.oTree.disableRecalc) this.recalcImages();
	if(this.bDynamicNode) {
		document.all['tlcnode' + this.ID].firstChild.className = 'tlc_node_row';

		this.bDynamicNode = false;
		var tempnode = new TreeListControlNode(false, this.oTree.iconPath + 'icon.arrow.gif');
		tempnode.setColumnText(this.oTree.nLabelColumn, '<span style="color:#FF6600">Loading...</span>');
		this.add(tempnode);

		this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		var treeid = this.oTree.ID;
		var nodeid = this.ID;
		this.xmlhttp.onreadystatechange = function() { TreeListControlHandler.xmlHTTPStateChange(treeid, nodeid); };
		try {
		this.xmlhttp.open("POST", this.sXMLSrc, true);
		this.xmlhttp.send(null);
		} catch(ex){}
	}
}

TreeListControlNode.prototype.collapse = function() {
	this.bShowChildren = false;
	var o = document.all['tlcnode' + this.ID];
	o.lastChild.style.display = 'none';
	var img = o.childNodes[0].childNodes[this.oTree.nLabelColumn].firstChild.lastChild.previousSibling;
	var id1 = this.oTree.ID;
	var id2 = this.ID;
	img.onclick = function() { TreeListControlHandler.callExpand(id1, id2); return false; };
	img.src = this.oTree.iconPath + (this.nextSibling ? TreeListControlHandler.imgHandleExpandMore : TreeListControlHandler.imgHandleExpandEnd);
}

TreeListControlNode.prototype.click = function() {
	
}

TreeListControlNode.prototype.setText = function() {
	for(var i=0; i<arguments.length; i++)
		this.setColumnText(i, arguments[i]);
}

TreeListControlNode.prototype.setColumnText = function(nColumn, sText) {

	this.columnText[nColumn] = (sText ? sText : '');
	if(this.rendered) {
		var o = document.all['tlcnode' + this.ID];
		o.firstChild.childNodes[nColumn].lastChild.innerHTML = this.columnText[nColumn];
	}
}

TreeListControlNode.prototype.add = function(oNode, bNoRedraw, oSibling, bInsertAfter) {
	if(bNoRedraw) this.oTree.disableRecalc = true;
	this.bDynamicNode = false;
	oNode.oTree = this.oTree;
	oNode.parentNode = this;
	if(oNode.refKey || oNode.refKey == 0) this.oTree.all[oNode.refKey] = oNode;
	this.oTree.allNodes[oNode.ID] = oNode;
	if(!this.firstChild) {
		this.firstChild = oNode;
		this.lastChild = oNode;
	} else {
		var node1, node2;
		if(oSibling) {
			if(bInsertAfter) {
				node1 = oSibling;
				node2 = oSibling.nextSibling;
			} else {
				node1 = oSibling.previousSibling;
				node2 = oSibling;

			}
		} else {
			node1 = this.lastChild;
			node2 = null;

		}
		if(node1) {
			oNode.previousSibling = node1;
			node1.nextSibling = oNode;
		} else {
			this.firstChild = oNode;
		}
		if(node2) {
			oNode.nextSibling = node2;
			node2.previousSibling = oNode;
		} else {
			this.lastChild = oNode;
		}
	}
	if(this.oTree.rendered) {
		var oSib;
		var html = oNode + '';
		var oParent = document.all['tlcnode' + this.ID];
		if(node1) {
			oSib = document.all['tlcnode' + node1.ID];
			oSib.insertAdjacentHTML('afterEnd', html);
		} else if(node2) {
			oSib = document.all['tlcnode' + node2.ID];
			oSib.insertAdjacentHTML('beforeBegin', html);
		} else {
			oParent.lastChild.innerHTML = html;
		}
		if(this.parentNode) this.expand();
		if(!node2 && node1) {
			node1.recalcImages();


			node1.recalcChildImages();
		}
	}
	if(bNoRedraw) this.oTree.disableRecalc = false;
}

TreeListControlNode.prototype.insertBefore = function(oNode, bNoRedraw) {
	this.parentNode.add(oNode, bNoRedraw, this, false);
}

TreeListControlNode.prototype.insertAfter = function(oNode, bNoRedraw) {
	this.parentNode.add(oNode, bNoRedraw, this, true);
}

TreeListControlNode.prototype.remove = function() {
	this.removeChildren();
	var node1 = this.previousSibling;
	var node2 = this.nextSibling;
	if(node1)
		node1.nextSibling = node2;
	else
		this.parentNode.firstChild = node2;
	if(node2)
		node2.previousSibling = node1;
	else
		this.parentNode.lastChild = node1;
	this.oTree.allNodes[this.ID] = null;
	if(this.refKey != null) this.oTree.all[this.refKey] = null;
	var p = document.all['tlcnode' + this.ID].parentElement;
	document.all['tlcnode' + this.ID].removeNode(true);
	if(this.rendered && this.previousSibling && !this.nextSibling) {
		this.previousSibling.recalcImages();
		this.previousSibling.recalcChildImages();
	}
	if(!this.parentNode.firstChild) {
		this.parentNode.recalcImages();


		p.style.display = 'none';
	}
	this.rendered = false;
	this.parentNode = null;
	this.nextSibling = null;
	this.previousSibling = null;
	this.firstChild = null;
	this.lastChild = null;
	return this;
}

TreeListControlNode.prototype.removeChildren = function() {
	var node = this.firstChild;
	while(node) {
		node.removeChildren();
		this.oTree.allNodes[node.ID] = null;
		var dead = node;
		node = node.nextSibling;
		delete dead;
	}
}

TreeListControlNode.prototype.xmlCallback = function() {
	var failed;
	if(this.xmlhttp.readyState == 4)
		if(this.xmlhttp.status==0) {
			var xml = new ActiveXObject("Microsoft.XMLDOM");
			if(xml.loadXML(this.xmlhttp.responseText)) {
				failed = false;
				this.firstChild.remove();
				if(xml.documentElement) {
					this.addXMLChildNodes(xml.documentElement, this);
				}

				this.recalcImages();

			} else {
				failed = true;
			}
		} else {
			failed = true;
		}
		if(failed) {
			this.firstChild.setColumnText(this.oTree.nLabelColumn, '<span style="color:red">Unavailable - ' + this.xmlhttp.status + '</span>');
			this.firstChild.useIcon = false;
			this.firstChild.recalcImages();
		}
}

TreeListControlNode.prototype.addXMLChildNodes = function(xml, oParent) {
	var showchildren, refkey, xmlsrc, onclick, iconsrc;
	if(xml.childNodes.length > 0) {
		var x = xml.lastChild;
		while(x) {

			showchildren = x.getAttribute('showchildren');
			if(!showchildren) showchildren = false;
			else showchildren = (showchildren == 'yes' ? true : false);
			refkey = x.getAttribute('refkey');
			if(!refkey) refkey = null;
			xmlsrc = x.getAttribute('xmlsrc');
			if(!xmlsrc) xmlsrc = null;
			onclick = x.getAttribute('onclick');
			if(!onclick) onclick = null;
			iconsrc = x.getAttribute('iconsrc');
			if(!iconsrc) iconsrc = null;
			var node = new TreeListControlNode(showchildren, iconsrc, xmlsrc, refkey);
			node.onclick = onclick;
			for(var i=0; i<x.childNodes.length-1; i++)
				node.setColumnText(i,x.childNodes[i].firstChild.nodeValue+'');
			if(oParent.firstChild)
				oParent.firstChild.insertBefore(node);
			else
				oParent.add(node);
			if(x.lastChild.childNodes.length > 0)
				this.addXMLChildNodes(x.lastChild, node)
			x = x.previousSibling;
		}
	}
}

/*
	------------------------------
	 Finish JScript TreeListControl v3.0
	------------------------------
	
*/
