/* * Created: 2007.11.27 * Updated: 2008.07.08 * Created by Martin Lazarov */ $base_url=document.location.protocol+"//"+location.host+"/dumi/"; function el(e){return document.getElementById(e);} if (navigator.appName.indexOf('Microsoft') != -1) $ie=true; else $ie=false; /* XML HTTP Functions */ var to_server=15000,alert_nc=true,$timer=false; function getReq(url,func){ var _t=this;var moz; if (window.XMLHttpRequest){this.xmlreq=new XMLHttpRequest();moz=1;} else if (window.ActiveXObject){this.xmlreq=new ActiveXObject("Microsoft.XMLHTTP");moz=0;} else return false; this.xmlto=setTimeout((function() {_t.timeout()}),to_server); this.xmlreq.onreadystatechange=(function() { if (_t.xmlreq.readyState==4){ clearTimeout(_t.xmlto); if (_t.xmlreq.status==200){ alert_nc=true; var $x=_t.xmlreq.responseXML; var $e=$x.getElementsByTagName("e")[0].firstChild.nodeValue; if ($e==0){$r=$x.getElementsByTagName("r");func.call(this,$x);} } } }); this.xmlreq.open("GET",url,true); if (moz==1) this.xmlreq.send(null); else this.xmlreq.send(); } getReq.prototype.timeout=function(){this.xmlreq.abort();} function parse_words($xml,$s){ var $wid=new Array(); var $wname=new Array(); var $wurl=new Array(); var $total_campaigns = $xml.getElementsByTagName("c")[0].firstChild.nodeValue; $xml_original = $xml; for(var $c=0; $c < $total_campaigns; $c++){ $xml = $xml_original.getElementsByTagName("campaign")[$c]; if($xml.getElementsByTagName("campaignid")[0]){ $campaignid=$xml.getElementsByTagName("campaignid")[0].firstChild.nodeValue; }else{ return false; } var oLink = document.createElement("link") oLink.href = "http://dumi.ibg.bg/css.php?campaignid="+$campaignid; oLink.rel = "stylesheet"; oLink.type = "text/css"; document.body.appendChild(oLink); if($xml.getElementsByTagName("html")[0]){ $html=$xml.getElementsByTagName("html")[0].firstChild.nodeValue; $html=$html.replace("<",'<').replace(">",'>'); }else{ $html=false; } //alert($html); if($html){ document.getElementsByTagName('BODY')[0].setAttribute('onclick','hide_win();'); var $abody = document.createElement('div'); if($ie){ $abody.setAttribute('className','ad_body'); }else{ $abody.setAttribute('class','ad_body'); } $abody.setAttribute('style','width: 240px; height: 200px; margin: 0px; margin-left: 6px !important; margin-top: 0px !important; border: 0px solid red;'); $abody.setAttribute('id','ad_body'); var $atitle = document.createElement('div'); if($ie){ $atitle.setAttribute('className','ad_title'); }else{ $atitle.setAttribute('class','ad_title'); $atitle.setAttribute('style','height: 30px; padding: 0px;'); } var $aclose=document.createElement('P'); if($ie){ $aclose.setAttribute('className','ad_close'); $aclose.onclick = function() { hide_win(); } }else{ $aclose.setAttribute('class','ad_close'); $aclose.setAttribute('onclick','hide_win()'); } $aclose.setAttribute('style','display: block; width: 13px; height: 13px; font-size: 5px !important; line-height: 13px !important; margin: 0px; margin-top: 4px !important; margin-right: 3px !important; cursor: pointer; float: right; border: 0px solid red;'); $atitle.appendChild($aclose); $awin=document.createElement('div'); if($ie){ $awin.setAttribute('className','ad_win'); }else{ $awin.setAttribute('class','ad_win'); } $awin.setAttribute('style','display: none; width: 252px; height: 235px; background-image: url(http://dumi.ibg.bg/templates/i/add_empty.png); margin: 0px !important; padding: 0px !important; border: 0px solid green; z-index: 2147483 !important;'); $awin.setAttribute('id','ad_win'); $awin.appendChild($atitle); $awin.appendChild($abody); document.body.appendChild($awin); document.getElementById('ad_body').innerHTML=$html; } if($xml.getElementsByTagName("limit")){ $limit=$xml.getElementsByTagName("limit")[0].firstChild.nodeValue; }else $limit=5; $words=$xml.getElementsByTagName("w"); for($i=0;$i<$words.length;$i++){ $w=$words[$i]; $wn=$w.getElementsByTagName("name")[0].firstChild.nodeValue; $wname[$i]=$wn; $wid[$wn]=$w.getElementsByTagName("id")[0].firstChild.nodeValue; $wurl[$wn]=unescape($w.getElementsByTagName("url")[0].firstChild.nodeValue); //alert("WN:"+$wn+' WID:'+$wid[$wn]); } // $reg = ''; // $reg += $wname.join('(?![à-ÿÀ-ßa-zA-Z0-9])|'); // $reg += '(?![à-ÿÀ-ßa-zA-Z0-9])'; $reg = ''; $reg += $wname.join('|'); $reg += ''; $qre=new RegExp($reg, "i"); if($wname.length>0) walk(el($jsw_div),1,textproc,$wid); if($swids.length > 0) break; } } var skipre = /^(script|style|textarea|table)/i; var jumppre = /^(div|p|i|u|font)/i; $swids = new Array(); $max_nodes = 100; function walk(node, depth, textproc,$wid) { var skipre = /^(script|style|textarea)/i; var count = 0; while (node && depth > 0) { count++; handler=false; if (count >= $max_nodes) {var handler = function() {if(node)walk(node, depth, textproc,$wid);};setTimeout(handler, 50);return;} if (node.nodeType == 1){if (!skipre.test(node.tagName) && node.childNodes.length > 0) {node = node.childNodes[0];depth++;continue;}} else if (node && node.nodeType == 3){node = textproc(node,$wid);} if (node.nextSibling) {node = node.nextSibling;} else if(node) { while (depth > 0){ node = node.parentNode;depth --;if (node.nextSibling) {node = node.nextSibling;break;} } } } send_stats(); }; $cnt=0; function textproc(node,$wid) { var match = $qre.exec(node.data); regex = new RegExp("[A-Za-zÀ-ßà-ÿ0-9]", "i"); if (match && !node.parentNode.href && regex.test(node.data.charAt(match.index-1)) == false) { var val = match[0].replace(/^\s+|\s+$|\.|,/g, ''); var k = ''; var node2 = node.splitText(match.index); var node3 = node2.splitText(val.length); var stock = document.createTextNode(val); node.parentNode.replaceChild(stock, node2); if (node3.data == null){node.parentNode.appendChild(stock);} else{node.parentNode.insertBefore(stock,node3);} var link = node.ownerDocument.createElement('A'); node.parentNode.replaceChild(link, stock); $lower_val=val.toLowerCase(); $lower_val=$lower_val.replace(/^\s+|\s+$/g, ''); $word_id=$wid[$lower_val]; $cnt++; link.className = "addword"; var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; if(is_chrome){ color = 'green'; link.style.color = color + " !important"; link.style.fontWeight = "bold !important"; link.style.borderBottom = "1px dotted " + color; link.style.textDecoration = "none"; } link.href="http://dumi.ibg.bg/redirect.php?id="+$word_id; link.target="_blank"; if($ie){ link.onmouseover = function() { mouseover(link.id); } link.onmouseout = function() { mouseout(); } }else{ link.setAttribute('onmouseover',"mouseover(this.id)"); link.setAttribute('onmouseout',"mouseout()"); } link.id='test'+$cnt; link.appendChild(stock); stats($word_id); if($cnt<$limit) return link; else return false; } else{return node;} }; function mouseover($id){ //alert("IN"+$id); if($html==false) return; var $x = getRealPos(document.getElementById($id),'x'); var $y = getRealPos(document.getElementById($id),'y'); //alert("X:"+$x+" Y:"+$y); if($ie){ $y+=30;//-245; $x+=10-240; } else{ $y+=20;//-245; $x+=0-240; } if($x < 0) $x = 0; //alert("x = " + $x + "\ny = " + $y); $ad_win=document.getElementById('ad_win'); $ad_win.style.display='block'; $ad_win.style.position='absolute'; $ad_win.style.top=$y+'px'; $ad_win.style.left=$x+'px'; if($ie){ $ad_win.onmouseover = function() { mouseover_ad(); } $ad_win.onmouseout = function() { mouseout(); } }else{ $ad_win.setAttribute('onmouseover','mouseover_ad()'); $ad_win.setAttribute('onmouseout','mouseout()'); } //$ad_win.setAttribute('onclick','return mouseover_ad()'); } function mouseover_ad(){ clearTimeout($timer); return false; } function mouseout(){ if($html==false)return; clearTimeout($timer); $timer=setTimeout('hide_win()',2000); } function hide_win(){ $ad_win=document.getElementById('ad_win'); $ad_win.style.display='none'; } function stats($wid){$swids.push($wid);} function send_stats(){ $tmp=$swids.join(","); $surl=$base_url+"xml/stats.php?pageid="+$jsw_pageid+'&words='+$tmp; if($tmp.length > 0) getReq($surl,stats_send); } function stats_send(){ //alert("Stats send"); } function getRealPos(ele,dir) { (dir=="x") ? pos = ele.offsetLeft : pos = ele.offsetTop; tempEle = ele.offsetParent; while(tempEle != null) { pos += (dir=="x") ? tempEle.offsetLeft : tempEle.offsetTop; tempEle = tempEle.offsetParent; } return pos; } function initKwAds(){ if($jsw_div != 'undefined' && typeof $jsw_active != 'undefined' && $jsw_active && typeof $jsw_pageid != 'undefined'){ $wurl=$base_url+"xml/words.php?pageid="+$jsw_pageid; getReq($wurl,parse_words); }else if(!$jsw_active){ alert("KeyWords disabled"); }else{ alert("Incorrect KeyWords setup"); } } $ua=navigator.userAgent; setTimeout('initKwAds()',2000); //window.onload = function() { //};