/*
	changeinflux.com, Common JavaScript Functions
	
	Description:
		Contains various JavaScript functions for the site.
	
	Change Log:
		2007-05-08 Created this file.
		2007-07-04 Updated name to id attributes for compliance.
		2007-07-19 Added e-mail display function.
		2007-07-23 Added ability to show/hide element by ID.
		2007-09-08 Added function to embed QuickTime video.
		2009-09-01 Added mail button output.
		2009-09-02 Added AJAX functionality for Twitter update.
*/

function embedQT(poster, movie, width, height) {
	document.write("<embed width=\"" + width +"\" height=\"" + height + "\" controller=\"false\" target=\"myself\" href=\"" + movie + "\" src=\"" + poster + "\" border=\"0\" pluginspage=\"http://www.apple.com/quicktime/download/indext.html\"><\/embed>");
}

function printMail(output) {
	if (output == null) output = "rich [at] changeinflux.com";
	document.write("<a href=mailto:" + "rich" + "@" + "changeinflux.com>" + output + "</a>");
}

function printMailButton() {
	document.write("<a href=mailto:" + "rich" + "@" + "changeinflux.com>" + "<div id=\"contact-me\" title=\"Contact Me\"></div>" + "</a>");
}

function hide(name) {
	document.getElementById(name).style.display = "none";
}

function show(name) {
	document.getElementById(name).style.display = "block";
}

function getTweet() {
	var xmlhttp;
	if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
	else if (window.ActiveXObject) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	else return;
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4) {
			var response = xmlhttp.responseText;
			var update = new Array();
			if(response.indexOf("|" != -1)) {
				update = response.split("|");
				document.getElementById(update[0]).innerHTML = update[1];
			}
		}
	}
	xmlhttp.open("get", "includes/twitter.php", true);
	xmlhttp.send(null);
}