// JavaScript Document

// functions to clear text fields on clickof any default text
function clearText(thefield){ if (thefield.defaultValue==thefield.value) thefield.value = "" }
function restoreText(thefield) { if (thefield.value=="") thefield.value = thefield.defaultValue; }


// add onclick to header h1
function goHome() {
	location.href='http://'+location.hostname;
}

function addclicktoh1(){
	h1array = getElementsByClass("blog-title");
	addEvent(h1array[0], 'click', goHome, false);
	h1array[0].setAttribute('title', 'Back to the homepage.');
}




// functions
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}


