function FloatingAdsLoader(a,b,c){	
	this.error='';
	if(document.getElementById(a)){
		var d=document.getElementById("box_"+a);
		if(d){d.style.display=""}this.placeHolderControl=document.getElementById(a);this.blocks=b;this.adCount=this.blocks.length;this.randPrefix=Math.floor(Math.random()*100000)+100000;this.mode=this.placeHolderControl.getAttribute("adMode");this.direction=this.placeHolderControl.getAttribute("adDirection");this.width=this.placeHolderControl.getAttribute("adWidth");this.height=this.placeHolderControl.getAttribute("adHeight");this.classe=this.placeHolderControl.getAttribute("adClass");this.brownTimmer=0;this.downloadCompleted=false;if(c)this.brownInterval=c;else this.brownInterval=10000}else this.error='PLACE_HOLDER_NOT_FOUND';this.brownRunningZone=brownRunningZone;this.brownZone=brownZone;this.doLoadFB=doLoadFB;this.fadeBlock=fadeBlock;this.swapBlocks=swapBlocks;this.genSquelette=genSquelette;this.rotateBlock=rotateBlock;this.onRotateBlock=onRotateBlock;this.onRotateZone=onRotateZone;this.fillAdPlace=fillAdPlace;this.downloadImage=downloadImage;this.swapfade=swapfade;this.brownBlock=brownBlock;this.stopBlocksSwapping=stopBlocksSwapping;this.genObjectCode=genObjectCode;
	this.JSFX_KeepInView=JSFX_KeepInView;
		for(var i=0;i<this.blocks.length;i++){
			this.blocks[i].width=this.width;
			this.blocks[i].height=this.height;
			this.blocks[i].classe=this.classe;
			this.blocks[i].direction=this.direction}
		}
	function doLoadFB(){
		if(this.error)return;
		var a=this;
		this.placeHolderControl.innerHTML=this.genSquelette();
		this.downloadImage();
		if(a.mode=='brown')this.brownRunningZone();
		if(a.mode=='brown'&&this.brownInterval>1){
			window.clearInterval(a.brownTimmer);
			a.brownTimmer=window.setInterval(function(){a.brownRunningZone()},this.brownInterval)}this.onRotateZone()
	}
	function JSFX_KeepInView(b){		
		var xf = 0;
		var c=function(a){return(a==null)?0:a.offsetTop+c(a.offsetParent)};		
		var d=function(){return document.body.scrollTop||document.documentElement.scrollTop};
		var e=document.getElementById(b);		
		if(e==null)return;				
		if(e.style.position=="absolute"){			
			e.startPageTop=-e.offsetTop;e.currentX=e.offsetLeft;e.currentY=e.offsetTop
		}else{			
			e.style.position="relative";
			e.startPageTop=c(e);
			e.currentX=e.currentY=0};									
			e.floatInView=function(){
				var a=(d()>this.startPageTop)?d()-this.startPageTop:0;											
				this.currentY+=(a-this.currentY)/4;
				this.style.top=(this.currentY)+"px"				
				};
			setInterval('document.getElementById("'+b+'").floatInView()',40)
		};			
			function onRotateZone(){
				for(var i=0;i<this.blocks.length;i++){
					this.onRotateBlock(this.blocks[i],i)}
				}
			function onRotateBlock(a,b){
				if((a.rotateInterval>0)&&(a.items.length>1)){
					a.img_control_id=''+this.randPrefix+'_'+b;window.clearInterval(a.timmer);
					a.timmer=window.setInterval(function(){this.fadeBlock(a,a.img_control_id)},a.rotateInterval)}
			}
			function stopBlocksSwapping(){
				for(var i=0;i<this.blocks.length;i++)window.clearInterval(this.blocks[i].timmer)
			}
			function brownRunningZone(){
				this.stopBlocksSwapping();
				for(var i=0;i<this.blocks.length-1;i++){
					if(!this.blocks[i].dock||this.blocks[i].dock==false){
						var a=Math.floor(Math.random()*1000)%(this.blocks.length-i-1)+i+1;
						if(!this.blocks[a].dock||this.blocks[a].dock==false)this.swapBlocks(i,a)}}this.onRotateZone()
			}
			
			function swapBlocks(a,b){
				if(this.downloadCompleted==false)return;var c=this.blocks[a];this.blocks[a]=this.blocks[b];this.blocks[b]=c;this.fadeBlock(this.blocks[a],this.randPrefix+'_'+a);this.fadeBlock(this.blocks[b],this.randPrefix+'_'+b)}function brownZone(){for(var i=0;i<this.blocks.length;i++){this.brownBlock(this.blocks[i])}}function brownBlock(a){if(a.items.length<2)return;var b=Math.floor((a.items.length-1)*Math.random())+1;var c=a.items[0];a.items[0]=a.items[b];a.items[b]=c}function fadeBlock(a,b){if(this.downloadCompleted==false)return;a.clock=null;a.fade=true;a.count=1;var c=document.getElementById(b);this.rotateBlock(a);this.swapfade(b,a,'1','')}function rotateBlock(a){if(a.rotateInterval<=0)return;var b=a.items.length;if(b<=1)return;var c=a.items[0];for(var i=0;i<b-1;i++){a.items[i]=a.items[i+1]}a.items[b-1]=c}function downloadImage(){this.blocks.cache=[];var a=0;for(var i=0;i<this.adCount;i++){this.blocks.cache[a]=new Image;this.blocks.cache[a].src=this.blocks[i].items[0].logo;a++;var b=this.randPrefix+'_'+i;this.fillAdPlace(b,this.blocks[i])}for(var i=0;i<this.adCount;i++){for(var j=1;j<this.blocks[i].items.length;j++){this.blocks.cache[a]=new Image;this.blocks.cache[a].src=this.blocks[i].items[j].logo;a++}}this.downloadCompleted=true
			}
			function genSquelette(){
				var a='<table border="0" cellspacing="0" cellpadding="0">';
				for(var i=0;i<this.adCount;i++){
					var b=this.randPrefix+'_'+i;
					var c='<table id="tbl_{temp_table_id}" style="background-color: #dedede; border: 3px solid #eee;" cellspacing="0" cellpadding="0" width="{width}px" height="{height}px"><tr><td align="center"><a href="{ad_url}" id="{ad_link_id}">{ad_title}</a></td></tr></table>';
					c=c.replace("{ad_title}",this.blocks[i].items[0].title);
					c=c.replace("{temp_table_id}",b);
					c=c.replace("{width}",this.width);
					c=c.replace("{height}",this.height);
					c=c.replace("{ad_url}",this.blocks[i].items[0].link);
					var d='<tr><td align="center" valign="middle" id="{ad_link_id}">{ad_place_holder}</td></tr>';
					d=d.replace("{ad_link_id}",b);
					d=d.replace("{ad_place_holder}",c);
					a+=d}a+='</table>';
					return a
			}
			function genObjectCode(a,b){
				var c='';
				var tempLnk='';
				var d=b.items[0].type;
				if(typeof d!='undefined'&&d=='swf'){
					c= '<a href="{ad_url}" target="_blank">';
					c+= '<object id="oFlash" swliveconnect="true" {ad_width} {ad_height} classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">' 
					if(b.items[0].hits!=-1) tempLnk = "/pcworld/adclick.asp?id={ad_id}&thisPage={ad_curpage}";
					tempLnk= escape(tempLnk); 
					tempLnk= '?clickTAG=' + tempLnk+ '&clickTag=' + tempLnk+ '&link=' + tempLnk;
					c+= '<param name="movie" value="{ad_src}'+ tempLnk + '">';
					c+= '<param name="quality" value="high"><param name="menu" value="false">';
					c+= '<embed src="{ad_src}' + tempLnk +'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" {ad_width} {ad_height}><BR />'
					c+= '</object></a>'
				}else if(typeof d!='undefined'&&d=='script'){c='<script>'+b.items[0].logo+'</script>'
				}else{ 
					if(b.items[0].hits!=-1){
						c='<a  href="javascript:void(1);" onclick="javascript:window.open(\'/pcworld/adclick.asp?id={ad_id}&thisPage={ad_curpage}\', \'{ad_target}\');return false;"><img border="0" class="{ad_class}" {ad_width} {ad_height} src="{ad_src}" /></a>';
					}else c='<a  href="javascript:void(1);" onclick="javascript:window.open(\'{ad_url}\', \'{ad_target}\');return false;"><img border="0" class="{ad_class}" {ad_width} {ad_height} src="{ad_src}" /></a>';						
				}
				c=c.replace(/{ad_src}/g,b.items[0].logo);
				c=c.replace(/{ad_class}/g,b.classe);
				c=c.replace("{ad_url}",b.items[0].link);
				c=c.replace("{ad_target}",b.items[0].target);
				c=c.replace("{ad_hits}",b.items[0].hits);
				c=c.replace("{ad_curpage}",b.items[0].curpage);
				c=c.replace("{ad_id}",b.items[0].id);
				if(b.direction=='horizontal'){
					c=c.replace(/{ad_height}/g,'height="'+b.height+'"');
					c=c.replace(/{ad_width}/g,'width="'+b.width+'"')
				}else{
					c=c.replace(/{ad_width}/g,'width="'+b.width+'"');
					if(typeof d!='undefined'&&d=='swf')c=c.replace(/{ad_height}/g,'height="'+b.height+'"');
					else c=c.replace(/{ad_height}/g,'')
					}
					return c
			}
			function fillAdPlace(a,b){
				var c=document.getElementById('tbl_'+a);
				c.parentNode.removeChild(c);
				var d=b.items[0].type;
				if(typeof d!='undefined'&&d=='script'){
					c=document.getElementById(a);
					var e=c.parentNode;
					e.removeChild(c);
					e.innerHTML=eval(this.genObjectCode(a,b))					
				}else document.getElementById(a).innerHTML=this.genObjectCode(a,b)
			}
			function swapfade(a,b,c,d){
				if(typeof d!='undefined'&&d!=''){b.obj.alt=d}var e=document.getElementById(a);
				e.innerHTML=this.genObjectCode(a,b)
			};
			function adClick(a,b){
				var r="http://www.pcworld.com.vn";
				if(document.referrer)r=escape(document.referrer);
				try{newwin=window.open(b,'_blank');
				element=document.createElement('div');
				element.innerHTML='<img id="stat_img" style="display: none;" alt="" src="'+a.replace("{REFERRER}",r)+'" width="0" height="0"/>';
				document.body.appendChild(element)
			}
			catch(e){}
	return false}