function gou (ur) {
         window.location.replace(ur);
}
function ope (cont, e, ca, w, h) {
         var cap = document.getElementById(ca);
         {
            cap.style.left       = e.pageX ? pageXOffset + e.clientX: w;
            cap.style.top        = e.pageY ? pageYOffset + e.clientY : h;
            cap.style.visibility = 'visible';
            cap.innerHTML        = cont;
         }
}
function closeT(ca) {
         var cap = document.getElementById(ca);
         if (cap.style.visibility=='visible') cap.style.visibility = 'hidden';
}
function centra (x,y) {
         var w= screen.width;
         var h= screen.height;
         var wx = (w - x)/2;
         var hy = (h - y)/2-50;
         var wh = new Array();
         wh[0]= wx;
         wh[1]= hy;
         return wh;
}
function log () {
         window.open ("login.php", "cla", "width=790 height=500 top=50 left=100 scrollbars=yes");
}
function oplog (i) {
         var co ="<table border=0 bgcolor=\"#008080\" cellpadding=2>";
         co+="<form name=\"flog\" method=\"post\" action=\"login.php?i="+i+"\">";
         co+="<tr> <td align=\"center\" class=\"login\" colspan=\"2\"> <b> Ingreso de Administrador </b> ";
         co+="<tr> <td class=\"login\"> Usuario: <td> <input name=\"user\">";
         co+="<tr> <td class=\"login\"> Clave: <td> <input type=\"password\" name=\"pass\">";
         co+="<tr> <td colspan=\"2\" align=\"center\"> <input type=\"submit\" value=\"Ingresar\" class=\"butlog\">\n";
         co+="<input type=\"button\" value=\"Cancelar\" class=\"butlog\" onClick=\"closeT('login')\">";
         co+="</table>";
         co+="</form>";
         ope(co, event, 'login',300 ,200);
         flog.user.focus();
}
function opei (cont, e, ca) {
         var cap = document.getElementById(ca);
         {
            //cap.style.left       = e.pageX ? pageXOffset + e.clientX: w;
            //cap.style.top        = e.pageY ? pageYOffset + e.clientY : h;
            cap.style.visibility = 'visible';
            cap.innerHTML        = cont;
         }
}
function addp () {
         var co="<textarea name=\"tit\" rows=\"2\" class=\"cmps\" onKeyPress=\"lar('des')\"></textarea>";
         opei(co, event, 'tit');
         var co="<select name=\"tip\" class=\"sti\">";
             co+="<option value=\"Casa\">Casa";
             co+="<option value=\"Departamento\">Departamento";
             co+="<option value=\"Local u oficina\">Local u oficina";
             co+="<option value=\"Terreno\">Terreno";
         co+="</select>";
         opei(co, event, 'tip');
         var co="<select name=\"mod\" class=\"smo\">";
             co+="<option value=\"Alquiler\">Alquiler";
             co+="<option value=\"Venta\">Venta";
         co+="</select>";
         opei(co, event, 'mod');
         neo.tit.focus();
}
function adda () {
         var co="<textarea name=\"hea\" rows=\"2\" class=\"cmpa\" onKeyPress=\"lara('hea')\"></textarea>";
         opei(co, event, 'hea');
         var co="<textarea name=\"con\" rows=\"2\" class=\"cmpa\" onKeyPress=\"lara('con')\"></textarea>";
         opei(co, event, 'con');
         neo.hea.focus();
}
function addm () {
         var ur= "ingreso.php?adm=1";
         gou(ur);
}
function addma () {
         var ur= "ingreso.php?mod=2"+"&adm=1";
         gou(ur);
}
function savep () {
         var ti = neo.tit.value;
         if (ti=="") {
            alert ("Debe llenar al menos el campo \"Título\"");
            neo.tit.focus();
         }
         else neo.submit();
}
function savea () {
         var he = neo.hea.value;
         if (he=="") {
            alert ("Debe llenar al menos el campo \"Encabezado\"");
            neo.he.focus();
         }
         else neo.submit();
}
function canp () {
         var ur="ingreso.php";
         gou(ur);
}
function cana () {
         var ur="ingreso.php?mod=2";
         gou(ur);
}
function del (id) {
         var ur="ingreso.php?ide="+id;
         if (confirm("¿Está seguro que desea borrar este elemento?")) gou(ur);
}
function dela (id) {
         var ur="ingreso.php?mod=2&idea="+id;
         if (confirm("¿Está seguro que desea borrar este elemento?")) gou(ur);
}
var lc=20
function lar (c) {
         var ti= neo.tit.value;
         var ub= neo.ubi.value;
         var de= neo.des.value;
         var t= ti.length;
         var u= ub.length;
         var d= de.length;
         var m= Math.max(t,u);
         m= Math.max(m,d);
         var sl = m % 32;
         if (sl == 31) {
            lc +=17;
            neo.tit.style.height= lc;
            neo.ubi.style.height= lc;
            neo.des.style.height= lc;
         }
         if (c!="") {
            var te= eval("neo."+c+".value;");
            var uc= te.substr(te.length-2);
            var ent= String.fromCharCode(13,10);
            if (uc==ent) {
               lc += 17;
               neo.tit.style.height= lc;
               neo.ubi.style.height= lc;
               neo.des.style.height= lc;
            }
         }
}
var lca=20;
function lara (cn) {
         var he= neo.hea.value;
         var co= neo.con.value;
         var h= he.length;
         var c= co.length;
         var m= Math.max(h,c);
         var sl = m % 38;
         if (sl == 37) {
            lca +=17;
            neo.hea.style.height= lca;
            neo.con.style.height= lca;
         };
         if (cn!="") {
            var te= eval("neo."+cn+".value;");
            var uc= te.substr(te.length-2);
            var ent= String.fromCharCode(13,10);
            if (uc==ent) {
               lca += 17;
               neo.hea.style.height= lca;
               neo.con.style.height= lca;
            }
         }
}
function larg () {
         var ti= neo.tit.value;
         var ub= neo.ubi.value;
         var de= neo.des.value;
         var t= ti.length;
         var u= ub.length;
         var d= de.length;
         var m= Math.max(t,u);
         m= Math.max(m,d);
         var sl = Math.ceil(m / 32);
         neo.tit.style.height= 20 + sl*15;
         neo.ubi.style.height= 20 + sl*15;
         neo.des.style.height= 20 + sl*15;
}
function larga () {
         var he= neo.hea.value;
         var co= neo.con.value;
         var h= he.length;
         var c= co.length;
         var m= Math.max(h,c);
         var sl = Math.ceil(m / 32);
         neo.hea.style.height= 20 + sl*15;
         neo.con.style.height= 20 + sl*15;
}
function selpro () {
         var id= prs.value;
         var ur = "data.php?id="+id+"&im=1";
         gou(ur);
}
function selact () {
         var id = act.value;
         var ur = "noti.php?id="+id+"&im=1";
         gou(ur);
}
function agre (id) {
         var co=" <table width=\"292\" height=\"240\" border=1 bordercolor=\"#006363\" bgcolor=\"#ECFEFE\" cellpadding=\"1\"> <td>";
         co+="<form name=\"img\" method=\"post\" action=\"addgal.php?id="+id+"\" enctype=\"multipart/form-data\">";
         co+= "<table border=0>";
         co+= "<td align=\"center\" valign=\"top\"><input name=\"tiag\" value=\"Nueva Imagen\" class=\"tag\">";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"4\">";
         co+="<tr> <td align=\"left\"> Escoja una imagen de su disco duro";
         co+= "<tr> <td> <input type=\"file\" name=\"foto\" class=\"gali\">";
         co+="<tr> <td align=\"left\"> Escriba un comentario sobre la imagen";
         co+="<tr> <td> <textarea name=\"coment\" class=\"galci\"></textarea>";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"3\">";
         co+= "<tr> <td align=\"center\"> <input type=\"submit\" value=\"Guardar\">\n";
         co+= "<input type=\"button\" value=\"Cancelar\" onClick=\"reloa()\">\n";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"4\">";
         co+= "</table>";
         co+="</table>";
         opei(co, event, 'input');
}
function agreact (id) {
         var co=" <table width=\"292\" height=\"240\" border=1 bordercolor=\"#006363\" bgcolor=\"#ECFEFE\" cellpadding=\"1\"> <td>";
         co+="<form name=\"img\" method=\"post\" action=\"addgal.php?id="+id+"&op=1\" enctype=\"multipart/form-data\">";
         co+= "<table border=0>";
         co+= "<td align=\"center\" valign=\"top\"><input name=\"tiag\" value=\"Nueva Imagen\" class=\"tag\">";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"4\">";
         co+="<tr> <td align=\"left\"> Escoja una imagen de su disco duro";
         co+= "<tr> <td> <input type=\"file\" name=\"foto\" class=\"gali\">";
         co+="<tr> <td align=\"left\"> Escriba un comentario sobre la imagen";
         co+="<tr> <td> <textarea name=\"coment\" class=\"galci\"></textarea>";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"3\">";
         co+= "<tr> <td align=\"center\"> <input type=\"submit\" value=\"Guardar\">\n";
         co+= "<input type=\"button\" value=\"Cancelar\" onClick=\"reloa()\">\n";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"4\">";
         co+= "</table>";
         co+="</table>";
         opei(co, event, 'input');
}
function reloa() {
         window.location.reload()
}
function modi (id, im, com) {
         com = com.replace(/%-%/g, "\n");
         var co=" <table width=\"292\" height=\"240\" border=1 bordercolor=\"#006363\" bgcolor=\"#ECFEFE\" cellpadding=\"1\"> <td>";
         co+="<form name=\"img\" method=\"post\" action=\"addgal.php?id="+id+"&im="+im+"\" enctype=\"multipart/form-data\">";
         co+= "<table border=0>";
         co+= "<td align=\"center\" valign=\"top\"><input name=\"tiag\" value=\"Modificar Imagen\" class=\"tag\">";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"4\">";
         co+="<tr> <td align=\"left\"> Escoja un imagen de su disco duro";
         co+= "<tr> <td> <input type=\"file\" name=\"foto\" class=\"gali\">";
         co+="<tr> <td align=\"left\"> Modifique el comentario";
         co+="<tr> <td> <textarea name=\"coment\" class=\"galci\">"+com+"</textarea>";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"3\">";
         co+= "<tr> <td align=\"center\"> <input type=\"submit\" value=\"Guardar\">\n";
         co+= "<input type=\"button\" value=\"Cancelar\" onClick=\"reloa()\">\n";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"4\">";
         co+= "</table>";
         co+="</table>";
         opei(co, event, 'input');
}
function modiact (id, im, com) {
         com = com.replace(/%-%/g, "\n");
         var co=" <table width=\"292\" height=\"240\" border=1 bordercolor=\"#006363\" bgcolor=\"#ECFEFE\" cellpadding=\"1\"> <td>";
         co+="<form name=\"img\" method=\"post\" action=\"addgal.php?id="+id+"&im="+im+"&op=1\" enctype=\"multipart/form-data\">";
         co+= "<table border=0>";
         co+= "<td align=\"center\" valign=\"top\"><input name=\"tiag\" value=\"Modificar Imagen\" class=\"tag\">";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"4\">";
         co+="<tr> <td align=\"left\"> Escoja un imagen de su disco duro";
         co+= "<tr> <td> <input type=\"file\" name=\"foto\" class=\"gali\">";
         co+="<tr> <td align=\"left\"> Modifique el comentario";
         co+="<tr> <td> <textarea name=\"coment\" class=\"galci\">"+com+"</textarea>";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"3\">";
         co+= "<tr> <td align=\"center\"> <input type=\"submit\" value=\"Guardar\">\n";
         co+= "<input type=\"button\" value=\"Cancelar\" onClick=\"reloa()\">\n";
         co+="<tr> <td> <img src=\"images/esp.gif\" height=\"4\">";
         co+= "</table>";
         co+="</table>";
         opei(co, event, 'input');
}
function dele (id, im) {
         if (confirm("¿Está seguro que desea eliminar este elemento?")) {
            gou("del.php?id="+id+"&im="+im);
         }
}

function deleact (id, im) {
         if (confirm("¿Está seguro que desea eliminar este elemento?")) {
            gou("delact.php?id="+id+"&im="+im+"&op=1");
         }
}
function camb (m) {
         var co = "<table> <td class=\"newc\">";
         co+= "<table cellpadding=\"0\" cellspacing=\"0\" class=\"newi\">";
         co+= "<form name= \"cam\" method = \"post\" action = \"change.php?m="+m+"\">";
         co+= "<tr> <td colspan=\"2\" align=\"center\"> <b> Cambio de Clave </b>";
         co+= "<tr> <td colspan=\"2\"> <img src=\"images/esp.gif\" height=\"5\">";
         co+= "<tr> <td> Clave anterior <td> <input type=\"password\" name=\"ppass\">";
         co+= "<tr> <td> Nueva clave <td> <input type=\"password\" name=\"npass\">";
         co+= "<tr> <td> Confirme la Nueva clave&nbsp; <td> <input type=\"password\" name=\"rpass\">";
         co+= "<tr> <td colspan=\"2\"> <img src=\"images/esp.gif\" height=\"5\">";
         co+= "<tr> <td colspan=\"2\" align=\"center\"> <input type=\"submit\" value= \"Aceptar\" class=\"butcla\">\n";
         co+= "<input type=\"button\" value= \"Cancelar\" onClick=\"closeT('inp')\" class=\"butcla\">";
         co+= "</table> </table></form>";
         ope(co, event, 'inp', 230, 82);
         cam.ppass.focus();
}
function vcla (cl) {
         var pc = cam.ppass.value;
         var nc = cam.npass.value;
         var rc = cam.rpass.value;
         var rs= 0;
         var me= "";
         if (pc!=cl) rs+=1;
         if (nc!=rc) rs+=2;
         if (rs==3) me = "La clave actual que ha escrito es incorrecta y no coincide la nueva clave con su confirmación";
         if (rs==2) me = "La nueva clave no coincide con su confirmación";
         if (rs==1) me = "La clave actual que ha escrito es incorrecta";
         if (rs==0) cam.submit();
         else alert(me);
}
function news (id) {
         var ur = "news.php?id="+id;
         window.open (ur, "ne", "width=500 height=550 top=100 left=150 scrollbars=yes");
}
function fullimg (di, im, w, h) {
         var ws= screen.width;
         var hs= screen.height;
         if (w > ws || h > hs) {
            if (w/ws > h/hs) {
               h = Math.floor(((h/w)*ws)*0.98);
               w = Math.floor(ws*0.98);
            } else {
               w = Math.floor(((w/h)*hs)*0.90);
               h = Math.floor(hs*0.90);
            }
         }
         var ur = "img.php?di="+di+"&im="+im+"&h="+h+"&w="+w;
         var wh = centra(w, h);
         var at = "width=" + w + " height=" + h + " top = "+wh[1]+" left="+wh[0];
         window.open (ur, "ima", at);
}
function princ (id, im, imx) {
         var ur = "data.php?id="+id+"&im="+imx+"&pr="+im;
         gou(ur);
}
function galeri (id) {
         var ur = "galeria.php?id="+id;
         var at = "width=670 height=550 top=120 left=150";
         window.open(ur, "gal", at);
}
function chagal () {
         var id= pro.value;
         var ur = "galeria.php?id="+id;
         gou(ur);
}
var x=5;
var y=0;
m=0;
function mueve (d) {
         var cap = not.document.getElementById('cnews');
         if (cap.style.visibility=='visible') cap.style.visibility = 'hidden';
         if (d=='U' && y < 0) y+=5;
         if (d=='D') y-=5;
         {
            cap.style.left       =  x;
            cap.style.top        =  y;
            cap.style.visibility = 'visible';
         }
         tim(d);
}
function ply (d) {
         m=1;
         tim(d);
         if (d=='U') document.bup.src="images/onup.gif";
         if (d=='D') document.bdow.src="images/ondown.gif";
}
function sto (d) {
         m=0;
         if (d=='U') document.bup.src="images/up.gif";
         if (d=='D') document.bdow.src="images/down.gif";
}
function tim (d) {
         if (m==1) {
            mu = "mueve('"+d+"')";
            setTimeout(mu, 100);
         }
}
function opca (ca, co) {
         opei ("", event, "pla");
         opei ("", event, "doc");
         opei ("", event, "inf");
         var con = eval(co+".value");
         con = con.replace(/#/g, "\"");
         con = con.replace("&&", "#");
         opei (con, event, ca);
}

function eti (ie) {
         var e= event;
         var et= new Array("Modificar", "Eliminar");
         var co ="<table><td class=\"eti\">"+et[ie]+"</table>";
         var cap = document.getElementById('eti');
         {
            cap.style.left       = e.pageX ? pageXOffset + e.clientX: document.body.scrollLeft + e.x + 7;
            cap.style.top        = e.pageY ? pageYOffset + e.clientY: document.body.scrollTop + e.y + 5;
            cap.style.visibility = 'visible';
            cap.innerHTML        = co;
         }

}
function deld (il, id, im) {
        ur = "load.php?il="+il+"&id="+id+"&im="+im;
        if (confirm("¿Está seguro que desea eliminar este documento?")) gou(ur);
}
function deli (ii, id, im, a) {
        ur = "load.php?ii="+ii+"&id="+id+"&im="+im;
        var mm="";
        if (a==0) mm="texto";
        if (a==1) mm="archivo";
        if (confirm("¿Está seguro que desea eliminar este "+mm+"?")) gou(ur);
}
function optxt (id) {
         var ur= "txt.php?id="+id;
         window.open (ur, "txt", "width=300 height=400 top=200 left=200 scrollbars=yes");
}
function opdet (id) {
         var ur = "detalles.php?id="+id;
         var at = "width=670 height=500 top=150 left=150 scrollbars=yes";
         window.open(ur, "gal", at);
}
function sendit () {
         var no = fsen.nombre.value;
         var me = fsen.mensaje.value;
         if (no=="" || me=="") alert ("Es necesario llenar los campos \"Nombre\" y \"Mensaje\"");
         else fsen.submit();
}
function msg(id) {
         var ur="msg.php?id="+id;
         var w= screen.width;
         var h= screen.height;
         var xk=320;
         var yh=330;
         xx= (w - xk)/2;
         yy= (h - yh)/2;
         xk+=30;
         yh+=95;
         window.open (ur, 'msg', "width="+xk+" height="+yh+" top="+yy+" left="+xx);
}
function sending () {
         var nm= mif.nombre.value;
         var fn= mif.fono.value;
         var as= mif.asunto.value;
         var ms= mif.mens.value;
         if (nm=="" || fn=="" || as=="" || ms=="") {
            alert("Todos los campos marcados con (*) son obligatorios");
            mif.nombre.focus();
         } else mif.submit();
}
function reimg (im, x, y, co) {
         parent.img.document['ima'].src="imgpro/"+im;
         parent.img.document['ima'].style.width= x;
         parent.img.document['ima'].style.height= y;
         var com = parent.img.document.getElementById('come');
         {
             com.innerHTML        = co;
         }
}