// JavaScript Document

//Especificar a que elementos afectará, añadiendo o quitando de la lista:
var tgs = new Array( 'div','td','tr','a','ul','li','p');

//Indicar el nombre de los diferentes tamaños de fuente:
var szs = new Array('x-small','small','medium','large','x-large');
var startSz = 1;

function ts( trgt,inc ) {
if (!document.getElementById) return
var d = document,cEl = null,sz = startSz,i,j,cTags;

sz += inc;
if ( sz < 0 ) sz = 0;
if ( sz > 4 ) sz = 4;
startSz = sz;

if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

cEl.style.fontSize = szs[ sz ];

for ( i = 0 ; i < tgs.length ; i++ ) {
cTags = cEl.getElementsByTagName( tgs[ i ] );
for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
}
}
function setOpacity(objId,opacity)
{
	opacity = (opacity == 100)?99.999:opacity;
	obj=document.getElementById(objId);
// IE/Win
	obj.style.filter = 'alpha(opacity:'+opacity+')';
	
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
	
	obj.style.zoom=1;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(objId,opacity);
      opacity +=10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

function fadeOut(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >=0) {
      setOpacity(objId,opacity);
      opacity -= 10;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 100);
    }
	else document.getElementById(objId).style.display='none';
  }
}

    var capa = null; // Almacena la capa que se mueve 
   var _IE_ = navigator.userAgent.indexOf("MSIE") != -1; // Si es IE 
  /* 
   5.  * Libera la capa del movimiento 
   6.  */ 
 function liberaCapa() { 
   capa = null; 
  } 
   /* 
  12.  * Cuando se pincha en la barra de la capa 
  13.  * se almacena la capa y se guarda la posición 
  14.  * del ratón respecto a la esquina superior 
  15.  * izquierda de la capa, para así mover la capa 
  16.  * desde el punto pichado y no desde la equina 
  17.  */ 
   function clickCapa(e, obj) { 
   capa = obj.parentNode; 
    
 // En IE y Opera se usa otra propiedad del evento 
  if (_IE_) { 
  difX = e.offsetX; 
  difY = e.offsetY; 
  } else { 
 difX = e.layerX; 
  difY = e.layerY; 
   } 
  } 
   
  /* 
  32.  * Mientras se mueva el ratón por el 
  33.  * body se mueve la capa 
  34.  */ 
  function mueveCapa(e) { 
  if (capa != null) { 
 capa.style.top = (e.clientY-difY)+"px"; 
  capa.style.left = (e.clientX-difX)+"px"; 
  } 
 } 
 
function checks_marcados()
{
	var elementos=document.getElementsByName('chk_item');
	var todos = document.getElementById('chk_todos');
	var tipo=typeof(elementos.length);
	
	if(todos.checked==true)
	{	
		if(tipo=='undefined') elementos.checked=true;
		else
		{
			for(i=0;i<elementos.length;i++) elementos[i].checked=true;
		}	
	}
	else
	{
		if(tipo=='undefined') elementos.checked=false;
		else
		{
			for(i=0;i<elementos.length;i++) elementos[i].checked=false;
		}
	}
}

function eliminar_registro(pag,opcion)
{
	var elementos=document.getElementsByName('chk_item');
	var tipo=typeof(elementos.length);
	var f=0;
 	
		if(tipo=='undefined')
		{
			for(i=0;i<1;i++)
			{
				if(elementos.checked==false) alert("Debe seleccionar un registro");
				else
				{
					if(confirm("¿Esta seguro de eliminar el registro(s)?")) eliminar(pag,opcion); 	
				}
			}
		}
		else
		{
			for(i=0;i<elementos.length;i++)
			{
				if(elementos[i].checked==false) f++;
			}
			if(f==elementos.length) alert("Debe seleccionar un registro");
			else
			{
				if(confirm("¿Esta seguro de eliminar el registro(s)?")) eliminar(pag,opcion);		
			}
		}
		
}

function mostrarCapa(div,w,h)
{
	escondeSelects();
	document.getElementById(div).style.top=((screen.height - (w+h))/2)+'px';
	document.getElementById(div).style.left=((screen.width - w)/2)+'px';
	document.getElementById(div).style.display='block';
	
	
	//setTimeout("cerrarMensaje('resultado')",5000);
}

function mostrarCapaImagen(div,w,h)
{
	escondeSelects();
	document.getElementById(div).style.top=((screen.height - h)/2)+'px';
	document.getElementById(div).style.left=((screen.width - w)/2)+'px';
	document.getElementById(div).style.display='block';
}
function mostrarMensaje(div,mensaje)
{
	
	document.getElementById(div).style.left=((screen.width-300)/2)+"px";
	document.getElementById(div).style.top=((screen.height-(300+30))/2)+"px";
	document.getElementById(div).style.display="block";
	document.getElementById(div).innerHTML="<img src='imagenes/loading.gif'/>&nbsp;&nbsp;&nbsp;&nbsp;Grabando contenido espere por favor...";
	mensajes(mensaje);
		
	setTimeout("cerrarMensaje('resultado','bnpsliscont.php')",4000);

	
}
function nextMensaje(div,mensaje)
{
	document.getElementById(div).innerHTML=mensaje;
}
function cerrarMensaje(div,pag)
{
	document.getElementById(div).style.display="none";
	muestraSelects();
	redir(pag);
}
function cerrarDiv(div)
{
	document.getElementById(div).style.display="none";
	muestraSelects();
	
}
function cerrarDivyAbrir(div,pag)
{
	document.getElementById(div).style.display="none";
	mostrarCapImg('bnpssubimag.php');

}
function frmSubmit(frm,pagina)
{
	document.getElementById(frm).action=pagina;
	document.getElementById(frm).submit();
}

function escondeSelects(){ 
if(!window.attachEvent) return false;
 var selects = document.getElementsByTagName("select");
 for( var i=0; i<selects.length; i++ ){
 selects[i].style.display = "none"; 
}
}

function muestraSelects(){ 
if(!window.attachEvent) return false;
 var selects = document.getElementsByTagName("select");
 for( var i=0; i<selects.length; i++ ){
 selects[i].style.display = "inline"; 
}
}

function desactivarRb(id)
{
	document.getElementById(id).checked=false;
}

function frmSubmitTarget(frm,pagina,target)
{
	
	frm.action=pagina;
	frm.target=target;
	frm.submit();
}

function limpiarCampos(frm)
{
	frm.txtNombre.value="";
	frm.cboOrden.value=0;
	frm.cboTipo.value=0;
	frm.vIdOpc.value="";
}
function cambiarDoc(div,div1)
{
	document.getElementById(div).style.display='none';
	document.getElementById(div1).style.display='block';
	
}

function getKey(e){
	if(!e)
		e=window.event;
	if(e.keyCode)
		code=e.keyCode;
	else
		code=e.which;
	if(code===13){
		
		return true;
	}
}

function Valida(forma,idioma,nombre,mail,area,comentario){
          if (forma.bnpnombre.value==""){
              alert(nombre);
				forma.bnpnombre.focus();
              return;
          }   
          if (checkEmail(forma,mail)==false){
              forma.bnpemail.focus();
	      return;	          	
          }
          if (forma.bnpsubject.value=="*"){
              alert(area);
				forma.bnpsubject.focus();
              return;
          }   
          if (forma.bnpcomentario.value==""){
              alert(comentario);
				forma.bnpcomentario.focus();
              return;
          }
		  /*forma.action="bnpsenvcontact.php";
          forma.submit();*/
		  enviar_contactenos('bnpsenvcontact.php',idioma);
     }

function checkEmail(myForm,mail) {  
   if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.bnpemail.value)){
	return (true)
    }
    alert(mail)
    return (false)
}

function verificarEmail(idioma,vacio,incorrecto)
{
	if(document.getElementById('txtEmail1').value=="")		
		alert(vacio);	
	else
	{
		 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('txtEmail1').value)){
			enviarPassword('bnpsusrwfunc.php',idioma);
		 }
		 else
			alert(incorrecto);
	}

		
}

function limpiarCamposEmail()
{
	document.getElementById('txtEmail1').value="";
	document.getElementById('result2').innerHTML="";
}
