﻿// INCIO DE FUNCIONES PARA ABRIR NUEVA VENTANA

		msg1 = document.getElementById('ayudaTelefono').innerHTML;
		
		tit1 = 'Ayuda contextual';
		w1 = '350';
		h1 = '200';

		//dentro1 = '<%=rutaImg + PreguntaActiva%>';
		//fuera1 = '<%=rutaImg + Pregunta%>';
		enlace1 = 'interrogacion1';
		
		valor1 = '<a href="javascript:void(0);" onmouseover="colocarImagen(dentro1,enlace1);" onmouseout="colocarImagen(fuera1,enlace1);"  onclick="posicionarVentana();nuevaVentana(msg1,tit1,w1,h1);return false;">';
		valor1 += '<img id="interrogacion1" src=' + fuera1 + ' alt="Ayuda" \/>';
		valor1 += '<\/a>';
		
		document.getElementById('ayudaTelefono').innerHTML = valor1;



var posicionX;
var posicionY;
var win = null;

function nuevaVentana(msg,tit,w,h)
{
	
	win = new Window(tit, {className: "dialog", title: "Lorem ipsum", width:500, height:0});
	
	win.setTitle(tit);
	win.getContent().innerHTML = msg;
	
	win.setDestroyOnClose();
	win.showCenter();
	win.setConstraint(false, {left:0, right:0});
	win.setSize(w,h);
	
	posicionX = posicionX - (w/2);
	posicionY = posicionY - (h/2);
//	alert("X =" + posicionX + ", Y="+posicionY);
	
	win.setLocation(posicionY,posicionX);
	
	var iden = win.getId();		
	var vent_close = iden+"_close";
  
	document.getElementById(vent_close).style.left = (w - 20) + "px";
	
	setTimeout(ponerFoco,1000);
}

function posicionarVentana()
{	
	if (window.innerHeight){
		var alto = window.innerHeight;
		var ancho = window.innerWidth;
	}else{
		var alto = document.documentElement.clientHeight;
		var ancho =document.documentElement.clientWidth;
	}
	
	
	posicionX = (ancho/2);
	posicionY = (alto/2);
	
}

function ponerFoco()
{
	document.getElementById("enlaceCerrar").focus();
}

// FIN DE FUNCIONES PARA ABRIR NUEVA VENTANA

function colocarImagen(imagen,iden)
{
	tot = document.getElementById(iden);
	tot.src = imagen;
}


//Ocultamos todas las ayudas cuando hay js activado
function ocultarAyudas()
{
	ayudas=getElementsByClassNamef(document, "div", "ayuda");
	for (i=0;i<ayudas.length;i++)
	{
		ayudas[i].className="oculto";
	}
}

function getElementsByClassNamef(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

