﻿// Archivo JScript

var variable = "";
var primeravez = "si";
function mostrarsubmenu(otromenu,nombresubmenu)
{
    if (variable!=otromenu)// || primeravez=="si")
    {
    if (primeravez=="si"){variable=otromenu;primeravez="no";}
    document.getElementById(variable +'normal').innerHTML = document.getElementById(variable +'claro').innerHTML;
    variable=otromenu;
    document.getElementById('submenu').innerHTML = document.getElementById(nombresubmenu).innerHTML;
    document.getElementById(otromenu +'normal').innerHTML = document.getElementById(otromenu +'oscuro').innerHTML;
    }
}
function ocultarsubmenu(otromenu,nombresubmenu)
{
/*
    if (variable!=otromenu)
    {
    variable=otromenu;
    //document.getElementById('submenu').innerHTML = document.getElementById(nombresubmenu).innerHTML;
    document.getElementById(otromenu +'normal').innerHTML = document.getElementById(otromenu +'claro').innerHTML;
    }
*/

}

function suministrarFormulario(querystring)
{/*
document.forms[0].action = querystring;
document.aspnetForm.action = querystring;
document.forms[0].submit();
*/
}
function LimpiarTexto(objeto)
{
objeto.value = "";
}
function limpia(elemento)
{
elemento.value = "";
}
function verifica(elemento)
{
/*if(elemento.value == "")elemento.value = "Escriba Aqui";*/
}
function VerificarSoloNumeros(e) {
                    //alert("puede que funcione");
                    tecla = (document.all) ? e.keyCode : e.which; // 2
                    if (tecla==8) return true; // 3
                    patron =/\d/; // 4
                    te = String.fromCharCode(tecla); // 5
                    return patron.test(te); // 6
                }
function CargarImagenGrande(elemento)
{
document.getElementById('divMostrarImagen').innerHTML = document.getElementById(elemento).innerHTML;
    
}
var nombreUltimoMenu = "";
var linkImagenUltimoMenu = "";
function GuardarInfoImagen(nombreObjeto,elemento)
{    
    nombreUltimoMenuClikeado = nombreObjeto;
    linkImagenUltimoMenu = elemento;
}
function LimpiarUltimaImagen()
{

    try
    {
    //alert(nombreUltimoMenuClikeado+linkImagenUltimoMenu.replace("_a",""));
    CargarImagen(nombreUltimoMenuClikeado,linkImagenUltimoMenu.replace("_a",""));
    }
    catch (e) 
    {
    }
}
function CargarImagen(nombreObjeto,elemento)
{
    //"http://beta.outlet.com.co/"
    //alert(nombreObjeto+""+elemento);
    //sector que guarda el ultimo objeto guardado
    
    //nombreUltimoMenuClikeado = nombreObjeto;
    //linkImagenUltimoMenu = elemento;
    var arrayVisores;
    
    if(document.getElementById(nombreObjeto))
    {
        arrayVisores = document.getElementById(nombreObjeto);
        arrayVisores.src = elemento;
    }
    else
    {
        //arrayVisores = document.getElementsByName(nombreObjeto);
        //arrayVisores[0].src = elemento;
        try
        {
        arrayVisores = document.getElementsByName(nombreObjeto);
        }
        catch (e) {}//arrayVisores = document.getElementsByClassName(nombreObjeto); }
        var i;
        i=0;
        for (i=0;i<arrayVisores.length;i++)
        {
        arrayVisores[i].src = elemento;
        }
    }    
}
function CambiarMenu(nombreObjeto,elemento)
{

    LimpiarUltimaImagen();
    CargarImagen(nombreObjeto,elemento);
    
}
function MostrarDivImagenGrande(elemento)
{
    document.getElementById('divisorMostrarImagen1').innerHTML = document.getElementById('divisorMostrarImagen').innerHTML;
    document.getElementById('divisorMostrarImagen1').style.display = "block";
    
}
function OcultarDivImagenGrande(elemento)
{
    document.getElementById('divisorMostrarImagen1').style.display = "none";
    
}
function TamVentana() {
  var Tamanyo = [0, 0];
  if (typeof window.innerWidth != 'undefined')
  {
    Tamanyo = [
        window.innerWidth,
        window.innerHeight
    ];
  }
  else if (typeof document.documentElement != 'undefined'
      && typeof document.documentElement.clientWidth !=
      'undefined' && document.documentElement.clientWidth != 0)
  {
 Tamanyo = [
        document.documentElement.clientWidth,
        document.documentElement.clientHeight
    ];
  }
  else   {
    //Tamanyo = [
    //    document.getElementsByTagName('body')[0].clientWidth,
     //   document.getElementsByTagName('body')[0].clientHeight
    //];
  }
  return Tamanyo;
}
function GetLeft(ele)
{
	if (ele.offsetParent)
		return ele.offsetLeft + GetLeft(ele.offsetParent);
	else
		return ele.offsetLeft;
}

function GetTop(ele)
{
	if (ele.offsetParent)
		return (ele.offsetTop + GetTop(ele.offsetParent));
	else
		return ele.offsetTop;
}
//var coordenadaX ;
//var coordenadaY ;
var tempX = 184;
var tempY = 200;

function MostrarDiv(elemento,mensaje)
{
    //getMouseXY();
    //muestraInformacion(document.onclick);
    document.getElementById(elemento).style.left = tempX.toString();
    document.getElementById(elemento).style.top = tempY.toString();
    //alert("Has pulsado el ratón en la posición: " + tempX.toString() + ", " + tempY.toString());
    document.getElementById('Txt'+ elemento).innerHTML = mensaje;//document.getElementById('divisorMostrarImagen').innerHTML;
    document.getElementById(elemento).style.display = "block";
    setTimeout("OcultarDiv('"+elemento+"');", 2500);
    
}
function MostrarDivXY(elemento,mensaje,tmpX,tmpY,Index,event,objetousado,direImagen)
{
    var Tam = TamVentana(); 
    var varr=GetLeft(objetousado) + 400 + 422;
    var valorizq = GetLeft(objetousado) - 330;
    var valorder = GetLeft(objetousado) + 230;
    var valorfinal;
    //getMouseXY();
    //muestraInformacion(document.onclick);
       
    if(valorizq < 0) valorfinal = valorder;
    else valorfinal = valorizq;
    //document.getElementById(elemento).style.left = valorderecha.toString();
    document.getElementById(elemento).style.left = valorfinal+'px';
    document.getElementById(elemento).style.top = tmpY+'px';
    document.getElementById(elemento + 'img').src = direImagen.toString();
    //alert("Has pulsado el ratón en la posición: " + tempX.toString() + ", " + tempY.toString());
       
   document.getElementById('Txt'+ elemento).innerHTML = 'es largo '+varr +' valorderecha ' + valorder+' La ventana mide: [' + Tam[0] + ', ' + Tam[1] + '] y mouse '+ event.clientX + '--' + event.clientY + 'y posision img '+ GetLeft(objetousado) + '--' + GetTop(objetousado);//mensaje;//document.getElementById('divisorMostrarImagen').innerHTML;
    document.getElementById(elemento).style.zIndex = "200";//Index;
    MostrarDivGeneralConValor(elemento,objetousado,tmpY);
    //document.getElementById(elemento).style.display = "block";
    //setTimeout("OcultarDiv('"+elemento+"');", 2500);
    
}
function OcultarDiv(elemento)
{
    document.getElementById(elemento).style.zIndex = 0;
    document.getElementById(elemento).style.display = "none";
    OcultarDivGeneral(elemento);
    
}
function MostrarDivGeneralConValor(elemento,objetousado,tmpY)
{
    var nomDivGeneral = "divgeneral";
    var varr=GetLeft(objetousado) + 400 + 422;
    var valorizq = GetLeft(objetousado) - 330;
    var valorder = GetLeft(objetousado) + 230;
    var valorfinal;
    
    if(valorizq < 0) valorfinal = valorder;
    else valorfinal = valorizq;
    
    document.getElementById(nomDivGeneral).style.left = valorfinal+'px';;
    document.getElementById(nomDivGeneral).style.top = tmpY+'px';
    document.getElementById(nomDivGeneral).style.zIndex = document.getElementById(elemento).style.zIndex;
    document.getElementById(nomDivGeneral).innerHTML = document.getElementById(elemento).innerHTML;
    document.getElementById(nomDivGeneral).style.display = "block";
}
function OcultarDivGeneral(elemento)
{
    var nomDivGeneral = "divgeneral";
    document.getElementById(nomDivGeneral).style.zIndex = 0;
    document.getElementById(nomDivGeneral).style.display = "none";
    
}
function MostrarDivNormal(elemento)
{
    document.getElementById(elemento).style.display = "block";
    
}
function PonerDivEnOtroDiv(elemento1,elemento2)
{
    ///alert(elemento1+elemento2);
    document.getElementById(elemento1).innerHTML = document.getElementById(elemento2).innerHTML ;
    //MostrarDiv(elemento1,"prueba");
    
}
function PonerDivEnOtroDivMensajes(elemento1,elemento2,mensaje)
{
    ///alert(elemento1+elemento2);
    document.getElementById(elemento1).innerHTML = document.getElementById(elemento2).innerHTML ;
    MostrarDiv(elemento1,mensaje);
    
}
function manejadorEventos(elEvento) {
  var evento = elEvento || window.event;
}
function muestraInformacion(elEvento) {
  var evento = elEvento || window.event;
  var coordenadaX = evento.clientX;
  var coordenadaY = evento.clientY;
  //alert("Has pulsado el ratón en la posición: " + coordenadaX + ", " + coordenadaY);
}
//document.onclick = muestraInformacion;

 //<script language="JavaScript1.2">
//<!--
/*
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false;

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE);

document.onmousemove = getMouseXY;

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  //document.Show.MouseX.value = tempX
  //document.Show.MouseY.value = tempY
  return true;
}

//-->
//</script>



/*este tres funciones siguientes manejan las cokies que se utilizan en milista*/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

/*funciones que se encargaran de abrir el visor de imagenes en una ventana separada*/
var winName="titulo";
var objVentVisorImagenes;
function Abrir_Ventana(a,w,h) 
{ 
    /*
    //para abrirla en pantalla completa
    alert("Para cerrar la ventana pulsa en tu teclado: ALT+F4") ;
    window.open("http://www.tutores.org","","fullscreen,scrollbars")

    //y esto para abrirla con una animacion 
    function expandingWindow(website) {
var heightspeed = 4; 
var widthspeed = 9; 
var leftdist = 0;
var topdist = 0; 
if (document.all) {
var winwidth = window.screen.availWidth - leftdist;
var winheight = window.screen.availHeight - topdist;
var sizer = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=1,height=1,scrollbars=yes");
for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
sizer.resizeTo("1", sizeheight);
}
for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) {
sizer.resizeTo(sizewidth, sizeheight);
}
sizer.location = website;
}
else
window.location = website;
}
</script>
<a href="http://www.tutores.org" onClick="expandingWindow('http://www.tutores.org/');return false;">Tutores.org</a> 
<br>
<a href="http://www.yahoo.com/" onClick="expandingWindow('http://www.yahoo.com/');return false;">Yahoo.com</a>     
    
    */    
    if(!objVentVisorImagenes)
    {
    theURL = a.getAttribute("href");
    var windowprops ="top=0,left=0,toolbar=no,location=no,status=no, menubar=no,scrollbars=yes, resizable=no,width=" + w + ",height=" + h;
    objVentVisorImagenes = window.open(theURL,winName,windowprops); 
    }
    else
    {
    objVentVisorImagenes.focus();
    }
} 
function Cerrar_Ventana() 
{ 
    window.close();
    if(objVentVisorImagenes)
    {
    objVentVisorImagenes.close();
    }
}
function Volver_Ventana_Anterior() 
{ 
    history.back();
    
}
function Abrir_Pagina(urlPagina) 
{
window.location=urlPagina; 
/*
//este es un ejemplo de como preguntar algo para dependiendo de la respuesta del cliente se realize o no
var donde_ir= confirm("Quieres visitarnos?");
if (donde_ir== true)
{ 
window.location="http://www.tutores.org/";
} 
else 
{ 
window.location="http://www.google.com/";
}*/
}


function ponervalorcajatexto(cajatextoid,valorponer,objcheckbox)
{
    var valortmp;
    var espaciador = "_";
    
    valortmp = document.getElementById(cajatextoid).value;
    if(objcheckbox.checked ) 
    {
    valortmp = valortmp + espaciador +  valorponer;
    }
    else
    {
    valortmp = valortmp.replace(espaciador + valorponer,"");
    }
    document.getElementById(cajatextoid).value = valortmp;
}
var tiendatimerID = 0;
var tiendacargado = false;
              
function ponertextoendivcambiante(numdatosborrados,iddivcambiar,cadenaarray,cadenaarraytele,cadenaarraydire,inicial,tiemporotacion,urlhrefreci)
{
    var nombre = "nombre";
    var otro = "otro";
    var otro1 = "otro";
    var urlhref = "urlhref";
    var urlonclick = "urlonclick";
    var espaciador = ",";
    var array,arraytele,arraydire;
    var i = inicial;
    
    //eval("alert('john');");
    
    array = cadenaarray.split(espaciador);
	arraytele = cadenaarraytele.split(espaciador);
	arraydire = cadenaarraydire.split(espaciador);
	
	if(numdatosborrados != 0)
	{
	//for(i=inicial;i<array.length;i++)
	//alert(tiemporotacion);
    ponertextoendiv(iddivcambiar+nombre,array[i]);
    ponertextoendiv(iddivcambiar+otro,arraytele[i]);
    ponertextoendiv(iddivcambiar+otro1,arraydire[i]);
    cambiarhref(iddivcambiar+urlhref,urlhrefreci);
    //cambiarhref(iddivcambiar+urlhref,"ListaTiendas.aspx?Empresa="+iddivcambiar);
    
    if(i<array.length-1) i++;
    else i=0;
    
    if (!tiendacargado) 
    {
           tiendatimerID = setTimeout("ponertextoendivcambiante('"+numdatosborrados+"','"+iddivcambiar+"','"+cadenaarray+"','"+cadenaarraytele+"','"+cadenaarraydire+"',"+i+","+tiemporotacion+",'"+urlhrefreci+"')", 7000);
    }
    }
}



function ponertextoendiv(iddivcambiar,mensajeponer)
{
    document.getElementById(iddivcambiar).innerHTML = mensajeponer ;
    
}
function cambiarhref(iddivcambiar,mensajeponer)
{
    document.getElementById(iddivcambiar).href = mensajeponer ;
    
}
function cambiarhrefonclick(iddivcambiar,mensajeponer)
{
    //alert(mensajeponer);
    document.getElementById(iddivcambiar).onClick = ""+mensajeponer+"" ;
    //document.getElementById(iddivcambiar).src = "css/ir.png" ;
    
    
}
function ejecutarcambiotxtdiv(numdatosborrados,iddivcambiar,cadenaarray,cadenaarraytele,cadenaarraydire,inicial,tiemporotacion,urlhrefreci)
{
    var nombre = "nombre";
    var tele = "tele";
    var dire = "dire";
    var urlhref = "urlhref";
    var urlonclick = "urlonclick";
    var espaciador = ",";
    var array,arraytele,arraydire;
    var i = inicial;
    
    try
    {
    //eval("alert('john');");
    
    array = cadenaarray.split(espaciador);
	arraytele = cadenaarraytele.split(espaciador);
	arraydire = cadenaarraydire.split(espaciador);
	
	if(numdatosborrados != 0)
	{
	//for(i=inicial;i<array.length;i++)
	//alert(tiemporotacion);
    ponertextoendiv(iddivcambiar+nombre,array[i]);
    ponertextoendiv(iddivcambiar+tele,arraytele[i]);
    ponertextoendiv(iddivcambiar+dire,arraydire[i]);
    cambiarhref(iddivcambiar+urlhref,urlhrefreci);
    cambiarhrefonclick(iddivcambiar+urlonclick,"Abrir_Pagina('"+urlhrefreci+"');");
    
    //cambiarhref(iddivcambiar+urlhref,"ListaTiendas.aspx?Empresa="+iddivcambiar);
    
    if(i<array.length-1) i++;
    else i=0;
    
    return i;
    }
    }
    catch (e)
    {
    //alert("hubo eror");
    }
}
function ciclocambiotxtdivzzz(cont1,cont2)
{
    //var cont1 = 0;
    //eval("alert('john');");
    cont1 = ejecutarcambiotxtdiv(2,12,'','','',cont1,200,'di.aspx/jj');
    cont2 = ejecutarcambiotxtdiv(2,12,'','','',cont2,200,'di.aspx/jj');
        
    if (!tiendacargado)
    {
           tiendatimerID = setTimeout("ciclocambiotxtdiv("+cont1+","+cont2+")", 7000);
    }
}



