function trim(string)
{
 	if (string == null) return null;
 	return string.strip();
}

function getElementTextNS(prefix, local, parentElem, index) {
	try
	{
    var result = "";
    if (prefix && isIE) {
        // IE/Windows way of handling namespaces
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    } else {
        // the namespace versions of this method 
        // (getElementsByTagNameNS()) operate
        // differently in Safari and Mozilla, but both
        // return value with just local name, provided 
        // there aren't conflicts with non-namespace element
        // names
        result = parentElem.getElementsByTagName(local)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes 
        if (result.childNodes.length > 1) {
            return trim(result.childNodes[1].nodeValue);
        } else {
            return trim(result.firstChild.nodeValue);    		
        }
    } else {
        return "";
    }
    }
    catch(e)
    {
    	return "";
    }
}


function NewDiv(className, html) {
	var div = $(document.createElement("div"));
	if (className != null && className != "")
	{
		div.addClassName(className);
	}
	if (html != null)
	{
		div.update(html);
	}
	return div;
}

function NewLink(className, url, target, text) {
	var a = $(document.createElement("a"));
	if (className != null && className != "")
	{
		a.addClassName(className);
	}
	
	if (url != null && url != "")
	{
		a.setAttribute("href", url);
	}
	
	if (target != null && target != "")
	{
		a.setAttribute("target", target);
	}
	
	if (text != null && text != "")
	{
		a.update(text);
	}
	return a;
}

function NewLink(className, url, target, text,track) {
	var a = $(document.createElement("a"));
	if (className != null && className != "")
	{
		a.addClassName(className);
	}
	
	if (url != null && url != "")
	{
		a.setAttribute("href", url);
	}
	
	if (target != null && target != "")
	{
		a.setAttribute("target", target);
	}

	if (track != null && track != "")
	{
		a.setAttribute("onclick", "clickTrack(clickTrakingArray['"+track+"'] , false);");
	}
	
	if (text != null && text != "")
	{
		a.update(text);
	}
	return a;
}

function Append(el, html) {
	new Insertion.Bottom(el, html);
}

function LineBreak(el) {
	if (el != null)
	{
		new Insertion.Bottom(el, "<br/>")
	}
	return el;
}


