jQuery.extend({adwords:function(a,h,f,e){if(a.nodeType===3){var c=a.data.match(h);if(c){var k=document.createElement(f||"span");k.className=e||"adwords";var g=a.splitText(c.index);g.splitText(c[0].length);var d=g.cloneNode(true);k.appendChild(d);g.parentNode.replaceChild(k,g);return 1}}else{if((a.nodeType===1&&a.childNodes)&&!/(script|style)/i.test(a.tagName)&&!(a.tagName===f.toUpperCase()&&a.className===e)){for(var b=0;b<a.childNodes.length;b++){b+=jQuery.adwords(a.childNodes[b],h,f,e)}}}return 0}});jQuery.fn.unadwords=function(a){var b={className:"adwords",element:"span"};jQuery.extend(b,a);return this.find(b.element+"."+b.className).each(function(){var c=this.parentNode;c.replaceChild(this.firstChild,this);c.normalize()}).end()};jQuery.fn.adwords=function(f,b){var d={className:"adwords",element:"span",caseSensitive:false,wordsOnly:false};jQuery.extend(d,b);if(f.constructor===String){f=[f]}var a=d.caseSensitive?"":"i";var e="("+f.join("|")+")";if(d.wordsOnly){e="\\b"+e+"\\b"}var c=new RegExp(e,a);return this.each(function(){jQuery.adwords(this,c,d.element,d.className)})};jQuery(function(){if(jQuery("#CtxKeywords").html()!=""){jQuery("#mainCol").append('<div id="CtxAdWordsList" style="display:none;"></div>');var ctxkeyword=jQuery("#CtxKeywords").html();try{jQuery("#CtxAdWordsList").load("/getexternalcontent.php",{want2Read:"http://community.tuanvietnam.net/AdWordsUserInterface_Controller/getAdWordsList?keywords="+ctxkeyword},function(){var strAds=jQuery(this).html();if(strAds!=""){jQuery("#mainCol").prepend('<div id="AdWordsText"></div>');jQuery("#mainCol").prepend('<div id="AdWordsHoverBox"></div>');jQuery("#AdWordsHoverBox").append('<div class="adbar"><div class="adbartext">Quảng cáo</div><div class="adclose"></div></div><div class="adcontent">content</div><div class="adbanner"> Sắp ra mắt (@ TuanVietNam)</div>');var stradwords="";ads=strAds.split("###");for(i=0;i<ads.length;i++){if(ads[i]==""){continue}var stringHtml='<div class="AdWordsItem">';adsctx=ads[i].split("##");for(j=0;j<adsctx.length;j++){pos=adsctx[j].indexOf(":");if(pos>0){field=adsctx[j].substr(0,pos);ctx=adsctx[j].substr(pos+1);stringHtml+='<div id="'+field+'">'+ctx+"</div>";if(field=="Words"){stradwords+=",'"+ctx+"'"}}}stringHtml+="</div>";jQuery("#AdWordsText").append(stringHtml)}stradwords='jQuery("#CtxText").adwords(['+stradwords.substring(1)+"],{element: 'a'});";eval(stradwords);var x=0;var y=0;var screenWidth=screen.width;var containerWidth=jQuery("#WrapperContainer").width();var boxHeight=jQuery("#AdWordsHoverBox").height();var boxWidth=jQuery("#AdWordsHoverBox").width();var mainWidth=jQuery("#mainCol").width();var spaceWidth=(screenWidth-containerWidth)/2;var fixed_ie_height=boxHeight*3;var fixed_ie_width=0;jQuery(".adwords").mouseover(function(e){if(jQuery.browser.msie){boxHeight=fixed_ie_height;fixed_ie_width=spaceWidth}x=e.pageX;var pos_x=e.pageX;jQuery("#AdWordsHoverBox").css("left",pos_x);if(pos_x+boxWidth<mainWidth+spaceWidth){jQuery("#AdWordsHoverBox").css("left",pos_x-fixed_ie_width)}else{jQuery("#AdWordsHoverBox").css("left",pos_x-boxWidth-fixed_ie_width)}jQuery("#AdWordsHoverBox").css("top",y=e.pageY-boxHeight-20);var adcontent="";var order=0;var text=jQuery(this).html();jQuery.each(jQuery(".AdWordsItem"),function(){word=jQuery(this).children("#Words");jTitle=jQuery(this).children("#AdTitle");jLink=jQuery(this).children("#AdLink");jDesc=jQuery(this).children("#AdDescription");var txtWord=word.html();var title=jQuery.trim(jTitle.html());var link=jQuery.trim(jLink.html());var description=jQuery.trim(jDesc.html());if(text.toLowerCase()==txtWord.toLowerCase()){order++;attrHref="";if(link!=""){attrHref='href="'+link+'"'}adcontent+="<div><div>"+order+". <a "+attrHref+' class="adtitle">'+title+'</a></div><div class="addescription">'+description+"</div></div>"}});jQuery(".adcontent").html(adcontent);jQuery("a.adtitle").click(function(event){event.preventDefault();window.open(jQuery(this).attr("href"))});jQuery("#AdWordsHoverBox").show()});jQuery(".adclose").click(function(){jQuery("#AdWordsHoverBox").hide()});jQuery(document).click(function(e){if(jQuery("#AdWordsHoverBox").css("display")=="none"){}else{currX=e.pageX;currY=e.pageY;if(currX>x&&currX<(currX+x+jQuery("#AdWordsHoverBox").width())&&currY>y&&(currY<y+jQuery("#AdWordsHoverBox").height())){}else{jQuery("#AdWordsHoverBox").hide()}}})}})}catch(ex){}}});