 var tagScript = '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)';
        /**
        * Eval script fragment
        * @return String
        */
        String.prototype.evalScript = function()
        {
                return (this.match(new RegExp(tagScript, 'img')) || []).evalScript();
        };
        /**
        * strip script fragment
        * @return String
        */
        String.prototype.stripScript = function()
        {
                return this.replace(new RegExp(tagScript, 'img'), '');
        };
        /**
        * extract script fragment
        * @return String
        */
        String.prototype.extractScript = function()
        {
                var matchAll = new RegExp(tagScript, 'img');
                return (this.match(matchAll) || []);
        };
        /**
        * Eval scripts
        * @return String
        */
        Array.prototype.evalScript = function(extracted)
        {
                var s=this.map(function(sr){
                         var sc=(sr.match(new RegExp(tagScript, 'im')) || ['', ''])[1];
                         if(window.execScript){
                              window.execScript(sc);
                         }
                        else
                       {
                           window.setTimeout(sc,0);
                        }
                });
                return true;
        };
        /**
        * Map array elements
        * @param {Function} fun
        * @return Function
        */
        Array.prototype.map = function(fun)
        {
                if(typeof fun!=="function"){return false;}
                var i = 0, l = this.length;
                for(i=0;i<l;i++)
                {
                        fun(this[i]);
                }
                return true;
        };


function mon (mon,cant) {

  document.getElementById(mon).innerHTML='';
  if (cant/10000>=1) {
  var m3 = document.createElement('img');
  m3.src='http://www1.tierrasdeleyenda.com/img/m3.gif';
  m3.title='Aurius';
  document.getElementById(mon).appendChild(m3);
  var t3 = document.createTextNode(' '+parseInt(cant/10000)+' ');
  document.getElementById(mon).appendChild(t3);
 }
  if (cant%10000/100>=1) {
  var m2 = document.createElement('img');
  m2.src='http://www1.tierrasdeleyenda.com/img/m2.gif';
  m2.title='Pleatus';
  document.getElementById(mon).appendChild(m2);
  var t2 = document.createTextNode(' '+parseInt(cant%10000/100)+' ');
  document.getElementById(mon).appendChild(t2);
 }
 if (cant%100>0||cant==0) {
  var m1 = document.createElement('img');
  m1.src='http://www1.tierrasdeleyenda.com/img/m1.gif';
  m1.title='Brons';
  document.getElementById(mon).appendChild(m1);
  var t1 = document.createTextNode(' '+cant%100+' ');
  document.getElementById(mon).appendChild(t1);
 }

 }

function la (url, id_c){var pr = false;if (window.XMLHttpRequest) {
    document.bgColor = '#600000';
    document.getElementById (id_c).innerHTML = "<font class='texto'>...cargando...<font>";
    pr = new XMLHttpRequest (); } else if (window.ActiveXObject)   { try  { pr = new ActiveXObject ("Msxml2.XMLHTTP"); } catch (e)
 { try { pr = new ActiveXObject ("Microsoft.XMLHTTP"); } catch (e) {}
  }} else window.location.href='?ac='+url;
    pr.onreadystatechange = function ()
    {
     cp (pr, id_c);
    }
    
    pr.open ('GET', 'inc/pant_esp/'+url+'.php?f=1', true);
    pr.send (null);
    }


function lb (url, id_c,p){var pr = false;if (window.XMLHttpRequest) {
    document.bgColor = '#600000';

    pr = new XMLHttpRequest (); } else if (window.ActiveXObject)   { try  { pr = new ActiveXObject ("Msxml2.XMLHTTP"); } catch (e)
 { try { pr = new ActiveXObject ("Microsoft.XMLHTTP"); } catch (e) {}
  }} else window.location.href='?ac='+url;
    pr.onreadystatechange = function ()
    {
     cp (pr, id_c);
    }
    pr.open ('GET', 'inc/pant_esp/'+url+'.php?f=1'+p, true);
    pr.send (null);

    if (id_c!='rec') repit();
    }

function cp (pr, id_c)
{
    if (pr.readyState == 4 && (pr.status == 200 || window.location.href.indexOf ("http") == - 1))
      {
       var scs=pr.responseText.extractScript();
       document.getElementById (id_c).innerHTML = pr.responseText.stripScript();
       scs.evalScript();
    }
}


function strtr (str, from) {
    var fr = '';
    for (fr in from) {
      str = str.replace(fr, from[fr]);
    }
    return str;
}

function confmsg(poc,cant) {
 if (cant<1) cant=1;
 if (cant<10) return(true);
 else {
 var poci = "¿Utilizar "+cant + " "+poc+" ?" ;
 var rep={'&aacute;':'á','&eacute;':'é','&iacute;':'í','&oacute;':'ó','&uacute;':'ú','<br>':''};
 poci = strtr(poci,rep); 
 a=(confirm(poci));
 return(a);
 }
}


function spos ( f_haystack, f_needle, f_offset ){
    var haystack = (f_haystack+'').toLowerCase();
    var needle = (f_needle+'').toLowerCase();
    var index = 0; 
    if ((index = haystack.indexOf(needle, f_offset)) !== -1) {
        return index;
    }
    return false;
}

function hs (iden,cant,tex) {
 
 document.getElementById('s'+iden).innerHTML='';
 var t1 = document.createElement("select");
 t1.setAttribute('class','tbox');
 t1.setAttribute('name','ac4'+iden);
 t1.setAttribute('Id','ac4'+iden);
 
 var uni=1;
 var dec=1;
 var q=uni*dec;

while (q<cant){
    t1.options[t1.options.length]=new Option(q,q,false,false);
    uni=uni+1;
    if (uni>9) {
            uni=1;
            dec=dec*10;
    }
    q=uni*dec;
 }
 if (cant<=q) t1.options[t1.options.length]=new Option(cant,cant,false,false);
 

 if (spos(navigator.userAgent,'MSIE')||spos(navigator.userAgent,'explorer')) {

         t1.onchange = function() {
                 document.getElementById('util'+iden).ac4.value=t1.value;
                 if (t1.value>9&&confmsg(tex,t1.value)) document.getElementById('util'+iden).submit();
         };
 }
 else
 t1.setAttribute('OnChange', "document.forms.util"+iden+".ac4.value=ac4"+iden+".value; if (ac4"+iden+".value>9&&confmsg('"+tex+"',ac4"+iden+".value)) document.forms.util"+iden+".submit()");

 document.getElementById('s'+iden).appendChild(t1);
}
