﻿
var __Browser = {};


__Browser.Exception = function(_Status, _Message)
{
	this.Status = _Status;
	this.Message = _Message;
}


__Browser.BrowserFunctions = new function()
{
	if(document.all)
	{
		this.BrowserIsIE = true;
		this.BrowserIsFF = false;
	}
	else
	{
		this.BrowserIsIE = false;
		this.BrowserIsFF = true;	
	}
	
	this.GetNodesWithClass = function (_NodeType, _ClassName)
	{
		var _AllDivTags = document.getElementsByTagName(_NodeType);
		var _AllContainers = new Array();

		for(var i=0; i<_AllDivTags.length; i++)
		{
			var _AttValue = "";
			if(_AllDivTags[i].attributes.getNamedItem("class") != null)
			{
				_AttValue = _AllDivTags[i].attributes.getNamedItem("class").value;
			}
			if(_AttValue  == _ClassName)
			{
				_AllContainers[_AllContainers.length] = _AllDivTags[i];		
			}
		}
	
		return _AllContainers;
	}
	
	this.GetChildrenNodesByNodeType = function(_Node, _NodeType)
	{		
		var _Nodes = new Array();
		
		for(var i=0; i<_Node.childNodes.length; i++)
		{
			if(_Node.childNodes[i].nodeName == _NodeType)
			{				
				_Nodes[_Nodes.length] = _Node.childNodes[i];
			}
		}
		return _Nodes;
	}	
	
	this.ReadAttributeValue = function(_Node, _AttributeName)
	{
		var _AttributeValue = "";
		try
		{
			if(_Node.attributes.getNamedItem(_AttributeName) != null)
			{
				_AttributeValue = _Node.attributes.getNamedItem(_AttributeName).value;
			}
		}
		catch(_ex)
		{
			_AttributeValue = "";
		}
		
		return _AttributeValue;
	}
	
	this.AttachEventFunctionToNode = function(_Node, _EventName, _Function)	
	{
		var _Return = new __Browser.Exception(true, "");
		if(this.BrowserIsIE) /* IF IE */
		{		
			try
			{
				eval("_Node.on" + _EventName + " = _Function;");	
			}
			catch(_EX)
			{
				_Return = new __Browser.Exception(false, _EX);			
			}
		}
		else if(this.BrowserIsFF)  /* ELSE FF */
		{		
			try
			{
				_Node.addEventListener(_EventName, _Function, false);
			}
			catch(_EX)
			{
				_Return = new __Browser.Exception(false, _EX);			
			}
		}
		return _Return;
	}

}