var $; if (typeof jQuery != 'undefined') $ = jQuery.noConflict(); clxRateWidget = function (options) { if (typeof jQuery == 'undefined') { var script = document.createElement('script'); script.type = "text/javascript"; script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"; var scriptParent = document.getElementById("clxSmallWidget"); var $this = this; var done = false; script.onload = script.onreadystatechange = function () { if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { done = true; $(document).ready(function () { $this.init(options); $this.injectCss(); $this.injectJsTexts(); }); script.onload = script.onreadystatechange = null; if (scriptParent && script.parentNode) { scriptParent.removeChild(script); } } }; scriptParent.insertBefore(script, scriptParent.firstChild); } else { this.init(options); this.injectCss(); this.injectJsTexts(); } } clxRateWidget.prototype = { name: 'Company Name', language: 'en-GB', fir_nr: 0, lkz: '', domain: '', siteUrl: '', backgroundColor: '#2d7681', linkColor: '#D0D9EA', textColor: '#FFFFFF', size: 'big', profileUrl: '', currentSite: '', showRichSearchResults : true, init: function (options) { this.name = options.name; this.language = options.language; this.fir_nr = options.fir_nr; this.lkz = options.lkz; this.domain = options.domain; this.siteUrl = options.siteUrl; if (options.backgroundColor) { this.backgroundColor = options.backgroundColor; } if (options.linkColor) { this.linkColor = options.linkColor; } if (options.textColor) { this.textColor = options.textColor; } if (options.size) { this.size = options.size; } if (typeof (options.showRichSearchResults) !== 'undefined') { this.showRichSearchResults = options.showRichSearchResults; } if (options.profileUrl) { this.profileUrl = options.profileUrl.replace('#reviews', '');//small } else { this.profileUrl = document.getElementById("clxReferrerRate").getAttribute("href").replace('#reviews', ''); } this.currentSite = window.location.href; }, injectCss: function () { var $head = $("head"); var $headlinklast = $head.find("link[rel='stylesheet']:last"); var linkElement = ""; if ($headlinklast.length && $headlinklast.length > 0) { $headlinklast.after(linkElement); } else { $head.append(linkElement); } }, injectJsTexts: function () { var $this = this; $.getScript(this.domain.replace('fr.', '') + '/js/globalVariables.' + this.language + '.js', function () { $this.applyConfig(); $this.writeWidget(); }); }, applyConfig: function () { var style = '\n'; $('head').append(style); }, writeWidget: function () { var $this = this; var widgetDiv = $('