
////
/// INICIALIZACOES
//

function aoCarregar() {
	window.focus();
		
	// # css
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);

	// # home
	if(window.location.href.indexOf('content/home',0)!=-1) {
	// # internas
	} else {

		// # ajusta largura dhtml
		if(document.getElementById("imglnk")) {
			//alert(document.getElementById("submenu").getElementsByTagName("a").length);
			var img = new Image();
			img.src = document.getElementById("imglnk").src;
			var w = img.width;
			
			var tagA = document.getElementById("submenu").getElementsByTagName("a")
			for(var i=0; i<tagA.length; i++) {
				tagA[i].style.width=w+"px";
				//alert(tagA[i].style.width);
			}
		}

	}
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

// Função Popup: <a href="arquivo.ext" onclick="popup(this.href,'360','535','1'); return false;"></a>
function popup(url,w,h,s) {
	var oW=window.open(url,'popup','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.availWidth-w)/2)+-10)+',top='+(((screen.height-h)/2)+-10));
}

//Troca imagens do Zoom
function overzoom(opcao,id){
	if (opcao == 1){
		document.getElementById("lupa"+id).src = "../../img/btn_zoom_over.gif";	
		document.getElementById("barra_lupa"+id).src = "../../img/img_bkg_zoom_over.gif";	
	}
	else{
		if (opcao == 0){
		document.getElementById("lupa"+id).src = "../../img/btn_zoom.gif";	
		document.getElementById("barra_lupa"+id).src = "../../img/img_bkg_zoom.gif";
		}
	}
	
	if (opcao == 2){
		document.getElementById("lupa"+id).src = "../../img/btn_zoom_b_over.gif";	
		document.getElementById("barra_lupa"+id).src = "../../img/img_bkg_zoom_over.gif";
	}
	else{
		if (opcao == 3){
		document.getElementById("lupa"+id).src = "../../img/btn_zoom_b.gif";	
		document.getElementById("barra_lupa"+id).src = "../../img/img_bkg_zoom.gif";
		}		
	}
}

// Função Popup com Resize do tamanho da imagem
var ImgGrande=[];
var Txt=[];
var Legenda=[];
var ImgTtl=[];

function popup_img(id){
	var w = ImgGrande[id].width;
	var h = ImgGrande[id].height;
	var x = h;
		
	var shtml = '';
	
	shtml = shtml + '<html><head><title>Indústria Aeronáutica Neiva</title>';
	shtml = shtml + '<script src="../../js/default.js" type="text/javascript"></script>';
	shtml = shtml + '<script src="../../js/ag2dhtml.js" type="text/javascript"></script>';
	shtml = shtml + '<script src="../../js/css.js" type="text/javascript"></script>';
	shtml = shtml + '<link rel="stylesheet" href="../../css/default.css" type="text/css"></head>';
	shtml = shtml + '<body bgcolor="#0E2D1C"><div style="background:#FFFFFF;padding:10px 0 10px 0;">';
	
	if ( ImgTtl[id] != undefined ){
		shtml = shtml + '<div style="margin-left:20px;"><img alt="" border="0" src="' + ImgTtl[id] + '" /><br /><img alt="" border="0" src="../../img/pix.gif" width="1" height="10" /><br /></div>';
		x = x + 21;
	}
			
	shtml = shtml + '<table cellpadding="0" cellspacing="0" border="0" style="margin:0 10px 0 10px;" align="center"><tr><td style="background:#E4E3E4;padding:10px;">';
	shtml = shtml + '<table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="3" bgcolor="#919191"><img alt="" border="0" src="../../img/pix.gif" width="1" height="1" />';
	shtml = shtml + '</td></tr><tr><td bgcolor="#919191"><img alt="" border="0" src="../../img/pix.gif" width="1" height="1" /></td><td>';
	shtml = shtml + '<img alt="" src="' + ImgGrande[id].src + '" height="' + h + '" width="' + w + '">';
	shtml = shtml + '</td><td bgcolor="#DFDFDF" valign="top"><img alt="" border="0" src="../../img/img_zoom_right_top.gif" width="1" height="3" /></td></tr><tr><td colspan="3" bgcolor="#DFDFDF"><img alt="" border="0" src="../../img/img_zoom_left_bottom.gif" width="4" height="1" /></td></tr>';
	shtml = shtml + '</table></td></tr></table>';
	
	h = x;
	
	if (Legenda[id] != undefined ){
		shtml = shtml + '<div align="center" class="txtmaior" style="margin-top:10px;height:15px;width:' + w + 'px">' + Legenda[id] + '</div>';
		h = h + 25;
	}
	else
		if (Txt[id] != undefined ){
			shtml = shtml + '<div class="txtmaior" style="margin-top:10px;margin-left:20px;height:45px;width:' + w + 'px">' + Txt[id] + '</div>';
			h = h + 57;
		}	
	
	shtml = shtml + '</div><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td height="7" bgcolor="#E4E3E4"><img src="../../img/pix.gif" alt="" width="1" height="1" border="0" /></td></tr><tr><td height="39" valign="top" bgcolor="#0E2D1C" align="right" style="padding:9px 20px 0 0;"><a href="javascript:window.close();"><img src="../../img/btn_fechar.gif" alt="" width="55" height="17" border="0" /></a></td></tr></table>';
	shtml = shtml + '</body></html>';	
	
	w = w + 42;
	h = h + 95;
	
	wOpen('','_blank',w,h,0,shtml,',status=yes');
}

//Função para impressão
function imprimir(){
	var h = document.getElementById("noticia").offsetHeight;
	h = h + 220;
	popimpressao = window.open('', '_blank', 'width=600,height='+ h +',left=0,top=0,scrollbars=yes,resizable=no,menubar=no,toolbar=no');
	
	with (popimpressao.document) {
		var curdate = new Date();
		var dia = curdate.getDate();
		var mes = curdate.getMonth() + 1;
			if (mes < 10)
				mes = '0' + mes;
		var ano = curdate.getYear();
		var data = dia + '/' + mes + '/' + ano;
		
		var url = document.location.href;
		
		write('<html><head><title></title><style type="text/css" media="print">.botaoimpressao{display:none;}</style></head>');
		write('<link rel="stylesheet" href="../../css/default.css" type="text/css">');
		write('<link rel="stylesheet" href="../../css/print.css" type="text/css">');
		write('<body>');
		write('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td height="1%">');
		write('<table cellpadding="0" cellspacing="0" border="0" width="100%">');
		write('<tr><td height="58" style="background: url(../../img/bgr_topo_pop_impresao.gif) top left repeat-x;"></td><td colspan="2" style="background: url(../../img/bgr_topo_pop_impresao.gif) top left repeat-x;"><img alt="" src="../../img/img_logo_neiva_menor.gif" /></td></tr>');
		write('<tr><td width="50%"></td><td style="padding:30px 0 30px 0;">');
		write(document.getElementById("noticia").innerHTML);
		write('</td><td width="50%"></td></tr>');
		write('<tr><td></td><td height="46" style="background: url(../../img/pix_DEDDDE.gif) top left repeat-x;">');
		write('<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td class="txtpretomenor">Impresso em ' + data + '</td></tr><tr><td class="txtpretomenor">Disponível em ' + url + '</td></tr></table>');
		write('</td><td></td></tr></table>');
		write('</td></tr><tr><td height="99%" valign="top" bgcolor="#0E2D1C">');
		write('<table class="botaoimpressao" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td height="7" bgcolor="#E4E3E4"><img src="../../img/pix.gif" alt="" width="1" height="1" border="0" /></td></tr><tr><td height="44" valign="top" bgcolor="#0E2D1C" align="right" style="padding:9px 20px 0 0;"><a href="javascript:window.close();"><img src="../../img/btn_fechar.gif" alt="" width="55" height="17" border="0" /></a></td></tr></table>');
		write('</td></tr></table>');		
		write('</body></html>');
		close();
		}
        popimpressao.print();
}


// ## Funcao generica para popups
var objWin;
function wOpen(sURL, sName, nW, nH, bScroll, sTxt, sXtras) {
	if(objWin) { objWin.close(); objWin=null }
	// # define W x H
	xLeft=(screen.width)?(screen.width-nW)/2:0; xTop=(screen.height)?(screen.height-nH)/2:0;
	// # configuracoes
	xSettings = 'width='+nW+',height='+nH+',top='+xTop+',left='+xLeft+',scrollbars='+bScroll+sXtras;
	objWin = window.open('about:blank',sName,xSettings);
	// # tela-cheia
	if((nW==screen.availWidth) && (nH==screen.availHeight) || (nW==screen.width) && (nH==screen.height))
			if(objWin){ if(objWin.moveTo)objWin.moveTo(0,0); if(objWin.resizeTo)objWin.resizeTo(nW,nH); if(objWin.window.focus)objWin.window.focus(); }
	// # URL
	if(sURL) objWin.document.location.href=sURL;
	// # texto
	if(sTxt!="") objWin.document.write(sTxt);
	// #ns4
	if(!document.all) objWin.document.close();
	//
	return objWin;
}

// ## precarga de imagens
function imgCarregar() {
	var p="../../img/";
	MM_preloadImages(p+'btn_caminho_pao_a_menos_on.png',p+'btn_caminho_pao_a_mais_on.png',p+'img_caminho_pao_seta_drop_on.gif',p+'btn_zoom_destaque_on.gif',p+'btn_destaques_n01_on.gif',p+'btn_destaques_n02_on.gif',p+'btn_destaques_n03_on.gif');
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// preload de imagens
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
MM_preloadImages('../../img/btn_zoom_over.gif','../../img/img_bkg_zoom_over.gif','../../img/btn_zoom.gif','../../img/img_bkg_zoom.gif');

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}