if (document.cookie && !window.webChattr && (location.href.indexOf("mysobrietyspace") == -1) && (location.href.indexOf("dogstarspace") == -1)) {
	webChattr = {
		channel:null,
		baseUrl: "http://webchattr.com/embed/sitechat",
		nickName: null,
		pictureUrl: null,
		profileUrl: null,
		width: "99%",
		height: "450px",
		hideOptIn: false,
		keepCloseChat: false,
		inlineBox: false,
		showOnMainPage: false,
		noChatHeader: false,
		putChatAtBottom: false,
		isSavedOpen: function() {
			return (
				(c=document.cookie)
				&&
				(c.indexOf("webChattrOpen=1") != -1)
			);
		}, 
		isSavedClosed: function() {
			return (
				(c=document.cookie)
				&&
				(c.indexOf("webChattrOpen=0") != -1)
			);
		},
		startChat: function(bypassSave) {
			if (webChattr.chattrBox) {
				webChattr.chattrBox.style.display = "block";
				webChattr.startLink.style.display = "none";
				if (!webChattr.hideOptIn || webChattr.keepCloseChat) {
					webChattr.closeLink.style.display = "block";
				}
				webChattr.chattrBox.src = webChattr.baseUrl + webChattr.params;
				if (!bypassSave) {
					webChattr.setPermCookie("webChattrOpen","1");
				}
			}
		},
		closeChat: function() {
			if (webChattr.chattrBox) {
				webChattr.chattrBox.style.display = "none";
				webChattr.startLink.style.display = "block";
				webChattr.closeLink.style.display = "none";
				webChattr.setPermCookie("webChattrOpen","0");
			}
		},
		scape: function(s) {
			return (window.encodeURIComponent?encodeURIComponent(s):escape(s));
		},
		setPermCookie: function(k,v) {
			dNow = (new Date()).getTime();
			expiry = dNow + (7 * 24 * 60 * 60 * 1000);
			dateExpiry = (new Date(expiry)).toGMTString();
			document.cookie = k + "=" + v + "; path=/; expires=" + dateExpiry;
		},
		params: null
	};
	
	if (window.webChattrChannel) {
		webChattr.channel = webChattr.scape(window.webChattrChannel);
	}
	if (window.webChattrWidth) {
		webChattr.width = window.webChattrWidth;
	}
	if (window.webChattrHeight) {
		webChattr.height = window.webChattrHeight;
	}
	if (window.webChattrHideOptIn) {
		webChattr.hideOptIn = true;
	}
	if (window.webChattrKeepCloseChat) {
		webChattr.keepCloseChat = true;
	}
	if (window.webChattrInlineBox) {
		webChattr.inlineBox = true;
	}
	if (window.webChattrShowOnMainPage) {
		webChattr.showOnMainPage = true;
	}
	if (window.webChattrNoChatHeader) {
		webChattr.noChatHeader = true;
	}
	if (window.webChattrPutChatAtBottom) {
		webChattr.putChatAtBottom = true;
	}
	if (window.ning && ning.CurrentProfile) {
		if (ning.CurrentProfile.fullName)
			webChattr.nickName = webChattr.scape(ning.CurrentProfile.fullName);
		if (ning.CurrentProfile.photoUrl)
			webChattr.pictureUrl = webChattr.scape(ning.CurrentProfile.photoUrl+"&width=24&height=24");
		if (ning.CurrentProfile.id && top.location && top.location.host)
			webChattr.profileUrl = webChattr.scape("http://"+top.location.host+"/xn/detail/u_"+ning.CurrentProfile.id);
	}
	webChattr.params = "?mode=2"; 
	if (webChattr.channel) webChattr.params += "&channel=" + webChattr.channel;
	if (webChattr.nickName) webChattr.params += "&nn=" + webChattr.nickName;
	if (webChattr.pictureUrl) webChattr.params += "&pic=" + webChattr.pictureUrl;
	if (webChattr.profileUrl) webChattr.params += "&pro=" + webChattr.profileUrl;
	
	if (webChattr.inlineBox) {
		document.write('<a name="webChattrAnchorLink" id="webChattrAnchor"></a>');
	}
	
	if (
		webChattr.nickName	&& webChattr.pictureUrl
							&& webChattr.profileUrl
							&&
							(
								webChattr.inlineBox
								||
								(
									window.dojo && dojo.html
									&& dojo.html.getElementsByClassName
									&& (colTwo = dojo.html.getElementsByClassName("xg_2col"))
									&& (colTwo = colTwo[0]) && (location.href.indexOf("/main/authorization/") == -1)
									&& (location.href.indexOf("/pending") == -1)
									&& (location.href.indexOf("/banned") == -1)
									&& (location.href.indexOf("/susp") == -1)
									&&
									(
										webChattr.showOnMainPage
										||
										(location.pathname != "/")
									)
								)
							)
		) {
		webChattr.chattrBox = document.createElement("iframe");
		webChattr.chattrBox.style.width=webChattr.width;
		webChattr.chattrBox.style.height=webChattr.height;
		webChattr.chattrBox.style.border="0px";
		webChattr.chattrBox.style.padding="0px";
		webChattr.chattrBox.style.margin="0px";
		webChattr.chattrBox.style.display="none";
	
		webChattr.startLink = document.createElement("a");
		webChattr.startLink.href = "javascript:webChattr.startChat()";
		webChattr.startLink.innerHTML = "";
		webChattr.startLink.style.display = webChattr.hideOptIn?"none":"block";
		webChattr.startLink.style.fontSize = "16px";
		webChattr.startLink.style.textAlign = "center";
		webChattr.startLink.style.width = webChattr.width;
		webChattr.startLink.style.height = "41px";
		webChattr.startLink.style.background = "url('http://apitools.webchattr.com/syndication/glue/open.png') top center no-repeat";
	
		webChattr.closeLink = webChattr.startLink.cloneNode(true);
		webChattr.closeLink.style.background = "url('http://apitools.webchattr.com/syndication/glue/close.png') top center no-repeat";
		webChattr.closeLink.style.display = "none";
		webChattr.closeLink.href = "javascript:webChattr.closeChat()";
	
		if (!webChattr.inlineBox) {
			mModule = document.createElement("div");
			mModule.className = "xg_module";
			if (!webChattr.noChatHeader) {
				mHead = document.createElement("div");
				mHead.className = "xg_module_head";
				mHeadText = document.createElement("h2");
				mHeadText.innerHTML = "Chat Live " + (webChattr.channel? (" on " + webChattr.channel) : "");
				mHead.appendChild(mHeadText);
			}
		}
	
		if (webChattr.inlineBox) {
			mBody = document.getElementById("webChattrAnchor").parentNode;
		} else {
			mBody = document.createElement("div");	
			mBody.className = "xg_module_body";
		}
		mBody.appendChild(webChattr.startLink);
		mBody.appendChild(webChattr.chattrBox);
		mBody.appendChild(webChattr.closeLink);
	
		if (!webChattr.inlineBox) {
			mModule.insertBefore(mBody,mModule.firstChild);
			if (!webChattr.noChatHeader) {
				mModule.insertBefore(mHead,mModule.firstChild);
			}
			if (!webChattr.putChatAtBottom) {
				colTwo.insertBefore(mModule,colTwo.firstChild);
			} else {
				colTwo.appendChild(mModule);
			}
		}
	}
	if (webChattr.hideOptIn && !webChattr.keepCloseChat) {
		webChattr.startChat(true);
	} else if ((webChattr.hideOptIn || webChattr.isSavedOpen()) && !webChattr.isSavedClosed()) {
		if (webChattr.hideOptIn && !webChattr.isSavedOpen()) {
			webChattr.startChat(true);
		} else {
			webChattr.startChat();
		}
	} else if (webChattr.isSavedClosed() && webChattr.keepCloseChat) {
		webChattr.closeChat();
	}
}