// global variables if (!IE) var IE = navigator.userAgent.indexOf("MSIE") != -1; if (!Opera) var Opera = navigator.userAgent.indexOf("Opera") != -1; if (!Mozilla) var Mozilla = navigator.userAgent.indexOf("Mozilla") != -1; if (!Safari) var Safari = navigator.userAgent.indexOf("Safari") != -1; if (!tt_iframe_loaded) var tt_iframe_loaded = 0; if (!tt_site_url) var tt_site_url = window.location.href; if (!tt_path) var tt_path = "http://www.thundertext.com/contextual/"; if (!tt_analysis_path) var tt_analysis_path = "http://contentanalysis.freesites.com/"; // inline ad variables if (!tt_timer) var tt_timer = null; if (!tt_div_bool) var tt_div_bool = false; if (!tt_word_bool) var tt_word_bool = false; // contextual ad variables if (!tt_ad_start) var tt_ad_start = 0; // visual definitions if (!thundertext_adtype) var thundertext_adtype = "contextual"; if (!thundertext_aff_id) var thundertext_aff_id = "thundertext"; if (!thundertext_cname) var thundertext_cname = "THUNDERTEXT"; if (!thundertext_site_url) var thundertext_site_url = "http://www.thundertext.com/"; if (!thundertext_template) var thundertext_template = "728x90"; if (!thundertext_sid) var thundertext_sid = ""; if (!thundertext_border_color) var thundertext_border_color = "336699"; if (!thundertext_bg_color) var thundertext_bg_color = "ffffff"; if (!thundertext_link_color) var thundertext_link_color = "4477aa"; if (!thundertext_text_color) var thundertext_text_color = "000000"; if (!thundertext_keyword_color) var thundertext_keyword_color = "336699"; if (!thundertext_exact) var thundertext_exact = true; if (!thundertext_max_nodes) var thundertext_max_nodes = "1138"; if (!thundertext_max_keyword_matches) var thundertext_max_keyword_matches = "5"; if (!thundertext_max_matches) var thundertext_max_matches = "20"; if (!thundertext_numOfAds) var thundertext_numOfAds = "1"; if (!thundertext_random_distribution) var thundertext_random_distribution = true; if (!thundertext_borderbottom) var thundertext_borderbottom = "3px double #336699"; // check to make sure the thundertext_template variable is of known dimensions get_num_ads(thundertext_template); function ThunderTextCore() { this.contextual_ads = new Array(); this.register_ad = function(ad_settings) { // ONLY ADD THE INLINE TO THE AD LIST ONCE if(ad_settings.type == 'inline' && ThunderText.inline_ran) { return; } if(ad_settings.type == 'inline') { ThunderText.inline_ran = true; } ThunderText.contextual_ads.push(ad_settings); } // ONLOAD FUNCTION this.start_thundertext = function() { // CHECK FOR ANALYSIS CACHE - SEND PAGE CONTENTS -> run begin_ads tt_site_url = escape(tt_site_url); // send the page contents along to be analyzed load_script(tt_analysis_path + "inline/ads.php?action=first_run&url=" + tt_site_url + "&aff_id=" + thundertext_aff_id + "&adtype=" + thundertext_adtype); } this.begin_ads = function(thunder_ads) { for(tt_x = 0; tt_x < ThunderText.contextual_ads.length; tt_x++) { if (ThunderText.contextual_ads[tt_x].type == 'contextual') { // grab the ad iframe var tt_ad_iframe = document.getElementById("tt_ad_frame_" + ThunderText.contextual_ads[tt_x].id); // get the number of ads for this template style var num_ads = get_num_ads(ThunderText.contextual_ads[tt_x].template); // create the source that we're going to send along for the iframe to load var tt_iframe_src = ""; tt_iframe_src += tt_path + "contextual/index.php?url=" + tt_site_url; tt_iframe_src += "&template=" + ThunderText.contextual_ads[tt_x].template; tt_iframe_src += "&aff_id=" + ThunderText.contextual_ads[tt_x].aff_id; tt_iframe_src += "&cname=" + ThunderText.contextual_ads[tt_x].cname; tt_iframe_src += "&site_url=" + ThunderText.contextual_ads[tt_x].site_url; tt_iframe_src += "&bg=" + ThunderText.contextual_ads[tt_x].bg_color; tt_iframe_src += "&text=" + ThunderText.contextual_ads[tt_x].text_color; tt_iframe_src += "&link=" + ThunderText.contextual_ads[tt_x].link_color; tt_iframe_src += "&border=" + ThunderText.contextual_ads[tt_x].border_color; tt_iframe_src += "&sid=" + ThunderText.contextual_ads[tt_x].sid; tt_iframe_src += "&tt_ad_start=" + tt_ad_start; tt_iframe_src += "&tt_num_ads=" + num_ads; tt_iframe_src += "&rnd=" + tt_rnd; // update the position in the ad array tt_ad_start += num_ads; // change the iframe's src tt_ad_iframe.src = tt_iframe_src; } else { // AD IS INLINE -> START THE HILIGHT tt_inline_obj.create_ad_div(); // define which in the ad array is the inline part so we can get the colors, etc. tt_inline_obj.elem_num = tt_x; // start the match + hilite process tt_inline_obj.match_elements(thunder_ads); } } } } // ##################################################################################################### function load_script(tt_url) { var tt_script = document.createElement('script'); tt_script.setAttribute('type','text/javascript'); tt_script.setAttribute('src', tt_url); document.body.appendChild(tt_script); } function strpos(str, ch) { for (var i = 0; i < str.length; i++) if (str.substring(i, i+1) == ch) return i; return -1; } function tt_iframe_onload() { // make sure this has loaded twice to guarentee data has been put in DB // the first time it loads is because the page has loaded and the second is caused // by the post of the page contents from ads.php if (tt_iframe_loaded++ == 1) { load_script(tt_analysis_path + "inline/ads.php?action=load_contents&url=" + tt_site_url + "&aff_id=" + thundertext_aff_id); } } function Ad_settings(id, type, aff_id, cname, site_url, template, sid, border_color, bg_color, link_color, text_color, keyword_color, exact, max_nodes, max_keyword_matches, max_matches, numOfAds, random_distribution, borderbottom) { this.id = id; this.type = type; this.aff_id = aff_id; this.cname = cname; this.site_url = site_url; this.template = template; this.sid = sid; this.border_color = border_color; this.bg_color = bg_color; this.link_color = link_color; this.text_color = text_color; this.keyword_color = keyword_color; this.exact = exact; this.max_nodes = max_nodes; this.max_keyword_matches = max_keyword_matches; this.max_matches = max_matches; this.num_ads = numOfAds; this.rnd_dist = random_distribution; this.border_bottom = borderbottom; } // if you add a random number to the end of the query string, IE will always update the page var tt_rnd = Math.round((Math.random()*10000)+1); // CHECK USER INPUT FOR ERRORS check_user_input(); var settings = new Ad_settings( tt_rnd, thundertext_adtype, thundertext_aff_id, thundertext_cname, thundertext_site_url, thundertext_template, thundertext_sid, thundertext_border_color, thundertext_bg_color, thundertext_link_color, thundertext_text_color, thundertext_keyword_color, thundertext_exact, thundertext_max_nodes, thundertext_max_keyword_matches, thundertext_max_matches, thundertext_numOfAds, thundertext_random_distribution, thundertext_borderbottom ) if(typeof(ThunderText) != 'object') { // THIS IS THE FIRST AD - START THINGS OFF var tt_inline_obj = new Inline(); // INIT THE CORE ThunderText = new ThunderTextCore(); // INIT THE ONLOAD var existing_onload = window.onload; if(typeof existing_onload == 'function') { window.onload = function () { ThunderText.start_thundertext; existing_onload(); //return exisiting_onload(); } } else { window.onload=ThunderText.start_thundertext; } ThunderText.register_ad(settings); // create the iframe to hold the page contents var tt_iframe_code = ""; tt_iframe_code += "