// Cargamos css para el widget var fileref=document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", "http://www.matrimonio.com/css/reviews.css"); document.getElementsByTagName("head")[0].appendChild(fileref) // Mostramos sello de recomendado function wpShowRated(idEmpresa) { var nOpiniones=false; url="http://www.matrimonio.com/wp-rated.php?id="+idEmpresa; xmlhttpa=creaXML(); /*peticion sincrona (se espera una respuesta antes de continuar ejecutando)*/ xmlhttpa.open("GET",url,false); xmlhttpa.setRequestHeader('Accept','message/x-jl-formresult'); xmlhttpa.send(null); if (xmlhttpa.readyState==4) { if (isNumber(xmlhttpa.responseText)) { nOpiniones=xmlhttpa.responseText; } } // Dependiendo del número de opiniones mostramos el sello recomendado if (nOpiniones>=10) { // Recomendado oro document.getElementById("wp-rated-top-img").src="http://www.matrimonio.com/img/badges/badge-gold-top-it_IT.jpg"; document.getElementById("wp-rated-bt-img").src="http://www.matrimonio.com/img/badges/badge-gold-bt-it_IT.jpg"; } else if (nOpiniones>=5) { // Recomendado plata document.getElementById("wp-rated-top-img").src="http://www.matrimonio.com/img/badges/badge-silver-top-it_IT.jpg"; document.getElementById("wp-rated-bt-img").src="http://www.matrimonio.com/img/badges/badge-silver-bt-it_IT.jpg"; } } //------------------------------------------------------------------------------------------- // AJAX //------------------------------------------------------------------------------------------- function creaXML(){ var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp=false; } } @else xmlhttp=false @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } } return xmlhttp; } //------------------------------------------------------------------------------------------- // FUNCIONES AUXILIARES //------------------------------------------------------------------------------------------- //Comprobamos si numérico function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); }