var foconum = 0;
var waitme  = '<img src="/v3/wait2.gif" alt="cargando..." />';
var waitmex  = '<img src="/media/spacer.gif" alt="" width="16" height="16" />';
function foco(fq) {
   if(foconum == fq) { return false; }
   $.ajax({ type: "GET", url:  "/v3/live/foco.php", data: "o="+fq, cache: false,
      success: function(h) { $('#foco').html(h); abajo("#foco"); }
   });
   return false;
}
function genReq(rid,arg,ww) {
   if(ww && ww!='') { $(ww).html(waitme); }
   $.ajax({ type: "GET", url:  "/v3/live/foco.php", data: arg,
      success: function(h) { $(rid).html(h); abajo(rid); }
   });
   return false;
}
function abajo(arg) { $(arg).hide().fadeIn('slow'); }
function foquito(num,arg) {
   $('#fqwait').html(waitme);
   $.ajax({ type: "GET", url:  "/v3/live/foco.php", data: "fq="+num+"&arg="+arg, cache: false,
      success: function(h) { if(h != '') { $("#foquito").html(h); } }
   });
   return false;
}
function gal(num,arg) {
   $.ajax({ type: "GET", url:  "/v3/live/foco.php", data: "gal="+num+"&arg="+arg, cache: false,
   success: function(h) { if(h != '') { $("#gal"+num).html(h); abajo("#gal"+num); } else { abajo("#gal"+num); } }
   });
   return false;
}
var lastcur = 'last';
//ultimas
function lstn(sec,num) {
   if(lastcur == sec) return false;
   else lastcur = sec;
   var tmp = [1,2,3,4];
   jQuery.each(tmp,function(x) { $('#lst'+x).removeClass('lastnewsheadcur'); });
   $('#lst'+num).addClass('lastnewsheadcur');
   $('#lst1').css("border-left","1px solid #c4ced9");
   $.ajax({ type: "GET", url:  "/cache/portada/last"+sec+".html",
      success: function(h) { if(h != '') { $("#ultimas").html(h); abajo("#ultimas"); } }
   });
   return false;
}
//caricatura
function carudp(id,img) {
   $('#cared').html('<a href="/noticia/'+id+'.html" onclick="return _(\'/v3/bin/foto.php?'+id+'\');"><img src="'+img+'" /></a>');
   abajo('#cared'); return false;
}
//destacamos
function dest(arg) {
   $('#destwait').html(waitme);
   $.ajax({ type: "GET", url:  "/v3/live/foco.php", data: "dest="+arg, 
      success: function(h) { if(h != '') { $("#destacamos").html(h); abajo("#destacamos"); } }
   });
   return false;
}
function evnt(arg,data) {
   $('#eventwait').html(waitme);
   $.ajax({ type: "GET", url:  "/v3/live/foco.php", data: "evento="+arg+"&data="+data, 
      success: function(h) { if(h != '') { $("#eventid").html(h); $('#eventwait').html(waitmex); abajo("#eventid"); } }
   });
   return false;
}
function evntm(arg,data) {
   $('eventwait').update(waitme);
   new Ajax.Request('/v3/live/foco.php?eventomes='+arg+'&data='+data, { method:'get', onSuccess: function(t){ $('eventcal').update(t.responseText); } });
   return false;
}
function finan(arg) {
   $('guiaswait').update(waitme);
   if(arg =='calculadora') new Ajax.Request('/live/calculadora-divisas.php', { method:'get', onSuccess: function(t){ $('finanzasid').update(t.responseText); $('guiaswait').update(waitmex);} });
   else new Ajax.Request('/cache/portada/guias-finanzas-'+arg+'.html', { method:'get', onSuccess: function(t){ $('finanzasid').update(t.responseText); $('guiaswait').update(waitmex);} });
   return false;
}
function guiax(arg) {
   $('#guiaswait').html(waitme);
   $.ajax({ type: "GET", url:  "/cache/portada/guias-"+arg+".html", 
      success: function(h) { $('#guiasbody').html(h); abajo("#guiasbody"); $('#guiaswait').html(waitmex); }
   });
   return false;
}
function galGo(wait,args,path) {
   $(wait).src = '/v3/fff.png';
   new Ajax.Request('/v3/live/foco.php?galit='+args, { method:'get', onSuccess: function(t){ $('imageit').update(t.responseText); $(wait).src = path;} });
   return false;
}
function _(url,nombre,ancho,alto) {
   ancho = ancho ? ancho : 600; alto = alto ? alto : 480; nombre = nombre ? nombre : 'aux';
   aux = window.open(url,nombre,"width="+ancho+",height="+alto+",toolbar=no,directories=no,location=no,copyhistory=no,scrollbars=yes,resizable=yes");
   aux.focus();
   return false;
}
if(portada === 1) {
   timerNR = setInterval("updateNR(0);",1000*22);
}
var update1 = 1;
function updateNR(arg) {
   if(update1 > 50 && timerNR) {
      clearInterval("timerNR");
      return false;
   }
   $('#noticiasrandimg').html('<img src="http://media.elsiglodetorreon.com.mx/v3/wait2.gif" />');
   $.ajax({
      type: 'GET',
      url:  '/v3/live/foco.php?',
      data: 'nr='+update1,
      cache: false,
      success: function(h) {
         $('#noticiasrand').html(h);
         update1++;
      }
   });
   return false;
}



         var fsize = '13';
         function mas() {
            if(fsize<=20) {
               fsize++;
               $('noticiabody').style.fontSize =fsize+'px';
               new Ajax.Request('/v3/live/letra.php', { method: 'get',parameters:{ size: fsize } });
            }
         }
         function menos() {
            if(fsize>=8) {
               fsize--;
               $('noticiabody').style.fontSize = fsize+'px';
               new Ajax.Request('/v3/live/letra.php', { method: 'get',parameters:{ size: fsize } });
            }
         }


function up2date(seccion) {
   new Ajax.Request('/addons/foros.php?s='+seccion, { method:'get', onSuccess: function(t){ $('forosx').update(t.responseText); } });
   return false;
}

function clickclear(thisfield, defaulttext) {
   if (thisfield.value == defaulttext) { thisfield.value = ""; }
}
function clickrecall(thisfield, defaulttext) {
   if (thisfield.value == "") { thisfield.value = defaulttext; }
}
function deleteComment(msg) {
   $.ajax({ type: "GET", url:  "/bin/dc;"+msg,
      success: function(h) { $('#m'+msg).html(h); abajo("#m"+msg); }
   });
   return false;
}
function cuadroSiguiente(no) {
   $.ajax({ type: "GET", url:  "/cache/portada/cuadros"+no+".html",
      success: function(h) { if(h != '') { $("#cuadros").html(h); } }
   });
   return false;
}

function galgox(wait,args) {
   $('#w'+wait).src='/v3/fff.png';
   $('#galwait').src='/v3/wait1.gif';
   $.ajax({ type: "GET", url:  "/v3/live/foco.php", data: "galit="+args, cache: false,
      success: function(h) { $('#imageit').html(h); abajo("#imageit"); }
   });
   return false;
}


/*
<!-- Dynamic Version by: Nannette Thacker -->
<!-- http://www.shiningstar.net -->
<!-- Original by :  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->
<!-- Use one function for multiple text areas on a page -->
<!-- Limit the number of characters per textarea -->
<!-- Begin */
function textCounter(field,cntfield,maxlimit) {
   if (field.value.length > maxlimit) // if too long...trim it!
      field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
   else
      cntfield.value = maxlimit - field.value.length;
}
