//-----

cambiarImagen = function (imgName, imgSrc) {

  if (document.images){

    if (imgSrc != "none"){

      document.images[imgName].src = imgSrc;

    }

  }

}

//-----

colorea = function (id, onmouse, tipo) {

	var obj = document.getElementById(id);

	if (onmouse == 'over' && tipo == 'mnu') {

		obj.style.cursor = 'pointer';

		obj.style.background = '#ffcc66';

	} else if (onmouse == 'out' && tipo == 'mnu') {

		obj.style.background = '#e2e2e2';

		obj.style.cursor = 'default';

	}

	if (onmouse == 'over' && tipo == 'sub') {

		obj.style.cursor = 'pointer';

		obj.style.background = '#ffcc66';

	} else if (onmouse == 'out' && tipo == 'sub') {

		obj.style.background = '';

		obj.style.cursor = 'default';

	}

}

//-----

redir = function (url) {

	document.location.href = url;

}

//-----

openSub = function (numTbl, idMnu) {

	var objSub;

	for (i=0; i<menuNum(); i++) {

		objSub = document.getElementById('tblSub_'+i);

		objSub.style.display = 'none';

	}

	

	var objMnuO;

	for (i=0; i<menuNum(); i++) {

		objMnuO = document.getElementById('btnMnu_'+i);

		objMnuO.style.background   = '#e2e2e2';

		objMnuO.onmouseover        = function () { this.style.background = '#ffcc66' };

		objMnuO.onmouseout         = function () { this.style.background = '#e2e2e2' };

		objMnuO.style.cursor       = 'pointer';

		

		objMnuO.style.border       = '1px solid #fff';

		objMnuO.style.borderBottom = '1px solid #999';

	}

	

	var objTbl = document.getElementById('tblSub_'+numTbl);

	objTbl.style.display = val();

	

	var objMnu = document.getElementById(idMnu);

	objMnu.style.background   = '#fff';

	objMnu.onmouseover        = function () { this.style.background = '#fff' };

	objMnu.onmouseout         = function () { this.style.background = '#fff' };

	objMnu.style.cursor       = 'default';

	

	objMnu.style.border       = '1px solid #999999';

	objMnu.style.borderBottom = '1px solid #fff';

}

//-----

function getWindowHeight() {

	var windowHeight = 0;

	if (typeof(window.innerHeight) == 'number') {

		windowHeight = window.innerHeight;

	}

	else {

		if (document.documentElement && document.documentElement.clientHeight) {

			windowHeight = document.documentElement.clientHeight;

		}

		else {

			if (document.body && document.body.clientHeight) {

				windowHeight = document.body.clientHeight;

			}

		}

	}

	return windowHeight;

}

//

function setContent(tipo, nomEmpr, lnkEmpr,ide) {

	//

	var objTransparentDiv = document.getElementById('transparent');

	objTransparentDiv.style.height = document.documentElement.scrollHeight+'px';

	objTransparentDiv.style.display = 'block';

	//

	if (document.getElementById) {

		var windowHeight = getWindowHeight();

		if (windowHeight > 0) {

			//

			var objF = document.getElementById('form');

			objF.style.display = 'block';

			var objForm = document.getElementById('content');

			switch (tipo) {

				case 'contacto':

					objForm.style.display = 'block';

					setContent();

					var form;

					objForm.innerHTML = '';

					form  = '<div id="titForm">CONTACTO CON elinmobiliario.com</div>';

					form += '<div id="cerrar"><a href="#" onclick="cerrar(); return false;">cerrar</a></div>';

					form += '<div style="clear:right; width:100%; class="clearfix">';

					form += '	<!--<form action="" method="post">-->';

					form += '	<table width="100%" cellspacing="3" cellpadding="0" border="0" style="border-spacing:3px; border-collapse:separate; background:#f4f4f4;">';

					form += '		<tr>';

					form += '			<td width="100%" colspan="2" align="center"><b>'+nomEmpr+'</b></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="100%" height="20" colspan="2" align="center"><img src="landnigpage/1px.gif" width="1" height="20px" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Nombre y Apellido&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="nombre" name="nombre" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">E-mail&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="email" name="email" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Tel&eacute;fono&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="telefono" name="telefono" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Comentario&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><textarea id="comentario" name="comentario" type="textarea" value="" style="height:40px;" class="txtForm"></textarea></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="100%" height="1" colspan="2" align="center"><img src="landnigpage/1px.gif" width="1" height="1px" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="100%" height="22" colspan="2" align="center"><input class="btn" type="button" value="Enviar" onclick="procesaForm(fieldsValuesForms(1));" /></td>';

					form += '		</tr>';

					form += '	</table>';

					form += '	<!--</form>-->';

					form += '</div>';

					

					objForm.innerHTML += form;

					break;

				case 'masinfo':

					objForm.style.display = 'block';

					setContent();

					var form;

					objForm.innerHTML = '';

					form  = '<div id="titForm">M&Aacute;S INFORMACI&Oacute;N DEL EMPRENDIMIENTO</div>';

					form += '<div id="cerrar"><a href="#" onclick="cerrar(); return false;">cerrar</a></div>';

					form += '<div id="contentForm" style="clear:right; width:100%; class="clearfix">';

					form += '	<!--<form action="" method="post">-->';

					form += '	<table width="100%" cellspacing="3" cellpadding="0" border="0" style="border-spacing:3px; border-collapse:separate; background:#f4f4f4;">';

					form += '		<tr>';

					form += '			<td width="100%" colspan="2" align="center"><b>'+nomEmpr+'</b></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="100%" height="20" colspan="2" align="center"><img src="landnigpage/1px.gif" width="1" height="20px" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Nombre y Apellido&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="nombre" name="nombre" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">E-mail&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="email" name="email" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Tel&eacute;fono&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="telefono" name="telefono" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Comentario&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><textarea id="comentario" name="comentario" type="textarea" value="" style="height:40px;" class="txtForm"></textarea></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="100%" height="1" colspan="2" align="center"><img src="landnigpage/1px.gif" width="1" height="1px" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="100%" height="25" colspan="2" align="center"><input type="hidden" name="id_emprop" id="id_emprop" value="'+ide+'"><input type="hidden" name="nombre_e" id="nombre_e" value="'+nomEmpr+'"><input class="btn" type="button" value="Enviar" onclick="enviarDatos();" /></td>';

					form += '		</tr>';

					form += '	</table>';

					form += '	<!--</form>-->';

					form += '</div>';

					

					objForm.innerHTML += form;

					break;

				case 'amigo':

					objForm.style.display = 'block';

					setContent();

					var form;

					objForm.innerHTML = '';

					form  = '<div id="titForm">ENVIAR A UN AMIGO</div>';

					form += '<div id="cerrar"><a href="#" onclick="cerrar(); return false;">cerrar</a></div>';

					form += '<div style="clear:right; width:100%;">';

					form += '	<!--<form action="" method="post">-->';

					form += '   <input id="lnkEmpr" name="lnkEmpr" type="hidden" value="'+lnkEmpr+'" />';

					form += '	<table width="100%" cellspacing="3" cellpadding="0" border="0" style="border-spacing:3px; border-collapse:separate; background:#f4f4f4;">';

					form += '		<tr>';

					form += '			<td width="100%" colspan="2" align="center"><b>'+nomEmpr+'</b></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="100%" height="0" colspan="2" align="center"><img src="landnigpage/1px.gif" width="1" height="0" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Tu Nombre y Apellido&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="nombre" name="nombre" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Tu E-mail&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="email" name="email" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Nombre y Apellido Amigo&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="nombre" name="nombre" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">E-mail Amigo&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><input id="email" name="email" type="text" value="" class="txtForm" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="40%" align="right">Comentario&nbsp;&nbsp;</td>';

					form += '			<td width="60%" align="left"><textarea id="comentario" name="comentario" type="textarea" value="" style="height:40px;" class="txtForm"></textarea></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="100%" height="1" colspan="2" align="center"><img src="landnigpage/1px.gif" width="1" height="1px" /></td>';

					form += '		</tr>';

					form += '		<tr>';

					form += '			<td width="100%" height="25" colspan="2" align="center"><input class="btn" type="button" value="Enviar" onclick="procesaForm(fieldsValuesForms(1));" /></td>';

					form += '		</tr>';

					form += '	</table>';

					form += '	<!--</form>-->';

					form += '</div>';

					

					objForm.innerHTML += form;

					break;

				

			}

			//

			var contentElement = document.getElementById('content');

			var contentHeight = contentElement.offsetHeight;

			if (windowHeight - contentHeight > 0) {

				contentElement.style.position = 'relative';

				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + getScrollXY() +'px'; 

			}

			else {

				contentElement.style.position = 'static';

			}

		}

	}

}

/*

function mostrar () {

	window.onload = function() {

		setContent();

	}

	window.onresize = function() {

		setContent();

	}

}

*/

//

function getScrollXY() {

	var scrOfX = 0, scrOfY = 0;

	if( typeof( window.pageYOffset ) == 'number' ) {

		scrOfY = window.pageYOffset;

		//scrOfX = window.pageXOffset;

	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {

		scrOfY = document.body.scrollTop;

		//scrOfX = document.body.scrollLeft;

	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {

		scrOfY = document.documentElement.scrollTop;

		//scrOfX = document.documentElement.scrollLeft;

	}

	//window.alert( 'Horizontal scrolling = ' + scrOfX + '\nVertical scrolling = ' + scrOfY );

	return scrOfY;

}

//

//window.onscroll = setContent();

//

lightwindow = function (tipo) {

	var objTransparentDiv = document.getElementById('transparent');

	objTransparentDiv.style.height = document.documentElement.scrollHeight+'px';

	objTransparentDiv.style.display = 'block';

	var objForm = document.getElementById('content');

	switch (tipo) {

		case 'contacto':

			objForm.style.display = 'block';

			setContent();

			objForm.innerHTML = '<b><a href="#">www.elinmobiliario.com</a></b>';

	}

}

//

cerrar = function () {

	var objForm = document.getElementById('content');

	objForm.style.display = 'none';

	var objTransparentDiv = document.getElementById('transparent');

	objTransparentDiv.style.display = 'none';

	var objF = document.getElementById('form');

	objF.style.display = 'none';

}



enviarDatos = function () 

{

		var retVal = true;

		var msg = "Es necesario que ingrese ";

		var nombre = "";

		var email = "";

		var telefono = "";

		var comentario = "";

		var id_emprop = "";

		var nombre_e = "";

		try

		{

			nombre = document.getElementById("nombre").value;

			email = document.getElementById("email").value;

			telefono = document.getElementById("telefono").value;

			comentario = document.getElementById("comentario").value;

			id_emprop = document.getElementById("id_emprop").value;

			nombre_e = document.getElementById("nombre_e").value;

			// limpiamos formulario

			//document.getElementById("nombre").value = "";

			//document.getElementById("email").value = "";

			//document.getElementById("telefono").value = "";

			//document.getElementById("comentario").value = "";

		} catch(e) {

			nombre = document.all.nombre.value;

			email = document.all.email.value;

			telefono = document.all.telefono.value;

			comentario = document.all.comentario.value;

			id_emprop = document.all.id_emprop.value;

			nombre_e = document.all.nombre_e.value;

			// limpiamos formulario

			//document.all.nombre.value = "";

			//document.all.email.value = "";

			//document.all.telefono.value = "";

			//document.all.comentario.value = "";

			//document.all.id_emprop.value = "";

		}

		if (nombre == "") {

			retVal = false;

			msg += " su nombre ";

		}

		if ((email == "") && (telefono == "")) {

			msg += ((!retVal)?"y":"") + " telefono o email ";

			retVal = false;

		}

		if (!retVal) {

			alert(msg);

			return retVal;

		}

		var cont = "";

		try

		{

			htmlContactForm = document.getElementById("contentForm").innerHTML;

			document.getElementById("contentForm").innerHTML = '<table style="margin:40px" border="0" cellspacing="0" cellpadding="0"><tr><td class="textochico" align="center" height="30"><font color="#ffffff" style="font-size:16px"><strong>Enviando el mensaje a la inmobiliaria, un momento por favor...</strong></font></td></tr></table>';

		} catch (e) {

			//htmlContactForm = document.all.content.innerHTML;

			//document.all.content.innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="textochico" align="center" height="30"><font color="#006699"><strong>Enviando email a la inmobiliaria, un momento por favor...</strong></font></td></tr></table>';

		}

		x_envioContacto (id_emprop, nombre_e, cont, nombre, email, telefono, comentario, enviarDatos_result);

		//enviarDatos_result('');

	}



enviarDatos_result = function (z)

{

	try{

		window.location.href = "http://www.elinmobiliario.com/info.php?cont=msgPta.inc.php";

	}catch (e){

	document.getElementById("contentForm").innerHTML = '<table style="margin:40px" border="0" cellspacing="0" cellpadding="0"><tr><td class="textochico" align="center" height="30"><font color="#ffffff" style="font-size:16px"><strong>El mensaje fue enviado correctamente a la inmobiliaria...</strong></font></td></tr></table>';

	setTimeout('cerrar()',2000);

	}

}


enviarDatosLanding = function () 

{

		var retVall = true;

		var msgl = "Es necesario que ingrese ";

		var nombrel = "";

		var emaill = "";

		var telefonol = "";

		var comentariol = "";

		var id_landingl = "";

		try

		{

			nombrel = document.getElementById("nombrel").value;

			emaill = document.getElementById("emaill").value;

			telefonol = document.getElementById("telefonol").value;

			comentariol = document.getElementById("comentariol").value;

			id_landingl = document.getElementById("id_landingl").value;

		} catch(e) {

			nombrel = document.all.nombrel.value;

			emaill = document.all.emaill.value;

			telefonol = document.all.telefonol.value;

			comentariol = document.all.comentariol.value;

			id_landingl = document.all.id_landingl.value;

		}

		if (nombrel == "") {

			retVall = false;

			msgl += " su nombre ";

		}

		if ((emaill == "") && (telefonol == "")) {

			msgl += ((!retVall)?"y":"") + " telefono o email ";

			retVall = false;

		}

		if (!retVall) {

			alert(msgl);

			return retVall;

		}

		//var contl = "";

		try

		{

			//htmlContactForm = document.getElementById("contentForm").innerHTML;

			//document.getElementById("contentForm").innerHTML = '<table style="margin:40px" border="0" cellspacing="0" cellpadding="0"><tr><td class="textochico" align="center" height="30"><font color="#ffffff" style="font-size:16px"><strong>Enviando el mensaje a la inmobiliaria, un momento por favor...</strong></font></td></tr></table>';

		} catch (e) {}

		x_envioContactoLanding (id_landingl, nombrel, emaill, telefonol, comentariol, enviarDatosLanding_result);

		//enviarDatosLanding_result('n');

	}



enviarDatosLanding_result = function (z)

{

	document.getElementById("ConfcontactoLanding").innerHTML = '<br><br><br>Su consulta fue enviada con &eacute;xito.';

	document.getElementById('boton_contactoLanding').disabled = false;

	document.getElementById("contactoLanding").style.display = 'none';

	document.getElementById("ConfcontactoLanding").style.display = '';

	setTimeout('restauraContacto()',3000);

}



restauraContacto = function ()

{

	document.getElementById("nombrel").value = "";

	document.getElementById("emaill").value = "";

	document.getElementById("telefonol").value = "";

	document.getElementById("comentariol").value = "";

	document.getElementById("ConfcontactoLanding").style.display = 'none';

	document.getElementById("contactoLanding").style.display = '';

}