var bnrtime=30,bnrtarget,bnrRun,bnrTrash,bnrData=null;
$(function(){
	$('.bnr').css({zIndex:'10'}).mouseover(function(){
		$(this).css({zIndex:'50',overflow:'visible'});
	}).mouseout(function(){
		$(this).css({zIndex:'10',overflow:'hidden'});
	});
	$('.bnrflybanner').unbind().css({zIndex:'700'}).mouseover(function(){
		$(this).css({zIndex:'1000'});
	}).mouseout(function(){
		$(this).css({zIndex:'700'});
	}).find('.dbnrflybanner').append('<a class="bnrflybanner-close" href="javascript:bnrCloseFlyBanner(this)" onclick="bnrCloseFlyBanner(this)">Fechar</a>');

	bnrTrash=$('<div id="bnrtrash"></div>').hide().appendTo('body');
	$.writetarget(bnrTrash);

	setTimeout('showFlyBannerClose()',5000);
	setTimeout('bnrRun()',bnrtime*1000);
	setTimeout('bnrCloseAllFlyBanner(0)',bnrtime*1000);
	setTimeout('bnrCloseAllFlyBanner(1)',bnrtime*1000+200);
});
function showFlyBannerClose() {
	$('.bnrflybanner-close').fadeIn();
}
function bnrCloseFlyBanner(t) {
	$(t).parent().fadeOut();
}
function bnrCloseFlyBannerById(id) {
	$('#bnrid'+id).fadeOut();
}
function bnrCloseAllFlyBanner(t) {
	if(t)$('.bnrflybanner').hide();
	else $('.bnrflybanner').fadeOut();
}
function bnrLoadBnr(k){
	var t;
	t=$('#bnr'+bnrData.b[k].id);
	$.writetarget(t);
	t.html(bnrData.b[k].tag);
}
function bnrProcess(d){
	var k,b;
	if(!d || !d.c)
		return;
	bnrData=d;
	for(k in d.b)
		if(d.b[k].tag.length){
			bnrLoadBnr(k);
		}
	$.writetarget(bnrTrash);
	setTimeout('bnrRun()',bnrtime*1000);
}
bnrRun=function(){};
