function fa_set_state(day, color) {
	day.style.color=color;
}

// Get text in element
function get_text(el) {
	var text = "";
	
	if (el != null) {
		if (el.childNodes) {
			for (var i = 0; i < el.childNodes.length; i++) {
				var childNode = el.childNodes[i];
				
				if (typeof childNode.textContent != 'undefined' && childNode.textContent != null) {
					text = text + childNode.textContent;
				} else if (typeof childNode.text != 'undefined' && childNode.text != null) {
					text = text + childNode.text;
				} else if (typeof childNode.innerText != 'undefined' && childNode.innerText != null) {
					text = text + childNode.innerText;
				} else if (typeof childNode.nodeValue != 'undefined' && childNode.nodeValue != null) {
					text = text + childNode.nodeValue;
				} else if (typeof childNode.firstChild.nodeValue == 'string') {
					text = text + childNode.firstChild.nodeValue;
				}
			}
		}
	}

	//text.normalize();

	return text;
}

function isArray(a) {
    return isObject(a) && a.constructor == Array;
}

function isBoolean(a) {
    return typeof a == 'boolean';
}

function isEmpty(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}

function isFunction(a) {
    return typeof a == 'function';
}

function isNull(a) {
    return a === null;
}

function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}

function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}

function isString(a) {
    return typeof a == 'string';
}

function isUndefined(a) {
    return typeof a == 'undefined';
} 

// Remove nodes recursive
function deleteNode(elementId){
	var label = document.getElementById(elementId);	
	
	while(label.hasChildNodes()) { 
		label.removeChild(label.lastChild);
	}
}

// Load from xml
function loadData(file, meth, pars, responseTo) {
	// Create request and on succes parse response to response handler
	new Ajax.Request(
			file, 
			{
				method: meth, 
				parameters: pars,
				postData: pars,
				onSuccess: responseTo,
				evalScripts: true
			}
		);
}

// Next 3 functions thanks to http://www.luar.com.hk/blog/?cat=24
// This will solve the Firefox problem with whitespace and XML
function is_ws(nod) {
	return !(/[^\t\n\r ]/.test(nod.data));
}

function findWhiteSpace(node, nodeNo) {
	for (i=0; i<node.childNodes.length; i++) {
		if (node.childNodes[i].nodeType == 3 && is_ws(node.childNodes[i])) {
			nodesToDelete[nodesToDelete.length] = node.childNodes[i]
		}
		if (node.childNodes[i].hasChildNodes()) {
			findWhiteSpace(node.childNodes[i], i);
		}
	}
	node = node.parentNode;
	i = nodeNo;
}

function stripWhiteSpace(node) {
	nodesToDelete = Array();
	findWhiteSpace(node, 0);
	for(i=nodesToDelete.length-1;i>=0;i--) {
		nodeRef = nodesToDelete[i];
		nodeRef.parentNode.removeChild(nodeRef)
	}
}

function submitForm(formId, action) {
	document.forms[formId].action = action;
	document.forms[formId].submit();
}