function checkem (id, checked) {
	var el = document.getElementById(id);
	for (var i = 0; i < el.elements.length; i++) {
	  el.elements[i].checked = checked;
	}
}

var ua = navigator.userAgent.toLowerCase();
var browser,version,data;
function detect(text) {
stringposition = ua.indexOf(text) + 1;
data = text;
return stringposition;
}

function add_smiley(smiley) {
var range = document.msgform.message_text;
var startPos = range.selectionStart;
var endPos = range.selectionEnd;
var before = range.value.substring( 0 , startPos );
var after = range.value.substring( endPos , 10000 );
var word = range.value.substring( startPos, endPos );

if (browser == 'Internet Explorer' && version >= 4) {
var str = document.selection.createRange().text;
range.focus();
var sel = document.selection.createRange();
sel.text =  str;
} else if (browser == 'Netscape Navigator' && version >= 5) { 
var str = '' + before + word + smiley + after + '';
range.value = str;
} else if (browser == 'Opera' && version >= 8) {
var str = '' + before + word + smiley + after + '';
range.value = str;
} else if (browser == 'Firefox' && version >= 0 ) {
var str = '' + before + word + smiley  + after + '';
range.value = str;
} else {
document.msgform.message_text.value += smiley;
alert('Sorry, Smilies will not work in ' + browser + ' ' + version + '.\nTested and Supported browsers are:\n\nInternet Explorer 6\nNetsacpe Navigator 7.2\nFireFox 0.10.1\nOpera 8\n\nTo manually add tags use the format:\n\n<' + tag + '> your text here </' + tag + '>');
}
document.msgform.message.focus();
}

//http://www.experts-exchange.com/Web/Q_21619018.html
function setCaretToEnd (control) {
        var length = control.value.length;
        if (control.createTextRange) {
            var range = control.createTextRange();
            range.collapse(false);
            range.select();
        }
        else if (control.setSelectionRange) {
            control.focus();
            control.setSelectionRange(length, length);
        }
        control.scrollTop = length ;
}

var quotes = [

"PC Load Letter? What the fuck does that mean?",
"Moo!",
"All your base are belong to us.",
"Of all the things I lost, I miss my mind the most...",
"Needs more cowbell.",
"Welcome to Good Burger, home of the Good Burger, can I take your order?",
"42",
"Now this is a story all about how my life got flipped, turned upside down, and I'd like to take a minute, just sit right there, I'll tell you how I became the prince of a town called Bel-Air.\n\n In West Philadelphia born and raised, on the playground is where I spent most of my days. Chillin' out, maxin', relaxin' all cool, and all shooting some b-ball outside of the school when a couple of guys who were up to no good started making trouble in my neighborhood. I got in one little fight and my mom got scared and said \"you're moving with your auntie and uncle in Bel-Air\".\n\n I begged and pleaded with her the other day, but she packed my suitcase and sent me on my way. She gave me a kissin' and she gave me my ticket, I put my walkman on and said I might as well kick it. \n\n First class, yo this is bad. Drinking orange juice out of a champagne glass. Is this what the people of Bel-Air livin' like? Hmm this might be alright!\n\nI whistled for a cab and when it came near the license plate said \"Fresh\" and had dice in the mirror. If anything I could say that this cab was rare, but I thought \"Nah, forget it, yo homes to Bel-Air!\"\n\nI pulled up to a house about seven or eight and I yelled to the cabby \"Yo, homes smell you later\". Looked at my kingdom, I was finally there, to sit on my throne as the prince of Bel-Air.",
"You would, wouldn't you?", "THERE'S A WHALE IN THE FISH NET!", "Quit pokin' me!",
"User Axed: FireCrotch", "User Axed: Mizua", "User Axed: Joe", "User Axed: Metal Gear", "User Axed: Jial Silverthorn", "User Axed: HiFiSi", "You have been banned from this site.", "Cheater!"

 ];

function getQuote()
{
var qs = document.getElementById("quote");
var quote = quotes[Math.floor(Math.random() * quotes.length)];

alert(quote);
}


var cheatCode = '3838404037393739666513';
var cheat = '';

document.onkeyup = function keyPress(event) {
if ( typeof event == "undefined" ) event = window.event
wkey = event.keyCode
if ( document.layers ) wkey = event.which
cheat = cheat + wkey;
if ( cheat.match(cheatCode) == cheatCode ) {
	alert('April Fools!');
	document.getElementById('userbar').innerHTML = document.getElementById('userbar').innerHTML + ' | <button onClick="getQuote()">PIE!</button>';
	cheat = ''
	}
}

function leavechat() {
		var url = 'http://www.randominsanityonline.com/boards/ajax.php?leavechat=1';
		var chatAjax = new Ajax.Request(url, {
		method: 'get',
		});
}

