/* 
Site Name: Editure/Zaltana
Version: 1.1
Author: Adam Hope
Author URI: http://www.steelwork.com.au
Modder: Marc Lee (Adviso Technologies)
Modder URI: http://www.adviso.com.au
Date: 2007-06-21
Description: Core functions that might be useful. 
*/

/*
--- Test to see if the Zaltana library has been loaded
*/

if (!Z){var Z={};};

// Begin Zaltana util library
Z.util = {};

// Zaltana util string functions
Z.util.string = {};

Z.util.string.removeWhiteSpace = function(str) {
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
};

Z.util.formManip = {};

// form manipulation functions taken from miform.js in the old mistyles
Z.Dom = {};

Z.Dom.getParentElementByClass = function(node, sClass)	{
	var regExp =  new RegExp(sClass,'g'); // TODO test this regexp
	while (node) {
		if(regExp.test(node.className)) {
			return node;
		} else {
			node = node.parentNode;
		}
	}
	return;
};

Z.Dom.getAncestorByTagName = function(node, tagName) {
	while (node) {
		if(node.tagName && node.tagName.toLowerCase() == tagName) {
			return node;
		} else {
			node = node.parentNode;
		}
	}
};
