jQuery.fn.extend({
	banner: function(o) {
    o = $.extend({
			path: '',
			type: 'iframe',
                        size: 0
		}, jQuery.fn.banner.defaults, o);

		if (typeof(window.waiting)!= 'undefined'){
			if (window.waiting == 'intro'){
				if (typeof(PUB_START)== 'object'){
					if (o.type == 'iframe'){
						PUB_START.list(this.attr('id'),o);
						return this;
					}
				}
			}
		}
                
                if (o.size != 0){
                    if (screen.width < o.size){
                        return null;
                    }
                }
                
		var div = $(this);
		
		if (o.type == 'iframe'){
			var bannerSize = o.path.slice(o.path.indexOf('adsize=')+7,o.path.length).split('x')
			var bannerTag = $('<iframe class="iframePub" src="http://ads.iol.pt/html.ng/'
				+ o.path + '&bust=' + (Math.round(Math.random()*10000000000)) 
				+ '" width="' + bannerSize[0] + '" height="' + bannerSize[1] 
				+ '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" border="0"></iframe>'
			)
	
				div.append(bannerTag)
			
		} else if (o.type == 'javascript'){
			var bannerTag = '<script type="text/javascript" src="http://ads.iol.pt/js.ng/' + o.path + '&bust=' + (Math.round(Math.random()*10000000000)) + '"></script>';
			document.write(bannerTag)
		}
	}

})
