/*
//	Adam's Common JavaScript Library :: Common Library Features
//	Copyright (c) 2010-2011 - Adam Rehn
*/

//Simplify document.getElementById() the same way jQuery does
function $(id)
{
	return document.getElementById(id);
}

//Simplify checking that a variable is defined and not null
function valid(variable)
{
	if (variable && typeof(variable) != 'undefined')
		return true;
	else
		return false;
}

//Function to check if we are using IE
//Adapted from code from here: <http://obvcode.blogspot.com/2007/11/easiest-way-to-check-ie-version-with.html>
function isIE()
{
	if (navigator.appVersion.indexOf("MSIE") != -1)
		return true;
	else
		return false;
}

//Function to enable indexOf in Internet Explorer
//From <http://soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/>
if(!Array.indexOf)
{
	Array.prototype.indexOf = function(obj)
	{
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}

//An array that holds the events to run on window load
var onloadFunctions = Array();

//Attach events on window load
window.onload = function()
{
	for (func in onloadFunctions)
	{
		if (typeof(onloadFunctions[func]) == 'function')
		{
			onloadFunctions[func]();
		}
	}
}

