var UOLAF = window.UOLAF || {};

UOLAF.init = function () {
	if(!UOLAF.runOnce) {
		UOLAF.runOnce=true;
		/*
		UOLAF.atual=1;
		ss = document.getElementsByTagName('script');
		UOLAF.afs=0;
		console.debug(ss.length);
		for(i=0;i<ss.length;i++) { var now = ss[i];
			if(now.src.match(/uolaf.js$/)) {
				UOLAF.afs++;
			}
		}
		*/
		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 () {
	adBlockCount = (typeof adBlockCount != "undefined")? adBlockCount+1 : 0;
	UOLAF.pg++;
	UOLAF.pg = (UOLAF.pg>9)?0:UOLAF.pg;
	url  = 'http://adclient-af.shopping.uol.com.br/';
	try{url += 'format'+formatId+'.html?&amp;';}catch(e){void(null)}
	try{url += 'page='+UOLAF.pg+'&amp;';}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 += 'numads='+numads+'&amp;';}catch(e){void(null)}
	try{url += 'borderColor='+borderColor+'&amp;';}catch(e){void(null)}
	try{url += 'bgColor='+bgColor+'&amp;';}catch(e){void(null)}
	try{url += 'titleColor='+titleColor+'&amp;';}catch(e){void(null)}
	try{url += 'descrColor='+descrColor+'&amp;';}catch(e){void(null)}
	try{url += 'urlColor='+urlColor+'&amp;';}catch(e){void(null)}
	try{url += 'altColor='+altColor+'&amp;';}catch(e){void(null)}
	try{url += 'hasFrames='+hasFrames+'&amp;';}catch(e){void(null)}
	try{url += 'deslabel='+deslabel+'&amp;';}catch(e){void(null)}
	try{url += 'adult=0&amp;';}catch(e){void(null)}
	try{url += 'coddisplaysupplier='+coddisplaysupplier+'&amp;';}catch(e){void(null)}
	try{url += 'idtShape='+idtShape+'&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 += 'has_search='+has_search+'&amp;';}catch(e){void(null)}
	try{url += 'par='+par;}catch(e){void(null)}
	document.cookie = 'UOLAFpg='+UOLAF.pg;
	html = '<iframe src="'+url+'" ';
	html += 'marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" frameborder="0" scrolling="no"';
	tipos = [null, null, null, null, null, null, null, null, null, null, null, null, [728,90], [125,125], [120,600], [160,600], [180,150], [300,250], [250,250], [336,280], [120,240], [468,60], [234,60] ];
	height = tipos[Number(formatId)][1];
	width  = tipos[Number(formatId)][0];
	html += 'height="'+height+'" width="'+width+'"></iframe>';
	document.write(html);
}

UOLAF.init();

var _eShopp = document.getElementById("af-shopping-uol");
if(_eShopp != null){
  _eShopp.style.textIndent = "-100000px";
  _eShopp.removeAttribute("id");
}