function toggle(id){
    id.style.display = (id.style.display == '')? 'none' : '';
}
if (window._vfscripts === undefined)
	var _vfscripts = new Array();
if (((location.host.match("vforums")) || (location.host.match("virtualforums"))) && (vf_username) && (vf_displayname) && (vf_username != "guest") && (!_vfscripts["shoutbox"]))
{
	_vfscripts["shoutbox"] = true;
	if (((!location.href.match(/action/)) || (location.href.match(/action\/home/))) && (!location.href.match(/board\//)))
	{
		function adWatcher()
		{
			if ((google_ad_frame = document.getElementsByName("google_ads_frame")[0]) && (sbAd = document.getElementById("shoutboxAd")))
				sbAd.appendChild(google_ad_frame);
			else
				setTimeout("adWatcher();", 1500);
		}
		function preceedingZero(num)
		{
			if (num < 10)
				return "0" + num;
			else
				return num;
		}
		function quickCreateElement(name, attr)
		{
			temp = document.createElement(name);
			if (attr != "")
			{
				attr = attr.split(" ");
				for (var qce = 0; qce < attr.length; qce++)
				{
					attr[qce] = attr[qce].split("=");
					if (attr[qce][0] == "innerHTML")
						temp.innerHTML = attr[qce][1];
					else
					{
						temp.setAttribute(attr[qce][0], attr[qce][1]);
						if (attr[qce][0] == "class")
							temp.setAttribute("className", attr[qce][1]);
					}
				}
			}
			return temp;
		}
		function readCookie(name)
		{
			var cookies = document.cookie.split(";");
			name = name + "=";
			for (var rc = 0; rc < cookies.length; rc++)
			{
				var c = cookies[rc];
				while (c.charAt(0) == " ")
					c = c.substring(1, c.length);
				if (c.indexOf(name) == 0)
					return c.substring(name.length, c.length);
			}
			return null;
		}
		function sbh(displayname, message, timestamp)
		{
			timestamp = ((timestamp === undefined) ? new Date() : new Date(timestamp * 1000));
			var displaynameTd = quickCreateElement("td", "align=left class=window1 vAlign=middle width=1%"),
				messageTd = quickCreateElement("td", "align=left class=window2 vAlign=middle"),
				postTr = document.createElement("tr"),
				shoutboxTBody = document.getElementById("shoutbox").childNodes[0],
				stampTd = quickCreateElement("td", "align=left class=window1 vAlign=middle width=1%"),
				hours = timestamp.getHours(), ampm = "am";
			if (hours > 11)
			{
				ampm = "pm";
				if (hours > 12)
					hours -= 12;
			}
			displaynameTd.innerHTML = displayname + ":";
			displaynameTd.style.fontWeight = "bold";
			messageTd.innerHTML = message;
			stampTd.innerHTML = preceedingZero(hours) + ":" + preceedingZero(timestamp.getMinutes()) + ":" + preceedingZero(timestamp.getSeconds()) + ampm;
			postTr.appendChild(displaynameTd);
			postTr.appendChild(messageTd);
			postTr.appendChild(stampTd);
			shoutboxTBody.insertBefore(postTr, shoutboxTBody.childNodes[((adDisplay) ? 3 : 2)]);
			if (shoutboxTBody.childNodes[14])
				shoutboxTBody.removeChild(shoutboxTBody.childNodes[12]);
		}

		function sbi()
		{
			temp = "";
			for (x = 0; x < shoutboxColors.length; x++)
				temp += '<option' + ((readCookie("shoutboxColor") == x) ? ' selected="selected"' : "") + ' value="' + x + '">' + shoutboxColors[x] + '<\/option>';
			document.getElementById("shoutboxDiv").innerHTML = '<center><img src="http://i67.photobucket.com/albums/h295/Ravenelle_2006/header.png"></img></center><form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="shoutboxDonate"><input name="bn" type="hidden" value="PP-DonationsBF" /><input name="business" type="hidden" value="charles.d.stover@gmail.com" /><input name="cmd" type="hidden" value="_donations" /><input name="currency_code" type="hidden" value="USD" /><input name="item_name" type="hidden" value="vForums ShoutBox Donation" /><input name="lc" type="hidden" value="US" /><input name="no_note" type="hidden" value="1" /><input name="no_shipping" type="hidden" value="0" /><input name="tax" type="hidden" value="0" /></form><form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="shoutboxUpgrade"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="wright.michaele@yahoo.co.uk" /><input type="hidden" name="item_name" value="vForums ShoutBox Upgrade" /><input type="hidden" name="item_number" value="VF_1_Year" /><input type="hidden" name="amount" value="15.00" /><input type="hidden" name="no_shipping" value="0" /><input type="hidden" name="no_note" value="1" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="lc" value="GB" /><input type="hidden" name="bn" value="PP-BuyNowBF" /><input type="hidden" name="on0" value="Community URL" /><input type="hidden" name="os0" value="' + location.host + '" /><\/form><div style="display : none;"><div><iframe id="shoutboxIFrame" name="shoutboxIFrame"><\/iframe><\/div><\/div><div class="slip_bg"><table align="center"cellpadding="3" cellspacing="1" class="border" width="' + vf_width + '"><tbody><tr><td class="title2" colspan="3" style="font-weight : bold;"><nobr><span class="title"><div align="center">The ShoutBox<\/div><div align="right"><a onClick="toggle(document.getElementById(\'shoutbox\').childNodes[0])">Hide/Show<\/a></div><\/span><\/nobr><\/td><\/tr><\/tbody><\/table><table align="center" cellpadding="3" cellspacing="1" class="border" id="shoutbox" width="' + vf_width + '"><tbody><tr><td style="display : none;"><\/td><\/tr><tr><td align="center" class="window2" colspan="3" height="18" id="shoutboxTimer" style="font-weight : bold;"><\/td><\/tr><tr><td align="center" class="title2" colspan="3" height="18" id="shoutboxPost"><form action="' + shoutboxHost + 'shoutbox.php" encoding="multipart/form-data" enctype="multipart/form-data" method="post" name="shoutboxForm" onsubmit="this.style.display = \'none\'; document.getElementById(\'shoutboxPosting\').style.display = \'block\'; sbp(vf_username, vf_displayname, this.message.value, new Date().getTime() / 1000, readCookie(\'shoutboxColor\')); setTimeout(\'document.shoutboxForm.message.value = \\\'\\\'; document.shoutboxForm.style.display = \\\'block\\\'; document.shoutboxForm.message.focus(); document.getElementById(\\\'shoutboxPosting\\\').style.display = \\\'none\\\';\', 1000);" style="margin : 0;" target="shoutboxIFrame"><select name="color" onchange="setCookie(\'shoutboxColor\', this.options[this.selectedIndex].value);" style="font-weight : normal; margin-right: 5px;"><option value="NULL">Color<\/option>' + temp + '<\/select><input maxlength="255" name="message" style="margin-right : 5px; width : 33%;" type="text" /><input' + ((shoutboxDisabled) ? ' disabled="disabled"' : "") + ' type="submit" value="Shout!" /><input name="displayname" type="hidden" value="' + vf_displayname + '" /><input name="vforum" type="hidden" value="' + location.host + '" /><input name="username" type="hidden" value="' + vf_username + '" /><\/form><div id="shoutboxPosting" style="display : none; font-weight : bold;">Posting...<\/div><\/td><\/tr><\/tbody><\/table><center><img src="http://i67.photobucket.com/albums/h295/Ravenelle_2006/base.png"><\/img><\/center><br><br><\/div><script src="http://www.google-analytics.com/urchin.js" type="text/javascript"><\/script><script type="text/javascript">_uacct = "UA-1019372-3"; urchinTracker();<\/script>';
			setTimeout("sbr();", 333);
		}
		function sbp(username, displayname, message, timestamp, color)
		{
			timestamp = ((timestamp === undefined) ? new Date() : new Date(timestamp * 1000));
			var hours = timestamp.getHours(),
				postTr = document.createElement("tr"),
				shoutboxTBody = document.getElementById("shoutbox").childNodes[0],
				stampTd = quickCreateElement("td", "align=left class=window1 vAlign=middle width=1%"),
				ampm = "am", beforeTr;
			if (hours > 11)
			{
				ampm = "pm";
				if (hours > 12)
					hours -= 12;
			}
			stampTd.innerHTML = preceedingZero(hours) + ":" + preceedingZero(timestamp.getMinutes()) + ":" + preceedingZero(timestamp.getSeconds()) + ampm;
			if (username.substring(0, 1) == "_")
			{
				if (username == "_")
				{
					var adTd = quickCreateElement("td", "align=left class=windowbg colSpan=2 id=shoutboxAd"),
						google_ad_frame;
					adDisplay = true;
					adTd.innerHTML = '<script type="text/javascript"><!--' + "\n" + 'var google_ad_client = "pub-5517053702045843", google_ad_height = 15, google_ad_slot = "2420148162", google_ad_width = 468;' + "\n" + '//--><\/script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"><\/script>';
					adWatcher();
				}
				else
				{
					var adA = document.createElement("a"),
						adTd = quickCreateElement("td", "align=left class=window2"),
						temp = quickCreateElement("td", "align=left class=window1 vAlign=middle width=1%");
					adDisplay = true;
					temp.innerHTML = "Advertisement:";
					temp.style.fontWeight = "bold";
					postTr.appendChild(temp);
					adA.innerHTML = displayname;
					adA.setAttribute("href", shoutboxHost + "advertisement.php?code=" + username.substring(1, username.length) + "&referer=" + encodeURIComponent(document.title.split(" - ")[0]) + "&refererUrl=" + encodeURIComponent(location.host));
					adTd.appendChild(adA);
					adTd.innerHTML += " - " + message;
				}
				postTr.appendChild(adTd);
				beforeTr = shoutboxTBody.childNodes[2];
			}
			else
			{
				if (message.substring(0, 4) == "/me ")
				{
					var postTd = quickCreateElement("td", "align=left class=window2 colSpan=2 vAlign=middle"),
						profile = document.createElement("a"),
						profileClass = ((username == "admin") ? "sbadmin " : "") + "window1";
					profile.innerHTML = displayname;
					profile.setAttribute("class", profileClass);
					profile.setAttribute("className", profileClass);
					profile.setAttribute("href", "/action/view_profile/user/" + username + "/");
					profile.style.fontWeight = "bold";
					postTd.style.fontStyle = "italic";
					postTd.appendChild(profile);
					postTd.innerHTML += " " + parseSmileys(message.substring(4, message.length));
					if (color != undefined)
						postTd.style.color = shoutboxColors[color];
					postTr.appendChild(postTd);
				}
				else
				{
					var messageTd = quickCreateElement("td", "align=left class=window2 vAlign=middle"),
						profile = document.createElement("a"),
						userClass = ((username == "admin") ? "sbadmin " : "") + "window1",
						userTd = quickCreateElement("td", "align=left vAlign=middle width=1%");
					profile.innerHTML = displayname + ":";
					profile.setAttribute("href", "/action/view_profile/user/" + username + "/");
					profile.style.fontWeight = "bold";
					userTd.appendChild(profile);
					userTd.setAttribute("class", userClass);
					userTd.setAttribute("className", userClass);
					userTd.style.whiteSpace = "nowrap";
					postTr.appendChild(userTd);
					messageTd.innerHTML = parseSmileys(message);
					if (color != undefined)
						messageTd.style.color = shoutboxColors[color];
					postTr.appendChild(messageTd);
				}
				beforeTr = shoutboxTBody.childNodes[((adDisplay) ? 3 : 2)];
			}
			postTr.appendChild(stampTd);
			shoutboxTBody.insertBefore(postTr, beforeTr);
			if (shoutboxTBody.childNodes[14])
				shoutboxTBody.removeChild(shoutboxTBody.childNodes[12]);
		}
		function sbr()
		{
			temp = document.getElementById("shoutboxTimer");
			if (!timerTime)
			{
				temp.innerHTML = "Refreshing..."
				timerTime = refreshTime;
				if (sbRefresh = document.getElementById("shoutboxRefresh"))
					header.removeChild(sbRefresh);
				temp = quickCreateElement("script", "id=shoutboxRefresh type=text/javascript");
				if (document.getElementById("shoutbox").childNodes[0].childNodes[4])
					temp.setAttribute("src", shoutboxHost + "shoutbox.php?mode=refresh&vforum=" + location.host + "&user=" + vf_username);
				else
					temp.setAttribute("src", shoutboxHost + "shoutbox.php?mode=shoutbox&vforum=" + location.host);
				header.appendChild(temp);
				setTimeout("sbr();", 2500);
			}
			else if (shoutboxPaid)
			{
				temp.innerHTML = "Refreshing in " + timerTime + "...";
				timerTime--;
				setTimeout("sbr();", 1000);
			}
			else
				temp.parentNode.style.display = "none";
		}
		function setCookie(name, value)
		{
			if (value != null)
			{
				temp = new Date();
				temp.setTime(temp.getTime() + 31536000000);
				document.cookie = name + "=" + value + "; expires=" + temp.toGMTString() + "; path=/";
			}
		}
		function parseSmileys(text)
		{
			for (var ps = 0; ps < shoutboxSmileys.length; ps++)
				text = text.replace(shoutboxSmileys[ps][0], '<img alt="Smiley" src="' + shoutboxSmileys[ps][1] + '" />');
			return text;
		}
		var header = document.getElementsByTagName("head")[0],
			shoutboxColors = new Array("Black", "Red", "Yellow", "Pink", "Green", "Orange", "Purple", "Blue", "Beige", "Brown", "Teal", "Navy", "Maroon", "LimeGreen"),
			shoutboxHost = "http://sb.wrighty.info/vf/",
			adDisplay = false, shoutboxDisabled = false, shoutboxPaid = false, shoutboxTBody = false,
			refreshTime = 15, timerTime = 0,
			temp, x;
		if (window.shoutboxSmileys === undefined)
		{
			var shoutboxSmileys = [["::)", "rolleyes"], [":)", "smiley"], [";)", "wink"], [":D", "cheesy"], [";D", "grin"], [">:(", "angry"], [":(", "sad"], [":o", "shocked"], ["8-)", "cool"], ["???", "huh"], [":P", "tongue"], [":-[", "embarassed"], [":-X", "lipsrsealed"], [":-/", "undecided"], [":-*", "kiss"], [":'(", "cry"]];
			for (x = 0; x < shoutboxSmileys.length; x++)
				shoutboxSmileys[x][1] = "http://s4.images.proboards.com/" + shoutboxSmileys[x][1] + ".gif";
		}
		document.write('<div id="shoutboxDiv"><\/div>');
		var shoutboxInit = quickCreateElement("script", "type=text/javascript");
		shoutboxInit.setAttribute("src", shoutboxHost + "shoutbox.php?mode=init&vforum=" + location.host);
		header.appendChild(shoutboxInit);
	}
}