var clipTop_ban = 0;
var clipWidth_ban = 110;
var clipBottom_ban = 120;
var topper_ban =350;
var lyrheight = 0;

var clipTop_ins = 0;
var clipWidth_ins = 360;
var clipBottom_ins = 180;
var topper_ins =285;

var clipTop_tipo = 0;
var clipWidth_tipo = 140;
var clipBottom_tipo = 210;
var topper_tipo = 255;

var clipTop_nombre = 0;
var clipWidth_nombre = 340;
var clipBottom_nombre = 240;
var topper_nombre = 230;

var clipTop_reg = 15;
var clipWidth_reg = 750;
var clipBottom_reg = 350;
var topper_reg = 220;

var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML;
var op_sel_out = 0;

function init(object)
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj(object);
	if (document.layers)
	{   
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
	}
	else if (document.getElementById || document.all)
	{	
		lyrheight = x.obj.offsetHeight;
		var clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		x.style.clip = clipstring;
		x.style.top  =  topper;
	}
}

function vis(val,object)
{
	if (!DHTML) return;
	var f = new getObj(object);
	f.style.visibility = val;
}

function getObj(name)
{
  if (document.getElementById)
  {
    this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
    this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function stopScroll()
{
	if (time) clearTimeout(time);
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	if(layername=='institucion')
   	realscroll_institucion();
   	else if(layername=='tipo')
   	realscroll_tipo();
   	else if(layername=='nombre')
   	realscroll_nombre();
   	else if(layername=='registro')
   	realscroll_registro();
   	else if(layername=='bancox')
   	realscroll_bancox();
}

function realscroll_institucion()
{
	var inst_height = document.getElementById("institucion").offsetHeight;
	if (!DHTML) return;
	clipTop_ins += amount;
	clipBottom_ins += amount;
	topper_ins -= amount;
	if (clipTop_ins < 0 || clipBottom_ins > inst_height)
	{
		clipTop_ins -= amount;
		clipBottom_ins -= amount;
		topper_ins += amount;
		return;
	}
	if (document.getElementById || document.all)
	{	
		clipstring = 'rect('+clipTop_ins+'px,'+clipWidth_ins+'px,'+clipBottom_ins+'px,0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper_ins + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop_ins;
		thelayer.style.clip.bottom = clipBottom_ins;
		thelayer.style.top = topper_ins;
	}
	time = setTimeout('realscroll_institucion()',theTime);
}

function realscroll_tipo()
{	
	var tipo_height = document.getElementById("tipo").offsetHeight;
	if (!DHTML) return;
	clipTop_tipo += amount;
	clipBottom_tipo += amount;
	topper_tipo -= amount;
	if (clipTop_tipo < 0 || clipBottom_tipo > tipo_height)
	{
		clipTop_tipo -= amount;
		clipBottom_tipo -= amount;
		topper_tipo += amount;
		return;
	}
	if (document.getElementById || document.all)
	{   
		clipstring = 'rect('+clipTop_tipo+'px,'+clipWidth_tipo+'px,'+clipBottom_tipo+'px,0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper_tipo + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop_tipo;
		thelayer.style.clip.bottom = clipBottom_tipo;
		thelayer.style.top = topper_tipo;
	}
	time = setTimeout('realscroll_tipo()',theTime);
}

function realscroll_nombre()
{
	var nombre_height = document.getElementById("nombre").offsetHeight;
	if (!DHTML) return;
	clipTop_nombre += amount;
	clipBottom_nombre += amount;
	topper_nombre -= amount;
	if (clipTop_nombre < 0 || clipBottom_nombre > nombre_height)
	{
		clipTop_nombre -= amount;
		clipBottom_nombre -= amount;
		topper_nombre += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop_nombre+'px,'+clipWidth_nombre+'px,'+clipBottom_nombre+'px,0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper_nombre + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop_nombre;
		thelayer.style.clip.bottom = clipBottom_nombre;
		thelayer.style.top = topper_nombre;
	}
	time = setTimeout('realscroll_nombre()',theTime);
}

function realscroll_registro()
{
	var reg_height = document.getElementById("registro").offsetHeight;
	if (!DHTML) return;
	clipTop_reg += amount;
	clipBottom_reg += amount;
	topper_reg -= amount; 
	if (clipTop_reg < 0 || clipBottom_reg > reg_height)
	{
		clipTop_reg -= amount;
		clipBottom_reg -= amount;
		topper_reg += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop_reg+'px,'+clipWidth_reg+'px,'+clipBottom_reg+'px,0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper_reg + 'px'; 
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop_reg;
		thelayer.style.clip.bottom = clipBottom_reg;
		thelayer.style.top = topper_reg;
	}
	time = setTimeout('realscroll_registro()',theTime);
}

function realscroll_bancox()

{
	var ban_height = document.getElementById("bancox").offsetHeight;
	//alert(clipTop_ban+','+clipBottom_ban+','+topper_ban+','+ban_height);
	if (!DHTML) return;
	
	clipTop_ban += amount;
	clipBottom_ban += amount;
	topper_ban -= amount; 
	
	if (clipTop_ban < 0 || clipBottom_ban > ban_height)
	{
		//alert(clipTop_ban+','+clipBottom_ban+','+topper_ban);
		clipTop_ban -= amount;
		clipBottom_ban -= amount;
		topper_ban += amount;
		return;
	}
	
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop_ban+'px,'+clipWidth_ban+'px,'+clipBottom_ban+'px,0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper_ban + 'px'; 
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop_ban;
		thelayer.style.clip.bottom = clipBottom_ban;
		thelayer.style.top = topper_ban;
	}
	time = setTimeout('realscroll_bancox()',theTime);
}


function inicia_objeto(){
	
    clipTop = 0;
    clipWidth = 110;
    clipBottom = 120;
    topper = 350;
	clipTop_ban = 0;
	clipWidth_ban = 110;
	clipBottom_ban = 120;
	topper_ban =350;
	lyrheight = 0;

    init('bancox');

	clipTop = 0;
    clipWidth = 138;
    clipBottom = 240;
    topper = 230;
	clipTop_nombre = 0;
	clipWidth_nombre = 340;
	clipBottom_nombre = 240;
	topper_nombre = 230;
	lyrheight = 0;

    init('nombre');

	clipTop = 0;
    clipWidth = 140;
    clipBottom = 210;
    topper = 255;
	clipTop_tipo = 0;
	clipWidth_tipo = 140;
	clipBottom_tipo = 210;
	topper_tipo = 255;
	lyrheight = 0;

    init('tipo');
    
    clipTop = 0;
    clipWidth = 360;
    clipBottom = 180;
    topper = 285;
	clipTop_ins = 0;
	clipWidth_ins = 360;
	clipBottom_ins = 180;
	topper_ins =285;
	lyrheight = 0;

    init('institucion');
}

function inicia_registro(){
	clipTop = 15;
	clipWidth = 750;
	clipBottom = 350;
	topper = 200;
	clipTop_reg = 15;
	clipWidth_reg = 750;
	clipBottom_reg = 350;
	topper_reg = 200;
	lyrheight = 0;
	
	init('registro');
}

function click_letras(id_opcion){
  op_sel_out=id_opcion;
  vis('visible','letras');
  vis('hidden','f2a');
  vis('hidden','f2a_');
  vis('hidden','f1a');
  vis('hidden','f1a_');
  vis('visible','anim_row');
}

function reset_color(id_div){
  var color_ch = "";
  if (id_div == "ban") {id_div = "bancox"; 		color_ch = "white";}
  if (id_div == "ins") {id_div = "institucion"; color_ch = "black";}
  if (id_div == "tip") {id_div = "tipo"; 		color_ch = "white";}
  if (id_div == "nom") {id_div = "nombre"; 		color_ch = "white";}
  
  var div_id = document.getElementById(id_div); 
  var labels = div_id.getElementsByTagName("label"); 
  for (var i = 0; i < labels.length; i++) { 
  	labels[i].style.color=color_ch;
  }	
}

function filtrar(){
	//var indice = document.getElementById("letra_combo").selectedIndex;
	var letra_selec = document.getElementById("letra_combo").value;
	if (letra_selec != ""){
		//var letra_selec = document.getElementById("letra_combo").options[indice].value;
		//alert("limpia");
		limpia();
		//alert("click sector");
		click_sector();
		//alert("inicia objeto");
		inicia_objeto(); 
		//alert("carga contenido");
		cargaContenido("ban", op_sel_out, letra_selec);
		
	}else return;
	//alert(op_sel_out);
}

function click_sector(){
  vis('visible','institucion');
  vis('visible','ins_flechas');
  vis('visible','f2a');
  vis('visible','f2a_');
  vis('hidden','f1a');
  vis('hidden','f1a_');
  vis('hidden','f3a');
  vis('hidden','f3a_');
  vis('hidden','f4a');
  vis('hidden','f4a_');
  vis('hidden','anim_row');
}

function click_institucion(){
  //vis('hidden','letras');	
  vis('visible','tipo');
  vis('visible','tip_flechas');
  vis('visible','f3a');
  vis('visible','f3a_');
  vis('hidden','f1a');
  vis('hidden','f1a_');
  vis('hidden','f2a');
  vis('hidden','f2a_');
  vis('hidden','f4a');
  vis('hidden','f4a_'); 
}

function click_producto(){
  vis('visible','nombre');
  vis('visible','nom_flechas');
  vis('visible','f4a');
  vis('visible','f4a_');
  vis('hidden','f1a');
  vis('hidden','f1a_');
  vis('hidden','f2a');
  vis('hidden','f2a_');
  vis('hidden','f3a');
  vis('hidden','f3a_');
}

function movepic(img_name,img_src) {
    document[img_name].src=img_src;
}


var maxAncho = 170 //define la anchura máxima de la imagen
var maxAlto = 120 //define la altura máxima de la imagen
function redim(ancho,alto,cual,idshower)
{
if (ancho > alto) {forma = 'apaisada'}
if (ancho < alto) {forma = 'retrato'}
//document.ima1.src = cual
shower = document.getElementByid('idshower')
shower.src = cual
if(forma == 'apaisada')
	{
	if(ancho > maxAncho)
		{
		porcientoAnchura = parseInt(maxAncho/ancho*100)
		shower.width = maxAncho
		shower.height = porcientoAnchura*alto/100
		}
	}
else if (forma == 'retrato')
	{
	if (alto > maxAlto)
		{
		porcientoAltura = maxAlto/alto*100
		shower.height = maxAlto
		shower.width = porcientoAltura*ancho/100
		}
	}
}

function show_linea(div_selected){
	var enr	= document.getElementById('enr');
	var er  = document.getElementById('er');
	var div = document.getElementById('sofom');
	var reg = document.getElementById('registro');
	var vol = document.getElementById('volver');
	var flu = document.getElementById('reg_up');
	var fld = document.getElementById('reg_dwn');
	
	vol.style.display='';
	div.style.display='none';	
	reg.style.display='';
	flu.style.display='';
	fld.style.display='';
	
	if (div_selected == 'enr'){
		er.style.display='none';
		enr.style.display='';
	}

	if (div_selected == 'er'){
		enr.style.display='none';
		er.style.display='';
	}
	
}


function volver(){
	var div = document.getElementById('sofom');
	var reg = document.getElementById('registro');
	var vol = document.getElementById('volver');
	var enr	= document.getElementById('enr');
	var er  = document.getElementById('er');
	var flu = document.getElementById('reg_up');
	var fld = document.getElementById('reg_dwn');
	
	div.style.display	= '';
	reg.style.display	= 'none';
	vol.style.display 	= 'none';
	er.style.display	= 'none';
	enr.style.display	= 'none';
	flu.style.display	= 'none';
	fld.style.display	= 'none';
}








