/*
 * Function to clear a text field
 * @param thefield
 *     the field to clear
 */

function cleartext(thefield) {
	if (thefield.defaultValue == thefield.value) {
		thefield.value = "";
	}
}

/*
 * Function to add tags to page
 * @param elem
 *     the input element holding the tag(s)
 * @param parent
 *     the parent node's ID
 */

/*function addTag(elem, parent) {
	var a = document.createElement("a");
	a.href = "/framework/client/csp/tags/listing/";
	a.appendChild(document.createTextNode(elem.value));
	if (document.getElementById(parent).getElementsByTagName('a').length != 0) {
		document.getElementById(parent).appendChild(document.createTextNode(", "));
	}
	document.getElementById(parent).appendChild(a);
	elem.value = "";
}*/

/*
 * Function to open popup window
 * @param el
 *     The link clicked on
 * @param win_width
 *     The window width
 * @param win_height
 *     The window height
*/

function openWin(el, win_width, win_height) {
	var url = el.href
	var win_left = (screen.width - win_width) / 2;
	var win_top = (screen.height - win_height) / 2;
	window.open(url , '', 'width='+win_width+', height='+win_height+', left='+win_left+', top='+win_top+', resizable=1, scrollbars=1');
	return false;
}

//alert(document.cookie);

DOM.getElementTextNS = function(a, tagName, startPoint, index) {
	// A wrapper for DOM.getElementText()
	if (!index) index = 0;
	var node = startPoint.getElementsByTagName(tagName)[index];
	if (DOM.isNode(node)) {
		return DOM.getElementText(node);
	} else {
		return null;
	}
};