
		var lcElements;
		var lcElementValues = new Array();
		var lcElementUrl = new Array();
	var lcFirstLoad = true;
		var lcUpdateStats = true;

		var lcPopupWidth = '500';
	var lcPopupHeight = '600';
	var lcWinLeft = (screen.width - 500) / 2;
	var lcWinTop = (screen.height - 600) / 2;
	
	var rnd = new Date().getTime();
	
		var lcValidRequest = true;
	
var debugIP = false; 
	var __lc_support = true;


	function lcBuildFrame(url) {
		var a = parent.leftFrame;
		if(typeof(a) == 'undefined') {
			document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"><html xmlns="http://www.w3.org/1999/xhtml">	<head>		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />		<title> Untitled Document</title>	</head>	<frameset id="frameset" cols="480,*" frameborder="no" border="0" framespacing="0">		<frame src="'+url+'" name="leftFrame" scrolling="auto" id="leftFrame" />		<frame src="'+document.URL+'?cache=1234567890" name="mainFrame" id="mainFrame" />	</frameset>		<noframes>		<body>			Frames are not supported!		</body>	</noframes></html>');
			document.close();
		} else {
			if(parent.document.getElementById('frameset').cols == '0,*') {
				parent.document.getElementById('frameset').cols="280,*";
			}
		}
	}

	function lcParseElementAttributes() {

		lcElements=document.getElementsByTagName('LC_element');
		if(!lcElements) { lcElements=document.getElementsByTagName('lc_element'); }
		
				var re = /\b(\w+)\s*=\s*['"]([^"]*)['"]\s*/gi; 
				for (var i=0; i<lcElements.length; i++) {
			var lc_frame = false;
			lcElementValues[i] = new Array();
						lcElementValues[i]['baseparent'] = lcElements.item(i).parentNode;
			lcElementValues[i]['attributes'] = new Array();

			var specified = 0;
			for (j=0; j<lcElements.item(i).attributes.length; j++) {
				
								var attribute = lcElements.item(i).attributes.item(j);
				
				if (attribute.nodeValue != null && attribute.specified) {
					lcElementValues[i]['attributes'][attribute.nodeName.toLowerCase()] = unescape(attribute.nodeValue);
					specified++;
				}
				
				if(attribute.nodeName.toLowerCase() == 'lc_frame' && attribute.nodeValue == 'true') {
					lc_frame = true;
				}
			}
						if (specified <= 0 && lcElements.item(i).outerHTML) {
												var result = lcElements.item(i).outerHTML.replace(/<LC_element\s*/gi, '');
								result = result.replace( re, "$1=$2&");
				var attributes = result.split('&');
				for (j=0; j<attributes.length; j++) {
					var values = attributes[j].split('=');
					lcElementValues[i]['attributes'][values[0].toLowerCase()] = unescape(values[1]);
				}
			}
						lcElementUrl[i] = lcGetClickUrl(lcElementValues[i]['attributes']);
			//document.write(lcElementUrl[i]);
			
						var targetSelf = (lcElementValues[i]['attributes']['lc_target'] ? true : lcElementValues[i]['attributes']['LChref'] ? true : false);
						lcElementValues[i]['parent'] = lcCreateAnchor(i,lcElementUrl[i],lcElementValues[i]['baseparent'],targetSelf,lcElementValues[i]['attributes']['lc_class'],lc_frame);
						lcElementValues[i]['mousestate'] = '';
		}	

				var j = lcElements.length;
		for (var i=0; i<j; i++) {
			lcElementValues[i]['baseparent'].removeChild(lcElements.item(0));
		}
	}

	function lcGetClickUrl(elementAttributes) {

		var clickUrl = 'http://chat.livecom.net/chat/window/index.lc?acc=100064&ltID='+lcGetCookie('LCLT')+'&wvID='+lcGetCookie('LCWV')+'&page_url='+escape(document.location)+'&page_referrer='+escape(document.referrer);
		var pagename = '';
		
		for(var attribute in elementAttributes) {
			if(attribute == 'lc_formfields') {
				//var formfields = elementAttributes[attribute];
				//clickUrl += '&lc_formfields='+formfields;
			} else if(attribute != 'offtxt' && attribute != 'ontxt' && attribute != 'lc_pic' && attribute != 'page' && attribute != 'onpic' && attribute != 'acc' && attribute != 'offpic' && attribute != 'lc_type' && attribute !='getitem' && attribute !='get_length' && attribute !='removeAt' && attribute !='remove' && attribute !='insert' && attribute !='forEach' && attribute !='indexOf' && attribute !='dequeue' && attribute !='contains' && attribute !='exists' && attribute !='clone' && attribute !='clear' && attribute !='addRange' && attribute !='add' && attribute !='queue') {
			
				//make sure `attribute` is not a function (produced by ajax/prototyping scripts)
				if( typeof(elementAttributes[attribute]) == 'string' || typeof(elementAttributes[attribute]) == 'integer') {
					clickUrl += '&'+attribute+'='+elementAttributes[attribute];
				}
			}
			
		}

		if(elementAttributes['page'] == '' || elementAttributes['page'] == '-') {
			clickUrl += '&pagename='+escape(document.location);
		} else {
			clickUrl += '&pagename='+elementAttributes['page'];
		}
//alert(clickUrl);
		return clickUrl;

	}

	function lcCreateAnchor(buttonId,targetUrl,parentObj,targetSelf,className,frame) {

		targetSelf = targetSelf || false;
		var anchor = document.createElement('a');
		anchor.id = 'lclink_'+buttonId;
		anchor.href = 'javascript:return(false);';
		anchor.className = className;
		var url = lcGetClickUrl(lcElementValues[buttonId]['attributes']);
				if(!frame) { 
						if(targetSelf) {
					anchor.onclick = function() {
						location.href = url;	
						return false;
					}
			} else {
				anchor.onclick = function() {
					
					if(lcElementValues[buttonId]['attributes']['lc_formfields']) {
						var formfields = lcElementValues[buttonId]['attributes']['lc_formfields'];
						var fields = formfields.split(",");
						for(var i=0; i<fields.length; i++) {
							var v = escape(document.getElementById(fields[i]).value);
							url += '&'+fields[i]+'='+v;	
						}
					}
					
					try {
						if(!lcWindow || lcWindow.closed) {
							var lcWindow = window.open(url,'lc100064','width='+lcPopupWidth+',height='+lcPopupHeight+',top='+lcWinTop+',resizable=YES,scrollbars=1,left='+lcWinLeft+'');
						} else {
							lcWindow.focus();
						}
					} catch(e) {
						var lcWindow = window.open(url,'lc100064','width=500,height=600,top='+lcWinTop+',resizable=YES,scrollbars=1,left='+lcWinLeft+'');
					}
					return false;
				}
			}
		} else {
						anchor.onclick = function () {
				lcBuildFrame(url);
				return false;
			}
		}

				anchor.onmouseover = function() {
			var buttonId = this.id.replace('lclink_','');
			lcElementValues[buttonId]['mousestate'] = 'over';
			var newImage = lcElementValues[buttonId]['attributes']['acc']+'_'+buttonId+'_'+lcElementValues[buttonId]['buttonstate']+lcElementValues[buttonId]['mousestate'];
			var previousImage = lcElementValues[buttonId]['attributes']['acc']+'_'+buttonId+'_'+lcElementValues[buttonId]['buttonstate'];
			
			if(newImage != previousImage) {
				var image = document.getElementById(newImage);
				var displayImage = document.getElementById('display_'+lcElementValues[buttonId]['attributes']['acc']+'_'+buttonId);
				if(displayImage && image) {
					displayImage.src = image.src;
				}
				image = null;
				displayImage = null;
			}
		}

				anchor.onmouseout = function() {
			var buttonId = this.id.replace('lclink_','');
			
			var newImage = lcElementValues[buttonId]['attributes']['acc']+'_'+buttonId+'_'+lcElementValues[buttonId]['buttonstate'];
			var previousImage = lcElementValues[buttonId]['attributes']['acc']+'_'+buttonId+'_'+lcElementValues[buttonId]['buttonstate']+lcElementValues[buttonId]['mousestate'];

			if(newImage != previousImage) {
				var image = document.getElementById(newImage);
				var displayImage = document.getElementById('display_'+lcElementValues[buttonId]['attributes']['acc']+'_'+buttonId);
				if(displayImage && image) {
					displayImage.src = image.src;
				}
			}
			lcElementValues[buttonId]['mousestate'] = '';

			image = null;
			displayImage = null;
		}
		
		return parentObj.appendChild(anchor);
		
	}
	
	function lcDisplayButton(buttonId) {
		var acc = lcElementValues[buttonId]['attributes']['acc'];
		var previousImage = acc+'_'+buttonId+'_'+lcElementValues[buttonId]['previousbuttonstate']+lcElementValues[buttonId]['previousmousestate'];
		var newImage = acc+'_'+buttonId+'_'+lcElementValues[buttonId]['buttonstate']+lcElementValues[buttonId]['previousmousestate'];
		if(previousImage != newImage) {
						var image = document.getElementById(newImage);
			
						var displayImage = document.getElementById('display_'+acc+'_'+buttonId);
			if(!displayImage && image) {
				displayImage = document.createElement('img');
				displayImage.id = 'display_'+acc+'_'+buttonId;
				displayImage.src = image.src;
				displayImage.alt = (lcElementValues[buttonId]['attributes']['alt'] ? lcElementValues[buttonId]['attributes']['alt'] : '');
				displayImage.title = (lcElementValues[buttonId]['attributes']['title'] ? lcElementValues[buttonId]['attributes']['title'] : '');
				displayImage.border = (lcElementValues[buttonId]['attributes']['border'] ? lcElementValues[buttonId]['attributes']['border'] : '0');
				var parentObj = document.getElementById('lclink_'+buttonId);
				if(parentObj) {
					parentObj.appendChild(displayImage);
				}
			} else if(image && image.src) {
				displayImage.src = image.src;
			}
			
			image = null;
			displayImage = null;
		}
	}

	
	function lcSetCookie(pf,cookieValue,sec) {

		var cookieName = pf+"_100064";
		var today = new Date();
		var expire = new Date();

		if (sec==null || sec==0) {
			sec=50;
		}
		expire.setTime(today.getTime() + 1000*sec);
		document.cookie = cookieName+"="+cookieValue + ";expires="+expire.toGMTString()+";path=/;";
	}

	

	function lcCookiesEnabled() {
		var tmpcookie = new Date();
		chkcookie = (tmpcookie.getTime() + '');
		document.cookie = "chkcookie=" + chkcookie + "; path=/";
		if (document.cookie.indexOf(chkcookie,0) < 0) {
			return(false);
		} else {
			return(true);
		}
	}

		
	function lcGetCookie(pf) {

		var dc = document.cookie;
		var prefix = pf+"_100064=";
		var begin = dc.indexOf("; " + prefix);

		if(lcCookiesEnabled()) {
			if (begin == -1) {
				begin = dc.indexOf(prefix);
				if (begin != 0) {
					if (pf == "LCLT") {
						lcSetCookie('LCLT','LT-2924207-20100730-044252',3600*24*365);
						return 'LT-2924207-20100730-044252';
					} else {
						lcSetCookie('LCWV','LCWV-9690583-20100730-044252',1800);
						return 'LCWV-9690583-20100730-044252';
					}
				}
			} else {
				begin += 2;
			}
			var end = document.cookie.indexOf(";", begin);
			if (end == -1) {
				end = dc.length;
			}
			return unescape(dc.substring(begin + prefix.length, end));
		} else {
						return pf+"-f77ed075a0c32372311be960285c05b9";
		}
	}

	
	function lcStartLoop() {
		lcLoadButtons();
		lcFirstLoad=false;
		if(lcValidRequest) setTimeout('lcStartLoop()', 45000);
	}

	
	function lcLoadButtons() {
		var scriptUrl=lcComposeButtonUrl();
		if(scriptUrl) {
			var head = document.getElementsByTagName('head').item(0);
			if (!head) {
				var head = document.createElement('head');
				var html = document.getElementsByTagName('html').item(0);
				if (html.hasChildNodes()) {
					html.insertBefore( html.firstChild, head );
				} else {
					html.appendChild( head );
				}
				html = null;
			}
	
			var script = document.getElementById('lcscript');
			if (script) {
				script.parentNode.removeChild(script);
			}
	
			var script = document.createElement('script');
			script.type = 'text/javascript';
			script.id = 'lcscript';
			
			script.src = scriptUrl;
			head.appendChild( script );
	
			lcUpdateStats = false;
			
			head = null;
			script = null;
		}
	}

	
	function lcComposeButtonUrl() {
		
				var buttonUrl = 'http://chat.livecom.net/chat/buttons/buttonloader.js?cache='+rnd+'&us='+lcUpdateStats;
		var cnt = 0;
		for(var i=0; i<lcElementValues.length; i++) {
			if (lcElementValues[i]['attributes']['lc_pic']) {
								
				if (lcFirstLoad) {
										var img = document.createElement('img');
					img.src = unescape(lcElementValues[i]['attributes']['lc_pic']);
					img.border = '0';
					lcElementValues[i]['parent'].appendChild(img);
					img = null;
				}
			} else if (lcElementValues[i]['attributes']['lc_txt']) {
								if (lcFirstLoad) { lcElementValues[i]['parent'].innerHTML=lcElementValues[i]['attributes']['lc_txt']; }
			} else {
				cnt++;
				for(var attribute in lcElementValues[i]['attributes']) {
					
										var attributeValue = lcElementValues[i]['attributes'][attribute];
					
					switch(attribute) {
						case 'acc':
							buttonUrl += '&acc'+i+'='+attributeValue;
							break;
						case 'group':
							buttonUrl += '&group'+i+'='+attributeValue;
							break;
						case 'onpic':
							buttonUrl += '&onpic'+i+'='+attributeValue;
							break;
						case 'offpic':
							buttonUrl += '&offpic'+i+'='+attributeValue;
							break;
						case 'lc_pic':
							//buttonUrl += '&lc_pic'+i+'='+attributeValue;
							//break;
						case 'lc_type':
							buttonUrl += '&lc_type'+i+'='+attributeValue;
							break;
						case 'lc_frame':
							if(attributeValue == 'true') {
								buttonURL += '&lc_frame'+i+'=true';
							}
						default:
							break;
					}
					
				}
			}

		}
				buttonUrl += '&count='+cnt;
		return buttonUrl;

	}
	
	
	function lcPreloadImage(id,imageUrl,parentObj) {	
		var button = document.getElementById(id);
		if(!button) {
			button = document.createElement('img');
			button.id = id;
			button.src = imageUrl + '?c='+rnd;
			button.style.display = 'none';
			button.border = '0';
			parentObj.appendChild(button);
		}
	}	
	
lcParseElementAttributes();
lcStartLoop();


