window.onload = function(){};
function registerOnload(newFunction){
	var curWinOnload = window.onload;

	if(typeof window.onload != 'function'){
		window.onload = newFunction;
	}
	else{
		window.onload = function(){
			curWinOnload();
			newFunction();
		};
	}
}

/* TIRA A BORDA DOS FLASHS
Copyright 2006 Adobe Systems, Inc. All rights reserved.
Versão compacta, alterada por Renato Herculano
	- src, width e height são obrigatórios
	- os demais parametros são opcionais
*/


function flash(src, width, height, id, flashVars, wmode, menu, scale, title){
	var ret = GetArgumentos(src, width, height, id, flashVars, wmode, menu, scale, title);
	var str = '<object ';
	for (var i in ret.objAttrs)
		str += i + '="' + ret.objAttrs[i] + '" ';
		str += '>';
	for (var i in ret.params)
		str += '<param name="' + i + '" value="' + ret.params[i] + '" /> ';
		str += '</object>';
	document.write(str);
}

function GetArgumentos(src, w, h, id, flashVars, wmode, menu, scale, title){
	var ret = new Object();
	ret.params = new Object();
	ret.objAttrs = new Object();

	ret.objAttrs['data'] = ret.params["movie"] = src;
	ret.objAttrs['width'] = w;
	ret.objAttrs['height'] = h;
	ret.params['quality'] = 'high';
	ret.objAttrs['type'] = 'application/x-shockwave-flash';
	ret.params['menu'] = 'false';
	ret.objAttrs['title'] = (title) ? title : '';
	if(id) ret.objAttrs['id'] = id;
	
	if(flashVars) ret.params['flashVars'] = flashVars;
	
	ret.params['wmode'] = (wmode)? wmode : 'transparent';
	ret.params['scale'] = (scale)? scale : 'exactfit';
	ret.params['menu'] = (menu)? menu : 'false';
	//ret.params['title'] = (title) ? title : '';
	return ret;
}

//video(): insere um video na página
//	- src, width e height são obrigatórios
//	- os demais parametros são opcionais
function video(src, width, height, id, showControls, autoStart, loop, showstatusbar){
	var str = '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&amp;sbp=mediaplayer&amp;ar=Media&amp;sba=Plugin&amp;"';
	str += ' src="'+ src + '"';
	str += ' width="'+width+'"';
	str += ' height="'+height+'"';
	if(id)
		str += ' id="'+id+'"';
	if(showControls)
		str += ' showControls="'+showControls+'"';
	if(autoStart)
		str += ' autostart="'+autoStart+'"';
	if(loop)
		str += ' loop="'+loop+'"';
	if(showstatusbar)
		str += ' showstatusbar="'+showstatusbar+'"';
	str += "></embed>";
	document.write(str);
}


// Imprime tabela ciclo mestrual
function imprimeTabela(){
	janela = window.open('/tabela.asp','imprime','width=10, height=10');
}

// retreiving stylesheets (cross browser)
function getAllSheets() {
  if( !window.ScriptEngine && navigator.__ice_version ) { return document.styleSheets; }
  if( document.getElementsByTagName ) { var Lt = document.getElementsByTagName('link'), St = document.getElementsByTagName('style');
  } else if( document.styleSheets && document.all ) { var Lt = document.all.tags('LINK'), St = document.all.tags('STYLE');
  } else { return []; } for( var x = 0, os = []; Lt[x]; x++ ) {
    var rel = Lt[x].rel ? Lt[x].rel : Lt[x].getAttribute ? Lt[x].getAttribute('rel') : '';
    if( typeof( rel ) == 'string' && rel.toLowerCase().indexOf('style') + 1 ) { os[os.length] = Lt[x]; }
  } for( var x = 0; St[x]; x++ ) { os[os.length] = St[x]; } return os;
}

/* ===-- FontSizer --=== */
function FontSize(idx, cssLinkId, controlImgSrc){
	this.idx = idx;
	this.cssLinkId = cssLinkId;
	this.controlImgSrc = controlImgSrc;
	this.cssLink = null;
	FontSize.prototype.initialize = function(){
		this.cssLink = document.getElementById(this.cssLinkId);
	}
	FontSize.prototype.enable = function(){
        //alert(getAllSheets());
		// alert("FontSize.enable:\nlink: " + this.cssLink);
        //alert(this.idx);
        
        // loop trough all available styleseets and simple disable - no switch of rel!!!
        for( var x = 0, ss = getAllSheets(); ss[x]; x++ ) {
             if( ss[x].title ) {
//                alert(ss[x].title);
                ss[x].disabled = true;
                //ss[x].rel = "alternate stylesheet";
             }
        }
        
         // now active the correct one, only way it to make it run in safari too,
         // all other browsers work like they did before...
         for( var x = 0, ss = getAllSheets(); ss[x]; x++ ) {
             if( ss[x].title ) {
                if( ss[x].title == this.cssLinkId) {
                    //alert(ss[x].title);
                    ss[x].disabled = false;
                    //ss[x].rel = "stylesheet";
                }
             }
        }
        
        return false;
        
		if(this.cssLink != null){
			this.cssLink.removeAttribute("disabled");
			this.cssLink.disabled = false;
			this.cssLink.rel = "stylesheet";
		}
		//this.debug();
	};
	FontSize.prototype.disable = function(){
        return;
		//alert("FontSize.disable:\nlink: " + this.cssLink);
		if(this.cssLink != null){
			this.cssLink.setAttribute("disabled", "disabled");
			this.cssLink.disabled = true;
			this.cssLink.rel = "alternate stylesheet";
		}
		//this.debug();
	};
	FontSize.prototype.debug = function(){
		alert(
				"FoneSize(" + this.idx + "):\n" +
				"disabled: " + this.cssLink.getAttribute("disabled") + "\n" +
				"disabled: " + this.cssLink.disabled + "\n" +
				"rel: " + this.cssLink.rel + "\n" +
				"\n" +
				"caller: " + FontSize.prototype.debug.caller
		);
	};
}
var FontSizer = {
	currentFontSizeIdx: 100,
	CurrentFontSize: null,
	FontSizes: new Array(),
	controlId: null,
	init: function(FontSizes, currentFontSizeIdx, controlId){
		this.FontSizes = FontSizes;
		this._initilizeFontSizes();
		this.currentFontSizeIdx = currentFontSizeIdx;
		this.controlId = controlId;
		this.set(this.currentFontSizeIdx);
	},
	add: function(dif){
		var newFontSizeIdx = this.currentFontSizeIdx + dif;
		this.set(newFontSizeIdx);
	},
	set: function(fontSizeIdx){
		
		// alert("set fontSizeIdx="+ fontSizeIdx);
		var NewFontSize = this._getFontSizeByIdx(fontSizeIdx);
		if(this.currentFontSizeIdx != fontSizeIdx && NewFontSize != null) {
			
			if(this.CurrentFontSize != null){
				
				if(this.CurrentFontSize.idx < NewFontSize.idx){
					NewFontSize.enable();
					this.CurrentFontSize.disable();
				} else{
					this.CurrentFontSize.disable();
					NewFontSize.enable();
				}
			} else{
				NewFontSize.enable();
			}
			this.currentFontSizeIdx = fontSizeIdx;
			this.CurrentFontSize = NewFontSize;
						
			
			// alert("1 NewFontSize="+ NewFontSize.idx +" myImg="+ myImg.src);	

			this._adjustControl();
		}
		//this.debug();
	},
	_initilizeFontSizes: function(){
		for(var i = 0; i < this.FontSizes.length; i++){
			this.FontSizes[i].initialize();
		}
	},
	_getFontSizeByIdx: function(idx){
		var _FontSize = null;
		for(var i = 0; i < this.FontSizes.length; i++){
			if(this.FontSizes[i].idx == idx){
				_FontSize = this.FontSizes[i];
				break;
			}
		}
		return _FontSize;
	},
	_adjustControl: function(){
		var Control = document.getElementById(this.controlId);
		if(Control) {		
			Control.src = this.CurrentFontSize.controlImgSrc;
		}
	},
	debug: function(){
		for(var i = 0; i < this.cssLinks.length; i++){
			var link = this.cssLinks[i];
			alert("id: " + link.id + "\ndisabled: " + link.getAttribute("disabled"));
		}
	}
}


var fontSize1 = new FontSize(1, "size1", "/Configuracao/images/fonte_1.gif");
var fontSize2 = new FontSize(2, "size2", "/Configuracao/images/fonte_2.gif");
var fontSize3 = new FontSize(3, "size3", "/Configuracao/images/fonte_3.gif");


function initFontSizer(){
	FontSizer.init(new Array(fontSize1,fontSize2,fontSize3), 1, "fontsizerControl");
}


//SCRIPT COMBOBOX EM TARGET BLANK
function selectLink(selObj, taregtself) {
	 if(taregtself) {
	 	location.href=selObj.options[selObj.selectedIndex].value
	 } else {
		 popUp = window.open(selObj.options[selObj.selectedIndex].value,'NewWindow','toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes');	 
	}
	 selObj.selectedIndex=0;
}


//SCRIPT MENU SUPERIOR

startList = function() {

if (document.all||document.getElementById) {

navRoot = document.getElementById("lista");
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", "out");
   }
   }
  }
 }
}

function RedimensionarDestaques(){
		
	var IE = (navigator.appName == 'Microsoft Internet Explorer');
	
	for(x=0; x < document.getElementsByTagName('div').length; x++){
	
		// Obtém todas as DIV´s de destaque
		if(document.getElementsByTagName('div')[x].id.indexOf('destaque_') == 0){
			
			// id do destaque
			var id = document.getElementsByTagName('div')[x].id.substring(9);
			
			// Tamanho da imagem do destaque
			var width = document.getElementById('image_' + id).width;
			
			if (IE){
				document.getElementById('destaque_' + id).style.width = width;
			}else{
				/*
				document.getElementById('destaque_' + id).width = 100px;
				var elt = document.getElementById('destaque_' + id).style;
				for (x in document.getElementById('destaque_' + id).style){
					if (x.indexOf('Width') != -1 )
						out += "  " + x + " - ";
				}
				alert(out); */
			}
		}
	}
}

registerOnload(initFontSizer);
registerOnload(startList);


  //SCRIPT PARA ESCONDER O SELECT


function escondeSelects(iframe){
	if(iframe.document.getElementById('conteudoIFrame')){
		var selects = iframe.document.getElementById('conteudoIFrame').getElementsByTagName('select');
		for(var i = 0; i < selects.length; i ++)
			selects[i].style.visibility = 'hidden';
	}
}
	
function voltaSelects(iframe){
	if(iframe.document.getElementById('conteudoIFrame')){
		var selects = iframe.document.getElementById('conteudoIFrame').getElementsByTagName('select');
		for(var i = 0; i < selects.length; i ++)
			selects[i].style.visibility = 'visible';
	}
}

function escondeComboFrame(){
	for(var i = 0; i < document.frames.length; i ++)
		escondeSelects(document.frames[i])
}


function voltaComboFrame(){
	for(var i = 0; i < document.frames.length; i ++)
		voltaSelects(document.frames[i])
}

