function ShowError(){
return true;
}
window.onerror=ShowError;

function abrirventana(pagina,titulo){
//w=660;
//h=530;
//t=(screen.width-w)/2;
//l=(screen.height-h)/2-33;
//win=window.open(pagina); //,'','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
document.location=pagina;
//win.moveTo(t,l);
//win.focus();
}

function abrirventanapop(pagina,titulo){
w=660;
h=530;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
win.moveTo(t,l);
win.focus();
}


function verterminos(){
abrirventanapop('index.php?Pagina=noticias&modo=popup&IDPagina=terminos','');
}

function abrirventanapop2(pagina){
w=540;
h=500;
t=(screen.width-w)/2;
l=(screen.height-h)/2-33;
win=window.open(pagina,'','width='+w+',height='+h+',scrollbars=no,resizable=no');
win.moveTo(t,l);
win.focus();
}


function openapp(extra){
titextra='';
if(extra) titextra='2';
abrirventana('attel.php'+extra,'attel'+titextra);
}
//var calWin;
var calObject;
function abreCalendario(object){
w=225;
h=270;
l=(screen.width-w)/2;
t=(screen.height-h)/2-33;
calObject=object;
calWin=window.open('calendario/cal.php','cal','width='+w+',height='+h+',left='+l+',top='+t+',scrollbars=no,resizable=no');
calwin.moveTo(t,l);
calwin.focus();
}
function cierraCalendario(dia,mes,anno){
if (calObject=='fechaini') {
document.forms[0].fechainidia.value=dia;
document.forms[0].fechainimes.value=mes;
document.forms[0].fechainianno.value=anno;
} else if(calObject=='fechafin') {
document.forms[0].fechafindia.value=dia;
document.forms[0].fechafinmes.value=mes;
document.forms[0].fechafinanno.value=anno;
}else if(calObject=='actafecha') {
document.forms[0].actafechadia.value=dia;
document.forms[0].actafechames.value=mes;
document.forms[0].actafechaanno.value=anno;
}
}

var validacion=false;

function validar(frm) {
if (!validacion) return true;
validacion=false;
retval=true;
n=frm.elements.length;
for (i=0; i<n; i++)
if (frm.elements[i].value==""){
s=frm.elements[i].name;
a=s.split('&_Campo=');
s=a[1];
if (s){
alert('Capture el '+s);
frm.elements[i].focus();
retval=false;
i=n;
}
}
return retval;
}

var cn_imgSrc='';
var cn_n=0;
var win='';

var cn_liga='';
var cn_textoliga='';

function ObtenerObjeto(n, d) {
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=ObtenerObjeto(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function EditarImagen(n,imgSrc){
cn_n=n;
cn_imgSrc=imgSrc;
w=400;
h=500;
l=(screen.width-w)/2;
t=(screen.height-h)/2;
win=window.open('SelImagen.php','SelImagen','scrollbars=yes,resizable=yes,width='+w+',height='+h+',left='+l+',top='+t);
//win.moveTo(l,t);
win.focus();
}

function SeleccionarImg(file){
if (cn_n>0){
if (win) win.close();
imgObject=ObtenerObjeto('img'+cn_n);
bObject=ObtenerObjeto('b'+cn_n);
bObject.value=file;
imgObject.src='pub/'+file;
window.focus();
}
cn_imgSrc='';
cn_n=0;
win='';
}

function EditarImagenGaleria(n,imgSrc){
cn_n=n;
cn_imgSrc=imgSrc;
w=400;
h=500;
l=(screen.width-w)/2;
t=(screen.height-h)/2;
win=window.open('SelImagenGaleria.php','SelImagen','scrollbars=yes,resizable=yes,width='+w+',height='+h+',left='+l+',top='+t);
//win.moveTo(l,t);
win.focus();
}

function SeleccionarImgGaleria(file){
if (cn_n>0){
if (win) win.close();
imgObject=ObtenerObjeto('img'+cn_n);
bObject=ObtenerObjeto('b'+cn_n);
bObject.value=file;
imgObject.src='pub/galeria/'+file;
window.focus();
}
cn_imgSrc='';
cn_n=0;
win='';
}

function AbrirEditor(n){
cn_n=n;
//cn_imgSrc=imgSrc;
imgObject=ObtenerObjeto('texto'+cn_n);
w=400;
h=500;
l=(screen.width-w)/2;
t=(screen.height-h)/2;
var texto=escape(imgObject.value);
win=window.open('editor/editor.php?valor='+texto,'editor','scrollbars=yes,resizable=yes,width='+w+',height='+h+',left='+l+',top='+t);
//win.foo.innerHTML=imgObject.value;
//win.moveTo(l,t);
win.focus();
}

function CerrarEditor(texto){
if (cn_n>0){
if (win) win.close();
imgObject=ObtenerObjeto('texto'+cn_n);

texto=texto.replace(/<BR>/g,'\n');
texto=texto.replace(/&nbsp;/g,' ');
texto=texto.replace(/<STRONG>/g,'<B>');
texto=texto.replace(/<\/STRONG>/g,'<\/B>');

imgObject.value=texto;
}
cn_n=0;
win='';
}

function EditarLiga(n,liga,textoliga) {
cn_n=n;
cn_liga=liga;
cn_textoliga=textoliga;
tipoliga=1; //falta identificar 1 0 3
w=440;
h=440;
l=(screen.width-w)/2;
t=(screen.height-h)/2;
win=window.open('editarligas.php?liga='+liga+'&textoliga='+textoliga,'editarligas','scrollbars=yes,resizable=yes,width='+w+',height='+h+',left='+l+',top='+t);
//win.moveTo(l,t);
win.focus();
//alert("n="+n+" , liga="+liga+" , textoliga="+textoliga);
}

function SeleccionarLiga(liga,textoliga){
if (cn_n>0){
if (win) win.close();
lObject=ObtenerObjeto('l'+cn_n);
tlObject=ObtenerObjeto('tl'+cn_n);
alObject=ObtenerObjeto('al'+cn_n);
lObject.value=liga;
tlObject.value=textoliga;
alObject.innerText='liga: '+textoliga;
window.focus();
}
cn_liga='';
cn_textoliga='';
cn_n=0;
win='';
}

function Cerrar(){
if (win) win.close();
window.focus();
cn_imgSrc='';
cn_liga='';
cn_textoliga='';
cn_n=0;
win='';
}




function button_over(eButton){
if(eButton.alternar==undefined) eButton.alternar=0;
if (eButton.alternar<2){
eButton.style.borderBottom = "buttonshadow solid 1px";
eButton.style.borderLeft = "buttonhighlight solid 1px";
eButton.style.borderRight = "buttonshadow solid 1px";
eButton.style.borderTop = "buttonhighlight solid 1px";
}
}

function button_out(eButton){
if(eButton.alternar==undefined) eButton.alternar=0;
if (eButton.alternar<2) eButton.style.borderColor = "threedface";
}

function button_down(eButton){
eButton.style.borderBottom = "buttonhighlight solid 1px";
eButton.style.borderLeft = "buttonshadow solid 1px";
eButton.style.borderRight = "buttonhighlight solid 1px";
eButton.style.borderTop = "buttonshadow solid 1px";
}


