var ad_index = 0;
var theTimer = 0;
var ad_length = 0;

function load_adv(){
	ad_length= ad_url.size();
	$('ad_image').onmouseout=continue_ad;
	$('ad_image').onmouseover=img_stop_ad;
	for(var i=0;i < ad_length; i ++){
		$('ad_button_'+i).onmouseout=continue_ad;
		$('ad_button_'+i).onmouseover=button_stop_ad;
		//$('ad_button_'+i).onclick=button_click;
	}
	continue_ad();
}
function next_adv(p_id){
	var isstop = false;
	if(typeof p_id != 'undefined')
	{
		ad_index=p_id;
		isstop=true;
	}else ad_index ++;
	if(ad_index == ad_length)ad_index=0;
	//alert(ad_index);
	for(var i = 0 ; i < ad_length ; i ++){
		if(i != ad_index){
			$('ad_button_'+i).className='ad_no1';
		}else{
		$('ad_button_'+i).className='ad_no2';
			$('ad_img_url').href=ad_url[i];
			setTransition();
			$('ad_image').src=ad_img[i];
			playTransition();
		}
	}
	if(isstop)img_stop_ad();
	else continue_ad();
}
function setTransition(){
	if(document.all){
		$('ad_image').filters.revealTrans.Transition=Math.floor(Math.random()*23);
		$('ad_image').filters.revealTrans.apply();
	}
}
function playTransition(){
if(document.all)$('ad_image').filters.revealTrans.play();
}
function continue_ad(){	clearTimeout(theTimer);theTimer=setTimeout("next_adv()", 3000);}
function img_stop_ad(){	clearTimeout(theTimer);}
function button_stop_ad(v){;
var element = getEventElement(getEvent(v)) ;
var el_name = element.id;
var index = parseInt(el_name.substr(10)) ;
next_adv(index);

}

function button_click(){return false ;}

function getEvent(eventTag){
return typeof eventTag == 'undefined' ? window.event : eventTag;
}

function getEventElement(event){
	return typeof event.srcElement == 'undefined' ? event.target : event.srcElement;
}