function dropshadow() {
// get the text used for the heading
var thetext=document.getElementsByTagName('h1')[0].innerHTML;
// append it to the end of the element
document.getElementsByTagName('h1')[0].innerHTML +=" <div id=\"dropshadow\">"+thetext+"</font>";
}


// note - need document.all for IE6??

///////////// Open Popup Window //////////////////
function openPopup(url) {
 window.open(url, "popup_id", "scrollbars,resizable,width=450,height=680");
 return false;
}


///////////// 2 column text ///////////////

function twoCol() {
	// TODO: not split up tags
	
	// Check for the two-col element.
	if ($('two-col')) {
		// Grab the two-col element and create
		// the two new column elemets. As well
		// as a "clearer" element.
		var twoCol = $('two-col');
		var rightCol = $new('span');
			rightCol.style.width='48%';
			rightCol.style.cssFloat='right';
			rightCol.style.display='block';
			rightCol.style.styleFloat='right';
		var leftCol = $new('span');
			leftCol.style.width='48%';
			leftCol.style.cssFloat='left';
			leftCol.style.display='block';
			leftCol.style.styleFloat='left';
		var clearCol = $new('br');
			clearCol.style.clear='both';
		
		// Split the words into two columns
		var leftWords = new String();
		var rightWords = new String();

		var ogHTML = twoCol.innerHTML;
		
		
			
		var words = ogHTML.split(' ');
		for (var i=0; i<words.length; i++) {
		
			if ( i < (words.length/2) )
				leftWords += words[i] +' ';
			else
				rightWords += words[i] +' ';
		}
		
		// test for exception
		if (ogHTML.match('<!-- split -->'))
		{
		
		var words = ogHTML.split('<!-- split -->', 2);
		
		leftWords=words[0];
		rightWords=words[1];
		
			}
			
		leftCol.innerHTML = leftWords;
		rightCol.innerHTML = rightWords;
		
		twoCol.innerHTML = '';
		twoCol.appendChild(leftCol);
		twoCol.appendChild(rightCol);
		twoCol.appendChild(clearCol);
	}
	return;
}

///////////// end 2 column text ///////////////



// library of functions
// --- Event Handler Functions --- //
// from: http://www.scottandrew.com/weblog/articles/cbs-events
function addEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else
		alert("Handler could not be attached");
}

function removeEvent(obj, evType, fn, useCapture) {
	if (obj.removeEventListener) {
		obj.removeEventListener(evType, fn, useCapture);
		return true;
	}
	else if (obj.detachEvent) {
		var r = obj.detachEvent("on"+evType, fn);
		return r;
	}
	else
		alert("Handler could not be removed");
}


function randomInt(length) {
	if (!length) length = 4;
	return Math.round(Math.random() * Math.pow(10,length));
}

function randomString(length) {
	return randomInt(length).toString();
}

function $(id) {
	return document.getElementById(id);
}

function $tags(name) {
	return document.getElementsByTagName(name);
}

function $new(type, id) {
	var element = document.createElement(type);
	if (id) element.id = id;
	return element;
}

function $text(text) {
	return document.createTextNode(text);
}

// run stuff
addEvent(window, "load", dropshadow);
addEvent(window, "load", twoCol);
