
	TextLinkPreview = { type: '', clickUrl: '', fileFormat: '', fileUrl: '' };

	function updateTextLinkPreview(type, title, text, displayUrl, clickUrl, fileFormat, fileUrl)
	{
		try {
			if (TextLinkPreview.type != type ||
				 TextLinkPreview.fileFormat != fileFormat ||
				 TextLinkPreview.fileUrl != fileUrl) {
				if (type == 0) {
					$('RLbody02').style.padding = '6px !important';
					$('RLbody02').innerHTML = '<DIV id=RLadtitle></DIV><DIV id=RLadtext></DIV>';
				} else if (type == 1) {
					$('RLbody02').style.padding = '6px !important';
					var logoSrc = getLogoSrc(fileUrl, type, fileFormat);
					$('RLbody02').innerHTML = logoSrc + "<div id='RLadtitle'></div><div id='RLadtext'></div>";
				} else if (type == 2) {
					$('RLbody02').style.padding = '6px !important';
					var logoSrc = getLogoSrc(fileUrl, type, fileFormat);
					$('RLbody02').innerHTML = "<table width='100%' cellpadding='0' cellspacing='0' class='RLAdTable'><tr><td width=90% style='padding-right:5px;' valign=top><div id='RLadtitle'></div><div id='RLadtext'></div></td><td rowspan=2>" + logoSrc + "</td></tr></table>";
				} else if (type == 3) {
					$('RLbody02').style.padding = "0px";
					var logoSrc = getLogoSrc('/flashexpand.swf?ad_title=' + urlEncode(title) + '&ad_text=' + urlEncode(text) + '&ad_source=' + urlEncode(fileUrl) + '&ad_click_url=' + urlEncode(clickUrl), type, 'flash');
					$('RLbody02').innerHTML = "<div id='RLadtitle' style='display: none;'></div><div id='RLadtext' style='display: none;'></div>" + logoSrc;
				} else if (type == 4) {
					$('RLbody02').style.padding = '6px';
					var logoSrc = getLogoSrc('/standard.swf?video_source=' + urlEncode(fileUrl) + '&video_click_url=' + urlEncode(clickUrl), type, 'flash');
					$('RLbody02').innerHTML = "<table width=295 cellpadding='0' cellspacing='0' class='RLAdTable'><tr><td width=90% style='padding-right:10px;padding-left:5px;' valign=top><div id='RLadtitle'></div><div id='RLadtext'></div></td><td rowspan=2>" + logoSrc + "</td></tr></table>";
				} else if (type == 5) {
					$('RLbody02').style.padding = '0px';
					var logoSrc = getLogoSrc('/widescreen.swf?video_source=' + urlEncode(fileUrl) + '&video_click_url=' + urlEncode(clickUrl), type, 'flash');
					$('RLbody02').innerHTML = "<div id='RLadtitle' style='display: none;'></div><div id='RLadtext' style='display: none;'></div>" + logoSrc;
				} else if (type == 6) {
					$('RLbody02').style.padding = '0px';
					var logoSrc = getLogoSrc('/expand.swf?vid_title=' + urlEncode(title) + '&vidx_text=' + urlEncode(text) + '&video_source=' + urlEncode(fileUrl) + '&video_click_url=' + urlEncode(clickUrl), type, 'flash');
					$('RLbody02').innerHTML = "<div id='RLadtitle' style='display: none;'></div><div id='RLadtext' style='display: none;'></div>" + logoSrc;
				} else if (type == 7) {
					$('RLbody02').style.padding = '0px';
					var logoSrc = getLogoSrc(fileUrl, type, fileFormat);
					$('RLbody02').innerHTML = "<div id='RLadtitle' style='display: none;'></div><div id='RLadtext' style='display: none;'></div>" + logoSrc;
				}

				TextLinkPreview.type       = type;
				TextLinkPreview.fileFormat = fileFormat;
				TextLinkPreview.fileUrl    = fileUrl;
			}

			TextLinkPreview.clickUrl = clickUrl;

			text = text.replace(/</g, "&lt;");
			text = text.replace(/>/g, "&gt;");
			text = text.replace(/\n/g, "<br />");

			$('RLadurl').innerHTML = '<nobr>' + displayUrl + '</nobr>';
			$('RLadtitle').innerHTML = '<nobr>' + title + '</nobr>';
			$('RLadtext').innerHTML = text;

		} catch (e) {
		}
	}

	function getLogoSrc(fileUrl, type, fileFormat)
	{
		if (type == 1) {
			var logoWidth = '234';
			var logoHeight = '60';
		} else if (type == 2) {
			var logoWidth = '125';
			var logoHeight = '125';
		} else if (type == 3 || type == 7) {
			var logoWidth = '300';
			var logoHeight = '250';
		} else if (type == 5 || type == 6) {
			var logoWidth = '300';
			var logoHeight = '200';
		} else if (type == 4) {
			var logoWidth = '180';
			var logoHeight = '150';
		}

		if (fileFormat == '') {
			fileUrl = '/images/tl/default' + type + '.gif';
			fileFormat = 'image';
		}

		if (fileFormat != 'flash')
			return '<center><img src="' + fileUrl + '" border="0" id="RLlogo' + type + '" width="' + logoWidth + '" height="' + logoHeight + '"></center>';
		else
			return '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + logoWidth + '" height="' + logoHeight + '" id="RLflash">' +
					 '   <param name="movie" value="' + fileUrl + '" />' +
					 '   <param name="quality" value="high" />' +
					 '   <embed src="' + fileUrl + '" quality="high" bgcolor="#ffffff" width="' + logoWidth + '" height="' + logoHeight + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="sameDomain" name="RLflash" />' +
					 '</object>';
	}

	function openAdUrl()
	{
		try {
			var u = TextLinkPreview.clickUrl;
			if (u.substr(0, 7) != 'http://' && u.substr(0, 8) != 'https://')
				u = 'http://' + u;
			if (u != 'http://' && u != 'https://')
				window.open(u, '_blank', 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes');
			else
				alert ('Please enter URL.');
		} catch (e) {
		}
	}
