function Banner()
{
	this.activeDiv = '';
	this.started = false
	this.oAjaxThreads = new Array();
	this.loadingThreads = 0;
	this.temp = new Array();
	this.oSite = null;
	this.oCelebrity = null;
	this.oTour = null;
	
	this.siteName = '';
	this.siteLogo = '';
	this.celebrityName = '';
	this.celebrityPictures = new Array();

	this.oScandals = new Array();
	this.oTours = new Array();
	this.oGalleries = new Array();
	
	this.currentTitleColor = '';
	this.currentFontColor = '';
	this.currentLinkColor = '';
	
	this.currentTitleSize = '';
	this.currentFontSize = '';
	this.currentLinkSize = '';
	
	this.width = 670;
	this.height = 280;
	this.webmasterCode = '';
	this.format = '';
	
	this.celebrityChanged = false;
	this.oExistentScandals = new Array();
	this.loadingScandal = false;
}

Banner.prototype.show = function(property)
{
	var windowX = 0;
	var windowY = 0;
	
	switch(property)
	{
		case 'bannerContent':
			windowX = 52;
			windowY = 60;
		break;
		case 'bannerSize':
			windowX = 52;
			windowY = 82;			
		break;
		case 'fontSize':
			windowX = 52;
			windowY = 104;
		break;
		case 'titleColor':
			windowX = 52;
			windowY = 126;
		break;
		
		case 'fontColor':
			windowX = 422;
			windowY = 60;
		break;
		case 'linkColor':
			windowX = 422;
			windowY = 82;
		break;
		case 'backgroundColor':
			windowX = 422;
			windowY = 104;			
		break;
		case 'borderColor':
			windowX = 422;
			windowY = 126;
		break;
	}
	
	if(!this.started)
	{
		this.startUp();
		this.started = true;
		document.getElementById('celebrityId').disabled = true;
		document.getElementById('format').disabled = true;
	}
	
	if(this.activeDiv != '')
	{
		document.getElementById(this.activeDiv).style.display = 'none';
	}
	
	var divId = property+'Div';
	this.activeDiv = divId;
	document.getElementById(this.activeDiv).style.display = '';
	document.getElementById(this.activeDiv).style.left = windowX;
	document.getElementById(this.activeDiv).style.top = windowY;
}

Banner.prototype.startUp = function()
{	
	this.setupTitles('#ff0000', '16px');
	this.setupFonts('#ff0000', '12px');
	this.setupLinks('#ffffff', '10px');
	
	this.setBackgroundColor('000000');
	this.setBorderColor('ff0000');
	
	this.setSelectValue(document.getElementById('titleColor'), 'ff0000');
	this.setSelectValue(document.getElementById('fontColor'), 'ff0000');
	this.setSelectValue(document.getElementById('linkColor'), 'ffffff');
	this.setSelectValue(document.getElementById('backgroundColor'), '000000');
	this.setSelectValue(document.getElementById('borderColor'), '000000');
	
	document.getElementById('titleColor').style.backgroundColor = '#ff0000';
	document.getElementById('fontColor').style.backgroundColor = '#ff0000';
	document.getElementById('linkColor').style.backgroundColor = '#ffffff';
	document.getElementById('backgroundColor').style.backgroundColor = '#000000';


	if(document.getElementById('backgroundColor').getAttribute('type') == 'hidden')
	{
		this.setBackgroundColor(document.getElementById('backgroundColor').value);
	}
	if(document.getElementById('borderColor').getAttribute('type') == 'hidden')
	{
		this.setBorderColor(document.getElementById('borderColor').value);
	}
	if(document.getElementById('titleColor').getAttribute('type') == 'hidden')
	{
		this.setupTitles(document.getElementById('titleColor').value, false);
	}
	if(document.getElementById('fontColor').getAttribute('type') == 'hidden')
	{
		this.setupFonts(document.getElementById('fontColor').value, false);
	}
	if(document.getElementById('linkColor').getAttribute('type') == 'hidden')
	{
		this.setupLinks(document.getElementById('linkColor').value, false);
	}
}

Banner.prototype.setupTitles = function(color, size)
{
	if ( color !== false && color.indexOf('#') < 0) 
	{
		color = '#' + color;
	}
	var divObj = document.getElementById('banner');
	var bObjs = divObj.getElementsByTagName('b');

	if (color)
	{
		this.currentTitleColor = color;
	}
	if (size)
	{
		this.currentTitleSize = size;
	}
			
	for (var i = 0; i < bObjs.length; i++)
	{
		if (color)
		{
			bObjs[i].style.color = color;
		}
		if (size)
		{
			bObjs[i].style.fontSize = size;
		}
	}
}

Banner.prototype.setupFonts = function(color, size)
{
	if ( color !== false && color.indexOf('#') < 0) 
	{
		color = '#' + color;
	}
	
	var divObj = document.getElementById('banner');
	var spanObjs = divObj.getElementsByTagName('span');
	
	if (color)
	{
		this.currentFontColor = color;
	}
	if (size)
	{
		this.currentFontSize = size;
	}
	
	for (var i = 0; i < spanObjs.length; i++)
	{
		if (color)
		{
			spanObjs[i].style.color = color;
		}
		if (size)
		{
			spanObjs[i].style.fontSize = size;
		}
	}
}

Banner.prototype.setupLinks = function(color, size)
{
	if ( color !== false && color.indexOf('#') < 0) 
	{
		color = '#' + color;
	}
	var divObj = document.getElementById('banner');
	var aObjs = divObj.getElementsByTagName('a');
	
	if (color)
	{
		this.currentLinkColor = color;
	}
	if (size)
	{
		this.currentLinkSize = size;
	}
	
	for (var i = 0; i < aObjs.length; i++)
	{
		if (color)
		{
			aObjs[i].style.color = color;
		}
		if (size)
		{
			aObjs[i].style.fontSize = size;
		}
	}
}

Banner.prototype.moreTitle = function()
{
	var size = eval(document.getElementById('titleSize').value) + 1;

	if (size <= 32)
	{
		document.getElementById('titleSize').value = size;
		var px = size.toString() + 'px';
		this.setupTitles(false, px)
	}
}

Banner.prototype.lessTitle = function()
{
	var size = eval(document.getElementById('titleSize').value) - 1;

	if (size >= 10)
	{
		document.getElementById('titleSize').value = size;
		var px = size.toString() + 'px';
		this.setupTitles(false, px)
	}
}

Banner.prototype.moreFont = function()
{
	var size = eval(document.getElementById('fontSize').value) + 1;

	if (size <= 24)
	{
		document.getElementById('fontSize').value = size;
		var px = size.toString() + 'px';
		this.setupFonts(false, px)
	}
}

Banner.prototype.lessFont = function()
{
	var size = eval(document.getElementById('fontSize').value) - 1;

	if (size >= 8)
	{
		document.getElementById('fontSize').value = size;
		var px = size.toString() + 'px';
		this.setupFonts(false, px)
	}
}

Banner.prototype.moreLink = function()
{
	var size = eval(document.getElementById('linkSize').value) + 1;

	if (size <= 24)
	{
		document.getElementById('linkSize').value = size;
		var px = size.toString() + 'px';
		this.setupLinks(false, px)
	}
}

Banner.prototype.lessLink = function()
{
	var size = eval(document.getElementById('linkSize').value) - 1;

	if (size >= 8)
	{
		document.getElementById('linkSize').value = size;
		var px = size.toString() + 'px';
		this.setupLinks(false, px)
	}
}

Banner.prototype.moreWidth = function()
{
	var width = eval(document.getElementById('width').value) + 20;

	if (width <= 1000)
	{
		document.getElementById('width').value = width;
		var px = width.toString() + 'px';
		document.getElementById('banner').style.width = px;
	}
	
	this.width = width;
	this.buildBanner();
}

Banner.prototype.lessWidth = function()
{
	var width = eval(document.getElementById('width').value) - 20;

	if (width >= 100)
	{
		document.getElementById('width').value = width;
		var px = width.toString() + 'px';
		document.getElementById('banner').style.width = px;
	}
	
	this.width = width;
	this.buildBanner();
}

Banner.prototype.moreHeight = function()
{
	var height = eval(document.getElementById('height').value) + 20;

	if (height <= 1000)
	{
		document.getElementById('height').value = height;
		var px = height.toString() + 'px';
		document.getElementById('banner').style.height = px;
	}
	
	this.height = height;
	this.buildBanner();
}

Banner.prototype.lessHeight = function()
{
	var height = eval(document.getElementById('height').value) - 20;

	if (height >= 100)
	{
		document.getElementById('height').value = height;
		var px = height.toString() + 'px';
		document.getElementById('banner').style.height = px;
	}
	
	this.height = height;
	this.buildBanner();
}

Banner.prototype.resizeWidth = function(width)
{
	if (width <= 1000 && width >= 100)
	{
		var px = width.toString() + 'px';
		document.getElementById('banner').style.width = px;
	}
	else
	{
		if (width >= 1000)
		{
			width = 1000;
		}
		else if(width <= 100)
		{
			width = 100;
		}
		
		document.getElementById('width').value = width; 
		var px = width.toString() + 'px';
		document.getElementById('banner').style.width = px;		
	}
	
	this.width = width;
	this.buildBanner();
}

Banner.prototype.resizeHeight = function(height)
{
	if (height <= 1000 && height >= 100)
	{
		var px = height.toString() + 'px';
		document.getElementById('banner').style.height = px;
	}
	else
	{
		if (height >= 1000)
		{
			height = 1000;
		}
		else if(height <= 100)
		{
			height = 100;
		}
		
		document.getElementById('height').value = height; 
		var px = height.toString() + 'px';
		document.getElementById('banner').style.height = px;		
	}
	
	this.height = height;
	this.buildBanner();
}

Banner.prototype.resizeTitle = function(size)
{
	if (size <= 32 && size >= 10)
	{
		var px = size.toString() + 'px';
		this.setupTitles(false, px);
	}
	else
	{
		if (size > 32)
		{
			size = 32;
		}
		else if (size < 10)
		{
			size = 10;
		}
		
		document.getElementById('titleSize').value = size; 
		var px = size.toString() + 'px';
		this.setupTitles(false, px);		
	}
}

Banner.prototype.resizeFont = function(size)
{
	if (size <= 24 && size >= 8)
	{
		var px = size.toString() + 'px';
		this.setupFonts(false, px);
	}
	else
	{
		if (size > 24)
		{
			size = 24;
		}
		else if (size < 8)
		{
			size = 8;
		}
		
		document.getElementById('titleSize').value = size; 
		var px = size.toString() + 'px';
		this.setupFonts(false, px);		
	}
}

Banner.prototype.resizeLink = function(size)
{
	if (size <= 24 && size >= 8)
	{
		var px = size.toString() + 'px';
		this.setupLinks(false, px);
	}
	else
	{
		if (size > 24)
		{
			size = 24;
		}
		else if (size < 8)
		{
			size = 8;
		}
		
		document.getElementById('titleSize').value = size; 
		var px = size.toString() + 'px';
		this.setupLinks(false, px);		
	}
}

Banner.prototype.getNextThread = function()
{
	var i = 0;
	
	if (this.oAjaxThreads.length == 0)
	{
		var oAjax = new AJAX();
		this.oAjaxThreads.push(oAjax);		
	}

	while (this.oAjaxThreads[i] && this.oAjaxThreads[i].working && i < this.oAjaxThreads.length )
	{
		i++;
	}
	
	if (!this.oAjaxThreads[i])
	{
		var oAjax = new AJAX();
		this.oAjaxThreads.push(oAjax);		
	}
	
	return this.oAjaxThreads[i];
}

Banner.prototype.selectSite = function(siteId)
{
	if (siteId > 0)
	{		
		var oAjax = this.getNextThread();
		oAjax.url = '/badge/banner/selectSite';
		oAjax.data = 'siteId=' + siteId;
		oAjax.method = 'POST';
		oAjax.addRequestListener(this, this.siteSelected);
		oAjax.open();
	}
	else
	{
		this.oSite = null;
		this.oCelebrity = null;
		document.getElementById('celebrityId').disabled = true;
		document.getElementById('format').disabled = true;
	}
}

Banner.prototype.siteSelected = function(xmlDocument, text)
{
	var oSites = eval('(' + text + ')');
	this.oSite = oSites[0];
	document.getElementById('celebrityId').disabled = false;
	document.getElementById('step3').style.display = '';
	
	if(document.getElementById('celebrityId').value > 0)
	{
		this.selectCelebrity(document.getElementById('celebrityId').value);
		document.getElementById('step5').style.display = '';
	}
	if(document.getElementById('scandalId').value > 0)
	{
		if (!this.loadingScandal)
		{
			this.selectScandal(document.getElementById('scandalId').value);
		}
	}
	
	this.siteName = this.oSite['name'];
	this.siteLogo = '/badge/images/sitelogo/'+this.oSite['id']+'.'+this.oSite['logoFileExtension'];
	
	if(oBrowser.isIE())
	{
		this.fixLogoPng();
	}
}

Banner.prototype.selectCelebrity = function(celebrityId)
{
	if (celebrityId > 0)
	{
		var noHardcore = 0;
		
		if(document.getElementById('allowHardcore').value == '0')
		{
			noHardcore = 1;
		}
		
		var oAjax = this.getNextThread();
		oAjax.url = '/badge/banner/selectCelebrity';
		oAjax.data = 'celebrityId=' + celebrityId+'&noHardcore='+noHardcore;
		oAjax.method = 'POST';
		oAjax.addRequestListener(this, this.celebritySelected);
		oAjax.open();
	}
	else
	{
		this.oCelebrity = null;
	}
}

Banner.prototype.celebritySelected = function(xmlDocument, text)
{	
	if (!this.started) 
	{
		this.startUp();
		this.started = true;
	}

	var oCelebrities = eval('(' + text + ')');
	
	if (this.oCelebrity && this.oCelebrity['id'] == oCelebrities[0]['id']) 
	{
		this.celebrityChanged = false;
	}
	else 
	{
		this.celebrityChanged = true;
	}
	
	this.oCelebrity = oCelebrities[0];
	this.celebrityMainPicture = oCelebrities[1]['fileExtension'];
	this.celebrityPictures = new Array();
	
	document.getElementById('step4').style.display = '';
	document.getElementById('step5').style.display = '';
	
	document.getElementById('format').disabled = false;
	document.getElementById('backgroundColor').disabled = false;
	document.getElementById('borderColor').disabled = false;
	document.getElementById('titleColor').disabled = false;
	document.getElementById('fontColor').disabled = false;
	document.getElementById('linkColor').disabled = false;
	
	if (document.getElementById('codeButton')) {
		document.getElementById('codeButton').disabled = false;
	}
	
	for (var i = 2; i < oCelebrities.length; i++) {
		var picture = '/badge/images/celebrities/thumbnails/' + oCelebrities[i]['id'] + '.' + oCelebrities[i]['fileExtension'];
		this.celebrityPictures.push(picture);
	}
	
	var celebName = this.oCelebrity['firstName'] + ' ' + this.oCelebrity['lastName'];
	this.celebrityName = celebName;
	this.buildBanner();
	
	this.resizeTitle(document.getElementById('titleSize').value);
	this.resizeFont(document.getElementById('fontSize').value);
	this.resizeLink(document.getElementById('linkSize').value);
	this.resizeWidth(document.getElementById('width').value);
	this.resizeHeight(document.getElementById('height').value);
	
	if (!this.oScandal || this.celebrityChanged) 
	{
		if (!this.loadingScandal)
		{
			this.selectScandal();
		}
	}
	
	if (!this.oTour || this.celebrityChanged) 
	{
		this.selectTour();
	}	
	
	this.resetAllLinks(this.oSite['url']+'?'+this.webmasterCode);
}

Banner.prototype.selectScandal = function()
{
	if (this.oCelebrity)
	{
		var celebrityId = this.oCelebrity['id'];
		
		if (celebrityId > 0)
		{
			if(this.oExistentScandals[celebrityId])
			{
				this.feedScandal(this.oExistentScandals[celebrityId]);
			}
			else
			{
				var oAjax = this.getNextThread();
				oAjax.url = '/badge/banner/selectScandal/';
				oAjax.method = 'POST';
				oAjax.data = 'celebrityId=' + celebrityId;
				oAjax.addRequestListener(this, this.scandalSelected, false);
				this.loadingScandal = true;
				oAjax.open();
			}
		}
	}
}

Banner.prototype.scandalSelected = function(xmlDocument, text)
{
	var oScandals = eval('(' + text + ')');
	this.loadingScandal = false;
	
	if(oScandals.length > 0 && oScandals[0]['id'] != '')
	{
		this.oScandal = oScandals[0];
		this.oExistentScandals[oScandals[0]['celebrityId']] = oScandals[0];
		this.feedScandal(oScandals[0]);
	}
}

Banner.prototype.feedScandal = function(oScandal)
{
	var title = oScandal['title'];
	var link = document.createElement('a');
	link.style.size = document.getElementById('linkSize').value+'px';
	link.style.color = document.getElementById('linkColor').value;
	link.appendChild(document.createTextNode(title));
	link.setAttribute('href', this.oSite['url']+'?'+this.webmasterCode);
	link.setAttribute('target', '_blank');
	var fontSize = document.getElementById('linkSize').value+'px';
	link.style.fontSize = fontSize;
	oDOMHelper.removeChilds(document.getElementById('scandalTitleTd'));
	document.getElementById('scandalTitleTd').appendChild(link);
	document.getElementById('scandalId').value = oScandal['id'];
}

Banner.prototype.selectTour = function()
{
	var celebrityId = this.oCelebrity['id'];
	var siteId = this.oSite['id'];
	
	if(celebrityId > 0 && siteId > 0)
	{
		var oAjax = this.getNextThread();
		oAjax.url = '/badge/banner/selectTour/';
		oAjax.method = 'POST';
		oAjax.data = 'celebrityId='+celebrityId+'&siteId='+siteId;
		oAjax.addRequestListener(this, this.tourSelected, false);
		oAjax.open();		
	}
}

Banner.prototype.tourSelected = function(xmlDocument, text)
{
	var oTours = eval('(' + text + ')');
	
	if(oTours.length > 0 && oTours[0]['url'] != '')
	{
		this.oTour = oTours[0];
		var url = oTours[0]['url'];
		document.getElementById('tourId').value = oTours[0]['id'];
		this.resetAllLinks(url+'?'+this.webmasterCode);
	}
}

Banner.prototype.resetAllLinks = function(url)
{
	var bannerDiv = document.getElementById('banner');
	var links = bannerDiv.getElementsByTagName('a');
	
	for(var i = 0; i < links.length; i++)
	{
		links[i].setAttribute('href', url);
		links[i].setAttribute('target', '_blank');
	}
}


Banner.prototype.buildBanner = function()
{
	var horizontal = true;
	var vertical = false;

	var widthForPics = this.width - 200;
	
	if(this.width < 180 || this.height <= 490)
	{
		if(this.width < 180)
		{
			var heightForPics = this.height - 360;
		}
		else
		{
			var heightForPics = this.height - 260;
		}
	}
	else
	{
		if (this.height >= 700)
		{
			if(this.height >= 610)
			{
				var heightForPics = this.height - 440;
			}
			else
			{
				var heightForPics = this.height - 300;
			}
		}
		else 
		{
			if(this.heigt >= 610)
			{
				var heightForPics = this.height - 460;
			}
			else
			{
				var heightForPics = this.height - 360;
			}
		}	
	}
	
	var url = '';
	
	if(this.oTour && this.oTour['url'] != '')
	{
		url = this.oTour['url']+'?'+this.webmasterCode;
	}
	else
	{
		url = this.oSite['url']+'?'+this.webmasterCode;
	}
	
	
	if(eval(this.width) < eval(this.height))
	{
		horizontal = false;
		vertical = true;		
	}
	
	if (horizontal)
	{
		var maxPics = eval(widthForPics / 80);
	}
	else
	{
		var maxPics = eval(heightForPics / 80);
	}
	
	var banner = document.getElementById('banner');
	oDOMHelper.removeChilds(banner);

	// Main Table
	var table = document.createElement('table');
	table.setAttribute('width', '100%');
	table.setAttribute('height', '100%');
	var tbody = document.createElement('tbody');
	table.appendChild(tbody);
	
	// First Line: Logo (and title for horizontal)
	var tr = document.createElement('tr');
	var td = document.createElement('td');
	
	if (horizontal)
	{
		if (this.height >= 240)
		{
			td.setAttribute('width', '200');
		}
		else
		{
			td.setAttribute('width', '130');
		}
	}
	td.setAttribute('align', 'center');
	td.setAttribute('valign', 'middle');
	td.setAttribute('id', 'leftTd');
	
	if ( (horizontal && this.height >= 240 && this.width >= 180) || ( vertical && this.height >= 510 && this.width >= 180))
	{
		var a = document.createElement('a');
		a.setAttribute('id', 'siteLogoLink');
		a.setAttribute('href', url);
		a.setAttribute('target', '_blank');
		var img = new Image();
		img.src = this.siteLogo;
		img.setAttribute('id', 'logoImage');
		img.border = 0;
		a.appendChild(img);
		td.appendChild(a);
		td.appendChild(document.createElement('br'));
	}

	var a = document.createElement('a');
	a.setAttribute('href', url);
	a.setAttribute('target', '_blank');
	
	var img = new Image();
	img.src = this.celebrityMainPicture;
	
	if(this.height < 180 && this.height >= 100)
	{
		var proportion = eval(this.height / 180);
		var imgHeight = 180 * proportion;
		img.setAttribute('height', imgHeight);
		img.width = img.width * proportion;
		img.height = imgHeight;
	}
	else if (this.height < 100)
	{
		var proportion = eval(100 / 180);
		var imgHeight = 180 * proportion;
		img.setAttribute('height', imgHeight);
		img.height = imgHeight;
		img.width = img.width * proportion;
	}
	
	if (this.width < 140 && this.width >= 100)
	{
		var proportion = eval(this.width / 140);
		var imgWidth = 130 * proportion;
		img.setAttribute('width', imgWidth);
		img.width = imgWidth;
		img.height = img.height * proportion;
	}
	else if (this.width < 100)
	{
		var proportion = eval(100 / 140);
		var imgWidth = 130 * proportion;
		img.setAttribute('width', imgWidth);
		img.width = imgWidth;
		img.height = img.height * proportion;
	}
	
	img.border = 0;
	
	a.appendChild(img);
	td.appendChild(a);
	
	tr.appendChild(td);
	
	if (vertical) 
	{
		tbody.appendChild(tr);
		tr = document.createElement('tr');
	}
	
	var td = document.createElement('td');
	
	if (horizontal) 
	{
		td.setAttribute('align', 'right');
	}
	else {
		td.setAttribute('align', 'center');
	}
	
	td.setAttribute('valign', 'top');
	
	if (horizontal && this.height >= 200)
	{
		var b = document.createElement('b');
		b.appendChild(document.createTextNode('Celebrities caught fucking on tape'));
		td.appendChild(b);
		td.appendChild(document.createElement('br'));
		td.appendChild(document.createElement('br'));
	}
	else if (vertical && this.height >= 700 && this.width >= 180)
	{
		var b = document.createElement('b');
		b.appendChild(document.createTextNode('Celebrities caught fucking on tape'));
		td.appendChild(b);
		td.appendChild(document.createElement('br'));
		td.appendChild(document.createElement('br'));		
	}
	
	tr.appendChild(td);
	tbody.appendChild(tr);
	
	var table2 = document.createElement('table');
	table2.setAttribute('width', '100%');
	var tbody2 = document.createElement('tbody');
	table2.appendChild(tbody2);
	td.appendChild(table2);
	
	var table3 = document.createElement('table');
	var tbody3 = document.createElement('tbody');
	table3.appendChild(tbody3);
	td.appendChild(table3);
	var tr = document.createElement('tr');
	tbody2.appendChild(tr);
	var td = document.createElement('td');
	
	if(vertical)
	{
		td.setAttribute('align', 'center');
	}
	
	var a = document.createElement('a');
	a.setAttribute('href', this.oSite['url']);
	a.setAttribute('target', '_blank');
	a.appendChild(document.createTextNode(this.celebrityName+' dirtiest secrets revealed'));
	td.appendChild(a);
	
	td.appendChild(document.createElement('br'));
	
	if(this.height >= 120)
	{
		td.appendChild(document.createElement('br'));
	}
	
	if(this.height > 140)
	{
		var span = document.createElement('span');
		span.appendChild(document.createTextNode('Sexy Pics: '+this.oCelebrity['imagesTotal']));
		td.appendChild(span);
		td.appendChild(document.createElement('br'));
		var span = document.createElement('span');
		span.appendChild(document.createTextNode('Sexy Videos: '+this.oCelebrity['videosTotal']));
		td.appendChild(span);
		td.appendChild(document.createElement('br'));
	}
	
	tr.appendChild(td);

	if (horizontal)
	{
		var td = document.createElement('td');

		var a = document.createElement('a');
		a.setAttribute('href', url);
		a.setAttribute('target', '_blank');
		a.appendChild(document.createTextNode(this.oSite["name"] + ': the largest nude celebs database'));
		td.appendChild(a);
		
		td.appendChild(document.createElement('br'));
		
		if (this.height >= 120) 
		{
			td.appendChild(document.createElement('br'));
		}
		
		if (horizontal && this.height > 140) 
		{
			var span = document.createElement('span');
			span.appendChild(document.createTextNode('Nude Pics: ' + this.oSite['imagesTotal']));
			td.appendChild(span);
			td.appendChild(document.createElement('br'));
			
			var span = document.createElement('span');
			span.appendChild(document.createTextNode('Nude Videos: ' + this.oSite['videosTotal']));
			td.appendChild(span);
			td.appendChild(document.createElement('br'));
		}
		
		tr.appendChild(td);
	}
	
	tbody2.appendChild(tr);
	
	// Lline for the pictures table
	var tr = document.createElement('tr');
	var td = document.createElement('td');
	tbody.appendChild(tr);

	var totalPics = 0;
	
	table3.setAttribute('width', '100%');
	var tr = document.createElement('tr');
	tr.setAttribute('id', 'picturesTr');
	for(var i = 0; i < this.celebrityPictures.length; i++)
	{
		totalPics++;
		if (totalPics <= maxPics)
		{
			var td = document.createElement('td');
			td.setAttribute('align', 'center');
			td.setAttribute('valign', 'middle');
			
			var a = document.createElement('a');
			a.setAttribute('href', url);
			a.setAttribute('target', '_blank');
			
			var img = new Image();
			img.src = this.celebrityPictures[i];
			img.border = 0;
			
			a.appendChild(img);
			td.appendChild(a);
			tr.appendChild(td);
			
			if (vertical) 
			{
				tbody.appendChild(tr);
				tr = document.createElement('tr');
			}
		}
	}

	var newTr = document.createElement('tr');
	var td = document.createElement('td');
	newTr.appendChild(td);
	
	td.setAttribute('colspan', totalPics);
	td.setAttribute('id', 'scandalTitleTd');
	
	if(vertical)
	{
		td.setAttribute('align', 'center');
	}
	
	if(horizontal && this.height < 160)
	{
		td.style.display = 'none';
	}
	else if (vertical && this.height <= 330)
	{
		td.style.display = 'none';
	}
	
	tbody3.appendChild(newTr);
	tbody3.appendChild(tr);

	if (vertical)
	{
		var tr = document.createElement('tr');
		var td = document.createElement('td');
		
		td.setAttribute('align', 'center');
		
		if(this.height > 610)
		{
			var a = document.createElement('a');
			a.setAttribute('href', url);
			a.setAttribute('target', '_blank');
			a.appendChild(document.createTextNode(this.oSite["name"] + ': the largest nude celebs database'));
			td.appendChild(a);
			td.appendChild(document.createElement('br'));
		}
		
		if (this.height >= 120) 
		{
			td.appendChild(document.createElement('br'));
		}
		
		if (this.height > 610)
		{
			var span = document.createElement('span');
			span.appendChild(document.createTextNode('Nude Pics: ' + this.oSite['imagesTotal']));
			td.appendChild(span);
			td.appendChild(document.createElement('br'));
			
			var span = document.createElement('span');
			span.appendChild(document.createTextNode('Nude Videos: ' + this.oSite['videosTotal']));
			td.appendChild(span);
			td.appendChild(document.createElement('br'));
		}
		
		tr.appendChild(td);
		tbody.appendChild(tr);
	}

	banner.appendChild(table);
	this.refreshAll();
	
	if(oBrowser.isIE())
	{
		this.fixLogoPng();
	}
	
	if (!this.loadingScandal)
	{
		this.selectScandal();
	}
	
	document.getElementById('banner').style.border = '3px solid '+document.getElementById('borderColor').value;
}

Banner.prototype.refreshAll = function()
{
	this.setupTitles(this.currentTitleColor, this.currentTitleSize);
	this.setupFonts(this.currentFontColor, this.currentFontSize);
	this.setupLinks(this.currentLinkColor, this.currentLinkSize);
}

Banner.prototype.generateBannerCode = function()
{
	var siteId = '';
	var celebrityId = '';
	var scandalId = '';
	var siteTourId = '';
	var siteGalleryId = '';
	var bannerWidth = '';
	var bannerHeight = '';
	var titleSize = '';
	var titleColor = '';
	var linkSize = '';
	var linkColor = '';
	var fontSize = '';
	var fontColor = '';
	var borderColor = '';
	var backgroundColor = '';
	var webmasterCode = '';

	webmasterCode = document.getElementById('accountId').value;
	siteId = document.getElementById('siteId').value;
	celebrityId = document.getElementById('celebrityId').value;
	scandalId = document.getElementById('scandalId').value;
	siteTourId = document.getElementById('tourId').value;
	siteGalleryId = document.getElementById('galleryId').value;
	bannerWidth = document.getElementById('width').value;
	bannerHeight = document.getElementById('height').value;
	titleSize = document.getElementById('titleSize').value;
	titleColor = document.getElementById('titleColor').value.replace('#', '');
	linkSize = document.getElementById('linkSize').value;
	linkColor = document.getElementById('linkColor').value.replace('#', '');
	fontSize = document.getElementById('fontSize').value;
	fontColor = document.getElementById('fontColor').value.replace('#', '');
	borderColor = document.getElementById('borderColor').value.replace('#', '');
	backgroundColor = document.getElementById('backgroundColor').value.replace('#', '');
	allowHardcore = document.getElementById('allowHardcore').value;
	
	var code = '';
	
	var url = 'http://rss.hollywoodtraffic.com/badge/banner/main/?id='+webmasterCode+'&s='+siteId+'&c='+celebrityId+'&w='+bannerWidth+'&h='+bannerHeight+'&ts='+titleSize+'&tc='+titleColor;
	url += '&ls='+linkSize+'&lc='+linkColor+'&fs='+fontSize+'&fc='+fontColor+'&bc='+borderColor+'&bg='+backgroundColor;
	url += '&scandalId='+scandalId+'&siteTourId='+siteTourId+'&siteGalleryId='+siteGalleryId+'&hc='+allowHardcore;
	
	if(oBrowser.isIE())
	{
		
	}
		
	var frameWidth = eval(bannerWidth)+6;
	var frameHeight = eval(bannerHeight)+6;
	
	code += '<!-- hollywoodtraffic dynamic banner code -->'+'\r\n'+'<iframe frameborder="no" style="border: 3px solid #'+borderColor+';" scrolling=no width="'+frameWidth+'" height="'+frameHeight+'" name="htbadge" src="'+url+'"></iframe>';
	document.getElementById('generatedCode').value = code;
}

Banner.prototype.swapFormat = function(format)
{
	var width = eval(document.getElementById('width').value);
	var height = eval(document.getElementById('height').value);
	
	switch(format)
	{
		case 'horizontal':
			if(height > width)
			{
				document.getElementById('width').value = height;
				document.getElementById('height').value = width;				

				width = document.getElementById('width').value;
				height = document.getElementById('height').value;
			}
		break;
		case 'vertical':
			if(width > height)
			{
				document.getElementById('width').value = height;
				document.getElementById('height').value = width;
				
				width = document.getElementById('width').value;
				height = document.getElementById('height').value;
			}
		break;
	}
	
	this.format = format;
	this.resizeWidth(width);
	this.resizeHeight(height);
	document.getElementById('step6').style.display = '';
}

Banner.prototype.setBackgroundColor = function(att)
{
	document.getElementById('banner').style.backgroundColor = att;
	document.getElementById('backgroundColor').style.backgroundColor = att;
}

Banner.prototype.setBorderColor = function(att)
{
	document.getElementById('banner').style.border = '3px solid '+att;
	document.getElementById('borderColor').style.backgroundColor = att;
}

Banner.prototype.setTitleColor = function(att)
{
	this.setupTitles(att, false);
	document.getElementById('titleColor').style.backgroundColor = att;
}

Banner.prototype.setFontColor = function(att)
{
	this.setupFonts(att, false);
	document.getElementById('fontColor').style.backgroundColor = att;
}

Banner.prototype.setLinkColor = function(att)
{
	this.setupLinks(att, false);
	document.getElementById('linkColor').style.backgroundColor = att;
}

Banner.prototype.setSelectValue = function(select, value)
{
	var options = select.getElementsByTagName('option');
	for (var i = 0; i < options.length; i++)
	{
		var optionValue = options[i].getAttribute('value');
		if(optionValue == value)
		{
			options[i].setAttribute('selected', 'selected');
			select.selectedIndex = i;
			select.value = value;
		}
	}
}

Banner.prototype.fixLogoPng = function()
{
	if (oBrowser.isIE())
	{
		var img = document.getElementById('logoImage');
		
		if (img) {
			var src = img.src;
			var shim = '/badge/images/x.gif';
			
			if (src.match(/\.png$/i) !== null) {
				img.style.width = img.width + "px";
				img.style.height = img.height + "px";
				img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
				img.src = shim;
			}
		}
	}
}

var oBanner = new Banner();