/**
*JAsafelloX - (Helpers) Version 0.1.0.0
*(Just Another Simple Ajax Framework Enviroment Linving Lost : X)
*
*/
function DocumentHelper()
{
	this.setInnerHTML=function(parentId,content)
	{
		document.getElementById(parentId).innerHTML=content;
	}

	this.appendInnerHTML=function(parentId,content)
	{
		document.getElementById(parentId).innerHTML+=content;
	}

	this.setTextNode=function(parentId,content)
	{
		var node=document.createTextNode(content);
		var element=document.getElementById(parentId);
		while (element.hasChildNodes())
  		element.removeChild(element.firstChild);
		element.appendChild(node);
	}
	this.appendTextNode=function(parentId,content)
	{
		var node=document.createTextNode(content);
		var element=document.getElementById(parentId);
		element.appendChild(node);
	}

	this.changeImage=function(imageId,imageUrl)
	{
		document.getElementById(imageId).setAttribute("src",imageUrl);
	}
}


function DOMHelper()
{
	this.getTagValue=function(nodeRoot,tagName,index)
	{
		if(index==null)
			index=0;
		var message = nodeRoot.getElementsByTagName(tagName)[index];
		return message.childNodes[0].nodeValue;
		/*result=null;
		if(index==null)
			index=0;
		result= nodeRoot.getElementsByTagName(tagName)[index].firstChild.nodeValue;
		if(result!=null)
			return result;
		if (result==null)
		{
			if (result.childNodes.length > 1)
			{return result.childNodes[1].nodeValue;}
			else
			{return result.firstChild.nodeValue;}
		}
		else
		{return "Value not Found";}
		return result;*/
		/*var result = "";
		prefix="";
		if(index==null)index=0;
    if (prefix && isExploter) {
        // IE/Windows way of handling namespaces
        result = nodeRoot.getElementsByTagName(prefix + ":" + tagName)[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 = nodeRoot.getElementsByTagName(tagName)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        } else {
            return result.firstChild.nodeValue;
        }
    } else {
        return "n/a";
    }*/
	}

	this.getNode=function (nodeRoot,nodeName,index)
	{
		if(index==null)index=0;
		prefix="";
		if (prefix && isExploter) {
        result = nodeRoot.getElementsByTagName(prefix + ":" + nodeName)[index];
    } else {
        result = nodeRoot.getElementsByTagName(nodeName)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes
        if (result.childNodes.length > 1)
        {return result.childNodes[1];}
        else
        {return result.firstChild;}
    }
    else
    {return null;}
		//return nodeRoot.getElementsByTagName(nodeName);
	}

	this.getNodeName=function(node)
	{
		return node.nodeName;
	}

	this.getNodeLength=function(node)
	{return node.lenght}
}
