var isNav = (navigator.appName.indexOf("Netscape") !=-1)

function ajax()
{  
    if(navigator.appName == 'Microsoft Internet Explorer') {
  http = new ActiveXObject('Microsoft.XMLHTTP');
  } else {
  http = new XMLHttpRequest();
 }  
 return http;
}

function CargaApplet()
{
		var ms;
        Today = new Date();
        ms = Today.getMilliseconds();         
        var params = "x="+ms;        
       // alert(params);
        var url = "http://www.euroamerica.cl/portalmf/analisisECB.aspx?";        
        var div = document.getElementById('div_applet');
		var request = new ajax();
        request.open("POST",url,true);
        request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
        request.onreadystatechange  = function() {
        if (request.readyState == 1)
            {
                div.innerHTML = "<center><img src=../img/cargando.gif /></center>";
            }
            
        if (request.readyState == 4)
        {
       // alert(request.responseText);
            if (request.status == 200)
                {
                    var respuesta = request.responseText;
                    div.innerHTML = respuesta;
                    request = null;    
                    
                }            
                else
                {  
                    alert('error status: ' + request.status ); 
                    return                           
                }                            
        }    
        }
		request.send(params);    
}		





/*
function ver_loginp()
{
	document.getElementById('divLoginPersona').style.display = 'block';
}

function ver_loginemp()
{
	document.getElementById('divLoginEmpresas').style.display = 'block';
}

function ver_serg_corp()
{
	document.getElementById('divLoginSegCorp').style.display = 'block';
}

function ver_emp_ffmm()
{
	document.getElementById('divLoginFFMMEcb').style.display = 'block';
}

function ver_emp_fac()
{
	document.getElementById('divLoginFactoring').style.display = 'block';
}
*/


function  clearForms()
{
    try
    {
    
    document.getElementById('username').value ='';
    document.getElementById('clave_col').value ='';
    document.getElementById('rut_ffmm').value ='';
    document.getElementById('codigo_ffmm').value ='';
    document.getElementById('clave_ffmm').value ='';
    document.getElementById('rut_fac').value ='';
    document.getElementById('codigo_fac').value ='';
    document.getElementById('clave_fac').value ='';
    document.getElementById('rut_p').value ='';
    document.getElementById('codigo_p').value ='';
    document.getElementById('clave_p').value ='';    
    }
    catch(err)
    {
    
    }
   
}


function fncPressEnter(e)
{
var keynum
var keychar
var numcheck
if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
keychar = String.fromCharCode(keynum)

if (keynum == 13)
{
return true;
}
else
{
	return false;
}

}


function loginEnter(e,login)
{
	if (fncPressEnter(e))
	{
		switch(login)
		{
			case "personas":
			//valida login personas
			ValidaCampos();
			break;
			
			case "seg_corp":
			//valida seguros corporativos
			SubmitPageCol();
			break;
			
			case "ffmm_ecb":
			//valida ffmm - ecb
			ValidaCamposFFMMECB();
			break;
			
			case "factoring":
			//valida factoring
			ValidaCamposFacoring();
			break;
			
		}
	
	}
	else
	{
		return false;
	}
}


function OnkeyPressAlfa(keyStroke)
{
	keyHit = (isNav) ? keyStroke.which : event.keyCode;
	if ((keyHit != 32) && 
	    (keyHit<97 || keyHit>122) && 
	    (keyHit<65 || keyHit>90))
	{	
			window.event.keyCode =null 
			window.event.returnValue=false
	}
}	

function hideLevel( _levelId) {
	var thisLevel = document.getElementById( _levelId );
	thisLevel.style.display = "none";
	}
function showLevel( _levelId) {
	var thisLevel = document.getElementById( _levelId );
	if ( thisLevel.style.display == "none") {
		hideAll();
		thisLevel.style.display = "block";
		}	
	else {
		hideLevel( _levelId);		
		}		
	}

function validate(emailad) {
var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
var check=/@[\w\-]+\./;
var checkend=/\.[a-zA-Z]{2,3}$/;
	if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1))
{
 return true
  }
 else  return false
}
function verifydigit(texto)
{
  largo = texto.length;
  for (i=0; i < largo ; i++ )
    {
   if ( texto.charAt(i) != "0" && 
        texto.charAt(i) != "1" && texto.charAt(i) != "2" && 
        texto.charAt(i) != "3" && texto.charAt(i) != "4" && 
        texto.charAt(i)!= "5" && texto.charAt(i) != "6" && 
        texto.charAt(i) != "7" && texto.charAt(i)!= "8" && 
        texto.charAt(i) != "9" && texto.charAt(i)!= "-")
        {
          return false;
        }
    }
    return true;
}
function verifyrut(rut, dv)
{
  var dvr = '0'
  var midv= dv.toUpperCase()
  suma = 0
  mul  = 2
 for (i= rut.length-1; i >= 0; i--)
    {
      suma = suma + parseInt(rut.charAt(i)) * mul
        if (mul == 7)
          mul = 2
        else
          mul++
   }
  res = suma % 11
  if (res==1)
  dvr = 'k'
  else if (res==0)
    dvr = '0'
 else
    {
      dvi = 11-res
      dvr = dvi + ""
    }
  if ( dvr != midv.toLowerCase() )
    { return false; }
  else
    { return true }
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0
  var obj=MM_findObj(objStr);
  if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');
}
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_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];}
}
var submitcount=0;

function conta() {
   if (submitcount == 0)
      {
      submitcount++;
      return true;
      }
   else 
      {
      alert("Los datos del formulario se están procesando..");
      return false;
      }
   }
/*function enviar_amigo(pagina)
{
	document.carga_nivel.action = pagina
	document.carga_nivel.submit()
}*/
function enviar_amigo(pagina)
{
	//page = "<%=pagina_envio%>";
	var getURL= document.URL
	window.open('enviar_amigo.asp?pagina='+getURL+'','','width=450,height=500,left=100,top=100')
}
function imprimir(pagina,pagina_imprime)
{
	//page = "<%=pagina_envio%>";
	window.open(''+pagina_imprime+''+pagina+'','imprimir','width=620,height=500,left=100,top=100')
}
function carga_pagina(pagina,n1,n2,n3,n4,n5)
{
	document.carga_nivel.Id_Nivel1.value=n1
	document.carga_nivel.Id_Nivel2.value=n2
	document.carga_nivel.Id_Nivel3.value=n3
	document.carga_nivel.Id_Nivel4.value=n4
	document.carga_nivel.Id_Nivel5.value=n5
	document.carga_nivel.Ver_Todo.value=""
	document.carga_nivel.action = pagina
	document.carga_nivel.submit()
}
function carga_pagina_noti(pagina,n1,n2,n3,n4,n5,noti)
{
	document.carga_nivel.Id_Nivel1.value=n1
	document.carga_nivel.Id_Nivel2.value=n2
	document.carga_nivel.Id_Nivel3.value=n3
	document.carga_nivel.Id_Nivel4.value=n4
	document.carga_nivel.Id_Nivel5.value=n5
	document.carga_nivel.noti.value=noti
	document.carga_nivel.Ver_Todo.value=""	
	document.carga_nivel.action = pagina
	document.carga_nivel.submit()
}
function carga_pagina_publica(pagina,noti)
{
	document.carga_nivel.noti.value=noti
	document.carga_nivel.Ver_Todo.value=""	
	document.carga_nivel.action = pagina
	document.carga_nivel.submit()
}
function carga_pagina_t()
{
	document.carga_nivel.Ver_Todo.value=1
	document.carga_nivel.submit()
}
function faq()
{
//	document.carga_nivel.method= "GET"
	document.carga_nivel.action = "faqs.asp"
	document.carga_nivel.submit()
}
function condicionado()
{
	document.carga_nivel.action = "condicionados.asp"
	document.carga_nivel.submit()
}
function reglamento()
{
	document.carga_nivel.action = "reglamentos.asp"
	document.carga_nivel.submit()
}
function factsheet()
{
	document.carga_nivel.action = "factsheet.asp"
	document.carga_nivel.submit()
}
function complemento()
{
	document.carga_nivel.action = "complementos.asp"
	document.carga_nivel.submit()
}
function ejemplo()
{
	document.carga_nivel.action = "ejemplos.asp"
	document.carga_nivel.submit()
}
function contratelo()
{
	document.carga_nivel.action = "contratelos.asp"
	document.carga_nivel.submit()
}
function noticias_vf(pagina,id)
{
	document.carga_nivel.action = pagina+"?id="+id
	document.carga_nivel.submit()
}
function productos(id,tipo)
{
	document.carga_nivel.Id_Producto.value = id
	document.carga_nivel.Tipo.value = tipo
	document.carga_nivel.action = "productos.asp"
	document.carga_nivel.submit()
}
function bajar_archivos(donde,archivo)
{
	document.location.href='download.asp?carpeta='+donde+'&id_archivo='+archivo+'';
}
function zona_interactiva()
{
	window.open('zona_interactiva.asp','interactiva','scrollbars=1,width=580,height=500,left=100,top=100')
}
function te_informa()
{
	window.open('te_informa.asp','informa','scrollbars=1,width=580,height=500,left=100,top=100')
}

function Trim(strTxt)
	{
	pos1 = 0;
	pos2 = strTxt.length-1;
	for (i=0; i<strTxt.length; i++)
	{
		if (strTxt.charAt(i) == ' ') pos1 = pos1 + 1;
		else break;
	}
	if (pos1 != (pos2+1))
		for (i=strTxt.length-1; i>0; i--)
		{
			if (strTxt.charAt(i) == ' ') pos2 = pos2 - 1
			else break;
		}
	return strTxt.substring(pos1,pos2+1);
	}

function validaFono(strCadena)
	{
	    var plant = strCadena.match(/(\d{0,2})(\-*)(\d{6,7})/gi);
	    if (strCadena!=plant)
	                return false;
	    else
	                 return true;
	}	
	
	
function openpdf(URL)
{		
	window.open(URL,'win_pdf','resizable=yes,toolbar=0,menubar=0,width=500,height=500,left=0,top=0');
}

function acceso_on()
{
	document.getElementById("acces01").style.display = "none";
	document.getElementById("acces02").style.display = "block";
}
function acceso_off()
{
	document.getElementById("acces01").style.display = "block";
	document.getElementById("acces02").style.display = "none";
}
function ver_acceso(nu)
{
	
	if(nu == 1)
	{
	document.getElementById("acceso").style.display = "none";
	document.getElementById("teclado1").style.display = "block";
	}
	else if(nu == 2)
	{
	if (document.getElementById("divLoginPersona") != null)
	{
		document.getElementById('divLoginPersona').style.display = 'none';
	}
	else
	{
	document.getElementById("acceso").style.display = "block";
	//document.getElementById("corredo").style.display = "block"
	document.getElementById("teclado1").style.display = "none";
	document.getElementById("teclado2").style.display = "none";
	document.getElementById("teclado3").style.display = "none";
	document.getElementById("teclado4").style.display = "none";
	}
	}
	else if(nu == 3)
	{
	document.getElementById("acceso").style.display = "none";
	document.getElementById("teclado2").style.display = "block";
	}
	else if(nu == 4)
	{
	document.getElementById("acceso").style.display = "none";
	document.getElementById("teclado4").style.display = "block";
	}
	else if(nu == 5)
	{
		document.getElementById('divLoginEmpresas').style.display = 'none';
	}
	else if(nu == 6)
	{
		document.getElementById('divLoginSegCorp').style.display = 'none';
	}
	else if(nu == 7)
	{
		document.getElementById('divLoginFFMMEcb').style.display = 'none';
	}	
	else if(nu == 8)
	{
		document.getElementById('divLoginFactoring').style.display = 'none';
	}
}
function ver_acceso1(nu)
{
	if(nu == 1)
	{
	document.getElementById("corredo").style.display = "none";
	document.getElementById("teclado3").style.display = "block";
	}
}

function FDK_setFormText(form,name,text) {
  textobject = eval('document.'+form+'.'+name);
  textobject.value = text;
}
function getOffsets (evt) {
  var target = evt.target;
  if (typeof target.offsetLeft == 'undefined') {
    target = target.parentNode;
  }
  var pageCoords = getPageCoords(target);
  var eventCoords = { 
    x: window.pageXOffset + evt.clientX,
    y: window.pageYOffset + evt.clientY
  };
  var offsets = {
    offsetX: eventCoords.x - pageCoords.x,
    offsetY: eventCoords.y - pageCoords.y
  }
  return offsets;
}

function getPageCoords (element) {
  var coords = {x : 0, y : 0};
  while (element) {
    coords.x += element.offsetLeft;
    coords.y += element.offsetTop;
    element = element.offsetParent;
  }
  return coords;
}
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ns6 = (document.getElementById)? true:false
function showHint(hintname, evt)
{
if(ie4)   // si es explorer el browser
{
	//document.all(hintname).style.pixelLeft = evt.clientX-evt.offsetX-5
	//document.all(hintname).style.pixelTop = document.body.scrollTop + event.clientY - 20;
	document.all("contenedor").style.pixelLeft = evt.clientX-evt.offsetX-148;
	document.all("contenedor").style.pixelTop = 94;
	document.all("contenedor").style.visibility="visible";
//	document.all("contenedor").style.pixelTop = document.body.scrollTop + event.clientY - 20;
	document.all(document.esconde.menu.value).style.visibility="visible";
	document.all(document.esconde.menu.value).style.display="block";
	}
	else if(ns4 || ns6)
	{
	//document.getElementById(hintname).style.left=evt.pageX-getOffsets(evt).offsetX-3+"px";
	//document.getElementById(hintname).style.top = document.body.scrollTop + event.clientY - 50+"px";
	document.getElementById("contenedor").style.left = evt.pageX-getOffsets(evt).offsetX-146+"px";
	document.getElementById("contenedor").style.top = 94+"px";
	document.getElementById("contenedor").style.visibility="visible";
	document.getElementById(document.esconde.menu.value).style.visibility="visible";
	document.getElementById(document.esconde.menu.value).style.display="block";
	}
}
function showHintpro(hintname, evt)
{
if(ie4)   // si es explorer el browser
{
	//document.all(hintname).style.pixelLeft = evt.clientX-evt.offsetX-5
	//document.all(hintname).style.pixelTop = document.body.scrollTop + event.clientY - 20;
	document.all("contenedor").style.pixelLeft = evt.clientX-evt.offsetX+148;
	document.all("contenedor").style.pixelTop = 94;
	document.all("contenedor").style.visibility="visible";
//	document.all("contenedor").style.pixelTop = document.body.scrollTop + event.clientY - 20;
	document.all(document.esconde.menu.value).style.visibility="visible";
	document.all(document.esconde.menu.value).style.display="block";
	}
	else if(ns4 || ns6)
	{
	//document.getElementById(hintname).style.left=evt.pageX-getOffsets(evt).offsetX-3+"px";
	//document.getElementById(hintname).style.top = document.body.scrollTop + event.clientY - 50+"px";
	document.getElementById("contenedor").style.left = evt.pageX-getOffsets(evt).offsetX+147+"px";
	document.getElementById("contenedor").style.top = 116+"px";
	document.getElementById("contenedor").style.visibility="visible";
	document.getElementById(document.esconde.menu.value).style.visibility="visible";
	document.getElementById(document.esconde.menu.value).style.display="block";
	}
}
function showHint2(hintname, event)
{
document.getElementById(document.esconde.menu.value).style.visibility="visible";
document.getElementById("contenedor").style.visibility="visible";
document.getElementById(document.esconde.menu.value).style.display="block";
}
function hideHint(hintname)
{
document.getElementById(hintname).style.visibility="hidden";
document.getElementById("contenedor").style.visibility="hidden";
document.getElementById(hintname).style.display="none";
}
function hideHint3()
{
document.getElementById("contenedor").style.visibility="hidden";
esco2(document.esconde.menu.value)
}
function esco2(valor)
{
document.getElementById(valor).style.visibility="hidden";
document.getElementById(valor).style.display="none";
}
function esco(valor)
{
document.esconde.menu.value = valor;

}

var getURL= document.URL
function EscribirValor()
{
var capturaURL = document.getElementById('resultadoURL');
capturaURL.innerHTML=getURL
}
