function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  ventana = window.open(theURL,winName,features);
  if (ventana.opener == null) ventana.opener = self;
	ventana.focus();
}

var capa=null; 

function mostrar_nd_foto(c) { 
  obj=document.getElementById(c); 
  if(capa!=null) 
    capa.style.visibility='hidden'; 
  obj.style.visibility='visible'; 
  capa=obj; 
} 

function ir_para(forma,pagina){
	forma.action =  pagina;
	forma.submit();		
}
function mostrar_r(opcion_combo,id,valor){
	if (opcion_combo==valor){
  		eval(id + ".style.display=\"inline\"");
	}else{
		eval(id + ".style.display =\"none\"");
	}
}

function mostrar_ramo(opcion_combo,id){
	if (opcion_combo=="Empresa Inmobiliaria"){
  		eval(id + ".style.display=\"inline\"");
	}else{
     eval(id + ".style.display =\"none\"");
	}
}

function asignar_valor(objtext,valor){
 objtext.value=valor;
}

function email_contacto(cadena_email,seleccionado,combo_contacto){
 var array;
 var temp;
 array=cadena_email.value.split("|");
 for(var i=0;i<array.length;i++){
  temp=array[i].split(";");
  if(temp[0]==seleccionado) {combo_contacto.value=temp[1];};
 }
}

function colocar_seleccionado(obj_opcion, valor){

 for(var i=0; i<obj_opcion.length;i++){
  if (obj_opcion.options[i].value==valor){
   obj_opcion.options[i].selected=true;

  }
 }
}

function validar_todo(laforma){
	fallo = false;
	for(var i = 0; i < laforma.elements.length && !fallo; i++){
		if(laforma.elements[i].value == ""){
			fallo = true;
			alert("Ingrese todos los campos requeridos como obligatorios");
			laforma.elements[i].focus();
		}
	}
	if(!fallo){
		return true;
	}else{
		return false;
	}
}

function limpialo(id){
	var idt=id;
	document.getElementById(idt).innerHTML = '';
	document.getElementById(idt).style.display = "none";
}


function validar_loguear(laforma){
	fallo = false;
	
	for(var i = 0; i < laforma.elements.length && !fallo; i++){
		if(laforma.elements[i].value == ""){
			fallo = true;		
			//alert("Ingresae todos los campos requeridos como obligatorios");
			laforma.elements[i].focus();
		}else{
				if(laforma.elements[i].value.indexOf ("'", 0) != -1){
					//alert("Elimine las comillas!");
					laforma.elements[i].focus();
					fallo = true;
					document.getElementById('txt_error_form').innerHTML = 'Elimine las comillas';
					document.getElementById('txt_error_form').style.display = "block";
				}
			}
	}
	
	if (laforma.var_mail.value.length <1) {
		document.getElementById('txt_error_email').innerHTML = 'Ingrese Correo';
		document.getElementById('txt_error_email').style.display = "block";

		fallo = true; 
	}
	
	if (fallo==false){
		if (laforma.var_mail.value.indexOf('@', 0) == -1 || laforma.var_mail.value.indexOf('.', 0) == -1){ 
			//alert("Por favor, debes escribir una dirección de correo válida"); 
			document.getElementById('txt_error_email').innerHTML = 'Correo no válido';
			document.getElementById('txt_error_email').style.display = "block";
			fallo = true; 
		}
	}
	
	
	if (laforma.var_password.value.length <1) {
		document.getElementById('txt_error_pass').innerHTML = 'Ingrese Contraseña';
		document.getElementById('txt_error_pass').style.display = "block";

		fallo = true; 
	}
	
	if(!fallo){
		return true;
	}else{
		return false;
	}
}

function validar_nuevo_password(laforma){
	if (laforma.password.value=="") {
	  alert("Deben ingresar el nuevo password");
	  laforma.password.focus();
	  return false;
	}else{
		if (laforma.npassword.value=="") {
		  alert("Deben confirmar el nuevo password");
		  laforma.npassword.focus();
		  return false;
		}else{
			if (laforma.password.value!=laforma.npassword.value) {
			  alert("Deben coincidir ambos password");
			  laforma.password.focus();
			  return false;
			}else{
				return true;
			}
		}
	}
}

function abrir_ventana(name){
	ventana = window.open(name, "ventana", "width=5,height=5,dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
	if (ventana.opener == null) ventana.opener = self;
}

function abrir_ventana2(name){
	ventana = window.open(name, "ventana", "width=5,height=5,dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=yes"); 
	if (ventana.opener == null) ventana.opener = self;
}

function detalle_inmueble(name,fav,id_usuario,mispub){
	var url = "i_detalle_inmueble.php?id_inmueble=" + name + "&mostrar_favorito=" + fav+"&id_usuario=" + id_usuario+"&mispub=" + mispub;
	ventana = window.open(url, "ventana", "width=700,height=500,dependent=yes,top=20px,left=20px,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
	if (ventana.opener == null) ventana.opener = self;
	ventana.focus();
}

function detalle_inmueble_externo(name,fav,id_usuario,mispub,xp){
	var url = "i_detalle_inmueble.php?id_inmueble=" + name + "&mostrar_favorito=" + fav+"&id_usuario=" + id_usuario+"&mispub=" + mispub+"&xp=" + xp;
	ventana = window.open(url, "ventana", "width=700,height=500,dependent=yes,top=20px,left=20px,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
	if (ventana.opener == null) ventana.opener = self;
	ventana.focus();
}

function detalle_nuevo_desarrollo(id){
	var url = "i_detalle_nuevos_desarrollos.php?id_nd=" + id;
	ventana = window.open(url, "ventana", "width=700,height=500,dependent=yes,top=20px,left=20px,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=no,resizable=no"); 
	if (ventana.opener == null) ventana.opener = self;
	ventana.focus();
}


/*
esta version de la funcion trabaja con el id comercial del inmueble, pasandoselo a la pagina
i_detalle_inmueble.php con un nombre distinto de variable (id_comercial) para que esta pueda diferenciar y
hacer la conversion necesaria (id_comercial->id_inmueble)
*/
function detalle_inmueble_id_comercial(name,id_usuario,id_empresa){
	if (document.buscar_codigo.id_comercial.value == "") {
		alert ("Dede ingresar el \"Código\" del inmueble ");
		document.buscar_codigo.id_comercial.focus()
	}else{
		var url = "i_detalle_inmueble.php?id_inmueble=" + name + "&ccod_inm=" + id_empresa + "&id_usuario=" + id_usuario;
		ventana = window.open(url, "ventana", "width=700,height=500,dependent=yes,top=20px,left=20px,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
		if (ventana.opener == null) ventana.opener = self;
		//document.buscar_codigo.submit();
		ventana.focus();
	}
}

function detalle_inmueble_id_comercial_externos(name,id_usuario,id_empresa){
	if (document.buscar_codigo.id_comercial.value == "") {
		alert ("Dede ingresar el \"Código\" del inmueble ");
		document.buscar_codigo.id_comercial.focus()
	}else{
		//alert("i_detalle_inmueble.php?id_inmueble=" + name + "&xp=" + id_empresa + "&id_usuario=" + id_usuario);
		var url = "i_detalle_inmueble.php?id_inmueble=" + name + "&xp=" + id_empresa + "&id_usuario=" + id_usuario;
		ventana = window.open(url, "ventana", "width=700,height=500,dependent=yes,top=20px,left=20px,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
		if (ventana.opener == null) ventana.opener = self;
		//document.buscar_codigo.submit();
		ventana.focus();
	}
}

function resize(ancho,alto){
	self.resizeTo(ancho,alto); 
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	self.moveTo(LeftPosition,TopPosition-70);
}

var w3c=(document.getElementById)? true: false;
var ie5=(w3c && document.all)? true : false;
var ns6=(w3c && (navigator.appName=="Netscape"))? true: false;
currIDb=null; xoff=0; yoff=0;
currRS=null; rsxoff=0; rsyoff=0;
oldac=null; newac=null; zdx=1; mx=0; my=0;

var idlist=new Array();
idlist.btns=new Array();
idlist.btns[0]=new Image(); idlist.btns[0].src="../images/min.gif";
idlist.btns[1]=new Image(); idlist.btns[1].src="../images/max.gif";
idlist.btns[2]=new Image(); idlist.btns[2].src="../images/close.gif";
idlist.btns[3]=new Image(); idlist.btns[3].src="../images/resize.gif";

function truebody(){ //Dynamic Drive added function
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidebox(id){
if(w3c){
document.getElementById(id+'_b').style.display='none';
document.getElementById(id+'_s').style.display='none';
}}

function showbox(id){
if(w3c){
var div;
div=id.split("_");
for (i=1;i<=14;i++)
{
	if (div[1]!=i)
		{
			hidebox("Div_"+i);
		}
}
var bx=document.getElementById(id+'_b').style;
var sh=document.getElementById(id+'_s').style;
bx.display='block';
sh.display='block';
sh.zIndex=++zdx;
bx.zIndex=++zdx;
}}

function minimize(){
if(w3c){
this.IDS[0].style.height=(ie5)? '28px':'24px';
this.IDS[3].style.height='28px';
this.IDS[2].style.display='none';
this.IDS[4].style.display='none';
setTimeout('ns6bugfix()',100);
}}

function restore(){
if(w3c){
var h=this.IDS[10];
this.IDS[0].style.height=h+'px'; //box
this.IDS[3].style.height=(ie5)? h+'px':h+5+'px'; //shd
this.IDS[2].style.display='block';
this.IDS[4].style.display='block'; 
setTimeout('ns6bugfix()',100);
}}

function ns6bugfix(){
self.resizeBy(0,1);
self.resizeBy(0,-1);
}

function trackmouse(evt){
mx=(ie5)?event.clientX+truebody().scrollLeft:evt.pageX;
my=(ie5)?event.clientY+truebody().scrollTop:evt.pageY;
if(!ns6)movepopup();
if((currIDb!=null)||(currRS!=null))return false;
}

function movepopup(){
if((currIDb!=null)&&w3c){
var x=mx+xoff;
var y=my+yoff;
currIDb.style.left=x+'px';
currIDs.style.left=x+8+'px';
currIDb.style.top=y+'px';
currIDs.style.top=y+8+'px';
}
if((currRS!=null)&&w3c){
var rx=mx+rsxoff;
var ry=my+rsyoff;
var c=currRS;
c.style.left=Math.max(rx,((ie5)?88:92))+'px';
c.style.top=Math.max(ry,((ie5)?68:72))+'px';
c.IDS[0].style.width=Math.max(rx+((ie5)?12:8),100)+'px';
c.IDS[0].style.height=Math.max(ry+((ie5)?12:8),80)+'px';
c.IDS[1].style.width=Math.max(rx+((ie5)?4:3),((ns6)?95:92))+'px';
c.IDS[5].style.left=parseInt(c.IDS[1].style.width)-48+'px';
c.IDS[3].style.width=Math.max(rx+12,((ie5)?100:104))+'px';
c.IDS[3].style.height=Math.max(ry+((ie5)?12:13),((ie5)?80:86))+'px';
c.IDS[2].style.width=Math.max(rx-((ie5)?-5:5),((ie5)?92:87))+'px';
c.IDS[2].style.height=Math.max(ry-((ie5)?24:28),44)+'px';
c.IDS[10]=parseInt(c.IDS[0].style.height);
}}

function startRS(evt){
var ex=(ie5)?event.clientX+truebody().scrollLeft:evt.pageX;
var ey=(ie5)?event.clientY+truebody().scrollTop:evt.pageY;
rsxoff=parseInt(this.style.left)-ex;
rsyoff=parseInt(this.style.top)-ey;
currRS=this;
if(ns6)this.IDS[2].style.overflow='hidden';
return false;
}

function stopdrag(){
currIDb=null;
ns6bugfix();
}

function grab_id(evt){
var ex=(ie5)?event.clientX+truebody().scrollLeft:evt.pageX;
var ey=(ie5)?event.clientY+truebody().scrollTop:evt.pageY;
xoff=parseInt(this.IDS[0].style.left)-ex;
yoff=parseInt(this.IDS[0].style.top)-ey;
currIDb=this.IDS[0];
currIDs=this.IDS[3];
return false;
}

function subBox(x,y,w,h,bgc,id){
var v=document.createElement('div');
v.setAttribute('id',id); 
v.style.position='absolute';
v.style.left=x+'px';
v.style.top=y+'px';
v.style.width=w+'px';
v.style.height=h+'px';
v.style.backgroundColor=bgc;
v.style.visibility='visible';
v.style.padding='0px 0px 0px 0px';
return v;
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}


function popUp(x,y,w,h,cid,text,bgcolor,textcolor,fontstyleset,title,titlecolor,titletextcolor,bordercolor,scrollcolor,shadowcolor,showonstart,isdrag,isresize,oldOK,POPPERSESSION){

var proceedtopop=false
if (POPPERSESSION){
if (get_cookie(cid)==""){
proceedtopop=true
document.cookie=cid+"=yes"
}
}
else
proceedtopop=true

if (proceedtopop){
if(w3c){
var tw, th;
w=Math.max(w,300);
h=Math.max(h,380);
var rdiv=new subBox(w-((ie5)?12:8),h-((ie5)?12:8),7,7,'',cid+'_rs');
if(isresize){
rdiv.innerHTML='<img src="../images/resize.gif" width="7" height="7">';
rdiv.style.cursor='move';
}
tw=(ie5)?w:w+4;
th=(ie5)?h:h+6;
var shadow=new subBox(x+8,y+8,tw,th,shadowcolor,cid+'_s');
if(ie5)shadow.style.filter="alpha(opacity=50)";
else shadow.style.MozOpacity=.5;
shadow.style.zIndex=++zdx;
var tw,th;
var outerdiv=new subBox(x,y,w,h,bordercolor,cid+'_b');
outerdiv.style.borderStyle="outset";
outerdiv.style.borderWidth="2px";
outerdiv.style.borderColor=bordercolor;
outerdiv.style.zIndex=++zdx;
tw=(ie5)?w-8:w-5;
th=(ie5)?h+4:h-4;
var titlebar=new subBox(2,2,tw,20,titlecolor,cid+'_t');
titlebar.style.overflow="hidden";
titlebar.style.cursor="default";
titlebar.innerHTML='<span style="position:absolute; left:3px; top:1px; font:bold 10pt sans-serif; color:'+titletextcolor+'; height:18px; overflow:hidden; clip-height:16px;">'+title+'</span><span id="'+cid+'_btt" style="position:absolute; width:48px; height:16px; left:'+(tw-48)+'px; top:2px;"><img src="../images/min.gif" width="16" height="16" id="'+cid+'_min"><img src="../images/max.gif" width="16" height="16"  id="'+cid+'_max"><img src="../images/close.gif" width="16" height="16" id="'+cid+'_cls"></span>';
tw=(ie5)?w-7:w-13;
th=(ie5)?h-36:h-36;
var content=new subBox(2,24,tw,th,bgcolor,cid+'_c');
content.style.borderColor=bordercolor;
content.style.borderStyle="inset";
content.style.borderWidth="2px";
content.style.overflow="auto";
content.style.padding="0px 2px 0px 4px";
content.style.font=fontstyleset;
content.style.color=textcolor;
if(ie5)content.style.scrollbarBaseColor=scrollcolor;
content.innerHTML=text;
outerdiv.appendChild(titlebar);
outerdiv.appendChild(content);
outerdiv.appendChild(rdiv);
document.body.appendChild(shadow);
document.body.appendChild(outerdiv);
if(!showonstart)hidebox(cid);
var IDS=new Array();
IDS[0]=document.getElementById(cid+'_b');
IDS[1]=document.getElementById(cid+'_t');
IDS[2]=document.getElementById(cid+'_c');
IDS[3]=document.getElementById(cid+'_s');
IDS[4]=document.getElementById(cid+'_rs');
IDS[5]=document.getElementById(cid+'_btt');
IDS[6]=document.getElementById(cid+'_min');
IDS[7]=document.getElementById(cid+'_max');
IDS[8]=document.getElementById(cid+'_cls');
IDS[9]=cid;
IDS[10]=h;
this.IDb=IDS[0]; this.IDb.IDS=IDS;
this.IDt=IDS[1]; this.IDt.IDS=IDS;
this.IDc=IDS[2]; this.IDc.IDS=IDS;
this.IDs=IDS[3]; this.IDs.IDS=IDS;
this.IDrs=IDS[4]; this.IDrs.IDS=IDS;
this.IDbtt=IDS[5]; this.IDbtt.IDS=IDS;
this.IDmin=IDS[6]; this.IDmin.IDS=IDS;
this.IDmax=IDS[7]; this.IDmax.IDS=IDS;
this.IDcls=IDS[8]; this.IDcls.IDS=IDS;
this.IDb.activecolor=titlecolor;
this.IDb.inactivecolor=scrollcolor;
if(oldac!=null)oldac.IDS[1].style.backgroundColor=oldac.inactivecolor;
oldac=this.IDb;
this.IDcls.onclick=new Function("hidebox('"+cid+"');");
if(isresize){
this.IDmin.onclick=minimize;
this.IDmax.onclick=restore;
this.IDrs.onmousedown=startRS;
this.IDrs.onmouseup=new Function("currRS=null");
}
this.IDb.onmousedown=function(){
   if(oldac!=null){
   oldac.IDS[1].style.backgroundColor=oldac.inactivecolor;
   }
   if(ns6)this.IDS[2].style.overflow='auto';
   oldac=this;
   this.IDS[1].style.backgroundColor=this.activecolor;
   this.IDS[3].style.zIndex=++zdx;
   this.style.zIndex=++zdx;
   }
if(isdrag){
this.IDt.onmousedown=grab_id;
this.IDt.onmouseup=stopdrag;
}
}else{
if(oldOK){
var ctr=new Date();
ctr=ctr.getTime();
var win=window.open("" , "abc"+ctr , "status=no,menubar=no,width="+w+",height="+h+",resizable=yes,scrollbars=yes");
var t='<html><head><title>'+title+'</title></head><body bgcolor="'+bgcolor+'"><font style="font:'+fontstyleset+'; color:'+textcolor+'">'+text+'</font></body></html>';
win.document.write(t);
win.document.close();
}

}}

}

if(ns6)setInterval('movepopup()',40);

if(w3c){
document.onmousemove=trackmouse;
document.onmouseup=new Function("currRS=null");
}

function poder_bajar(tipo_usuario,id_file,archivo){
	if(tipo_usuario!="C" && id_file=="1"){
		alert("Disculpe!\nUd. debe ser un usuario Cipco para poder visualizar este archivo.\nIdentifiquese en el site en caso de ser usuario CIPCO.");
		return false;
	}
	if(tipo_usuario=="" && id_file=="2"){
		alert("Disculpe!\nUd. debe registrarse en el site para poder visualizar este archivo.");
		return false;
	}
	window.location = archivo;
}

function poder_bajar_pl(tipo_usuario){
	if(tipo_usuario=="Invitado!"){
		alert("Disculpe!\nUd. debe registrarse en el site para poder descargar esta presentación.");
		return false;
	}
	return true;
}

function bajar_archivo(tipo_usuario){
	if(poder_bajar_pl(tipo_usuario)){
		window.location = "../images/demo_cipco.zip";
	}
}

var decimalSeparator = ',';
var groupingSeparator = '.';

function formatNumber(initNumber, fieldSize) {
    var stringNumber = Math.round( initNumber) + "";

    if( isNaN( stringNumber))
        return initNumber;

    var tempNumber = "";
    var numberLen = stringNumber.length;
    var charTemp;
    var maxLen = fieldSize;

    if( maxLen == null)
        maxLen = 0;

    for (i=numberLen; i >=0; i--) {
        charTemp = stringNumber.charAt(i);
        if (((numberLen - i)%3)== 1) {
            if ((tempNumber != "") && ( charTemp != '-')) {
               tempNumber = groupingSeparator + tempNumber;
            }
        }
        tempNumber = charTemp + tempNumber;
    }
    stringNumber = tempNumber;
    numberLen = stringNumber.length;
    for (i=1; i < (maxLen -numberLen); i++) {
        stringNumber = " " + stringNumber;
    }
  return stringNumber;
}


function unformatNumber( initNumber) {
    //var validNumbers = "0123456789-";
    var stemp = initNumber + "";
    var newNum = "";
    var i;
    var charTemp;

    for( i = 0; i<stemp.length; i++ ) {
        charTemp = stemp.charAt(i);

        //if (validNumbers.indexOf( charTemp) >=0 ) {
        if( charTemp != groupingSeparator) {
	        newNum=newNum + charTemp;
        }
    }

  	return newNum;
}

function parseFmtNumber( initNumber) {
	return parseInt( unformatNumber( initNumber));
}

var Format = true;


var esc = "\\\\";
var space = "\\s";
var openBR = "\\[";
var closeBR = "\\]";
var nonASCII = "\\x80-\\xff";
var ctrl = "\\000-\\037";

var illegal = space + "\\(\\)<>\\@,;:\\\"" + esc + openBR + closeBR + nonASCII + ctrl;
var atom = "[^" + "\\." + illegal + "]";

var localPart = atom + "+(\\.{1}" + atom + "+)*";
var domain = atom + "+(\\.{1}" + atom + "+)+";
var email = "^" + localPart + "\@" + domain + "$";
var reEmail = new RegExp( email);

var reWhitespace = /^\s+$/
var reInteger = /^\d+$/

var mP = "No ingresó ningún valor en el campo "
var mPMax = "El campo '"
var mSuffix = " . Es un campo requerido. Por favor ingrese un valor."
var mSuffixMax = "' debe tener un máximo de ";
var mSuffixMax2 = " caracteres.";
var mRadio = "Debe especificar una opción.";

var iEmail = "Este campo debe ser una dirección válida de correo electrónico (ejemplo: foo@bar.com). Por favor cámbiela."

var defEOK = false

var invalidF = null;

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhitespace (s) {
    return ( isEmpty(s) || reWhitespace.test(s));
}

function isInteger (s){

	var i;

    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return defEOK;
       else return (isInteger.arguments[1] == true);

    return reInteger.test(s)
}

function isEmail (s){
	if (isEmpty(s))
       if (isEmail.arguments.length == 1) return defEOK;
       else return (isEmail.arguments[1] == true);

    else {
       return reEmail.test(s)
    }
}

function getFrmFldType( f) {
	var t;

	t = f.type;
	if(( t == null) && ( f[ 0] != null))
		t = f[ 0].type;

	return t;

}

function setFocus( f) {

	var t = getFrmFldType( f);

	if(	( t == "radio") && f.length) {
		f[ 0].focus();
	} else {
		f.focus();

		if( f.select != null)
		    f.select();

	}

}

var lastMarked;
var lastColor;

function anyColorInput( f, c) {
    if( f.label)
		f.label.style.color = c;
	else if( f.parentElement != null)
		f.parentElement.style.color = c;
	else if( f.length && ( f[ 0] != null)) {
		if( f[ 0].parentElement != null)
			for( var i = 0; i < f.length; i++)
				f[ i].parentElement.style.color = c;
	}

	lastMarked = f;
}

function colorInput( f) {

	if( lastMarked != null) {
		anyColorInput( lastMarked, "#000000");
		lastMarked = null;
	}

	anyColorInput( f, "#FF0000");
	lastMarked = f;
}

function warnEmpty (f, s, uM, cI)
{
	var result;
	var fieldType = getFrmFldType( f);

	if( f.uM != null)
		uM = f.uM;
	else if( fieldType == "radio") {
		if( uM == null)
			uM = mRadio;
	}

	setFocus( f);
	result = warnEmptyNoFocus( s, uM);
	setFocus( f);

    if( cI)
        colorInput( f);

    invalidF = f;
    setTimeout( "setFocus( invalidF);", 1);

	return result;
}

function warnEmptyNoFocus( s, uM) {
	if( uM == null)
    	alert( mP + s + mSuffix);
    else
    	alert( uM);

    return false
}


function checkString (f, s, eOK, mL)
{
    if (checkString.arguments.length == 2) eOK = defEOK;
    if (checkString.arguments.length == 3) mL = 0;

    if ((eOK == true) && (isEmpty(f.value))) return true;
    if (isWhitespace(f.value))
       return warnEmpty (f, s);

    if( ( mL > 0) && ( f.value.length > mL))
    	return warnInvalid( f, mPMax + s + mSuffixMax + mL + mSuffixMax2);
    else return true;
}

function checkSelectValue (f, s, eOK)
{
	var lV;

	with( f.options[ f.selectedIndex]) {
		lV = value;
		if( ( lV == null) || ( lV.length == 0))
			lV = text;
	}

    if (checkSelectValue.arguments.length == 2) eOK = defEOK;
    if ((eOK == true) && (isEmpty( lV))) return true;
    if (isWhitespace( lV))
       return warnEmpty (f, s);
    else return true;
}


function checkPositiveInteger (f, s, eOK) {
    var v = f.value;

    if (checkPositiveInteger.arguments.length == 2) eOK = defEOK;
    if ((eOK == true) && (isEmpty( v))) return true;
    if (!isInteger( v))
       return warnInvalid (f, s);
    else if ( !isPositiveInteger( v))
       return warnInvalid (f, s);
    else return true;
}

function checkInteger (f, s, eOK) {
    var v = f.value;

    if (checkInteger.arguments.length == 2) eOK = defEOK;
    if ((eOK == true) && (isEmpty( v))) return true;
    if (!isInteger( v))
       return warnInvalid (f, s);
    else return true;
}

function checkEmail (f, eOK)
{
    var v = f.value;

    if (checkEmail.arguments.length == 1) eOK = defEOK;
    if ((eOK == true) && (isEmpty( v))) return true;
    else if( !isEmail( v, false)) return warnInvalid (f, iEmail);
    else return true;
}

function warnInvalid (f, s, cI)
{
	var result;
	var fieldType = getFrmFldType( f);

	setFocus( f);
	alert( s);
	setFocus( f);

    if( cI)
    	colorInput( f);

    invalidF = f;
    setTimeout( "setFocus( invalidF);", 1);

	return false;
}

function isPositiveInteger (s)
{   var secondArg = defEOK;

    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];

    return (isInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}

function getRadioBtnValue( f) {
	if( f.length) {
		for( var i = 0; i < f.length; i++) {
			if( f[ i].checked) {
				return f[ i].value;
			}
	    }
	} else
		if( f.checked) {
			return f.value;
		}

	return -1;

}


function checkRadioBtn( f, eOK, uM) {
	var isRE;

	if ( checkRadioBtn.arguments.length == 1) {
		eOK = defEOK;
		uM = "";
	}
	isRE = ( getRadioBtnValue( f) == -1);

	if( isRE)
		if ( eOK == true)
			return true;
		else
	    	return warnEmpty( f, null, uM);
	else return true;
}

function enableFrmFld( f, enable) {

	if( f.name == null) {
		if( f[ 0].name != null) {
			if( f[ 0].disabled != null) {
				for( var i = 0; i < f.length; i++)
					f[ i].disabled = !enable;
			}
		}
	} else if( f.disabled != null)
		f.disabled = !enable;
}

function checkFieldLength( f, mL, ccf) {
	var s = f.value;
	var l;
	var r;

	r = ( s == null);
	if( !r) {
        l = s.length;
		r = ( l < mL);
		if( !r) {
			f.value = s.substring( 0, mL);
		}

        if( ccf != null)
            ccf.value = l;
	}

	return r;
}

var FormCheck = true;


function expandir(id)
{
var obj = objHtml(id)
if (miNavegador.standard)
   {
    if (obj.style.display == "none")
       obj.style.display = 'block';
    else
       obj.style.display = 'none';
   }
else
   {
    if (obj.display == "none")
       obj.display = 'block';
    else
       obj.display = 'none';
   } 
}
function objHtml(n, d) { 
  var p,i,x;  
  if(!d) d=document; 
  if (miNavegador.standard)
	  x = d.getElementById(n)	
  if(!(x=d[n]) && miNavegador.IE) 
      x=d.all[n]; 
  for (i=0; !x && i<d.forms.length; i++) 
      x=d.forms[i][n];
  for(i=0; !x && d.layers &&i< d.layers.length; i++) 
      x=objHtml(n,d.layers[i].document); 
  return x;
}
window.miNavegador = new oNavegador()
window.miNavegador.iniciar();
function oNavegador(  ) {
	this.nombre = navigator.appName;
	this.iniciar = iniciar;
	this.IE = this.nombre.toUpperCase().indexOf('MICROSOFT') >=0;
	this.NS = this.nombre.toUpperCase().indexOf('NETSCAPE') >=0;
	this.OP = this.nombre.toUpperCase().indexOf('OPERA') >= 0;
	this.XX = !this.IE && !this.NS && !this.OP;
	this.version = this.iniciar();
	this.Verent = parseInt(this.version);
	this.standard = (this.IE && this.Verent >=5) || (this.NS && this.Verent >=6)

/* ======================================================================
	FUNCION:	iniciar( ), miembro de oNavegador
	ARGS: 		none.
	DEVUELVE:	nada
	DESCRIP:	Inicializa los valores del objeto
====================================================================== */
  function iniciar() {
  var ver = navigator.appVersion;
  if(ver+"" != "NaN")
	if (this.IE)
		{
		ver.match(/(MSIE)(\s*)([0-9].[0-9]+)/ig);
  		ver = RegExp.$3;
		}
  return ver;
  } //Termina la funcion iniciar el objeto
}

function ver(id)
{
var obj = objHtml(id)
if (miNavegador.standard)
   {
		obj.style.display = 'block';
   }
else
   {
       obj.display = 'block';
   } 
}

function no_ver(id)
{
var obj = objHtml(id)
if (miNavegador.standard)
   {
		obj.style.display = 'none';
   }
else
   {
       obj.display = 'none';
   } 
MM_swapImgRestore();
}

function jumpTo(URL_List){
   var URL = '/cipco/site/p_contenido.php?id_sec=2&ciudad=' + URL_List.options[URL_List.selectedIndex].value;
   window.location.href = URL;
}

function mostrar(id){
	document.getElementById(id).style.display = 'block';
}

function esconder(id){
	document.getElementById(id).style.display = 'none';
}

function mostrar_todos(){
	document.getElementById('pais').style.display = "block";
	document.getElementById('estado').style.display = "block";
	document.getElementById('ciudad').style.display = "block";
	document.getElementById('urbanizacion').style.display = "block";
	document.getElementById('n_pais').style.display = "none";
	document.getElementById('listar').style.display = "none";
	document.getElementById('n_estado').style.display = "none";
	document.getElementById('n_ciudad').style.display = "none";
	document.getElementById('n_urbanizacion').style.display = "none";
	document.getElementById('n_pais').value = "";
	document.getElementById('n_estado').value = "";
	document.getElementById('n_ciudad').value = "";
	document.getElementById('n_urbanizacion').value = "";
	document.getElementById("i_pais").style.color = "#333333";
	document.getElementById("i_pais").innerHTML = "Pa&iacute;s:";
	document.getElementById("i_estado").style.color = "#333333";
	document.getElementById("i_estado").innerHTML = "Estado o Prov.:";
	document.getElementById("i_ciudad").style.color = "#333333";
	document.getElementById("i_ciudad").innerHTML = "Ciudad:";
	document.getElementById("i_urbanizacion").style.color = "#333333";
	document.getElementById("i_urbanizacion").innerHTML = "Urb., barrio o sector: ";
	
	
}

function esconder_urbanizaciones(){
	if(document.getElementById("urbanizacion")&&(document.getElementById("urbanizacion").value=="nuevo")){
		document.getElementById("urbanizacion").style.display = "none";
		document.getElementById("n_urbanizacion").style.display = "block";
		document.getElementById("i_urbanizacion").style.color = "#990000";
		document.getElementById("i_urbanizacion").innerHTML = "Ingrese Urb., barrio o sector:";
	}
}

function color_textos(valor){
	if(valor=="pais"){
		document.getElementById("i_pais").style.color = "#990000";
		document.getElementById("i_pais").innerHTML = "Ingrese Pa&iacute;s:";
		document.getElementById("i_estado").style.color = "#990000";
		document.getElementById("i_estado").innerHTML = "Ingrese Estado o Prov.:";
		document.getElementById("i_ciudad").style.color = "#990000";
		document.getElementById("i_ciudad").innerHTML = "Ingrese Ciudad:";
		document.getElementById("i_urbanizacion").style.color = "#990000";
		document.getElementById("i_urbanizacion").innerHTML = "Ingrese Urb., barrio o sector:";
	}else if(valor=="estado"){
		document.getElementById("i_estado").style.color = "#990000";
		document.getElementById("i_estado").innerHTML = "Ingrese Estado o Prov.:";
		document.getElementById("i_ciudad").style.color = "#990000";
		document.getElementById("i_ciudad").innerHTML = "Ingrese Ciudad:";
		document.getElementById("i_urbanizacion").style.color = "#990000";
		document.getElementById("i_urbanizacion").innerHTML = "Ingrese Urb., barrio o sector:";
	}else if(valor=="ciudad"){
		document.getElementById("i_ciudad").style.color = "#990000";
		document.getElementById("i_ciudad").innerHTML = "Ingrese Ciudad:";
		document.getElementById("i_urbanizacion").style.color = "#990000";
		document.getElementById("i_urbanizacion").innerHTML = "Ingrese Urb., barrio o sector:";
	}else if(valor=="urbanizacion"){
		document.getElementById("i_urbanizacion").style.color = "#990000";
		document.getElementById("i_urbanizacion").innerHTML = "Ingrese Urb., barrio o sector:";
	}
}

function volver_color_original(){
	if(document.getElementById("i_pais")&&document.getElementById("i_estado")&&document.getElementById("i_ciudad")&&document.getElementById("i_urbanizacion")){	
	document.getElementById("i_pais").style.color = "#333333";
	document.getElementById("i_pais").innerHTML = "Pa&iacute;s:";
	document.getElementById("i_estado").style.color = "#333333";
	document.getElementById("i_estado").innerHTML = "Estado o Prov.:";
	document.getElementById("i_ciudad").style.color = "#333333";
	document.getElementById("i_ciudad").innerHTML = "Ciudad:";
	document.getElementById("i_urbanizacion").style.color = "#333333";
	document.getElementById("i_urbanizacion").innerHTML = "Urb., barrio o sector: ";
	document.getElementById('pais').style.display = "block";
	document.getElementById('estado').style.display = "block";
	document.getElementById('ciudad').style.display = "block";
	document.getElementById('urbanizacion').style.display = "block";
	document.getElementById('n_pais').value= "";
	document.getElementById('n_estado').value= "";
	document.getElementById('n_ciudad').value= "";
	document.getElementById('n_urbanizacion').value= "";
	document.getElementById('n_pais').style.display = "none";
	document.getElementById('n_estado').style.display = "none";
	document.getElementById('n_ciudad').style.display = "none";
	document.getElementById('n_urbanizacion').style.display = "none";
			}
}

function cambia(oCntrl,array,actual,valor){
	var indice;
	if(actual!=""){
		if (actual.value != "nuevo") { 
			volver_color_original();
			while (oCntrl.length) oCntrl.remove(0);
			
				for (var i=0;i<array[actual.value].length;i++){
					var selOpcion=new Option(array[actual.value][i][1], array[actual.value][i][0]);
					if (array[actual.value][i][0]==valor) indice=i;
					eval(oCntrl.options[i]=selOpcion);
				}
				oCntrl.selectedIndex=indice;
			
		}else{
			
			color_textos(actual.name.substring(0,actual.name.length-1));
			//MM_openBrWindow('m_solicitar_urb.php','','scrollbars=no,width=380,height=280')
			//alert(actual.name.substring(0,actual.name.length-1));
			if(actual.name.substring(0,actual.name.length-1)=="pais"){
				if(document.getElementById('n_pais')){ 
					document.getElementById('n_pais').style.display = "block";
					document.getElementById('listar').style.display = "block";
					document.getElementById('n_estado').style.display = "block";
					document.getElementById('n_ciudad').style.display = "block";
					document.getElementById('n_urbanizacion').style.display = "block";
					document.getElementById('pais').style.display = "none";
					document.getElementById('pais').selectedIndex = "0";
					document.getElementById('estado').style.display = "none";
					document.getElementById('estado').length = 0;
					document.getElementById('ciudad').style.display = "none";
					document.getElementById('ciudad').length = 0;
					document.getElementById('urbanizacion').style.display = "none";
					document.getElementById('urbanizacion').length = 0;
					
				}
			}
			if(actual.name.substring(0,actual.name.length-1)=="estado"){
				if(document.getElementById('n_estado')){ 
					document.getElementById('n_estado').style.display = "block";
					document.getElementById('n_ciudad').style.display = "block";
					document.getElementById('n_urbanizacion').style.display = "block";
					document.getElementById('estado').style.display = "none";
					document.getElementById('estado').length = 0;
					document.getElementById('ciudad').style.display = "none";
					document.getElementById('ciudad').length = 0;
					document.getElementById('urbanizacion').style.display = "none";
					document.getElementById('urbanizacion').length = 0;
				}
			}
			if(actual.name.substring(0,actual.name.length-1)=="ciudad"){
				if(document.getElementById('n_ciudad')){
					document.getElementById('n_ciudad').style.display = "block";
					document.getElementById('n_urbanizacion').style.display = "block";
					document.getElementById('ciudad').style.display = "none";
					document.getElementById('ciudad').length = 0;
					document.getElementById('urbanizacion').style.display = "none";
					document.getElementById('urbanizacion').length = 0;
				}
			}
			if(actual.name.substring(0,actual.name.length-1)=="urbanizacion"){
				if(document.getElementById('n_urbanizacion')){
					document.getElementById('n_urbanizacion').style.display = "block";
					document.getElementById('urbanizacion').style.display = "none";
					document.getElementById('urbanizacion').length = 0;
				}
			}
		}
	}//actual !=""
    
}

function campos_ubicacion_bloqueados(){
	if(document.getElementById("pais_s")){ 
		document.getElementById("pais*").value = document.getElementById("pais_s").value;
		document.getElementById("estado*").value = document.getElementById("estado_s").value;
		document.getElementById("ciudad*").value = document.getElementById("ciudad_s").value;
		document.getElementById("urbanizacion*").value = document.getElementById("urbanizacion_s").value;
		document.getElementById("pais_s").disabled = "true";
		document.getElementById("estado_s").disabled = "true";
		document.getElementById("ciudad_s").disabled = "true";
		document.getElementById("urbanizacion_s").disabled = "true";
	}
}

function inicializar_campo(name_input){
	name_input.length = "0"
}

function checkNumeric(objName,minval, maxval)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval)
{
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789";
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
alertsay = "Por favor ingrese sólo estos valores \""
alertsay = alertsay + checkOK + "\" en el campo \"" + checkStr.name + "\"."
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "Por favor ingrese un valor que sea "
alertsay = alertsay + "mayor a \"" + minval + "\" y menor a "
alertsay = alertsay + " \"" + maxval + "\" en el campo \"" + checkStr.name + "\"."
alert(alertsay);
return (false);
}
}

function validar_busqueda() {
	if (document.buscar.tipo_oferta.value == "") {
		alert ("Dede seleccionar el \"Tipo de Oferta\" ");
		document.buscar.tipo_oferta.focus()
	}else{
		if (document.buscar.ciudad.value == "") {
			alert ("Dede seleccionar la \"Ciudad\" ");
			document.buscar.ciudad.focus()
		}else{
			document.buscar.submit();
		}
	}
}

function validar_busqueda_codigo() {
	if (document.buscar_codigo.id_comercial.value == "") {
		alert ("Dede ingresar el \"Código\" del inmueble ");
		document.buscar_codigo.id_comercial.focus()
	}else{
		document.buscar_codigo.submit();
	}
}

function validar_con_filtros2() {
	if ((document.filtro.moneda.value == "") && (document.filtro.precio.value == "") && (document.filtro.area.value == "") && (document.filtro.urbanizacion.value == "") && (document.filtro.hab.value == "") && (document.filtro.ban.value == "") && (document.filtro.est.value == "") && (document.filtro.est.value == "")) {
		alert ("Dede seleccionar por lo menos un parámetro para el filtro ");
		document.filtro.moneda.focus()
	}else{
		document.filtro.submit();
	}
}

function validar_con_filtros3() {
	if ((document.filtro.moneda.value == "") && (document.filtro.precio.value == "") && (document.filtro.area.value == "") && (document.filtro.urbanizacion.value == "") && (document.filtro.uso.value == "")) {
		alert ("Dede seleccionar por lo menos un parámetro para el filtro ");
		document.filtro.moneda.focus()
	}else{
		document.filtro.submit();
	}
}

function validar_filtro_noticia() {
	document.busq_noticias.submit();
	
}

function sumar_varios() {
    var a=sumar_varios.arguments;
	re_2 = /,/gi
	a[a.length-1].value=0;	
	for(var i=0;i < a.length-1;i++)
	{
     if(isNaN(parseFloat(a[i].value))==false)
a[a.length-1].value=parseFloat(a[a.length-1].value.replace(re_2,"."))+parseFloat(a[i].value.replace(re_2,"."));
	}
		
	var sat=0;
	var dec_sat=2;

	a[a.length-1].value=Math.round(a[a.length-1].value * Math.pow(10, dec_sat)) / Math.pow(10, dec_sat);
	
}

function validar_solo_numeros_decimales(e) { 
	tecla=(document.all) ? e.keyCode : e.which; 
	if((tecla<48 || tecla>57) && tecla!=44){
		alert ("Sólo números por favor");
		return false; 
	}
}

function validar_solo_numeros(e) { 
	tecla=(document.all) ? e.keyCode : e.which; 
	if(tecla<48 || tecla>57){
		alert ("Sólo números por favor");
		return false; 
	}
}

function validar_solo_numeros_precios(e) { 
	tecla=(document.all) ? e.keyCode : e.which; 
	if(tecla<48 || tecla>57){
		alert ("Sólo números por favor");
		return false; 
	}
}


function redondear(campo){
	if ((isNaN(campo.value)==false)&&(campo.value!="")){
		var num = parseFloat(campo.value); 
		var dec = 2; 
	    campo.value=Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec); 
	}else if(campo.value=""){
		campo.value=0;
	}
}

function mostrar_select(este){
	if(este.name=="pais*"){
		if(document.getElementById("n_pais").style.display!="block"){
			if(document.getElementById("n_estado").style.display=="block"){
				document.getElementById("estado").style.display="block";
				document.getElementById("n_estado").style.display="none";
				document.getElementById("n_estado").value="";
			}
			if(document.getElementById("n_ciudad").style.display=="block"){
				document.getElementById("ciudad").style.display="block";
				document.getElementById("n_ciudad").style.display="none";
				document.getElementById("n_ciudad").value="";
			}
			if(document.getElementById("n_urbanizacion").style.display=="block"){
				document.getElementById("urbanizacion").style.display="block";
				document.getElementById("n_urbanizacion").style.display="none";
				document.getElementById("n_urbanizacion").value="";
			}
		}
	}else if(este.name=="estado*"){
		if(document.getElementById("n_estado").style.display!="block"){
			if(document.getElementById("n_ciudad").style.display=="block"){
				document.getElementById("ciudad").style.display="block";
				document.getElementById("n_ciudad").style.display="none";
				document.getElementById("n_ciudad").value="";
			}
			if(document.getElementById("n_urbanizacion").style.display=="block"){
				document.getElementById("urbanizacion").style.display="block";
				document.getElementById("n_urbanizacion").style.display="none";
				document.getElementById("n_urbanizacion").value="";
			}
		}
	}else if(este.name=="ciudad*"){
		if(document.getElementById("n_ciudad").style.display!="block"){
			if(document.getElementById("n_urbanizacion").style.display=="block"){
				document.getElementById("urbanizacion").style.display="block";
				document.getElementById("n_urbanizacion").style.display="none";
				document.getElementById("n_urbanizacion").value="";
			}
		}
	}
	
}

function verificarFormu(cualo) {
	for(m=0;m<cualo.length;m++) {
	  if(cualo.elements[m].name.charAt(cualo.elements[m].name.length-1) == "*") {
		if(cualo.elements[m].value=="") {
				if((cualo.elements[m].name=="pais*")&&(document.getElementById("n_pais").style.display=="block")){
					if(document.getElementById("n_pais").style.display=="block"){ 				
						if(document.getElementById("n_pais").value==""){
							alert("Ingrese el nombre del pais");
							document.getElementById("n_pais").focus();
							return false;
							break;
						}
					}  if(document.getElementById("n_estado").style.display=="block"){ 
						if(document.getElementById("n_estado").value==""){
							alert("Ingrese el nombre del estado");
							document.getElementById("n_estado").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_ciudad").style.display=="block"){
						if(document.getElementById("n_ciudad").value==""){
							alert("Ingrese el nombre de la ciudad");
							document.getElementById("n_ciudad").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_urbanizacion").style.display=="block"){ 
						if(document.getElementById("n_urbanizacion").value==""){
							alert("Ingrese el nombre de la urbanizacion");
							document.getElementById("n_urbanizacion").focus();
							return false;
							break;
						}
					}else{
						alert("Ingrese todos los campos requeridos como obligatorios");
						cualo.elements[m].focus()
				 		return false;
					}
				}else if((cualo.elements[m].name=="estado*")&&(document.getElementById("n_estado").style.display=="block")){
					if(document.getElementById("n_pais").style.display=="block"){ 				
						if(document.getElementById("n_pais").value==""){
							alert("Ingrese el nombre del pais");
							document.getElementById("n_pais").focus();
							return false;
							break;
						}
					}  if(document.getElementById("n_estado").style.display=="block"){ 
						if(document.getElementById("n_estado").value==""){
							alert("Ingrese el nombre del estado");
							document.getElementById("n_estado").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_ciudad").style.display=="block"){
						if(document.getElementById("n_ciudad").value==""){
							alert("Ingrese el nombre de la ciudad");
							document.getElementById("n_ciudad").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_urbanizacion").style.display=="block"){ 
						if(document.getElementById("n_urbanizacion").value==""){
							alert("Ingrese el nombre de la urbanizacion");
							document.getElementById("n_urbanizacion").focus();
							return false;
							break;
						}
					}else{
						alert("Ingrese todos los campos requeridos como obligatorios");
						cualo.elements[m].focus()
				 		return false;
					}
				}else if((cualo.elements[m].name=="ciudad*")&&(document.getElementById("n_ciudad").style.display=="block")){
					if(document.getElementById("n_pais").style.display=="block"){					
						if(document.getElementById("n_pais").value==""){
							alert("Ingrese el nombre del pais");
							document.getElementById("n_pais").focus();
							return false;
							break;
						}
					} 
					if(document.getElementById("n_estado").style.display=="block"){
						if(document.getElementById("n_estado").value==""){
							alert("Ingrese el nombre del estado");
							document.getElementById("n_estado").focus();
							return false;
							break;
						}
					}if(document.getElementById("n_ciudad").style.display=="block"){
						if(document.getElementById("n_ciudad").value==""){
							alert("Ingrese el nombre de la ciudad");
							document.getElementById("n_ciudad").focus();
							return false;
							break;
						}
					}if(document.getElementById("n_urbanizacion").style.display=="block"){ 
						if(document.getElementById("n_urbanizacion").value==""){
							alert("Ingrese el nombre de la urbanizacion");
							document.getElementById("n_urbanizacion").focus();
							return false;
							break;
						}
					}else{
						alert("Ingrese todos los campos requeridos como obligatorios");
						cualo.elements[m].focus()
				 		return false;
					}
					
				}else if((cualo.elements[m].name=="urbanizacion*")&&(document.getElementById("n_urbanizacion").style.display=="block")){
					if(document.getElementById("n_pais").style.display=="block"){					
						if(document.getElementById("n_pais").value==""){
							alert("Ingrese el nombre del pais");
							document.getElementById("n_pais").focus();
							return false;
							break;
						}
					}if(document.getElementById("n_estado").style.display=="block"){
						if(document.getElementById("n_estado").value==""){
							alert("Ingrese el nombre del estado");
							document.getElementById("n_estado").focus();
							return false;
							break;
						}
					}if(document.getElementById("n_ciudad").style.display=="block"){
						if(document.getElementById("n_ciudad").value==""){
							alert("Ingrese el nombre de la ciudad");
							document.getElementById("n_ciudad").focus();
							return false;
							break;
						}
					}if(document.getElementById("n_urbanizacion").style.display=="block"){
						if(document.getElementById("n_urbanizacion").value==""){
							alert("Ingrese el nombre de la urbanizacion");
							document.getElementById("n_urbanizacion").focus();
							return false;
							break;
						}
					}else{
						alert("Ingrese todos los campos requeridos como obligatorios");
						cualo.elements[m].focus()
				 		return false;
					}
			 }else{
				  alert("Ingrese todos los campos requeridos como obligatorios") //+ cualo.elements[m].name.substring(0,cualo.elements[m].name.length-1))
				  cualo.elements[m].focus()
				  return false
				  break;
			 }
			  
		  
		}
		if(cualo.elements[m].value=="nuevo") { 
				if(cualo.elements[m].name=="pais*"){
					if(document.getElementById("n_pais").style.display=="block"){					
						if(document.getElementById("n_pais").value==""){
							alert("Ingrese el nombre del pais");
							document.getElementById("n_pais").focus();
							return false;
							break;
						}
					}  if(document.getElementById("n_estado").style.display=="block"){
						if(document.getElementById("n_estado").value==""){
							alert("Ingrese el nombre del estado");
							document.getElementById("n_estado").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_ciudad").style.display=="block"){
						if(document.getElementById("n_ciudad").value==""){
							alert("Ingrese el nombre de la ciudad");
							document.getElementById("n_ciudad").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_urbanizacion").style.display=="block"){
						if(document.getElementById("n_urbanizacion").value==""){
							alert("Ingrese el nombre de la urbanizacion");
							document.getElementById("n_urbanizacion").focus();
							return false;
							break;
						}
					}
				}
				if(cualo.elements[m].name=="estado*"){
					if(document.getElementById("n_pais").style.display=="block"){					
						if(document.getElementById("n_pais").value==""){
							alert("Ingrese el nombre del pais");
							document.getElementById("n_pais").focus();
							return false;
							break;
						}
					}  if(document.getElementById("n_estado").style.display=="block"){
						if(document.getElementById("n_estado").value==""){
							alert("Ingrese el nombre del estado");
							document.getElementById("n_estado").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_ciudad").style.display=="block"){
						if(document.getElementById("n_ciudad").value==""){
							alert("Ingrese el nombre de la ciudad");
							document.getElementById("n_ciudad").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_urbanizacion").style.display=="block"){
						if(document.getElementById("n_urbanizacion").value==""){
							alert("Ingrese el nombre de la urbanizacion");
							document.getElementById("n_urbanizacion").focus();
							return false;
							break;
						}
					}
				}
				if(cualo.elements[m].name=="ciudad*"){
					if(document.getElementById("n_pais").style.display=="block"){					
						if(document.getElementById("n_pais").value==""){
							alert("Ingrese el nombre del pais");
							document.getElementById("n_pais").focus();
							return false;
							break;
						}
					}  if(document.getElementById("n_estado").style.display=="block"){
						if(document.getElementById("n_estado").value==""){
							alert("Ingrese el nombre del estado");
							document.getElementById("n_estado").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_ciudad").style.display=="block"){
						if(document.getElementById("n_ciudad").value==""){
							alert("Ingrese el nombre de la ciudad");
							document.getElementById("n_ciudad").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_urbanizacion").style.display=="block"){
						if(document.getElementById("n_urbanizacion").value==""){
							alert("Ingrese el nombre de la urbanizacion");
							document.getElementById("n_urbanizacion").focus();
							return false;
							break;
						}
					}
				}
				if(cualo.elements[m].name=="urbanizacion*"){ 
					if(document.getElementById("n_pais").style.display=="block"){					
						if(document.getElementById("n_pais").value==""){
							alert("Ingrese el nombre del pais");
							document.getElementById("n_pais").focus();
							return false;
							break;
						}
					}  if(document.getElementById("n_estado").style.display=="block"){
						if(document.getElementById("n_estado").value==""){
							alert("Ingrese el nombre del estado");
							document.getElementById("n_estado").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_ciudad").style.display=="block"){
						if(document.getElementById("n_ciudad").value==""){
							alert("Ingrese el nombre de la ciudad");
							document.getElementById("n_ciudad").focus();
							return false;
							break;
						}
					} if(document.getElementById("n_urbanizacion").style.display=="block"){
						if(document.getElementById("n_urbanizacion").value==""){
							alert("Ingrese el nombre de la urbanizacion");
							document.getElementById("n_urbanizacion").focus();
							return false;
							break;
						}
					}
				}
		}

		if(cualo.elements[m].name=="Email" || cualo.elements[m].name=="Email*") {
		  pat=/^[\w\_\.çñ]{2,255}@[\w]{2,255}\.[a-z]{1,3}\.?[a-z]{0,3}$/
			if(!pat.test(cualo.elements[m].value)) {
			 alert("Introduzca un E-mail válido")
			 cualo.elements[m].focus()
			 return false
			}
		}
	  }	else {
		 continue;
		//document.cualo.submit();
	  }
	}
	if (((cualo.tipo_oferta.value=="Venta") || (cualo.tipo_oferta.value=="Permuta")) && (cualo.precio_venta.value=="")) {
	  alert("Según su Tipo de Oferta el campo Precio Venta es obligatorio")
	  cualo.precio_venta.focus()
	  return false
	  //break;
	}
	if ((cualo.tipo_oferta.value=="Comodato") && (cualo.precio_alquiler.value=="")) {
	  alert("Según su Tipo de Oferta el campo Precio Alquiler es obligatorio")
	  cualo.precio_alquiler.focus()
	  return false
	  //break;
	}
	if ((cualo.tipo_oferta.value=="Alquiler") && (cualo.precio_alquiler.value=="")) {
	  alert("Según su Tipo de Oferta el campo Precio Alquiler es obligatorio")
	  cualo.precio_alquiler.focus()
	  return false
	}
	if ((cualo.tipo_oferta.value=="Alquiler o Venta") && (cualo.precio_venta.value=="") && (cualo.precio_alquiler.value=="")) {
	  alert("Según su Tipo de Oferta los campos Precio Alquiler y Precio Venta son obligatorios")
	  cualo.precio_alquiler.focus()
	  return false
	}
	if ((cualo.tipo_oferta.value=="Alquiler o Venta") && (cualo.precio_alquiler.value=="")) {
	  alert("Según su Tipo de Oferta el campo Precio Alquiler es obligatorio")
	  cualo.precio_alquiler.focus()
	  return false
	}
	if ((cualo.tipo_oferta.value=="Alquiler o Venta") && (cualo.precio_venta.value=="")) {
	  alert("Según su Tipo de Oferta el campo Precio Venta es obligatorio")
	  cualo.precio_venta.focus()
	  return false
	}
	if ((cualo.tipo_oferta.value=="Alq. con Opción a Compra") && (cualo.precio_venta.value=="") && (cualo.precio_alquiler.value=="")) {
	  alert("Según su Tipo de Oferta los campos Precio Alquiler y Precio Venta son obligatorios")
	  cualo.precio_alquiler.focus()
	  return false
	}
	if ((cualo.tipo_oferta.value=="Alq. con Opción a Compra") && (cualo.precio_alquiler.value=="")) {
	  alert("Según su Tipo de Oferta el campo Precio Alquiler es obligatorio")
	  cualo.preprecio_alquilercio_venta.focus()
	  return false
	}
	if ((cualo.tipo_oferta.value=="Alq. con Opción a Compra") && (cualo.precio_venta.value=="")) {
	  alert("Según su Tipo de Oferta el campo Precio Venta es obligatorio")
	  cualo.precio_venta.focus()
	  return false
	}

}

function Elimina_Art(id,msn,id_sec,id_subsec,eliminar,op)
	{
		if (msn==1){
			var respuesta=confirm("¿Está seguro de querer eliminar este aviso de la base de datos? \n                    No podrá deshacer esta acción.");
		}else if (msn==2){
			var respuesta=confirm("¿Está seguro de querer eliminar este aviso de sus Favoritos? \n                    No podrá deshacer esta acción.");
		}
		if (respuesta==true){
		self.location = "p_contenido.php?id_sec="+id_sec+"&id_subsec="+id_subsec+"&op="+op+"&eliminar="+eliminar+"&id_inmueble="+id
	}
}

function Elimina_Art_Externo(id,msn,id_sec,id_subsec,eliminar,op)
	{
		if (msn==1){
			var respuesta=confirm("¿Está seguro de querer eliminar este aviso de la base de datos? \n                    No podrá deshacer esta acción.");
		}else if (msn==2){
			var respuesta=confirm("¿Está seguro de querer eliminar este aviso de sus Favoritos? \n                    No podrá deshacer esta acción.");
		}
		if (respuesta==true){
		self.location = "p_index_externo.php?id_sec="+id_sec+"&id_subsec="+id_subsec+"&op="+op+"&eliminar="+eliminar+"&id_inmueble="+id
	}
}

function poner_1(frm) {
  val=frm.origen_area_vendible.value;
  switch (val) {
    case '01': frm.area_vendible.value=frm.area.value; frm.area_vendible_hidden.value=frm.area.value; frm.area_vendible.disabled=true; break;
    case '02': frm.area_vendible.value=frm.SAT.value; frm.area_vendible_hidden.value=frm.SAT.value; frm.area_vendible.disabled=true; break;
    case '03': frm.area_vendible.value=(1*(frm.SAT.value))+(1*(frm.DAT.value)); frm.area_vendible_hidden.value=(1*(frm.SAT.value))+(1*(frm.DAT.value)); frm.area_vendible.disabled=true; break;
    case '04': frm.area_vendible.disabled=false; frm.area_vendible.value="";
  }
} 

function poner_2(frm) {
  val=frm.origen_area_vendible.value;
  switch (val) {
    case '01': frm.area_vendible.value=frm.area_techada.value; frm.area_vendible_hidden.value=frm.area_techada.value; frm.area_vendible.disabled=true; break;
    case '02': frm.area_vendible.value=frm.area.value; frm.area_vendible_hidden.value=frm.area.value; frm.area_vendible.disabled=true; break;
    case '03': frm.area_vendible.value=frm.terreno_principal.value; frm.area_vendible_hidden.value=frm.terreno_principal.value; frm.area_vendible.disabled=true; break;
    case '04': frm.area_vendible.disabled=false; frm.area_vendible.value="";
  }
} 

function poner_3(frm) {
  val=frm.origen_area_vendible.value;
  switch (val) {
    case '01': frm.area_vendible.value=frm.area_techada.value; frm.area_vendible_hidden.value=frm.area_techada.value; frm.area_vendible.disabled=true; break;
    case '02': frm.area_vendible.value=frm.area.value; frm.area_vendible_hidden.value=frm.area.value; frm.area_vendible.disabled=true; break;
    case '03': frm.area_vendible.value=frm.terreno_principal.value; frm.area_vendible_hidden.value=frm.terreno_principal.value; frm.area_vendible.disabled=true; break;
    case '04': frm.area_vendible.disabled=false; frm.area_vendible.value="";
  }
} 

function poner_4(frm) {
  val=frm.origen_area_vendible.value;
  switch (val) {
    case '01': frm.area_vendible.value=frm.area.value; frm.area_vendible_hidden.value=frm.area.value; frm.area_vendible.disabled=true; break;
    case '02': frm.area_vendible.value=frm.SAT.value; frm.area_vendible_hidden.value=frm.SAT.value; frm.area_vendible.disabled=true; break;
    case '03': 		
		Var1=frm.SAT.value.replace(/,/g,'.');
		Var2=frm.DAT.value.replace(/,/g,'.');
		frm.area_vendible.value=(1*(Var1))+(1*(Var2)); 		
		frm.area_vendible_hidden.value=(1*(Var1))+(1*(Var2)); 
		frm.area_vendible.disabled=true; 
		break;
    case '04': frm.area_vendible.disabled=false; frm.area_vendible.value="";
  }
} 

function poner_5(frm) {
  val=frm.origen_area_vendible.value;
  switch (val) {
    case '01': frm.area_vendible.value=frm.area.value; frm.area_vendible_hidden.value=frm.area.value; frm.area_vendible.disabled=true; break;
    case '02': frm.area_vendible.value=frm.SAT.value; frm.area_vendible_hidden.value=frm.SAT.value; frm.area_vendible.disabled=true; break;
    case '03': frm.area_vendible.value=(1*(frm.SAT.value))+(1*(frm.DAT.value)); frm.area_vendible_hidden.value=(1*(frm.SAT.value))+(1*(frm.DAT.value)); frm.area_vendible.disabled=true; break;
    case '04': frm.area_vendible.disabled=false; frm.area_vendible.value="";
  }
} 

function poner_6(frm) {
  val=frm.origen_area_vendible.value;
  switch (val) {
    case '01': frm.area_vendible.value=frm.area_bruta.value; frm.area_vendible_hidden.value=frm.area_bruta.value; frm.area_vendible.disabled=true; break;
    case '02': frm.area_vendible.value=frm.area_neta.value; frm.area_vendible_hidden.value=frm.area_neta.value; frm.area_vendible.disabled=true; break;
    case '03': frm.area_vendible.value=frm.area_aprovechable.value; frm.area_vendible_hidden.value=frm.area_aprovechable.value; frm.area_vendible.disabled=true; break;
    case '04': frm.area_vendible.value=parseFloat(frm.pendiente_menor_20.value)+parseFloat(frm.pendiente_menor_40.value); frm.area_vendible_hidden.value=parseFloat(frm.pendiente_menor_20.value)+parseFloat(frm.pendiente_menor_40.value); frm.area_vendible.disabled=true; break;
    case '05': frm.area_vendible.value=parseFloat(frm.pendiente_menor_20.value)+parseFloat(frm.pendiente_menor_40.value)+parseFloat(frm.pendiente_menor_60.value); frm.area_vendible_hidden.value=parseFloat(frm.pendiente_menor_20.value)+parseFloat(frm.pendiente_menor_40.value)+parseFloat(frm.pendiente_menor_60.value); frm.area_vendible.disabled=true; break;
    case '06': frm.area_vendible.disabled=false; frm.area_vendible.value="";
  }
} 

function poner_7(frm) {
  val=frm.origen_area_vendible.value;
  switch (val) {
    case '01': frm.area_vendible.value=frm.area_bruta.value; frm.area_vendible_hidden.value=frm.area_bruta.value; frm.area_vendible.disabled=true; break;
    case '02': frm.area_vendible.value=frm.area_neta.value; frm.area_vendible_hidden.value=frm.area_neta.value; frm.area_vendible.disabled=true; break;
    case '03': frm.area_vendible.value=frm.terreno.value; frm.area_vendible_hidden.value=frm.terreno.value; frm.area_vendible.disabled=true; break;
    case '04': frm.area_vendible.disabled=false; frm.area_vendible.value="";
  }
} 

function poner_8(frm) {
  val=frm.origen_area_vendible.value;
  switch (val) {
    case '01': frm.area_vendible.value=frm.area_bruta.value; frm.area_vendible_hidden.value=frm.area_bruta.value; frm.area_vendible.disabled=true; break;
    case '02': frm.area_vendible.value=frm.area_neta.value; frm.area_vendible_hidden.value=frm.area_neta.value; frm.area_vendible.disabled=true; break;
    case '03': frm.area_vendible.value=frm.terreno.value; frm.area_vendible_hidden.value=frm.terreno.value; frm.area_vendible.disabled=true; break;
    case '04': frm.area_vendible.disabled=false; frm.area_vendible.value="";
  }
} 

function poner_9(frm) {
  val=frm.origen_area_vendible.value;
  switch (val) {
    case '01': frm.area_vendible.value=frm.area_bruta.value; frm.area_vendible_hidden.value=frm.area_bruta.value; frm.area_vendible.disabled=true; //alert("-");
	break;
    case '02': frm.area_vendible.value=frm.area_neta.value; frm.area_vendible_hidden.value=frm.area_neta.value; frm.area_vendible.disabled=true; break;
    case '03': frm.area_vendible.value=frm.terreno2.value; frm.area_vendible_hidden.value=frm.terreno2.value; frm.area_vendible.disabled=true; break;
    case '04': frm.area_vendible.disabled=false; frm.area_vendible.value="";
  }
} 

function Ir_Login(){
	opener.name = "principal;"
	opener.location.href = "p_contenido.php?id_sec=1&id_subsec=4&opc=1";
	opener.focus();
	window.close();
}

function stripHTML(cadena){
    return cadena.replace(/<[^>]+>/g,'');
}

function eliminar_comentario(url,com){
		if(confirm("¿Está seguro que desea eliminar este comentario? no se podrán deshacer los cambios")){
		window.location.href='p_contenido.php?'+url+'del=1&id_com='+com;
		}
	}
function editar_comentario(id_com){
		var comentario = "";
		if(document.getElementById('text_comen')){
			comentario = stripHTML(document.getElementById('cap_'+id_com).innerHTML);
			document.getElementById('text_comen').value = "";
			document.getElementById('text_comen').value = comentario;	
			document.getElementById('edit_com').value = id_com;
			document.getElementById('cancela_edit').style.display = "block";
			document.getElementById('env_com').value = "EDITAR COMENTARIO >>";
		}
}
function cancelar_edit(){
		if(document.getElementById('text_comen')){
			document.getElementById('text_comen').value = "";
			document.getElementById('edit_com').value = "";
			document.getElementById('env_com').value = "ENVIAR COMENTARIO >>";
			document.getElementById('cancela_edit').style.display = "none";
		}
}

function validar_comentario(form){
			if((form.comentario.value == "")||(form.comentario.value < 1)){
				alert("Debe ingresar su comentario en el campo \"Comentario\". ")
				form.comentario.focus();
				return false;
			}
			return true;
}

function validar_sol_eventos(form){
	if(form.nom_eve.value == ""){
		alert("Debe ingresar el nombre del evento, en el campo \"Nombre del Evento\"");
		form.nom_eve.focus();
		return false;
	}
	if(form.fec_eve.value == ""){
		alert("Debe ingresar la fecha del evento, en el campo \"Fecha de Inicio\"");
		form.fec_eve.focus();
		return false;
	}
	if(form.lug_eve.value == ""){
		alert("Debe ingresar el lugar del evento, en el campo \"Lugar\"");
		form.lug_eve.focus();
		return false;
	}
	if(form.tip_eve.value == ""){
		alert("Debe ingresar el tipo de evento, en el campo \"Tipo de Evento\"");
		form.tip_eve.focus();
		return false;
	}
	if(form.org_eve.value == ""){
		alert("Debe ingresar el organizador de evento, en el campo \"Organizador\"");
		form.org_eve.focus();
		return false;
	}
	if(form.s_nombre.value == ""){
		alert("Debe indicar su nombre, en el campo \"Su nombre\"");
		form.s_nombre.focus();
		return false;
	}
	if(form.s_correo.value == ""){
		alert("Debe indicar su correo, en el campo \"Su correo\"");
		form.s_correo.focus();
		return false;
	}
	
	pat=/^[\w\_\.çñ]{2,255}@[\w]{2,255}\.[a-z]{1,3}\.?[a-z]{0,3}$/
	if(!pat.test(form.s_correo.value)) {
		alert("Introduzca un E-mail válido")
		form.s_correo.focus()
		return false
	}
	
	return true;
}





