﻿//v1.0.0
var dr = {
    settings: {
        cid: 'bqmms',
        img_href: 'http://media.readspeaker.com/images/buttons/listen_icons/icon_16px.gif',
        img_alt: 'ReadSpeaker docReader',
        lang: 'no_nb',
        doc_list: ['doc', 'docx', 'odt', 'pdf', 'rtf']
    }, filter: function (b) { var e = b.href; var a = b.className; var d = b.innerHTML.toLowerCase(); if (e && e.length > 1) { for (var c = 0; c < dr.settings.doc_list.length; c++) { if (e.indexOf(dr.settings.doc_list[c], e.length - 4) > -1) { return (true) } } } return (false) }, returnUrl: function (b) { var a = ""; if (b.indexOf("http") > -1 || b.indexOf("https") > -1) { a = b } else { if (b.indexOf("/") == 0) { a = document.loaction.protocol + "://" + document.location.hostname + b } else { if (b.indexOf("/") == -1) { a = document.loaction.protocol + "://" + document.location.hostname + document.location.pathname + b } else { a = b } } } return a }, addButton: function (d, b) { var a = document.createElement("img"); a.setAttribute("src", dr.settings.img_href); a.setAttribute("alt", dr.settings.img_alt); a.setAttribute("title", dr.settings.img_alt); a.style.border = "0px"; a.style.display = "inline"; var f = document.createElement("a"); var e = "http://docreader.readspeaker.com/docreader/?cid=REPLACE_CID&lang=REPLACE_LANG&url=REPLACE_URL"; e = e.replace("REPLACE_CID", dr.settings.cid); e = e.replace("REPLACE_LANG", dr.settings.lang); e = e.replace("REPLACE_URL", escape(b)); f.setAttribute("href", e); thescript = "window.open(this.href); return false;"; f.setAttribute("onclick", thescript); f.style.margin = "0 0 0 3px"; f.onclick = new Function(thescript); f.setAttribute("target", "_blank"); f.appendChild(a); var c = document.createDocumentFragment(); c.appendChild(f); d.parentNode.insertBefore(c, d.nextSibling) }, init: function () { var d = document.getElementsByTagName("A"); var e = new Array(); for (var b = 0; b < d.length; b++) { e[b] = d[b] } for (var c = 0; c < e.length; c++) { if (dr.filter(e[c])) { var a = dr.returnUrl(e[c].href); if (a != "") { dr.addButton(e[c], a) } } } } 
}; $(document).ready(function () { dr.init() });
