////
/// INICIALIZACOES
//

onload = function() {
	window.focus();
	// home
	if(window.location.href.indexOf('content/home',0)!=-1) {
	// internas
	} else {

	}
	AR_ini(); wSt();
	imgCarregar();
}

// preload de imagens
function imgCarregar() {
	var p="../../img/";
	MM_preloadImages('../../img/ar_avcomercial_on.gif','../../img/ar_avcorporativa_on.gif','../../img/ar_avdefesa_on.gif','../../img/ar_avcomercial.gif','../../img/ar_avcorporativa.gif','../../img/ar_avdefesa.gif','../../img/bgr_over_acesso_rapido.gif','../aeronaves/img/img_photo_gallery_on.gif','../aeronaves/img/img_video_on.gif','../aeronaves/img/img_wallpaper_on.gif','../aeronaves/img/img_tour_360_on.gif','../aeronaves/img/img_progress_report_on.gif',p+'blt_portais.gif',p+'itm_portais_com_ovr.gif',p+'itm_invest_ovr.gif',p+'itm_corporate_jets_ovr.gif',p+'itm_portais_def_ovr.gif',p+'itm_portais_gal_ovr.gif',p+'itm_portais_leg_ovr.gif',p+'itm_portais_ri_ovr.gif',p+'txt_rodape_aeronave_on.gif',p+'txt_rodape_downloads_on.gif',p+'txt_rodape_empresa_on.gif',p+'txt_rodape_recursos_on.gif',p+'txt_rodape_sala_imprensa_on.gif',p+'txt_rodape_servicos_on.gif',p+'txt_rodape_usadas_on.gif');
}

// window.status
function wSt(t) {
	var t=(t==null)?'Embraer':'Embraer: '+t;
	window.status=t;
}

// selecao de css
function selecionarCSS(){
	estiloCerto=(document.getElementById)?'ie.css':((document.all)?'ie.css':'ns.css');
	correcaoPath=((document.location+'-').indexOf('/content')!=-1)?'../../':'';
	document.write('<link rel="stylesheet" href="'+correcaoPath+'css/'+estiloCerto+'" type="text/css" />');
}
selecionarCSS();

var objWin;
function wOpen(pURL, pName, w, h, scroll, text, specialSettings){
	if(document.all) if(objWin) { objWin.close(); objWin=null; }
	xLeft=(screen.width)?(screen.width-w)/2:0;
	xTop=(screen.height)?(screen.height-h)/2:0;
	xSettings = 'height='+h+',width='+w+',top='+xTop+',left='+xLeft+',scrollbars='+scroll+specialSettings;
	objWin = window.open(pURL,pName,xSettings);
	if(objWin.window.focus){objWin.window.focus();}
	if(text != "") objWin.document.write(text);
	//ns4
	if(!document.all) objWin.document.close();
	//
	return objWin;
}

////
/// BIBLIOTECA de SCRIPTS COMUNS
//

function KW_updateItems(d,o,fn) { //v2.6 By Paul Davis www.kaosweaver.com

  var i,s,l=MM_findObj(d),b,z=o.options[o.selectedIndex].value;

  l.length=0;
  l.options[0]=new Option('tbd','tbd');
  b=(z!='nill')?eval('a'+z+'_items'):0;
	
  for(i=0;i<b.length;i++){
	  s=b[i].split("|");
	  l.options[i]=new Option(s[1],s[0]);
  }
  l.selectedIndex=0;if (!fn) return;eval(fn)
}

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;
}

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];}}
}

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;
}
function impressao(){
popimpressao = window.open('', '_blank', 'width=650,height=450,left=0,top=0,scrollbars=yes,resizable=no,menubar=no,toolbar=no');

with (popimpressao.document) {
	write('<html><head><title>.: Embraer :.</title><style type="text/css"> .hide {	visibility: hidden;}</style></head>');
	write('<link rel="stylesheet" href="../../css/ie.css" type="text/css">');
	write('<body  leftmargin="10" topmargin="10" marginwidth="0" marginheight="0" style="background:none;">');
	write(document.getElementById("impressao").innerHTML);
	write('</body></html>');
	close();
	}
       popimpressao.print();
}
var nivel = '';
function popups(pg,nome,fs,w,h,rolagem) {
	if(fs) { // fullscreen
		var w=screen.availWidth,h=screen.availHeight;
		var winObj = window.open(pg,nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left=0,top=0');
		with(winObj) { moveTo(0,0); resizeTo(w,h); focus(); }
	} else { // popup normal
		var winObj=window.open(pg,nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.width-w)/2)+-10)+',top='+(((screen.height-h)/2)+-30));
		winObj.focus();
	}
}
function abreDentro() {	window.top.document.location="http://mediamanager.embraer.com.br/english" }
function abrePLegacy() { window.top.document.location="http://www.legacybyembraer.com/english"; }
function popCentro(url,w,h,param) {
  var x=window.open(url,'_blank','width='+w+',height='+h+','+param+',left='+(((screen.width-w)/2)+-10)+',top='+(((screen.height-h)/2)+-30));
}

// Função para aceitar apenas números em campos texto
function soNumeros(e){
     var key;
     var keychar;

     if (window.event) {
        key = window.event.keyCode;
     } else if (e) {
        key = e.which;
     } else {
        return true;
     }

     keychar = String.fromCharCode(key);

     // teclas de controle
     if ((key==null) || (key==0) || (key==8) ||
          (key==9) || (key==13) || (key==27) ) {
        return true;
     } else if ((("0123456789").indexOf(keychar) > -1)) {
        return true;     
     } else {
        return false;
     }
}




//função alterada
function checkDate(valueFields){
	var checkstr = "0123456789";
	var DateTemp = "";
	var day;
	var month;
	var year;
	var leap = 0;
	var err = 0;
	var i;
	var strDataMsg = "";
	var curdate = new Date();
	var yearDate = curdate.getFullYear();
  
	err = 0;
	DateValue = valueFields;
     /* Delete all chars except 0..9 */
     for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
		 DateTemp = DateTemp + DateValue.substr(i,1);
	  }
     }
     DateValue = DateTemp;
     /* Always change date to 8 digits - string*/
     /* if year is entered as 2-digit / always assume 20xx */
     if (DateValue.length == 6) {
	  DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
     if (DateValue.length != 8) {
	  err = 19;
	  strDataMsg = " • Invalid date.";		  
	}
  
     /* year is wrong if year = 0000 */
     year = DateValue.substr(4,4);
     if (year == 0) {
	  err = 20;
	  strDataMsg = " • Invalid year.";
     }

     if (year >= yearDate) {
	  err = 18;
	  strDataMsg = " • Invalid year.";
     }


     /* Validation of month*/
     month = DateValue.substr(2,2);
     if ((month < 1) || (month > 12)) {
	  err = 21;
	  strDataMsg = " • Invalid month.";
     }
  
     /* Validation of day*/
     day = DateValue.substr(0,2);
     if (day < 1) {
	 err = 22;
	 strDataMsg = " • Invalid day.";
     }
  
     /* Validation leap-year / february / day */
     if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
	  leap = 1;
     }
     if ((month == 2) && (leap == 1) && (day > 29)) {
	  err = 23;
	  strDataMsg = " • The month has more than 29 days.";
     }
     if ((month == 2) && (leap != 1) && (day > 28)) {
	  err = 24;
	  strDataMsg = " • The month has more than 28 days.";
     }
     /* Validation of other months */
     if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
	  err = 25;
	  strDataMsg = " • The month has more than 31 days.";
     }
     if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
	  err = 26;
	  strDataMsg = " • The month has more than 30 days.";
     }
     /* if 00 ist entered, no error, deleting the entry */
     if ((day == 0) && (month == 0) && (year == 00)) {
	  err = 0; day = ""; month = ""; year = ""; 
     }
     
	 /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
	 if (err == 0) {
		return '';
	 } else {	  
		return strDataMsg + "\n";
	 }
  }
  
  function Organiza_Casa(Campo,arrpos,teclapres_key,strtext){
	if (((arrpos == "/") || (arrpos == ".") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 8)){
		separador = arrpos
		masktext = strtext + separador
		Campo.value = masktext
	}
  }
  function Detona_Event(Campo,strtext){
	event.returnValue = false
	if (strtext != "") {
		Campo.value = strtext
	}
  }