SREImonedas = Array('eur','usd','gbp','aud','brl','cad','cny','czk','dkk','hkd','huf','isk','inr','jpy','krw','myr','mxn','ron','try','nzd','nok','php','pln','sgd','zar','sek','chf','thb','idr','ils','mad'); SREIratio = Array('1.000000','1.146000','0.858800','1.609500','5.885700','1.605600','7.675500','24.339001','7.475400','8.990300','364.279999','139.399994','109.875504','180.940002','1590.760010','4.676300','19.685499','5.264700','55.907700','2.006800','10.809500','71.972000','4.363500','1.465100','18.648199','11.291500','0.946200','38.224998','20424.810547','3.481200','10.638298'); SREIm = Array('eur','usd','gbp','aud','brl','cad','cny','czk','dkk','hkd','huf','isk','inr','jpy','krw','myr','mxn','ron','try','nzd','nok','php','pln','sgd','zar','sek','chf','thb','idr','ils','mad'); SREIp = Array('euro','us dollar','uk pound','australian dollar','brazilian real','canadian dollar','chinese yuan','czech koruna','danish krone','hong kong dollar','hungarian forint','icelandic krona','indian rupee','japanese yen','korea won','malasian ringgit','mexican peso','new romanian leu','new turkish lira','new zealand dollar','norwegian krone','philippine peso','polish zloty','singapore dollar','south african rand','swedish krona','swiss franc','thai baht','indonesian rupiahs','Israeli New Shekel','Dirhams'); 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; }