SREImonedas = Array(); SREIratio = Array(); SREIm = Array(); SREIp = Array(); SREIs=Array('€','€','euro','euros','£','£','pounds','pound','Â¥','¥','¤','¤','$','dollars','dollar','peso','pesos','real','reales','lev','yuan','kuna','koruna','krone','kroon','forint','krona','rupee','won','lats','litas','ringgit','leu','lira','zloty','rouble','rand','franc','bolivar','baht'); //var SREItiempo; var SREIcur; var SREIcurActual; function initSREICurrencyConverter() { if (!(SREInumDecimal > 0)) SREInumDecimal = 0; Di=document.getElementsByTagName("div"); conta=0; baseDiv=document.getElementById('SREIdivBase'); moneda_tag=baseDiv.getElementsByTagName("acronym"); moneda_tag[0].innerHTML=SREIbaseCodeCurrency.toUpperCase(); moneda_tag[0].setAttribute("title",SREIgetArrayVal(SREIm,SREIbaseCodeCurrency,SREIp).toUpperCase()); tmp=baseDiv.getElementsByTagName('span'); long=tmp.length-1; tmp[long].style.display='none'; clonDiv=baseDiv.cloneNode(true); clonDiv.style.display=''; baseDiv.style.display='none'; //alert(clonDiv.style.display); clonDiv.setAttribute("actual",SREIbaseCodeCurrency); baseSe=clonDiv.getElementsByTagName("select"); // añado las monedas baseOp=clonDiv.getElementsByTagName("option"); for (y=0; y < SREIm.length; y++) { clonOp=baseOp[0].cloneNode(true); clonOp.setAttribute("value",SREIm[y]); clonOp.innerHTML=SREIp[y]; baseSe[0].appendChild(clonOp); } for (x=0;x'; if (Di[x].innerHTML=='ShowCurrency') { // document.getElementById('debug').innerHTML=document.getElementById('debug').innerHTML+'encontrado
'; Ta=Di[x].nextSibling; if (navigator.appName != "Microsoft Internet Explorer" && Ta.nodeName=="#text") Ta=Ta.nextSibling; // alert(Ta.tagName+' '+Ta.nodeName); if (Ta.tagName=="TABLE") { tmpDiv=clonDiv.cloneNode(true); conta++; Di[x].setAttribute('currency','converter'); parentDiv = Di[x].parentNode; parentDiv.replaceChild(tmpDiv, Di[x]); Di[x].setAttribute("id","SREIdiv"+conta); } if (navigator.appName == "Microsoft Internet Explorer") { x=-1; } } } } function SREIshow(elDiv) { elDiv.style.display="none"; tmp=elDiv.parentNode.getElementsByTagName('span'); long=tmp.length-1; tmp[long].style.display=""; } function SREIhide(elDiv) { tmp=elDiv.parentNode.parentNode.getElementsByTagName('span'); long=tmp.length-1; tmp[long].style.display="none"; tmp[5].style.display=""; } function SREIchange(currency,elDiv) { padre=elDiv.parentNode; span=padre.getElementsByTagName("a"); for (t=0;t0) aDiv[0].style.backgroundColor="#9E1D17"; aDiv[0].style.color="#ffffff"; SREIcurActual=padre.getAttribute("actual"); SREIcur=currency; padre.setAttribute("actual",SREIcur); moneda_tag=padre.getElementsByTagName("acronym"); moneda_tag[0].innerHTML=SREIcur.toUpperCase(); moneda_tag[0].setAttribute("title",SREIgetArrayVal(SREIm,SREIcur,SREIp).toUpperCase()); Ta=padre.nextSibling; if (navigator.appName != "Microsoft Internet Explorer" && Ta.nodeName=="#text") Ta=Ta.nextSibling; for (tR=0;tR indiceA) { // signos al reves while(tmp.indexOf(SREIdecimal)!=-1) tmp=tmp.replace(SREIdecimal,"*"); while(tmp.indexOf(SREImiles)!=-1) tmp=tmp.replace(SREImiles,SREIdecimal); while(tmp.indexOf("*")!=-1) tmp=tmp.replace("*",SREImiles); } valtmp = SREIlimpia(tmp,SREImiles); valtmp = valtmp.replace(SREIdecimal,'.'); // document.getElementById('debug').innerHTML=document.getElementById('debug').innerHTML+'
valtmp:'+valtmp+'
'; //alert(valtmp); if (!SREIisNumeric(tmp,false)) { return;} SREIdefaultRatio=SREIgetArrayVal(SREImonedas,'eur',SREIratio); SREIbaseRatio=SREIgetArrayVal(SREImonedas,SREIcurActual,SREIratio); SREIcurRatio=SREIgetArrayVal(SREImonedas,SREIcur,SREIratio); tmp=Math.round(((SREIdefaultRatio*valtmp*Math.pow(10,SREInumDecimal))/SREIbaseRatio)*SREIcurRatio)/Math.pow(10,SREInumDecimal); //tmp=Math.round(((SREIdefaultRatio*valtmp)/SREIbaseRatio)*SREIcurRatio); // ponemos signos tmp += ''; tmp = tmp.replace('.',SREIdecimal); tmp=SREIaddCommas(tmp); if (SREIshowCurrency=='yes') tmp=tmp+" "+SREIcur; nodo.data=tmp; } function SREIaddCommas(nStr) { nStr += ''; x = nStr.split(SREIdecimal); x1 = x[0]; x2 = x.length > 1 ? SREIdecimal + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + SREImiles + '$2'); } return x1 + x2; } function SREIlimpia(str,que) { while(str.indexOf(que)!=-1){ str=str.replace(que,""); } return str; } function SREIgetArrayVal(arr1,clave,arr2) { for(x=0;x -1) { // blnResult = false; blnResult = true; } } else { if (strValidChars.indexOf(strChar) == -1) { // blnResult = false; return false; } } } return blnResult; }