function getPathToRoot() {
	if (location.host == 'projects.presencemultimedia.co.uk') {
		return '/ramage/';
	} else {
		return '/';
	}
}

function clearMe(thefield){
	if (thefield.defaultValue==thefield.value) {
		thefield.value = "";
	}
} 

function pop(ShowPage, intwidth, intheight) {

	var leftpos = (screen.width - intwidth) / 2;
	var toppos = (screen.height - intheight) / 2;
	var winprops = 'toolbar=0, scrollbars=1, location=0, statusbars=0, menubar=0, width=' + intwidth + ', height=' + intheight + ', left=' + leftpos + ', top=' + toppos + ', resizable=1';
    var popupwindow = window.open(ShowPage, 'poppage', winprops);

}

function in_array(stringToSearch, arrayToSearch) {
	for (s = 0; s < arrayToSearch.length; s++) {
		thisEntry = arrayToSearch[s].toString();
		if (thisEntry == stringToSearch) {
			return true;
		}
	}
	return false;
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function addEvent(elm, evType, fn, useCapture) {
	// cross-browser event handling for IE5+, NS6 and Mozilla 
	// By Scott Andrew 
	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;
	}
}

function findTarget(e) {
	// cross-browser function to find the event target
	var target;
	if (window.event && window.event.srcElement) {
		// IE does it differently... stores the event in a window.event object
		target = window.event.srcElement;
	}
	if (e && e.target) {
		target = e.target;
	}
	return target;
}

function changeSelect(selectID, paramName) {
	if (document.getElementById(selectID)) {
		var paramValue = document.getElementById(selectID).value;
		document.location.href = '?' + paramName + '=' + paramValue;
	}
}

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 cancelClick(e) {
	if (window.event){
		window.event.cancelBubble = true;
		window.event.returnValue = false;
		return;
	}
	if (e){
		e.stopPropagation();
		e.preventDefault();
	}
}
