function sponsorship_box() { // defaults this.sponsors = []; this.moreLink = null; this.headertxt = "Sponsor links"; this.moreLinktxt = "View more deals"; this.site = "daytondailynews"; this.url = location.href.replace(/^https?:\/\/(\w|\.)+\//, "/"); // available methods this.setSite = function() { var sites = ['daytondailynews', 'springfieldnewssun', 'activedayton', 'journal-news', 'middletownjournal', 'pulsejournal', 'western-star', 'oxfordpress', 'fairfield-echo', '937moms', '513moms' ]; for(var i=0;i 0) { if(sponsor.sites.toString().indexOf(this.site) < 0) return false; } if(sponsor.url && typeof(sponsor.url)!='undefined') { if(typeof(sponsor.url)=='string') { if(!this.url.match(sponsor.url)) return false; } else { var urlmatch = false; for(var i=0;i this.today()) return false; } if(sponsor.thru && typeof(sponsor.thru)=='string') { var threshold = Number(sponsor.thru.replace(/\//g, "")); if(threshold < this.today()) return false; } this.sponsors.push(sponsor); }; this.write = function(div_id) { if(typeof(div_id)=='undefined' || div_id=="") div_id = "sponsorshipBox"+Math.floor(Math.random()*1111); if(typeof(div_id)!='string' || this.sponsors.length < 1) return false; if(!document.getElementById(div_id)) document.write('
'); // Container var box = document.createElement('div'); box.className = "section"; // Header var header = document.createElement('div'); header.className = "sponsor_headline"; var headertxt = document.createTextNode(this.headertxt); header.appendChild(headertxt); if(this.moreLink!=null && typeof(this.moreLink)=='string') { var headerlink = document.createElement('a'); headerlink.className = "caps sponsor_all"; headerlink.setAttribute("href", this.moreLink); var headerlinktxt = document.createTextNode(this.moreLinktxt); headerlink.appendChild(headerlinktxt); header.appendChild(headerlink); } // List var list = document.createElement("ul"); list.className = "sponsor_subheads"; for(var i=0;i var container = document.getElementById(div_id); container.className = "sponsorships_box"; container.appendChild(box); } // write stylesheet to if(document.getElementById('sponsorship_bootstrap_css')) return; var css = document.createElement('link'); css.setAttribute("id", "sponsorship_bootstrap_css"); css.setAttribute("rel", "stylesheet"); css.setAttribute("type", "text/css"); css.setAttribute("media", "all"); css.setAttribute("href", "http://alt.coxnewsweb.com/daytondailynews/sponsorships/styles.css"); document.getElementsByTagName("head")[0].appendChild(css); this.setSite(); }