var UOLAF = window.UOLAF || {};

UOLAF.init = function () {
	if(!UOLAF.runOnce) {
		UOLAF.runOnce=true;
		try {
			UOLAF.pg = Number((/UOLAFpg=([^|;]+)/).exec(document.cookie)[1]);
			//console.debug('leu '+UOLAF.pg)
		} catch(e) {
			UOLAF.pg = -1;
		}
	} else {
		//UOLAF.pg++;
	}
	UOLAF.ads();
}

UOLAF.ads = function () {

	adBlockCountBanner = (typeof adBlockCountBanner != "undefined")? adBlockCountBanner+1:0;
	UOLAF.pg++;
	UOLAF.pg = (UOLAF.pg>9)?0:UOLAF.pg;
	var scw=0,sch=0; if(screen.height){scw=screen.width;sch=screen.height;}
	var reso = scw + 'x' + sch;
	var conntype=document.body; conntype.style.behavior='url(#default#clientCaps)'; conntype=(conntype.connectionType=='lan')?1:0;
	var dt=new Date(); dt=dt.getTime(); tile=Math.floor(dt*1000*Math.random());
	url  = 'http://adclient-dart.afiliados.uol.com.br/';
	try{url += 'format'+formatId+'.html?&amp;';}catch(e){void(null)}
	try{url += 'adBlockCount='+adBlockCountBanner+'&';}catch(e){void(null)}
	try{url += 'urlReferer='+encodeURIComponent(document.location.href)+'&amp;';}catch(e){void(null)}
	try{url += 'formatId='+formatId+'&amp;';}catch(e){void(null)}
    try{url += 'bwidth='+bwidth+'&amp;';}catch(e){void(null)}
    try{url += 'bheight='+bheight+'&amp;';}catch(e){void(null)}
	try{url += 'bgColor='+bgColor+'&amp;';}catch(e){void(null)}
    try{url += 'category='+category+'&amp;';}catch(e){void(null)}
	try{url += 'type='+type+'&amp;';}catch(e){void(null)}
    try{url += 'page='+page+'&amp;';}catch(e){void(null)}  
	try{url += 'deslabel='+deslabel+'&amp;';}catch(e){void(null)}
	try{url += 'reso='+reso+'&amp;';}catch(e){void(null)}
	try{url += 'conntype='+conntype+'&amp;';}catch(e){void(null)}
	try{url += 'tile='+tile+'&amp;';}catch(e){void(null)}
	try{url += 'coddisplaysupplier='+coddisplaysupplier+'&amp;';}catch(e){void(null)}
    html = '<iframe src="'+url+'" ';
	html += 'marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" frameborder="0" scrolling="no"';
	html += 'height="'+ bheight +'" width="'+ bwidth +'"></iframe>';
	document.write(html);
	delete deslabel; //deleta deslabel para nao gerar conflito na próxima requisição

}

UOLAF.init();