/***************************************************************************
 *                                advert.js
 *                            -------------------
 *   begin                : Wednesday, October 18, 2006
 *   copyright            : (C) 2007 The Vietfox Group
 *   email                : dovanxuan2008@yahoo.com
 *
 *
 ***************************************************************************/
 
 /***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
var _AD_SET_ = [];
function Advert()
{
	var o = document.createElement('div');
	this.id = _AD_SET_.length;
	this.current = 0;
	this.delay = 5000;
	this.left = 0;
	this.top = 0;
	this.adv = [];
	this.obj = o;
	_AD_SET_[this.id] = this;
}
Advert.prototype.GetObj = function(){
	return this.obj;
}
Advert.prototype.GetHtml = function(){
	return this.obj.innerHTML;
}
Advert.prototype.Insert = function(img,lnk,width,height)
{
	var i = this.adv.length;
	document.write('<div id="adv_____' + this.id + '_' + i + '" style="visibility:hidden;position:absolute;left:0px;top:0px;">');
	document.write('<div><a target="_blank" href="'+lnk+'">'+show_image(img,width,height)+'</a></div>');
	document.write('</div>');
	this.adv[i] = document.getElementById('adv_____' + this.id + '_' + i);
}
Advert.prototype.MoveRel = function(dx,dy)
{
	this.left += dx;
	this.top += dy;
	this.MoveTo(this.left,this.top);
}
Advert.prototype.MoveTo = function(x,y)
{
	this.left = x;
	this.top = y;
	try{
		var o = this.obj;
		o.style.position = "absolute";
		o.style.left = this.left + "px";
		o.style.top = this.top + "px";
	}catch(e){
	}
}

Advert.prototype.Run = function()
{
	try{
		/*
		var o1 = this.adv[this.current];
		this.obj.innerHTML = o1.innerHTML;
		this.current = this.current+1;
		if(this.current>=this.adv.length) this.current=0;
		*/
		this.obj.innerHTML = '';
		for(var i=0; i<this.adv.length; i++){
			this.obj.innerHTML += this.adv[i].innerHTML;
		}
		setTimeout("_AD_SET_["+this.id+"].Run();",this.delay);
	}catch(e){
		setTimeout("_AD_SET_["+this.id+"].Run();",100);
	}
}
function show_image(src,w,h){
	var img = "";
	try{
		var ext = src.substr(src.length-3,3).toLowerCase();
		switch(ext){
		case "swf":
			img = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+w+'" height="'+h+'" id="equation" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+src+'" /><param name="quality" value="high" /><PARAM NAME="WMODE" VALUE="transparent"><embed src="'+src+'" WMODE="transparent" quality="high" width="'+w+'" height="'+h+'" name="equation" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
			break;
		default:
			img = "<img src=" + src + " width=" + w + " height=" + h + " border=0/>";
		};
	}catch(e){
	}
	return img;
}


var advertL1 = new Advert();
var advertL2 = new Advert();
var advertL3 = new Advert();
var advertR1 = new Advert();
var advertR2 = new Advert();
var advertR3 = new Advert();

advertL1.Run();
advertL2.Run();
advertL3.Run();
advertR1.Run();
advertR2.Run();
advertR3.Run();

document.write('<div id="adleft____" style="visibility:visible;position:absolute;z-index:555;"></div>'); 
var adleft = document.getElementById("adleft____");
adleft.appendChild(advertL1.GetObj());
adleft.appendChild(advertL2.GetObj());
adleft.appendChild(advertL3.GetObj());

document.write('<div id="adright____" style="visibility:visible;position:absolute;z-index:555;"></div>'); 
var adright = document.getElementById("adright____");
adright.appendChild(advertR1.GetObj());
adright.appendChild(advertR2.GetObj());
adright.appendChild(advertR3.GetObj());

function scroll_ad(__top)
{
	var ada = adleft;
	var adb = adright;
	try{
		if(document.body.offsetWidth<1000){
			ada.style.visibility = "hidden";
			adb.style.visibility = "hidden";
			setTimeout("scroll_ad(0)",500);
		}else{
			var top = document.documentElement.scrollTop+document.body.scrollTop;
			var right = document.body.offsetWidth-110;
			window.status = 'a';
			ada.style.left = "0px";
			adb.style.left = "0px";
			if(Math.abs(top-__top)>0){
				var dy = top-__top;
				dy = (Math.abs(dy)>6)?Math.floor(dy/6):dy-1;
				__top += dy;
				ada.style.top = __top + "px";
				adb.style.top = __top + "px";
				setTimeout("scroll_ad("+__top+")",100);
			}else{
				ada.style.top = "0px";
				adb.style.top = "0px";
				setTimeout("scroll_ad("+__top+")",1000);
			}
			ada.style.left = "0px";
			adb.style.left = right + "px";
			ada.style.position = "absolute";
			adb.style.position = "absolute";
			ada.style.visibility = "visible";
			adb.style.visibility = "visible";
		}
	}catch(e){
		setTimeout("scroll_ad(0)",100);
	}
}
scroll_ad(0);
function blurscreen()
{
	if (document.getElementById('blurscreen').style.display=='none')
	{
		document.getElementById('blurscreen').style.display='block';
		document.getElementById('blurscreen').style.top=0;
		document.getElementById('blurscreen').style.left=0;
		document.getElementById('blurscreen').style.width=document.body.scrollWidth;
		document.getElementById('blurscreen').style.height=document.body.scrollHeight;
	}
	else 	
		document.getElementById('blurscreen').style.display='none';
}
