
/// Invitacion a un colega
function invitaacolega(val, idusu, opc){makeRequest("bienvenidos/invitaracolega.m3?idusu="+idusu+"&valor="+val+"&opc="+opc, moduloicc);}
function moduloicc(){if (http_request.readyState==4){document.getElementById("invitaracolega").innerHTML=http_request.responseText;}}
function cerrarinv(val){if (val==1){invitaracolega.innerHTML="";}else{alert ("???");}}

/////////////

function enviarmails(val, opc){
	
	if (val==1){if (document.frminvitacolega.para.value!=""){if (document.frminvitacolega.mensaje.value!=""){if (validarEmail(document.frminvitacolega.para.value))
			{makeRequest("bienvenidos/enviodemails.m3?val="+val+"&de="+document.frminvitacolega.de.value+"&para="+document.frminvitacolega.para.value+"&mensaje="+document.frminvitacolega.mensaje.value+"&mailde="+document.frminvitacolega.mailde.value+"&idusu="+document.frminvitacolega.idusu.value+"&opc="+opc, moduloicc);}}else{alert ("Debe de agregar un mensaje . . .");document.frminvitacolega.mensaje.focus();}}else{alert ("Debe de agregar un(s) mail(s) . . .");document.frminvitacolega.para.focus();}}
	if (val==2){
		if (document.frmhelpdesk.soporte.value!="")
		{
		makeRequest("bienvenidos/enviodemails.m3?val="+val+"&de="+document.frmhelpdesk.de.value+"&soporte="+document.frmhelpdesk.soporte.value+"&mailde="+document.frmhelpdesk.mailde.value+"&opc="+opc, modulos1);	
		}else{
		alert ("¿En que lo podemos ayudar?");
		document.frmhelpdesk.soporte.focus();
		}
	}
	if (val==3){
	
		if (document.frmhelpdesk.quejas.value!="")
		{
		idusu=document.frmhelpdesk.idusu.value;
		//alert("bienvenidos/enviodemails.m3?idusu="+document.frmhelpdesk.idusu.value+"&val="+val+"&de="+document.frmhelpdesk.de.value+"&quejas="+document.frmhelpdesk.quejas.value+"&mailde="+document.frmhelpdesk.mailde.value+"&opc="+opc);
		makeRequest("bienvenidos/enviodemails.m3?idusu="+document.frmhelpdesk.idusu.value+"&val="+val+"&de="+document.frmhelpdesk.de.value+"&quejas="+document.frmhelpdesk.quejas.value+"&mailde="+document.frmhelpdesk.mailde.value+"&opc="+opc, modulos1);	
		
		}else{
		alert ("Agregar una queja o una sugerencia");
		document.frmhelpdesk.quejas.focus();
		}
	}
	}
function entrada_comunidad(idpreg)
{
alert(idpreg);
}



function modulos1(){if (http_request.readyState==4){document.getElementById("sqys").innerHTML=http_request.responseText;}}

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

var count;
function ismaxlength2(obj,count){

	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	var contador2=obj.getAttribute("maxlength")-obj.value.length;
	//alert (contador2);
	//document.getElementById("cont_reportar_"+global_reportar).innerHTML=http_request.responseText
	document.getElementById("contador"+count).innerHTML="Max Caracteres "+contador2;
	
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}
function letras_gral(texto, contador, limite)
{
	if(texto.value.length>limite)
	{
	texto.value=texto.value.substring(0, limite);
	}else{
	contador.value=limite-texto.value.length;
	}
}



///// Cambia a municipio y estado
function cambialoc(){document.frmregini2.idmunicipio.disabled=0;makeRequest("registro/cargacombos.m3?idopcion=1&idmun=" + document.frmregini2.idestado.value, modulomun);}
function mun(){makeRequest("registro/cargacombos.m3?idopcion=1&idmun=" + document.frmregini2.idestado.value, modulomun);}
function modulomun(){if (http_request.readyState==4){document.getElementById("vermun").innerHTML=http_request.responseText;}}
function col(){document.frmregini2.idcolonia.disabled=0;makeRequest("registro/cargacombos.m3?idopcion=2&idcol=" + document.frmregini2.idmunicipio.value, modulocol);}
function modulocol(){if (http_request.readyState==4){document.getElementById("vercol").innerHTML=http_request.responseText;}}
//// Fin

function cambiaregistro(val)
	{
		if (val==1)
			{
			//alert ("Gratis");
			}else{
		if (val==2)
			{
			//alert ("Completo");
			}}
	}

function guardau(val)
{
	if (val==1)
	{
		alert ("El registro gratuito esta en contruccion");
	}else{
	    if (val==2)
            {
		///Registro de Usuarios
			for (i=0;i<document.frmregini2.cargo.length;i++){if (document.frmregini2.cargo[i].checked == true){cargo = document.frmregini2.cargo[i].value;}}
		
			if (document.frmregini2.nombreu.value!="")
			{
			if (document.frmregini2.apellidosu.value!="")
			{
			if (document.frmregini2.inmobiliarias.selectedIndex>0)
			{
			if (document.frmregini2.telu.value!="")
			{
			if (document.frmregini2.mailu.value!="")
			{
				if ((document.frmregini2.pwdu1.value!="") && (document.frmregini2.pwdu2.value!=""))
				{
					
					if ((document.frmregini2.pwdu1.value)==(document.frmregini2.pwdu2.value))
						{
							if (validarEmail(document.frmregini2.mailu.value))
							    {
								if (document.frmregini2.mailu.value==document.frmregini2.mailutmp.value)
								{
								document.getElementById("addreg").innerHTML=makeRequestSync("registro/agregausu.m3?idopcion=2&nomu="+document.frmregini2.nombreu.value+"&apeu="+document.frmregini2.apellidosu.value+"&idempresa="+document.frmregini2.inmobiliarias.value+"&telu="+document.frmregini2.telu.value+"&celu="+document.frmregini2.celu.value+"&nextu="+document.frmregini2.nextu.value+"&mailu="+document.frmregini2.mailu.value+"&pwdu1="+document.frmregini2.pwdu1.value+"&tit="+document.frmregini2.titulo.value+"&cargo="+cargo+"&coment="+document.frmregini2.coment.value);
							    	tb_remove();// cerramos el sombreado
								}else{
								alert ("Los correos electrónicos son diferentes, favor de corregirlos, gracias . . .");
								document.frmregini2.mailu.focus();
								}
							    }
						}else{
						alert ("Los passwords son diferentes");
						}
				}else{
				alert ("Agregar passwords");
				}
				}else{
				alert ("Agregar un correo electrónico");
				document.frmregini2.mailu.focus();
				}
				}else{
				alert ("Agregar el telefono");
				document.frmregini2.telu.focus();
				}
				}else{
				alert ("Seleccionar una inmobiliaria");
				document.frmregini2.inmobiliarias.focus();
				}
				}else{
				alert ("Agregar el campo de apellido");
				document.frmregini2.apellidosu.focus();
				}
				}else{
				alert ("Agregar el campo de nombre");
				document.frmregini2.nombreu.focus();
				}
		
		}else{
		///Prospectos
			if (document.frmregini2.nombreu.value!="")
			{
			if (document.frmregini2.telu.value!="")
			{
			if (document.frmregini2.mailu.value!="")
			{
			if (document.frmregini2.empresa.value!="")
			{

				if (validarEmail(document.frmregini2.mailu.value))
				    {
					document.getElementById("addreg").innerHTML=makeRequestSync("registro/agregausu.m3?idopcion=3&nomu="+document.frmregini2.nombreu.value+"&empresa="+document.frmregini2.empresa.value+"&telu="+document.frmregini2.telu.value+"&mailu="+document.frmregini2.mailu.value+"&coment="+document.frmregini2.coment.value+"&origen="+document.frmregini2.origen.value);
					setTimeout("tb_remove();",2000)// cerramos el sombreado en 5 segundos
				    }	
			}else{
			alert ("Debe de agregar el nombre de su empresa");
			document.frmregini2.empresa.focus();
			}
			}else{
			alert ("Agregar un correo electrónico");
			document.frmregini2.coment.focus();
			}
			}else{
			alert ("Agregar el telefono");
			document.frmregini2.telu.focus();
			}
			}else{
				alert ("Agregar el campo de nombre");
				document.frmregini2.nombreu.focus();
			}

		}
		}
	}

function GetFileExtension(Filename) 
	{
	var I = Filename.lastIndexOf(".");
	return (I > -1) ? Filename.substring(I + 1, Filename.length).toLowerCase() : "";
	}



function cargafoto2()
	{
	if (document.frmcargalog.fileUpload2.value!="")
		{

		if (document.frmregini2.mailu.value!="")
			{
			mailu=document.frmregini2.mailu.value;
			document.frmcargalog.mailu2.value=mailu;
			frmcargalog.submit();
			}else{
			alert ("para subir la foto necesita agregar el mail");
			document.frmregini2.mailu.focus();
			}
		}else{
		alert ("Agregar una foto");
		}
	}

function accsotmp()
{
	us=document.frmregini2.mailu.value
	up=document.frmregini2.pwdu1.value;
	//ub=pasoa5("" + us + up);
	
	  addreg.innerHTML='<center><img src=/m3/images/spinner.gif></center>';
	//logns.innerHTML=document.getElementById('<center><img src=/m3/images/spinner.gif></center>');
	
	
	//alert ("valida.m3?us=" + us + "&up=" + up);
	makeRequest("valida.m3?us=" + us + "&up=" + up, modulotmp);
	
	if (us!="" && up!="")
	{
	      addreg.innerHTML="<center><img class='bcomed' src=/m3/images/spinner.gif><br>Validando usuario.....!</center>";
	    //logns.innerHTML=document.getElementById("<center><img src=/m3/images/spinner.gif><br>Validando usuario.....!</center>");
	}else
		{
		 addreg.innerHTML="<font class='bcomed'><center>No puede omitir los campos<br> Usuario o Contraseña </center></b></font>";
		 setTimeout("ptaule=0;ptaul();",650);
		}
}

function modulotmp()
{
	if (http_request.readyState == 4)
	{	
		if (http_request.status == 200)
		{
			datos=http_request.responseText;
			eval(datos);
		}else{
			alert("No se encontraron datos");
		}
	}
}


function detalle2(idinm, id)
{
	makeRequest("detallegral.m3?idinm="+idinm+"&opc="+id, modulode);
	scroll(0,0);
	/*	
	document.getElementById("muestrapag1").style.display="";
	document.getElementById("gridmuestra").innerHTML="OKSM";
	Scroll(0,0);
	
	

	
		makeRequest("detalle.m3?idinmueble="+idinm+"&sta=1&oculta=1", modulode);
		document.getElementById("gridmuestra").innerHTML=sH;
		setTimeout(function(){muestraimgs(idinm);},4000);
	*/
}

function modulode(){
	if (http_request.readyState==4){document.getElementById("gridmuestra").innerHTML=http_request.responseText;
}}


function muestraimgs(idinm){

	var muestraimgsHTTP=makeRequestSync("imagenes.m3?idinmueble="+idinm);
	galeria.innerHTML=muestraimgsHTTP;
	
	}

function Pagina(nropagina, idinm){if (nropagina){makeRequest("imagenes.m3?pag="+nropagina+"&idinmueble="+idinm, modresultfoto);}}
function modresultfoto(){if (http_request.readyState==4){document.getElementById("galeria").innerHTML=http_request.responseText;}}
function allphotos(idinm) {open("allphotos.m3?idinmueble="+idinm,"miVentana", "width=400,height=500,toolbar=no,scrollbars=yes,directories=no,menubar=no,status=no"); } 

//////////

var tooltip=function(){

	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
		
			if(tt == null){
			
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				
				
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			
			tt.style.display = 'block';
					
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		border:function(obj){
		

			var id_ajax=obj.id;

			document.getElementById(id_ajax).border="2 px";
			document.getElementById(id_ajax).borderStyle="solid";
			document.getElementById(id_ajax).style.borderColor="red";

			
		},
		hide_border:function(obj){
				
					obj.setAttribute("border", "0px ");
		
				
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

function busco_change(idopcion3)
{
var busco=makeRequestSync("foro/buscoofrezco.m3?idopcion3="+idopcion3);
document.getElementById("show_selector").innerHTML=busco;
}

function promo(){alert ("próximamente");}

function regresar()
{
 window.history.go(-1);
}

function frmpromo(val, cta)
{
	if (val==1)
	{
		var promo=document.getElementById("frmreporte"); 
		if (promo.value!="")
		{
			var varx = "&opc='1b'&idsubcanal=7&opc2=1";
			var varxx = Base64.encode(varx);
			window.location.href="admin.m3?tit=Reporte de promoción&cad="+ varxx +"&cve="+promo.value;
		}else{
			alert ("Favor de agregar la clave, gracias . . .");
		}
	}

	if (val==2)
	{
		if (document.frmcvepromo.cvepromo.value!="")
			{
				var idcli=document.frmcvepromo.idcli.value;
				var varx = "&opc='1b'&idsubcanal=7&opc2=2&idcli="+idcli;
				var varxx = Base64.encode(varx);
				window.location.href="admin.m3?tit=Reporte de promoción&cad="+ varxx +"&cve="+document.frmcvepromo.cvepromo.value;
			}else{
				alert ("Favor de agregar la clave del inmueble, gracias");
			}
	}

	if (val==3)
	{
		var promo=document.getElementById("frmreporte_"+cta); 
		if (promo.value!="")
		{
			var varx = "&opc='1b'&idsubcanal=7&opc2=1";
			var varxx = Base64.encode(varx);
			window.location.href="admin.m3?tit=Reporte de promoción&cad="+ varxx +"&cve="+promo.value;
		}else{
			alert ("Favor de agregar la clave, gracias . . .");
		}
	}

}


function cargapromo(val)
{

document.getElementById("pediralfa").style.visibility="visible";

/*
var cve = prompt("Ingresa la clave", "");

if (cve!="" || cve!=null)
{
	document.location="admin.m3?tit=Crear reporte de propietario&cad="+val+"&cve="+cve;
}else{
	alert ("Debe de proporcionar una clave");
}
*/
	
}

function promoref()
{

if (document.frmpubli.nom.value!="")
{
if (document.frmpubli.tel.value!="")
{
if (document.frmpubli.mail.value!="")
{
if (document.frmpubli.coment.value!="")
{
	if (validarEmail(document.frmpubli.mail.value))
	{

	var a = document.frmpubli.nom.value;
	var b = document.frmpubli.tel.value;
	var c = document.frmpubli.mail.value;
	var d = document.frmpubli.coment.value;
	var e = document.frmpubli.horario.value;

		var promo=makeRequestSync("publicidad/mail_publi.m3?nom="+a+"&tel="+b+"&mail="+c+"&coment="+d+"&horario="+e);
		document.getElementById("show_promo").innerHTML=promo;
		alert ("Correo electrónico enviado, gracias . . .");
		tb_remove();

	}	
}else{
document.frmpubli.coment.focus()
alert ("Agregar de favor un comentario, gracias . . .")
}
}else{
document.frmpubli.mail.focus()
alert ("Agregar de favor un correo electrónico, gracias . . .")
}
}else{
document.frmpubli.tel.focus()
alert ("Agregar de favor un número telefónico, gracias . . .")
}
}else{
document.frmpubli.nom.focus()
alert ("Agregar de favor un nombre, gracias . . .")
}
}

function pulsar(obj) { 
    if (!obj.checked) return 
    elem=document.getElementsByName('chk'); 
    for(i=0;i<elem.length;i++)  
        elem[i].checked=false; 
    obj.checked=true; 
} 

function selfpago(idusu)
{
	var val;
	if (document.getElementById('chk1').checked){val=1;}
	if (document.getElementById('chk2').checked){val=2;}
	if (document.getElementById('chk3').checked){val=3;}
	if (document.getElementById('chk4').checked){val=4;}
	if (val>0)
	{
		//alert (val + " - " + idusu);
		var fpago=makeRequestSync("edocta/actualiza.m3?idusu="+idusu+"&val="+val);
		document.getElementById("edocta").innerHTML=fpago;
		alert ("Su opción de pago se registro con éxito, gracias  . . .");
		//tb_remove();
		window.location.reload();
	}else{
	alert ("Debes de elegir tu forma de pago, Gracias . . .");
	}
}

