//Please Modify the $COMMON_DIR$ to the js directory

if(typeof($JS_DIR$)!="string") $JS_DIR$ = "/js/"; 

/*=================================================================================================
// Figure out what browser is being used
=================================================================================================*/
var userAgent = navigator.userAgent.toLowerCase();
browser = 
{
	version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
	safari: /webkit/.test(userAgent),
	opera: /opera/.test(userAgent),
	msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
	mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
};
//The End

/*=================================================================================================
Array's Remove
=================================================================================================*/
Array.prototype.remove= function(rmExp,Opt) 
{
	var vOpt = Opt || false ;
	for(var i=this.length-1;i>-1;i--)
	{
		if(vOpt)
		{
			if(rmExp(this[i])) this.splice(i,1);
		}
		else
		{
			if(this[i]==rmExp) this.splice(i,1);
		}
	}
};
//The End

/*=================================================================================================
contains for all node
check whether the this node contains the node or not
=================================================================================================*/
if(!browser.msie)
HTMLElement.prototype.contains= function(node) 
{
	if(node == null) return false; 
	if(node == this) return true; 
	else return this.contains(node.parentNode); 
};
//The End

/*=================================================================================================
bind for all functions 
change THIS in the function to obj the you want	
=================================================================================================*/
Function.prototype.bind = function(obj) 
{
	var method = this;
	temp = function() { return method.apply(obj,arguments); };
	return temp;
};
//The End

/*=================================================================================================
short cut to the document.getElementById
=================================================================================================*/
if(typeof($)!="function")
$ = function(id)
{
	return document.getElementById(id);
};
//The End

/*=================================================================================================
To encode the HTML,ie < change to &lt; and so on
=================================================================================================*/
function htmlEncode(str)
{
  	var div = document.createElement('div');
   	var text = document.createTextNode(str);
   	div.appendChild(text);
   	return div.innerHTML;
		
}
//The End

function removeAllChild(node)
{
	node = (typeof(node)=="string") ? document.getElementById(node) : node ;
	if(node.hasChildNodes())
	{
		while(node.childNodes.length >= 1)
		{node.removeChild(node.firstChild);} 
	}	
}






