/**
 *	Created with MAX's HTML Beauty++ 2004
 *	domHelper.js
 *	@author Jordi Cuadros
 *	@date December 15 2004
*/

var isMac=(navigator.userAgent.toLowerCase().indexOf('mac')!=-1);
var isNotMozilla=(navigator.userAgent.toLowerCase().indexOf('mozilla')==-1 || 
		navigator.userAgent.toLowerCase().indexOf('compatible')!=-1 ||
		navigator.userAgent.toLowerCase().indexOf('safari')!=-1)

/**
 * Removes all html tags from a given string
 *
 * @param	given	a string containing html tags
 * @return	IDname	a string with all the html tags removed
 */
function removeTags(given){
	var IDname = "";

	if(given.indexOf('-') != -1)
		given = given.substring(0, given.indexOf('-'));
	else if(given.indexOf('+') != -1)
		given = given.substring(0, given.indexOf('+'));
	
	while(given.length >= 0){
		if(given.indexOf('<') != -1){
			indexBegin = 0;			
			indexEnd = given.indexOf('<');
			IDname += given.substring(indexBegin, indexEnd);		
			given = given.substring(given.indexOf('>')+1, given.length);
		}else break;	
	}
	
	IDname+=given;	
	return IDname;	
}

/**
* Sets the inner HTML in a node selected by Id
*
* @param	id	id of the recipient node
*			html	HTML text
*/
function setInnerHTMLById(id,html) {
	if (!isMac || !isNotMozilla) {
		document.getElementById(id).innerHTML=html;
	} else {
		removeChildren(document.getElementById(id));
		document.getElementById(id).appendChild(document.createTextNode(removeTags(html)));
	}
}


/**
* Remove all the children of a node object
*
* @param	node	node object
*/
function removeChildren(node) {
	while (node.childNodes.length!=0) {
		node.removeChild(node.childNodes[0]);
	}
}
