function TransAD(){
	var $box = null;
	var $len = 0;
	var $arr = new Array();
	var $delay = 4000;
	var $number = null;
	var $oThis = this;
	var $key = 0;
	var $timeout = null;
	var $last = 0;
	
	this.loadFromArray = function(arr){
		for(var i = 0; i < arr.length; i++){
			if(!arr[i] || arr[i].length == 0)continue;
			var obj = _create('a');
			obj.href = arr[i][0];
			obj.target = '_blank';
			obj.innerHTML = '<img src="' + arr[i][1] + '" />';
			$arr[$len++] = obj;
		}
	}
	
	this.setBox = function(id){
		$box = _get(id);
	}
	
	this.setDelay = function(delay){
		$delay = delay;
	}
	
	this.display = function(){
		if(!$box)return;
		$box.innerHTML = '<p>&nbsp;</p>';
		_play(0);
		
	}
	
	function _change(){
		if(document.all 
			&& $box.filters 
			&& $box.filters.revealTrans){
			$box.filters.revealTrans.Transition = Math.floor(Math.random() * 23);
				$box.filters.revealTrans.apply();
		}
		$box.replaceChild($arr[$key], $box.childNodes[$last]);
		if(document.all 
			&& $box.filters 
			&& $box.filters.revealTrans){
			$box.filters.revealTrans.Transition = Math.floor(Math.random() * 23);
				$box.filters.revealTrans.play();
		}
	}
	
	function _play(key){
		window.clearTimeout($timeout);
		_newKey(key);
		_change();
		if($len > 1)$timeout = window.setTimeout(function(){_play()}, $delay);
	}
	
	function _stop(){
		window.clearTimeout($timeout);
	}
	
	function _newKey(key){
		if(key || key === 0){
			$key = key;
		}
		else{
			$key ++;
		}
		$key = $key % $len;
	}
	
	function _get(_id){
		if(typeof _id != 'string')return _id
		var _e = document.getElementById(_id);
		if(_e)return _e;
		_e = document.getElementsByName(_id);
		if(_e.length == 1)return _e[0];
		return _e;
	}
	
	function _create(_tagName){
		return document.createElement(_tagName);
	}
}
