function $(id) {

	return document.getElementById(id);

}

function ajax() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}
	return ro;
}

function showMenu(theid) {
	
	if(fadepos[theid] == "") {
	
		fadepos[theid] = 0;
	
	}
	
	clearTimeout(navdelay[theid]);
	$("menu_" + theid).className = 'show';
	
}

function hideMenu(theid) {
	$("menu_" + theid).className = 'semishow';
	navdelay[theid] = setTimeout("hideDelay('" + theid + "')", 10);
}

function hideDelay(theid) {
	
	$("menu_" + theid).className = 'hide';	

	fadepos[theid] = 0;
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
	
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function photoBox(cattype, catid, cattitle, hideupload, loc) {
	

	var xmlfile = '/includes/imagexml.php?cache=' + Math.random(99999999999999);

	if(loc != "footer") {

		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="514" height="160"> <PARAM name="movie" value="/flash/photobox.swf?xmlfile=' + xmlfile + '&contype=' + cattype + '&conid=' + catid + '&contitle=' + cattitle + '&cachebreak=' + Math.random(99999999999999) + '&hideUpload=' + hideupload + '"> <PARAM name="quality" value="high"> <PARAM name="wmode" value="transparent"> <EMBED src="/flash/photobox.swf?xmlfile=' + xmlfile + '&contype=' + cattype + '&conid=' + catid + '&contitle=' + cattitle + '&cachebreak=' + Math.random(99999999999999) + '&hideUpload=' + hideupload + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="514" height="160" wmode="transparent"></embed></OBJECT>');
		
	} else {
	
		$('photobox').innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="514" height="160"> <PARAM name="movie" value="/flash/photobox.swf?xmlfile=' + xmlfile + '&contype=' + cattype + '&conid=' + catid + '&contitle=' + cattitle + '&cachebreak=' + Math.random(99999999999999) + '&hideUpload=' + hideupload + '"> <PARAM name="quality" value="high"> <PARAM name="wmode" value="transparent"> <EMBED src="/flash/photobox.swf?xmlfile=' + xmlfile + '&contype=' + cattype + '&conid=' + catid + '&contitle=' + cattitle + '&cachebreak=' + Math.random(99999999999999) + '&hideUpload=' + hideupload + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="514" height="160" wmode="transparent"></embed></OBJECT>';
	
	}

}

function writeCal(m,w,y,d) {
		
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="210" height="280"> <PARAM name="movie" value="/flash/calendar.swf?monthtext=' + m + '&weekdaytxt=' + w + '&yeartxt=' + y + '&daytxt=' + d + '"> <PARAM name="quality" value="high"> <PARAM name="wmode" value="transparent"> <EMBED src="/flash/calendar.swf?monthtext=' + m + '&weekdaytxt=' + w + '&yeartxt=' + y + '&daytxt=' + d + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="210" height="280" wmode="transparent"></embed></OBJECT>');

}

function showPB() {

	if($('pb') != undefined) {
		$('pb').style.height = "160px";
		$('moar').style.display = "block";
	}

}

function selected(itemid) {

	if(document.all) {
		itemid.setAttribute("className", "selected");
	} else {
		itemid.setAttribute("class", "selected");
	}

}

function deselected(itemid) {

	if(document.all) {
		itemid.setAttribute("className", "");
	} else {
		itemid.setAttribute("class", "");
	}

}

function mySpaceShare(T, C, U, L) {
    var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(T)
    + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
    window.open(targetUrl);
}

function upload() {

	

}

function uploaded() {

	$('format_image').style.display = "block";

}

function cropImage() {

	/*
	
		Capture all variables associated
		
	*/
	
	var image = $('yui_img').src;
	
	var croptop = $('croptop').value;
	
	var cropleft = $('cropleft').value;
	
	var cropheight = $('cropheight').value;
	
	var cropwidth = $('cropwidth').value;
	
	/*
		
		PHP FUNCTION:
		cropImage($img, $w, $h, $sx, $sy, $filename) {
	
		croptop = region.top;
		cropleft = region.left;	
		cropwidth = region.height;
		cropheight = region.width;	
	*/

	var ajx = ajax();
	ajx.open('open', '/includes/ajax.php?action=crop&file=' + image + '&width=' + cropwidth + '&height=' + cropheight + '&top=' + croptop + '&left=' + cropleft + '&random=' + Math.random(9999999999999));
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
		
			$('format_image').style.display = "none";
			$('userimage').src = '/images/photos/profile_' + ajx.responseText + '.jpg?random=' + Math.random(999999999999);
			$('userimagethumb').src = '/images/photos/profile_' + ajx.responseText + '_s.jpg?random=' + Math.random(999999999999);
			$('format_image_hint').style.display = "none";
			$('results').style.display = "none";
			$('uimage').style.display = "block";
		
		}
		
	}
	ajx.send(null);
	
}

function cropImageBand() {

	/*
	
		Capture all variables associated
		
	*/
	
	var image = $('yui_img').src;
	
	var croptop = $('croptop').value;
	
	var cropleft = $('cropleft').value;
	
	var cropheight = $('cropheight').value;
	
	var cropwidth = $('cropwidth').value;
	
	/*
		
		PHP FUNCTION:
		cropImage($img, $w, $h, $sx, $sy, $filename) {
	
		croptop = region.top;
		cropleft = region.left;	
		cropwidth = region.height;
		cropheight = region.width;	
	*/

	var ajx = ajax();
	ajx.open('open', '/includes/ajax.php?action=cropband&file=' + image + '&width=' + cropwidth + '&height=' + cropheight + '&top=' + croptop + '&left=' + cropleft + '&random=' + Math.random(9999999999999), true);
	ajx.onreadystatechange = function() {
		
		if(ajx.readyState == 4) {
		
		
			$('format_image').style.display = "none";
			$('result_image').style.width = "150px";
			$('result_image').style.height = "150px";
			$('result_image').style.top = "0px";
			$('result_image').style.left = "0px";			
			$('result_image').src = '/images/photos/band_' + ajx.responseText + '.jpg?random=' + Math.random(999999999999);
			$('format_image_hint').style.display = "none";
		
		}
		
	}
	ajx.send(null);
	
}


function swapClass(itemid, classNameid) {

	if(document.all) {
		itemid.setAttribute("className", classNameid);
	} else {
		itemid.setAttribute("class", classNameid);
	}
	
}

function imageUploaded(filename, id) {

	$('article_images').innerHTML += '<div align="center" style="width:97px; float:left;" id="imgbox_' + id + '"><div class="imagepreview"><img src="/images/photos/s_' + filename + '" border="0" /></div><div align="center" class="options"><input type="button" onclick="delImage(\'' + id + '\');" value="   DELETE   " /></div></div>';

}

function startShoutback(id) {

	setTimeout("switchQuote('leftballoon','leftballtext', '" + id + "')", 2000);	
	setTimeout("switchQuote('rightballoon','rightballtext', '" + id + "')", 6000);	

}

function switchQuote(id,txtbox,qid) {

	var ajx = ajax(); // pull data for left box
	ajx.open('get', '/includes/ajax.php?action=shoutback&id=' + qid + '&random=' + Math.random(9999999999), true);
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
			
			if(ajx.responseText != "") {
				$(txtbox).innerHTML = ajx.responseText;
				setTimeout("opacity('" + id + "',0,100,900)");
				setTimeout("opacity('" + id + "',100,0,900)", 18000);
			}
			setTimeout("switchQuote('" + id + "','" + txtbox + "','" + qid + "')", 20000);	
			
		}
	
	}
	ajx.send(null);		
	
}

function updateSbox(id) {

	

}

function musicPlayer(mp3) {

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="192" height="67"><param name="movie" value="/flash/playerSingle.swf?autoPlay=yes&soundPath=' + mp3 + '"><param name="quality" value="high"><embed src="/flash/playerSingle.swf?autoPlay=yes&soundPath=' + mp3 + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="192" height="67"></embed></object>');

}

function delImage(id) {

	$('imgbox_' + id).innerHTML = '';
	$('imgbox_' + id).style.display = 'none';	

	var ajx = ajax(); // pull data for left box
	ajx.open('get', '/includes/ajax.php?action=delimage&id=' + id + '&random=' + Math.random(9999999999), true);
	ajx.onreadystatechange = function() {
	
		if(ajx.readyState == 4) {
			
		}
	}
	ajx.send(null);	

}

function expandDiv(id) {

	var divdisp = $(id).style.display;
	
	if(divdisp == "none") {
		$(id).style.display = "block";
	} else {
		$(id).style.display = "none";	
	}

}

function uStream(size) {

	if(size == "large") {
	
		document.write('<div style="float:left;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="320" id="utv112961"><param name="flashvars" value="viewcount=true&amp;autoplay=false&amp;brand=embed"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/live/1/475510"/><embed flashvars="viewcount=true&amp;autoplay=false&amp;brand=embed" width="400" height="320" allowfullscreen="true" allowscriptaccess="always" id="utv112961" name="utv_n_671355" src="http://www.ustream.tv/flash/live/1/475510" type="application/x-shockwave-flash" /></object><a href="http://www.ustream.tv/" style="padding:2px 0px 4px;width:400px;background:#FFFFFF;display:block;color:#000000;font-weight:normal;font-size:10px;text-decoration:underline;text-align:center;" target="_blank">Live streaming video by Ustream</a></div><div style="float:left; padding-left:10px;"><embed width="563" height="320" type="application/x-shockwave-flash" flashvars="channelId=475510&brandId=1&channel=#inthisweek&server=chat1.ustream.tv" pluginspage="http://www.adobe.com/go/getflashplayer" src="http://www.ustream.tv/IrcClient.swf" allowfullscreen="true" /></div>');

	} else {
		
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="130" height="100" id="utv188883"><param name="flashvars" value="autoplay=false&amp;brand=embed"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/live/1/475510"/><embed flashvars="autoplay=false&amp;brand=embed" width="130" height="100" allowfullscreen="true" allowscriptaccess="always" id="utv188883" name="utv_n_576909" src="http://www.ustream.tv/flash/live/1/475510" type="application/x-shockwave-flash" /></object>');
		
	}

}

function youTube(url) {

	document.write('<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/' + url + '&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&ap=%2526fmt%3D18"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + url + '&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>');

}

function writePromo() {

	$('promo').innerHTML = '<object width="300" height="200"><param name="movie" value="http://dev.inthisweek.com/flash/promo.swf"></param><param name="wmode" value="transparent"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://dev.inthisweek.com/flash/promo.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="300" height="200"></embed></object>';

}

function writePromoIE() {

	document.write('<object width="300" height="200"><param name="movie" value="http://dev.inthisweek.com/flash/promo.swf"></param><param name="wmode" value="transparent"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://dev.inthisweek.com/flash/promo.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="300" height="200"></embed></object>');

}


function reportAbuse(type,id) {
	var ajx = ajax();
	ajx.open('open', '/includes/ajax.php?action=reportAbuse&id=' + id + '&type=' + type + '&random=' + Math.random(9999999999999));
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			if(ajx.responseText == "reported") {
				document.getElementById('reportAbuseButton').innerHTML = "<img src='/images/buttons/reported.gif' height='19' width='94' alt='reported' />";
			} else if(ajx.responseText == "login") {
				alert("You must be logged in to report abuse.");
			} else if(ajx.responseText == "alreadyReported") {
				alert("You have already reported this item.  Thank you.");
			} else {
				alert("Could not process report - please try again soon.");
			}
		}
	}
	ajx.send(null);	
}


function deleteItem(type, id, returnURL) {
	if(returnURL == "") {
		returnURL == "/index.php";
	}
	if(type != "" && id != "") {
		if(confirm("Are you sure you want to delete this item?")) {							
			var ajx = ajax();
			ajx.open('get', '/includes/delete.php?type='+type+'&id='+id+'&random=' + Math.random(9999999), true);
			
			ajx.onreadystatechange = function() {
				if(ajx.readyState == 4) {
					if(ajx.responseText == "deleted") {
						window.location = returnURL;
					} else {
						alert('Could not delete file');
					}
				}
			}
			ajx.send(null);
		}
	} else {
		window.location = returnURL;
	}
}


function pushchat(channel) {
	
	var message = $(channel + '_input').value;

	if(message == '') 
		return;
	
	$(channel + '_input').value = '';
	
	var ajx = ajax();
	ajx.open('get', '/includes/ajax.php?action=pushchat&channel='+channel+'&message='+message+'&random=' + Math.random(999999999), true);
	
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			
			pullchat(channel);
			//alert(ajx.responseText);
			
		}
	}
	ajx.send(null);
	
}

var chatpull = "";
var userpull = "";

function pullchat(channel,action) {
	
	$(channel + '_output').scrollTop = $(channel + '_output').scrollHeight;
	
	var ajx = ajax();
	
	if(action == "off") {
		
		ajx.open('get', '/includes/ajax.php?action=offchat&channel='+channel+'&random=' + Math.random(999999999), true);
		
		ajx.onreadystatechange = function() {
			if(ajx.readyState == 4) {

				clearInterval(chatpull);
				clearInterval(userpull);

			}
		}
		ajx.send(null);		
		
	} else if(action == "on") {
	
		ajx.open('get', '/includes/ajax.php?action=onchat&channel='+channel+'&random=' + Math.random(999999999), true);
		
		ajx.onreadystatechange = function() {
			if(ajx.readyState == 4) {

				chatpull = setInterval("pullchat('" + channel + "')", 7000);
				userpull = setInterval("pullUsers()", 7000);

			}
		}
		ajx.send(null);	
	
	
	} else {
	
		ajx.open('get', '/includes/ajax.php?action=pullchat&channel='+channel+'&random=' + Math.random(999999999), true);
		
		ajx.onreadystatechange = function() {
			if(ajx.readyState == 4) {

				
				var rows = ajx.responseText.split("||");
				
				rows.reverse();
				
				for(var i in rows) {
					
	
					var items = rows[i].split("|");
					if(items[2] == undefined) continue;
	
					var response = items[3].replace("\\","\'");
	
					if($('messageid_' + items[0]) == undefined || $('messageid_' + items[0]) == "") {
					
						$(channel + '_output').innerHTML += '<span id="messageid_' + items[0] + '"><b>' + items[2] + ' says:</b> ' + response + '</span><br>';
						
						if($(channel).style.display == "none") {
							
							$('activechat_' + channel).style.fontWeight = "bold";
							$('activechat_' + channel).style.fontStyle = "italic";
							$('activechat_' + channel).style.textDecoration = "underline";
							
						}
					
					}
					$(channel + '_output').scrollTop = $(channel + '_output').scrollHeight;
	
		
				}
				
				
			}
		}
		ajx.send(null);
	
	}
	
}

function oc(a)
{
  var o = {};
  for(var i=0;i<a.length;i++)
  {
    o[a[i]]='';
  }
  return o;
}

function pullUsers() {
	
	var ajx = ajax();

	ajx.open('get', '/includes/ajax.php?action=pullgeneralusers&random=' + Math.random(999999999), true);
		
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			
			// user array
			// username array
			// chat_'userid'
			
			//$().
			
			var users = ajx.responseText.split("||");
			
			for(var i in users) {
			
				// break user row apart
				var usr = users[i].split("|");
				if($('chat_' + usr[0]) == undefined || $('chat' + usr[0]) == "") {
					
					 if(usr[1] == undefined)
					 	continue;
					
					$('generalchatusers').innerHTML += '<div class="friendchat" align="left" id="chat_' + usr[0] +'"><img src="/images/photos/profile_' + usr[0] +'_s.jpg" onerror="this.src=\'/images/inguest.jpg\'" />&nbsp;&nbsp;<span class="usernamechat">' + usr[1] + '</span></div>';
					
				}
			
			}
			
			// purge old users
			
			var usrlist = $('generalchatusers').getElementsByTagName("div");

			for(var i in usrlist) {
				
				if(usrlist[i].id == undefined)
					continue;
				
				var divname = usrlist[i].id;
				
				//working to this point!
				
				//alert(divname.substr(5));
					
				instr = 0;
				
				for(var j in users) {
					
					var usr = users[j].split("|");
					
					//alert(usr[0])
					
					if(divname.substr(5) == usr[0]) {
						// user is valid
						instr++;
						//alert(divname.substr(5) == usr[0]);
						
					}
				}
				
				if(instr < 1) {
				
					$(divname).innerHTML = '';
					$(divname).style.display = 'none';
					$(divname).id = '';
				
				}
				
			}
			//$('generalchatusers').innerHTML = ajx.responseText;
			
		}
	}
	ajx.send(null);

}

function openChat(chatid) {
	
	/*if(chatid != "generalchat") {	
		$('activechat_' + chatid).style.fontWeight = "normal";
		$('activechat_' + chatid).style.fontStyle = "normal";
		$('activechat_' + chatid).style.textDecoration = "none";
	}*/
	
	if($(chatid).style.display == "block") {
		
		hideAllChats();
		
		$(chatid).style.display = "none";
		pullchat(chatid,'off');
		
		if(chatid != "generalchat") {
		
			var ajx = ajax();
			
			ajx.open('get', '/includes/ajax.php?action=hidechat&channel='+chatid+'&random=' + Math.random(999999999), true);
			
			ajx.onreadystatechange = function() {
				if(ajx.readyState == 4) {
	
				}
			}
			ajx.send(null);	
		
		}
		
	} else {
		
		hideAllChats();
		
		$(chatid).style.display = "block";
		pullchat(chatid,'on');
		
		if(chatid != "generalchat") {
		
			var ajx = ajax();
			
			ajx.open('get', '/includes/ajax.php?action=showchat&channel='+chatid+'&random=' + Math.random(999999999), true);
			
			ajx.onreadystatechange = function() {
				if(ajx.readyState == 4) {
	
				}
			}
			ajx.send(null);	
		
		}
	}
	
}

function closeChat(chatid) {

	$('activechat_' + chatid).style.display = "none";
	$('activechat_' + chatid).innerHTML = "";	
	$('activechat_' + chatid).id = "";	
	$(chatid).style.display = "none";
	$(chatid).innerHTML = "";
	$(chatid).id = "";
	
	var ajx = ajax();

	ajx.open('get', '/includes/ajax.php?action=hidechat&id=' + chatid + '&random=' + Math.random(999999999), true);
		
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			
		}
	}
	ajx.send(null);

}

function hideAllChats() {

	var chats = $('conversationbox').getElementsByTagName("div");
	for(var i in chats) {
			
		
		
	}

}

function newchat(chatid, user, status) {

	hideAllChats();

	if($(chatid) == undefined || $(chatid).innerHTML == "") {

		$('generalchat').style.display = "none";
		
		if(status == 1) {
			
			var ajx = ajax();

			ajx.open('get', '/includes/ajax.php?action=openchat&id=' + chatid + '&random=' + Math.random(999999999), true);
				
			ajx.onreadystatechange = function() {
				if(ajx.readyState == 4) {
					// Do nothing
				}
			}
			ajx.send(null);
					
			$('conversationbox').innerHTML += '<a href="javascript:openChat(\'' + chatid + '\');" style="padding-left:20px; padding-right:20px;" id="activechat_' + chatid + '">' + user + '</a>';
			$('conversationbox').innerHTML += '<div class="chatbox" id="' + chatid + '" style="display:block; width:343px;"><div class="hide"><a href="javascript:openChat(\'' + chatid + '\');">Hide Chat</a></div><div class="close"><a href="javascript:closeChat(\'' + chatid + '\');">Close Chat</a></div><div class="chattitle" align="left">' + user + '</div><div id="' + chatid + '_output" class="output" align="left"></div><form action="javascript:pushchat(\'' + chatid + '\');" id="' + chatid + '_form"><input type="text" id="' + chatid + '_input" onKeyPress="checkEnter(event,\'' + chatid + '_form\')" /></form></div>';
	
		}
		
		//showFriends();
		$(chatid + '_input').focus();
		
		setInterval("pullchat('" + chatid + "')", 7000);
	}

}

activechats = new Array();

function checkChat() {

	var ajx = ajax();

	ajx.open('get', '/includes/ajax.php?action=checkchat&random=' + Math.random(999999999), true);
		
	ajx.onreadystatechange = function() {
		if(ajx.readyState == 4) {
			
			if(ajx.responseText != "") {
				
				var chatinfo = ajx.responseText.split("||");
				
				for(var i in chatinfo) {

					chatsplit = chatinfo[i].split("|");
					
					if(chatsplit[1] != undefined) {
							
						existingchat = 0;
						
						for(var j in activechats) {
							
							if(activechats[j] == chatsplit[10])
								existingchat++;
							
						}
						
						if(existingchat < 1) {
						
							newchat(chatsplit[0], chatsplit[1], chatsplit[2]);
							pullchat(chatsplit[0]);
							activechats[chatsplit[0]];
						
						}
					}
				}
				
			}
			
		}
	}
	ajx.send(null);
	
	//setInterval("checkChat()", 7000);

}

function showFriends() {

	if($('friendsbox').style.display == "block") {
		$('friendsbox').style.display = "none";
	} else {
		$('friendsbox').style.display = "block";
	}

}

function checkEnter(e, formname){ 
	var characterCode;
	
	if(e && e.which){ 
		e = e;
		characterCode = e.which ;
	} else {
		e = event;
		characterCode = e.keyCode; 
	}
	
	if(characterCode == 13){ 
		$(formname).submit();
		return false;
	} else{
		return true;
	}

}