function fill(fill) {
	document.getElementById("text").value += fill;
}

var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}


function showcomments(id, add) {
	document.getElementById("comments_"+id).innerHTML = "Loading... Please wait";

	var getURL = "comments.php?id="+id;
	if (add == true) {
		getURL += "&addcomment=1";
	}
	var iframeName = "comments_frame_"+id;

	xmlhttp.open("GET", getURL, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			document.getElementById("comments_"+id).innerHTML = "<div class=\"minus\" onclick=\"hide('"+id+"')\">—</div>";
			document.getElementById("comments_"+id).innerHTML += (xmlhttp.responseText);
		}
	}
	xmlhttp.send(null)
}

function hide(id) {
	document.getElementById("comments_"+id).innerHTML = "";
}

function submitform(form) {
	/*
	This function is to fix a bug in Opera. Hopefully by their next version
	release they will have it fixed.
	*/
	var hiddenform = document.getElementById('hiddenform');
	hiddenform.name.value = document.getElementById(form + "_name").value;
	hiddenform.email.value = document.getElementById(form + "_email").value;
	hiddenform.text.value = document.getElementById(form + "_text").value;
	hiddenform.blog_id.value = document.getElementById(form + "_blog_id").value;
	hiddenform.submit();
}

function noIE() {
	var agt=navigator.userAgent.toLowerCase();
	if ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) {
		alert("Wow.... you're using Internet Explorer to view my website???");
		alert("Do you think I should let you get away with that?");
		alert("You know, there is a huge security hole in IE that Microsoft hasn't fixed for over 6 months now...");
		alert("Do you feel safe?");
		alert("I could take advantage of that vulnerability right now");
		alert("And bring your computer to its knees");
		alert("Poof! You have a virus!");
		alert("HAHAHA just kidding");
		alert("But I have a solution to your problem");
		alert("You can use another browser instead of Internet Explorer. I recommend the Opera web browser");

		var where_to= confirm("Do you want to download Opera and secure your computer?");
		if (where_to == true) {
			window.location="http://www.opera.com/";
		}
		else {
			alert("Seriously? You would rather use a BROKEN browser? You're strange.");
		}
	}
}


function formatText(tagstart,tagend) {
	el = document.getElementById('text');
	if (el.setSelectionRange) {
		start = el.selectionStart + tagstart.length;
		end = start + el.selectionEnd - el.selectionStart;
		el.value = el.value.substring(0,el.selectionStart) + tagstart + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
		el.focus();

		el.selectionStart = start;
		el.selectionEnd = end;
	}
	else {
  // IE code here...
  // Ha-Ha! IE isn't allowed access...
	}
}
function setInfo(string) {
	document.getElementById('desc').value = string;
}
function c(color) {
	formatText('[color=#'+color+']','[/color]');
	disableColorChange();
}
function ci(color) {
	var thestring = "Color Chooser :: Hex Value: #"+color;
	setInfo(thestring);
	if (document.getElementById('colorchange').value == "true") {
		document.getElementById('currentcolor').style.backgroundColor = '#'+color;
	}
}
function disableColorChange() {
	document.getElementById('colorchange').value = "false";
}
function enableColorChange() {
	document.getElementById('colorchange').value = "true";
}
