//Đối tượng Container để chứa các đối tượng khác
function Container()
{
	this.Objects = new BinhBK_Objects();
	this.DOM = new BinhBK_DOM();
}
//Đối tượng BinhBK_Objects dùng để lưu trữ các Object
function BinhBK_Objects()
{
	this.Items = new Array();
	this.nextIndex = 1;
	this.Length = 0;
}
BinhBK_Objects.prototype.Save = function(name,value)
{
	for (var i=0;i<this.Items.length;i++)
	{
		if (this.Items[i][0] == name)
		{
			this.Items[i][1] = value;
			alert(this.Items[i][1].Titles.length);
		}
	}
}
BinhBK_Objects.prototype.Add = function(obj)
{
	this.Items[this.Items.length] = ["object #"+this.nextIndex,obj];
	this.nextIndex++;
	this.Length = this.Items.length;
	return "object #"+(this.nextIndex-1)
}
BinhBK_Objects.prototype.Remove = function(obj)
{
	var tempArr = new Array();
	for (var i=0;i<this.Items.length;i++)
	{
		if (this.Items[i] != obj)
			tempArr[tempArr.length] = this.Items[i];
	}
	this.Items = tempArr;
	this.Length = this.Items.length;
}
BinhBK_Objects.prototype.GetObject = function(objName)
{
	for (var i=0;i<this.Items.length;i++)
	{
		if (this.Items[i][0] == objName)
		{
			return this.Items[i][1];
		}
	}
	return null;
}
//---- End BinhBK_Objects ----//

//---- Đối tượng phục vụ cho DOM ----//
function BinhBK_DOM()
{
	
}
//Phương thức để tạo nhanh một đối tượng HTML
BinhBK_DOM.prototype.createElement = function(doc,tagName,name,id,type,value)
{
	var input = doc.createElement(tagName);
	input.setAttribute("type",type);
	input.setAttribute("name",name);
	input.setAttribute("id",id);
	input.setAttribute("value",value);
	return input;
}
//Phương thức dùng để cài đặt class cho element
BinhBK_DOM.prototype.SetClass = function(elem,className)
{
	if (navigator.appName == "Microsoft Internet Explorer")
		elem.setAttribute("className",className);
	else
		elem.setAttribute("class",className);
}
//Phương thức dùng để thêm class cho Element
BinhBK_DOM.prototype.AddClass = function(elem,className)
{
	var oldClass = "";
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		oldClass = elem.getAttribute("className");
		elem.setAttribute("className",oldClass+" "+className);
	}
	else
	{
		oldClass = elem.getAttribute("class");
		elem.setAttribute("class",oldClass+" "+className);
	}
}
//Phương thức dùng để lấy ClassName của element
BinhBK_DOM.prototype.GetClass = function(elem,className)
{
	if (navigator.appName == "Microsoft Internet Explorer")
		return elem.getAttribute("className");
	else
		return elem.getAttribute("class");
}
//Phương thức dùng để thêm listener cho đối tượng
BinhBK_DOM.prototype.AddEventListener = function(elem,eventStr,callBackMethod)
{
	if (elem.addEventListener) {
		elem.addEventListener(eventStr, callBackMethod, true);
	} else {
		elem.attachEvent("on"+eventStr, callBackMethod);
	}
}
BinhBK_DOM.prototype.RemoveEventListener = function(elem,eventStr,callBackMethod)
{
	if (elem.removeEventListener) {
		elem.removeEventListener(eventStr, callBackMethod, true);
	} else {
		elem.detachEvent("on"+eventStr, callBackMethod);
	}
}
BinhBK_DOM.prototype.IsIE = function()
{
	if (navigator.appName == "Microsoft Internet Explorer")
		return true;
	else
		return false;
}
// modifier by day
BinhBK_DOM.prototype.GetCurrentElementFireEvent = function (evt)
{
	// valid if firefox is evt or event of IE
	evt = (evt) ? evt : event; 
	// get object link with event of IE or FireFox 
	// currentTarget is property of DOM Event
   	var target = (evt.target) ? evt.target : ((evt.currentTarget) ? evt.currentTarget : evt.srcElement);
	return target;
}

BinhBK_DOM.prototype.SetVisible  = function  ( elem, value ) {
	if(value == 0)	elem.style.display = "none";
	else if(value == 1) elem.style.display = "block";
}

BinhBK_DOM.prototype.SetVisibleRow = function ( elem, value ) {
	if(value == 0) {
		elem.style.display = "none";
	}
	else if(value == 1) {
		
		if(Container.DOM.IsIE())
			elem.style.display = "block";
		else
			elem.style.display = "table-row";
	}
}	

BinhBK_DOM.prototype.SetAnchorCollectionsStyle = function (curLink, regexStr, arrayLinkElements, activeLinkStyle, linkStyle) {
	re = regexStr;
	var linkNo = 1;
	if(re.test(curLink)) {
		linkNo = RegExp.$1;
	}	
	//var arrElem = document.getElementsByName ("faqLink");
	for(var i=0; i<arrayLinkElements.length; i++)
	{
		if(linkNo == arrayLinkElements[i].title)  
			arrayLinkElements[i].className = activeLinkStyle;
		else 
			arrayLinkElements[i].className = linkStyle;
	}
}
BinhBK_DOM.prototype.getPosition = function(el)
{
	xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return {Left:xPos,Top:yPos};
}
//---- Kết thúc đối tượng phục vụ cho DOM ----//
Container = new Container();

