﻿// Archivo JScript

/************** BASICOS ****************/
function left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i) ==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i) ==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}

function getMonth(month){
    
    switch(month){
        case '1':
            return 'Enero';
            break;
        case '2':
            return 'Febrero';
            break;
        case '3':
            return 'Marzo';
            break;
        case '4':
            return 'Abril';
            break;
        case '5':
            return 'Mayo';
            break;
        case '6':
            return 'Junio';
            break;
        case '7':
            return 'Julio';
            break;
        case '8':
            return 'Agosto';
            break;
        case '9':
            return 'Septiembre';
            break;
        case '10':
            return 'Octubre';
            break;
        case '11':
            return 'Noviembre';
            break;
        case '12':
            return 'Diciembre';
            break;
        default: 
            return '';
            break;
    }
}

//********************************************************//
//********* Funciones de codificacion de texto ***********//
//********************************************************//

 function encodeMyHtml(html) {
     encodedHtml = html;
     encodedHtml = encodedHtml.replace(/\//g,"%2F");
     encodedHtml = encodedHtml.replace(/\?/g,"%3F");
     encodedHtml = encodedHtml.replace(/=/g,"%3D");
     encodedHtml = encodedHtml.replace(/&/g,"%26");
     encodedHtml = encodedHtml.replace(/@/g,"%40");
     encodedHtml = encodedHtml.replace(/\+/g,"%2B");
     return encodedHtml;
   } 

//********************************************************//
//********* Funciones de comportamiento dinamico objetos *//
//********************************************************//
function toggleMenu(e){
   var els = $$('table[rel="tb_sm_on"]');
   for(var i = 0; i< els.length ; i++){
        if(els[i].id != $('tb_sm_'+e).id){
            $(els[i].id).setStyle({'visibility':'hidden','display':'none'}); 
            //cambiar clase a los link
        }
   }
  
  if($('tb_sm_'+e).getAttribute('rel') == 'tb_sm_off'){
        $('tb_sm_'+e).setStyle({'visibility':'visible','display':''}); 
        $('tb_sm_'+e).setAttribute('rel','tb_sm_on');          
        $('lnk_img_'+e).className = 'menuselectedoff cur-pointer';
        //$('lnk_txt_'+e).className = 'fc-black fs-12 fw-bold';
        $('td_'+e).className = 'pad-left-15 bgc-white bl-left-base bl-right-base bl-top-base';
    } else {
        $('tb_sm_'+e).setStyle({'visibility':'hidden','display':'none'});        
        $('tb_sm_'+e).setAttribute('rel','tb_sm_off');           
        $('lnk_img_'+e).className = 'menuselectedon cur-pointer';
        //$('lnk_txt_'+e).className = 'fc-black fs-12 fw-normal';
        $('td_'+e).className = 'pad-left-15 fw-normal bl-top-base';        
    }
    

}

function toggleMenuHorizontal(e){
   var els = $$('table[rel="tb_sm_on"]');
   for(var i = 0; i< els.length ; i++){
        if(els[i].id != $('tb_sm_'+e).id){
            $(els[i].id).setStyle({'visibility':'hidden','display':'none'}); 
            //cambiar clase a los link
        }
   }
  
  if($('tb_sm_'+e).getAttribute('rel') == 'tb_sm_off'){
        $('tb_sm_'+e).setStyle({'visibility':'visible','display':''}); 
        $('tb_sm_'+e).setAttribute('rel','tb_sm_on');          
        $('lnk_img_'+e).className = 'menuselectedoff cur-pointer';
        //$('lnk_txt_'+e).className = 'fc-black fs-12 fw-bold';
        $('td_'+e).className = 'bgc-white bl-left-base bl-right-base bl-top-base';
    } else {
        $('tb_sm_'+e).setStyle({'visibility':'hidden','display':'none'});        
        $('tb_sm_'+e).setAttribute('rel','tb_sm_off');           
        $('lnk_img_'+e).className = 'menuselectedon cur-pointer';
        //$('lnk_txt_'+e).className = 'fc-black fs-12 fw-normal';
        $('td_'+e).className = 'fw-normal bl-top-base';        
    }
    

}

function addNavClass(id){
    $(id).addClassName('hover');
}

function removeNavClass(id){
    $(id).removeClassName('hover');
}



/*************** POP UPS **************/

function abrirrecorridos08(tipo){
    _ancho = 500;
    _alto = 630;	
    _left = (document.viewport.getWidth()/2) - (_ancho/2);
	_top = (document.viewport.getDimensions().height/2) - (_alto/2);
	   
	window.open(Path+'pages/pop/recorridos08.aspx?r='+tipo, 'recorridos08', 'scrollbars=no,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function abrirmensaje(idu_to, idmensaje, subject){		
	 _ancho = 570;
     _alto = 465;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	   
	window.open(Path+'pages/pop/mensajes.aspx?idu='+idu_to+'&idm='+idmensaje+'&subject='+subject, 'Mensajes_'+idmensaje, 'scrollbars=no,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function abrircondicioneslopd(){		
	 _ancho = 870;
     _alto = 700;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	   
	window.open(Path+'pages/pop/condiciones.aspx', 'CondicionesLOPD', 'scrollbars=yes,resizable=yes,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function abrirmensajeenviado(idu, idmensaje){		
	 _ancho = 570;
     _alto = 465;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	   
	window.open(Path+'pages/pop/mensajes.aspx?ide='+idu+'&idm='+idmensaje, 'Mensajes_'+idmensaje, 'scrollbars=no,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function fotousuario(){
     _ancho = 570;
     _alto = 480;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	 
	window.open(Path+'pages/pop/upload.aspx?id=1', 'FotoUsuario', 'scrollbars=yes,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function abrirUpload(entidad,id){
     _ancho = 570;
     _alto = 487;	
     
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	 
	window.open(Path+'pages/pop/upload.aspx?e='+entidad+'&id='+id, 'Upload', 'scrollbars=yes,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function abrirqec(){
    _ancho = 700;
    _alto = 700;	
    _left = (document.viewport.getWidth()/2) - (_ancho/2);
	_top = (document.viewport.getDimensions().height/2) - (_alto/2);
	   
	window.open(Path+'pages/pop/quienestacorriendo.aspx', 'recorridos08', 'scrollbars=no,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function verCorredor(id,k) {
    _ancho = 600;
    _alto = 550;	
    _left = (document.viewport.getWidth()/2) - (_ancho/2);
	_top = (document.viewport.getDimensions().height/2) - (_alto/2);
	   
	window.open(Path+'pages/pop/ficha.aspx?k='+k, 'ficha'+id, 'scrollbars=yes,resizable=yes,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);

}

function abrirBuzonEV(id,idpd){		
	_ancho = 700;
    _alto = 500;	
    _left = (document.viewport.getWidth()/2) - (_ancho/2);
	_top = (document.viewport.getDimensions().height/2) - (_alto/2);
	window.open(Path+'pages/pop/evbuzon.aspx?id='+id+'&idpd='+idpd,'buzonev','scrollbars=no,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
	
	
}

function imprimirPlanEntrenamiento(i,m,f){
     _ancho = 700;
     _alto = 480;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	 
	window.open(Path+'pages/pop/evprint.aspx?ip='+i+'&m='+m+'&f='+f, 'ImprimirPE', 'scrollbars=yes,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function imprimirJustificante(){
     _ancho = 670;
     _alto = 700;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
     _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	 
    window.open(Path+'pages/pop/justificante.aspx', 'ImprimirJustificante', 'scrollbars=yes,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function imprimirDiploma(key){
     _ancho = 670;
     _alto = 700;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	 
	window.open(Path+'pages/pop/diploma.aspx?k='+key, 'ImprimirDiploma', 'scrollbars=yes,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);

}

function imprimirClasificacion(key){
     _ancho = 670;
     _alto = 700;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	 
	window.open(Path+'pages/pop/clasificacionprint.aspx?e='+key, 'ImprimirClasificacion', 'scrollbars=yes,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);

}



function abrirGaleria(e){		
	 _ancho = 750;
     _alto = 575;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	 var fecha = new Date();
     var str = '';
     str = fecha.getDay()+'_'+parseInt(fecha.getMinutes())+'_'+parseInt(fecha.getSeconds())+'_'+parseInt(fecha.getMilliseconds())
	window.open(Path+'pages/pop/galeria.aspx?e='+encodeMyHtml(e), 'FotosGaleria_'+str, 'scrollbars=no,resizable=yes,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

function abrirThumb(e){		
	 _ancho = 910;
     _alto = 470;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	 var fecha = new Date();
     var str = '';
     str = fecha.getDay()+'_'+parseInt(fecha.getMinutes())+'_'+parseInt(fecha.getSeconds())+'_'+parseInt(fecha.getMilliseconds())
	window.open( e , 'FotosGaleria_'+str, 'scrollbars=no,resizable=yes,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
   }

function subirFotos(tipo){
     _ancho = 750;
     _alto = 560;	
     _left = (document.viewport.getWidth()/2) - (_ancho/2);
	 _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	   
	window.open(Path+'pages/pop/multiupload.aspx?tipo='+tipo, 'SubirFotos', 'scrollbars=yes,resizable=yes,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
    
}

function abrirBases(id){
    _ancho = 700;
    _alto = 700;	
    _left = (document.viewport.getWidth()/2) - (_ancho/2);
    _top = (document.viewport.getDimensions().height/2) - (_alto/2);
	   
    window.open(Path+'pages/pop/basesconcurso.aspx?id='+id, 'basesconcurso', 'scrollbars=yes,resizable=no,status=no,width='+_ancho+',height='+_alto+',top='+_top+',left='+_left);
}

/*********** VALIDACIONES *************/

function IsEmail(sText){
    var s = '';
    s = trim(sText);
    
    if(sText.length == s.length){
        var filter =/^(.+)@(.+)$/;
        if (sText.length == 0 ) return false;
        if (filter.test(sText)){
            return true;
        }else{
            return false;}
    } else {return false;}
}

function IsPhone(sText){
    var IsCorrect = true;

    if(sText.length >= 9){
        
        var Char;
        for (i = 0; i < sText.length ; i++) 
        { 
            Char = sText.charAt(i); 
            if(isNaN(Char)){
                if(!(i==0 & Char == '+')){
                    IsCorrect = false;                     
                }               
            }
        }
        return IsCorrect;
    } else {return false;}
}

function IsMoney(sText){
    var IsCorrect = true;
    if(sText.length > 0){
        var Char;
        for(i = 0; i < sText.length; i++){
            Char = sText.charAt(i);
            if(!(!isNaN(Char) | Char == ',')){
                IsCorrect = false;
            }
        }
        
        return IsCorrect;
    } else {
        return false;
    }
    
}

function SoloNumeros(e){
        
    var tcl = (document.all)?e.keyCode:e.which;
    if ((tcl >= 48 && tcl <= 57) || tcl == 8 || tcl == 0 || tcl == 44){
           return true;
    }else{
           try{
            e.keyCode = 0;
           } catch(e){}
           return false;
    }

}

function soloNumerosDeTelefono(e){
    //Solo permite números y el caracter +
    var tecla = (document.all)?e.keyCode:e.which;
    
    if ((tecla < 48 || tecla > 57) && (tecla != 43) && (tecla != 8) && (tecla != 0)) 
    {
        try{
        e.keyCode = 0;
       } catch(e){}
       return false;
    } else {return true;}
}

function soloMoneda(e){
    //Solo permite números y el caracter ,
    var tecla = (document.all)?e.keyCode:e.which;
    if ((tecla < 48 || tecla > 57) && (tecla != 44) && (tecla != 8) && (tecla != 0)) 
    {
        try{
        e.keyCode = 0;
       
       } catch(ex){}
       return false;
    } else {return true;}
}

function SoloAlphaNumericos(e){
        
    tecla = (document.all) ? e.keyCode : e.which; 
    if ((tecla < 225 || tecla > 255) && (tecla < 65 || tecla > 90) && (tecla < 97 || tecla > 122) && (tecla < 48 || tecla > 57) && (tecla != 8) && (tecla != 32)) { 
        try{
            e.keyCode=0; 
        } catch(e){}
        
        return false;
    } 
    else {return true; }

}

function limitarLongitudTexto(txt,maxL,e){
    var tcl = (document.all)?e.keyCode:e.which;
    // Se permite SIEMPRE pulsar las teclas de suprimir y retroceso
    // para poder borrar los caracteres aunque la longitud sea la máxima permitida
    if (tcl == 8 || tcl == 0) {
        return true;
    } else {
        if (txt.value.length >= maxL)
        {
            e.returnValue = false;
            return false;
        }
        e.returnValue = true;
        return true;
    }
}

function IsPostal(sText){
   var IsCorrect=true;
   
   if (!(sText.length == 5 && IsNumeric(sText))){IsCorrect = false;}
   return IsCorrect;   
}

function IsNumeric(sText){
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   if(sText.length == 0){
        IsNumber = false;
   } else{
       for (i = 0; i < sText.length && IsNumber == true; i++) 
          { 
          Char = sText.charAt(i); 
          if (ValidChars.indexOf(Char) == -1) 
             {
             IsNumber = false;
             }
          }
    } 
   return IsNumber;   
}

function IsAlphaNumeric(sText){
   var ValidChars = '0123456789abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ áéíóúÁÉÍÓÚ';
   var IsCorrect=true;
   var Char;
   for (i = 0; i < sText.length && IsCorrect == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsCorrect = false;
         }
      }
   if (sText.length == 0){IsCorrect = false;}
   return IsCorrect;   
}

function IsDNI(sText){
    if ((sText.substr(0,1) =='X') || (sText.substr(0,1) =='x') || (sText.substr(0,1) =='y') || (sText.substr(0,1) =='Y') || (sText.substr(0,1) =='z') || (sText.substr(0,1) =='Z')){
        var numsustitucion = '';
		switch(sText.substr(0,1).toUpperCase())	{
		    case 'X': numsustitucion = '0'; break;
		    case 'Y': numsustitucion = '1'; break;
		    case 'Z': numsustitucion = '2'; break;
		}
		sText = sText.substr(1,sText.length-1);	
		sText = numsustitucion + sText;
	}
	numero = sText.substr(0,sText.length-1);
	let = sText.substr(sText.length-1,1);
	numero = numero % 23;
	letra='TRWAGMYFPDXBNJZSQVHLCKET';
	letra=letra.substring(numero,numero+1);
	let = let.toUpperCase();
	if (letra!=let){return false;}
	else {return true;}
}

function IsDate(sText){

    var Fecha= new String(sText);	// Crea un string
	var RealFecha= new Date();	// Para sacar la fecha de hoy
	// Cadena Año
	var Ano= new String(Fecha.substring(Fecha.lastIndexOf("/")+1,Fecha.length));
	// Cadena Mes
	var Mes= new String(Fecha.substring(Fecha.indexOf("/")+1,Fecha.lastIndexOf("/")));
	// Cadena Día
	var Dia= new String(Fecha.substring(0,Fecha.indexOf("/")));

	// Valido el año
	if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1800){
        	
		return false;
	}
	// Valido el Mes
	if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){
		
		return false;
	}
	// Valido el Dia
	if (isNaN(Dia) || parseInt(Dia, 10)<1 || parseInt(Dia, 10)>31){
		
		return false;
	}
	if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {
		if (Mes==2 && Dia > 28 || Dia>30) {
			//Si es febrero y dia 29 debo mirar si es año bisiesto
			if(Mes == 2 && Dia == 29){
			    var Resto = Ano%4;
			    if(Resto == 0){
			        Resto = Ano%100;
			        if(Resto == 0) {
			            Resto = Ano%400;
			            if (Resto != 0){
			                return false;
			            }
			           
			        }
			        
			    } else {return false;}
			}
			else {
			    return false;
			}
		}
	}

  return true;	

}

function IsNumCorredor(sText) {
    var IsCorrect = false;

  var sText= sText.replace(/\D/g, '');
  var number_length = sText.length;
  var parity=number_length % 2;
  var total=0;
  
  for (i=0; i < number_length; i++) {
    var digit = sText.charAt(i);
       if (i % 2 == parity) {
      digit=digit * 2;
          if (digit > 9) {
        digit=digit - 9;
      }
    }
      total = total + parseInt(digit);
  }
   if (total % 10 == 0 || sText <=10000) {
     IsCorrect = true;  
  }
 
  return IsCorrect;

}

function dateDiffYear(dia,mes,anio){
    f1t = new Date();
    f1 = new Date();
    f1.setTime(f1t.getTime());
    
    f2t = new Date(anio,mes-1,dia,0,0,0);
    
    f2 = new Date();
    f2.setTime(f2t.getTime());
    
    diff = new Date();
    diff.setTime(Math.abs(f1.getTime() - f2.getTime()));

    timediff = diff.getTime();
    
    anios = Math.floor(timediff / (1000 * 60 * 60 * 24 * 365));
    timediff -= anios * (1000 * 60 * 60 * 24 * 365);
    
  
    return anios;
}
                    
function esMayor(dia,mes,anio,dia2,mes2,anio2){
   if(anio<anio2){ 
        return true;
    } else {
        if(anio>anio2){return false;}
        else {
           if(anio==anio2){
                if(mes<mes2){
                    return true;
                } else {
                    if(mes > mes2){return false;} else {
                        if(mes == mes2){
                            if(dia<dia2){
                                return true;
                            } else {                                                        
                                return false;                                                        
                            }
                        }
                    }
                } 
            }
        }
    }
    
}


function ocultarMostrarIconosValidacion(imgOk,imgError,correcto){
    if(correcto){
        $(imgOk).setStyle({display:'',visibility:'visible'});
        $(imgError).setStyle({display:'none',visibility:'hidden'});
    } else {
        $(imgOk).setStyle({display:'none',visibility:'hidden'});
        $(imgError).setStyle({display:'',visibility:'visible'});        
    }
}

function ocultarIconosValidacion(imgOk,imgError){
    $(imgError).setStyle({display:'none',visibility:'hidden'});
    $(imgOk).setStyle({display:'none',visibility:'hidden'});
}

/************************** MISCELANEO *************************/

function initGoogle(){
    try{
        initialize();
    }
    catch(e){}
    
}

/****************************************************/
/*************** EFECTOS CABECERA *******************/
/****************************************************/

function toggleimg(obj){
    try {clearInterval(intervalo);}
    catch (ex){}

    var contenedores = document.getElementsByClassName('header');
    for(var i = 0; i < contenedores.length; i++){
        $(contenedores[i]).setStyle({display:'none',visibility:'hidden'});
    }

    if (obj != '0') {//le mando un cero a la funcion para que me oculte las capas por si no hay nada a la capa a la que voy
        $(obj).setStyle({display:'inline',visibility:'visible'});}
                
}

function toggleimgwithEffect(obj){
    if (obj != '0') {//le mando un cero a la funcion para que me oculte las capas por si no hay nada a la capa a la que voy
        Effect.Appear($(obj).id, { duration:1, from:0.0, to:1.0 });
        $(obj).setStyle({visibility:'visible'});
    }        
    
}
function startPage() {
    intervalo =  setInterval('swapFade()',wait);   
}

function swapFade() {
    Effect.Fade(divs_to_fade[h], { duration:1, from:1.0, to:0.0 });
    h++;
    if (h == divs_to_fade.length) h = 0;

    toggleimgwithEffect(divs_to_fade[h]);    
    
    changeButtonImg(h+1);
}

 function pausa(){
    clearInterval(intervalo);
 }
 
 function siguiente(){
    pausa();
    Effect.Fade(divs_to_fade[h], { duration:1, from:1.0, to:0.0 });
    h++;
    if (h == divs_to_fade.length) h = 0;
    toggleimgwithEffect(divs_to_fade[h]);
    changeButtonImg(h+1);
 }
 
 function anterior(){
     pausa();
     Effect.Fade(divs_to_fade[h], { duration:1, from:1.0, to:0.0 });
     h--;
     if (h < 0) {
        h = divs_to_fade.length-1;        
    }
    
     toggleimgwithEffect(divs_to_fade[h]);
     changeButtonImg(h+1);
 }
 
 function gotoImg(i){
    pausa();
    Effect.Fade(divs_to_fade[h], { duration:1, from:1.0, to:0.0 });
    h = i - 1 ;            
    toggleimgwithEffect(divs_to_fade[h]);
    changeButtonImg(h+1);
 }

 var imgButton = '';
 var imgButtonSelected = '';
        
 function changeButtonImg(id){
    id = parseInt(id);
    
    if(parseInt(id) <= 9){
        id = '0'+id;
    }
 
    if(imgButtonSelected != '' && imgButton != ''){
        $(imgButtonSelected).setStyle({display:'none',visibility:'hidden'});
        $(imgButton).setStyle({display:'',visibility:'visible'});
    }
    
    imgButton = 'img_button_'+id;
    imgButtonSelected = 'img_button_selected_'+id;
    
    $(imgButton).setStyle({display:'none',visibility:'hidden'});
    $(imgButtonSelected).setStyle({display:'',visibility:'visible'});
 }

/*************************************************************/
/******************** ROTACION GALERIAS **********************/
/*************************************************************/


function galeriaRotatoria(divsToFade, classToFade, secondsFade ){
    this._divsToFade = divsToFade;
    this._classToFade = classToFade;
    this._secondsToFade = secondsFade * 1000;
    
    this._item = 0;
    this._intervalo;
    
        
    this.toggle = function (div, clase, stopInterval){
        if(stopInterval == true){
            try {clearInterval(this._intervalo);}
            catch (ex){}
        }
        var contenedores = document.getElementsByClassName(clase);
        for(var i = 0; i < contenedores.length; i++){
            $(contenedores[i]).setStyle({display:'none',visibility:'hidden'});
        }        
        $(div).setStyle({'display':'', 'visibility':'visible'});
    }
    
    this.swapFade = function(){     
        Effect.Fade(this._divsToFade[this._item], { duration:1, from:1.0, to:0.0 });
        this._item++;
        if (this._item == this._divsToFade.length) this._item = 0;

        this.toggle(this._divsToFade[this._item], this._classToFade, false);
    }    
    
    this.toggle(this._divsToFade[0],this._classToFade, true);
}


/********************* NAVEGACION ****************************/
function refreshParentAndClose() {
    try{
        window.opener.location.href=window.opener.location.href;
       }
       catch(e) {}
    window.close();
}

function refreshWindow(){
    location.href = location.href;
}

function backWindow(){
    history.back();
}

function closeWindow(){
    window.close();
}



/************************* FLASH ******************************/
function runSWF(archivo, ancho, alto, version, bgcolor, id, menu, FlashVars, quality, allowScriptAccess) { 
// tutorial by IVI CONCEPT - www.ivi-concept.com
		if(version!=""){
			var version_data=version;
		}else{
			var version_data="6,0,0,0";
		}
		if(menu!=""){
			menu_data=menu;
		}else{
			menu_data=false;
		}
		if(bgcolor!=""){
			var bgcolor_data=bgcolor;
		}else{
			var bgcolor_data="#FFFFFF";
		}
		if(id!=""){
			id_data=id;
		}else{
			id_data="flashMovie";
		}
		if(quality!=""){
			quality_data=quality;
		}else{
			quality_data="high";
		}
		if(allowScriptAccess!=""){
			allowScriptAccess_data=allowScriptAccess;
		}else{
			allowScriptAccess_data="always";
		}
		var quality="high"; // calidad de visualización de la peli
		 document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n');
		 document.write('<param name="movie" value='+archivo+'>\n');
		 document.write('<param name="allowScriptAccess" value='+allowScriptAccess_data+'>\n');
		 document.write('<param name="quality" value='+quality_data+'>\n');
		 document.write('<param name="FlashVars" value='+FlashVars+'>\n');
		 document.write('<param name="bgcolor" value='+bgcolor_data+'>\n');
		 document.write('<param name="menu" value='+menu_data+' >\n');
		 document.write('<embed src='+archivo+' bgcolor='+bgcolor_data+' FlashVars='+FlashVars+' menu='+menu_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' swLiveConnect=true name='+id_data+'></embed>');
		 document.write('</object>\n');
}

function runSWFSSL(archivo, ancho, alto, version, bgcolor, id, menu, FlashVars, quality, allowScriptAccess) { 
// tutorial by IVI CONCEPT - www.ivi-concept.com
		if(version!=""){
			var version_data=version;
		}else{
			var version_data="6,0,0,0";
		}
		if(menu!=""){
			menu_data=menu;
		}else{
			menu_data=false;
		}
		if(bgcolor!=""){
			var bgcolor_data=bgcolor;
		}else{
			var bgcolor_data="#FFFFFF";
		}
		if(id!=""){
			id_data=id;
		}else{
			id_data="flashMovie";
		}
		if(quality!=""){
			quality_data=quality;
		}else{
			quality_data="high";
		}
		if(allowScriptAccess!=""){
			allowScriptAccess_data=allowScriptAccess;
		}else{
			allowScriptAccess_data="always";
		}
		var quality="high"; // calidad de visualización de la peli
		 document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n');
		 document.write('<param name="movie" value='+archivo+'>\n');
		 document.write('<param name="allowScriptAccess" value='+allowScriptAccess_data+'>\n');
		 document.write('<param name="quality" value='+quality_data+'>\n');
		 document.write('<param name="FlashVars" value='+FlashVars+'>\n');
		 document.write('<param name="bgcolor" value='+bgcolor_data+'>\n');
		 document.write('<param name="menu" value='+menu_data+' >\n');
		 document.write('<embed src='+archivo+' bgcolor='+bgcolor_data+' FlashVars='+FlashVars+' menu='+menu_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+' pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' swLiveConnect=true name='+id_data+'></embed>');
		 document.write('</object>\n');
}
