// JavaScript Document

function searchCommentCoord(obj, menu) {
	if (document.getElementById){
		var i = document.getElementById(obj)
		var c = document.getElementById(menu)
		
		if (c.style.display != "block"){
			var l=0
			var t=0
			aTag = i
		
			do {
				aTag = aTag.offsetParent
				l += aTag.offsetLeft
				t += aTag.offsetTop
			} while (aTag.offsetParent && aTag.tagName != 'BODY')
				var left =  i.offsetLeft + l
				var top = i.offsetTop + t + i.offsetHeight
				
//				left = left - parseInt(c.style.width)
//				top = top - parseInt(c.style.height)
	
				c.style.left = eval(left-280)+'px'
				c.style.top = eval(top-100)+'px'
//				c.style.display = "block"
		} else {
			c.style.display="none"
		}
	}
}

function checkAsistance (PageLocation){
	var reqPage = false;
	
	if (window.XMLHttpRequest){
		reqPage = new XMLHttpRequest ();
	} else if (window.ActiveXObject){
		try {
			reqPage = new ActiveXObject ("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				reqPage = new ActiveXObject ("Microsoft.XMLHTTP");
			} catch (e) {
			
			}
		}
	} else
		return false;
		reqPage.onreadystatechange = function (){
		LoadAsistancePage (reqPage);
		}

		reqPage.open ('GET', PageLocation, true); 
		reqPage.send (null);
}

var onLine = false
var nowVar = false
var onLineCode = "<a href='#' onClick='return initAsistance()'><img src='/interact/images/boton_consejero_online.gif' border='0' id='chatBottom' onmouseover=\"searchCommentCoord(this.id,'chatMessage'); document.getElementById('chatMessage').style.display = 'block'\" onmouseout=\"document.getElementById('chatMessage').style.display = 'none'\"></a>"
	onLineCode += "<div id='chatMessage' align='left' style='background-color:white; padding:10px; border:1px solid #DDDDDD; display:none; font-size:11px; width:250px; position:absolute;'><p><b>Este módulo está disponible exclusivamente para nuestros clientes con interés en cualquiera de nuestros programas de Lunas de Miel y Celebraciones, listados en la categoría “Destinos”</b></p><p>Para cualquier otro destino (Las Vegas, Playas, boletos de avión, etc.) favor de comunicarte por teléfono a cualquiera de nuestras oficinas.</p></div>"
var offLineCode = "<a href='#' onClick='return initAsistance()'><img src='/interact/images/boton_consejero_offline.gif' border='0'></a>"

var onLineCodeForm = "<input type='image' name='imageField' src='images/boton_consejero_online.gif'>"
var offLineCodeForm = "<input type='image' name='imageField' src='images/boton_consejero_offline.gif'>"

document.getElementById("chatStatusConse").innerHTML = offLineCode
if (document.getElementById("chatStatusConse1")){ document.getElementById("chatStatusConse1").innerHTML = offLineCode }

function LoadAsistancePage (reqPage) {
	if (reqPage.readyState == 4 && (reqPage.status == 200 || window.location.href.indexOf ("http") == - 1)){
		if (reqPage.responseText == "noconse"){
			onLine = false
		} else {
			onLine = true
		}
		
		if (nowVar != onLine){
			if (onLine){
				document.getElementById("chatStatusConse").innerHTML = onLineCode
				if (document.getElementById("chatStatusConse1")){ document.getElementById("chatStatusConse1").innerHTML = onLineCodeForm }
			} else {
				document.getElementById("chatStatusConse").innerHTML = offLineCode
				if (document.getElementById("chatStatusConse1")){ document.getElementById("chatStatusConse1").innerHTML = offLineCodeForm }
			}
			
			nowVar = onLine
		}
	}
}

var theTime

function checkConse(){
	checkAsistance("/asistencia/checkConse.htm")
}

function initAsistance(){
	open('/asistencia/initAsist1.htm','','toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=no, width=400, height=600, top=100, left=100, dependent')
	return false
}

setInterval("checkConse()",1000)
