var ShowAdInContent = true; function PlaceAdInContent() { //------------------------------------------------------------------------- // Skip all of this if the browser is not Internet Explorer. var ua = window.navigator.userAgent.toLowerCase(); if (ua.indexOf('msie') == -1) { return; } if(ShowAdInContent == false) { return; } if(document.getElementById) { var ac_obj = document.getElementById("ArticleContent"); if(ac_obj == null) { return; } if(!ac_obj.getElementsByTagName) { return; } //--------------------------------------------------------------------- var s_objs = ac_obj.getElementsByTagName("span"); //--------------------------------------------------------------------- for (var i = s_objs.length - 1; i >= 0; i--){ var rx = /^\s*$/; //----------------------------------------------------------------- // Find the name of the class that is applied to the current span. var str_ClassName = ""; if(s_objs[i].className) { var str_ClassName = s_objs[i].className; } else if (s_objs[i]["class"]) { var str_ClassName = s_objs[i]["class"]; } //----------------------------------------------------------------- // We are only interested in working with the vitstorybody portion. if(str_ClassName != "vitstorybody") { continue; } var a_objs = s_objs[i].childNodes; var t_objs = new Array(); var p_obj_1 = null; var p_count = 0; var idx; //----------------------------------------------------------------- // Loop through all of the nodes in the content area looking for // the information that we want. for(idx = 0; idx < a_objs.length; idx++) { if(a_objs[idx].tagName) { if(a_objs[idx].tagName.toLowerCase() == "p") { if(!rx.test(a_objs[idx].innerHTML)) { p_count++; //------------------------------------------------- // Get any table object that are inside of this // paragraph element. var t_obs_tmp = story_GetTableObjects(a_objs[idx]); if(t_obs_tmp.length != 0) { for(var j = 0; j < t_obs_tmp.length; j++) { t_objs[t_objs.length] = t_obs_tmp[j]; } } if(p_count == 1) { p_obj_1 = a_objs[idx]; } else if(p_count == 5) { break; } } } else { if(p_count == 0) { return;} //----------------------------------------------------- // Get any table object that are inside of this element. var t_obs_tmp = story_GetTableObjects(a_objs[idx]); if(t_obs_tmp.length != 0) { for(var j = 0; j < t_obs_tmp.length; j++) { t_objs[t_objs.length] = t_obs_tmp[j]; } } } } } //----------------------------------------------------------------- // First of all, try to move all of the tables that we found before // the 5th paragraph so that they are after the 5th paragraph. if(p_obj_1 != null) { if(p_obj_1.insertAdjacentElement) { //--------------------------------------------------------- // Create the new
element that we will be adding the // tables too. var oDiv = document.createElement("div"); if(oDiv != null) { oDiv.id = "dyn_sidebar"; } else { return; } //--------------------------------------------------------- // Move the advertisement to the new
element. var ad_obj = document.getElementById("oas_ad_bottom1"); if(ad_obj != null) { oDiv.appendChild(ad_obj); ad_obj.style.display = "inline"; } //--------------------------------------------------------- // Add all of the tables to the new
. for(idx = 0; idx < t_objs.length; idx++) { oDiv.appendChild(t_objs[idx]); } //--------------------------------------------------------- // Add the new div to the content after the 1st paragraph. p_obj_1.insertAdjacentElement("afterEnd", oDiv); } } return; } } } function story_GetTableObjects(node) { var t_objs = new Array(); node.normalize(); if(node.tagName.toLowerCase() == "table") { t_objs[t_objs.length] = node; } else if(node.hasChildNodes()) { var n_children = node.childNodes; for(var i = 0; i < n_children.length; i++) { if(n_children[i].tagName != null) { var tmp_objs = story_GetTableObjects(n_children[i]); if(tmp_objs.length != 0) { for(var j = 0; j < tmp_objs.length; j++) { t_objs[t_objs.length] = tmp_objs[j]; } } } } } return t_objs; }