YAHOO = new function()
{
	var _Base= this;
	this._guid = Date.parse(new Date);

	this.getUniqueId = function()
	{
		
		return  _Base._guid++;
	};

	this.getElementUniqueId = function(oNode)
	{
		
		if(oNode.id=='')
		{
			var sid = '__YCguid__' + _Base.getUniqueId();
			while(document.getElementById(sid))
			{
				sid = '__YCguid__' + _Base.getUniqueId();
			};
			oNode.id =  sid;
		}
		else
		{
			return oNode['id'];
		};			
	};



	this.getElementsByClassName = function(sClassName,sTagName,oNode,iMaxLength)
	{
		
		if(!sClassName){return [];};
			sTagName = sTagName || "*";
			oNode = oNode || document;

			var a = [];		
			var els = oNode.getElementsByTagName(sTagName);
			var elsLen = els.length;
			
			var pattern = new RegExp("(^|\\s)"+sClassName+"(\\s|$)");
			for (i = 0, j = 0; i < elsLen; i++)
			{
				if ( pattern.test(els[i].className) ) 
				{
					a[j] = els[i];
					j++;
					if(iMaxLength)
					{
						iMaxLength--;
						if(iMaxLength<=0){return a;};
					};
				}
			};
			return a;
		
	};

	this.getElementsByClass = this.getElementsByClass;

	this.popElementByClass = function(oNode,sClass,iMaxLevel)
	{
		var re = new RegExp('\\b' + sClass + '\\b');
		
		while(oNode)
		{
			
			if(iMaxLevel)
			{
				if( iMaxLevel<0){return null;}	
				else{ iMaxLevel--;};				
			};
			
			
			var c = oNode['className'];
			
			if(c==null ){return null;}
			else if ( re.test(c) ) {return oNode;}		
			else
			{				
				oNode = oNode['parentNode'];
			};			
		};
		return null;
	};



	this.getNextElementByTagName = function(oNode,sTag)
	{
		
		while(oNode['nextSibling'])
		{
			oNode = oNode['nextSibling'];
			var t = oNode.tagName;
			
			if(t && t==sTag.toUpperCase())
			{			
				return oNode;
			};
		};

		return null;
	};

	this.getPreviousElementByTagName = function(oNode,sTag)
	{
		
		while(oNode['previousSibling'])
		{
			oNode = oNode['previousSibling'];
			var t = oNode.tagName;
			
			if(t && t==sTag.toUpperCase())
			{			
				return oNode;
			};
		};

		return null;
	};


	this.addClassName = function(oNode,sClassName)
	{
				var pattern = new RegExp("(^|\\s)"+sClassName+"(\\s|$)");
				
				var c = oNode['className'];
				if(!pattern.test(c))
				{
					oNode['className'] = [c,sClassName].join(' ');
				};
	};

	this.removeClassName = function(oNode,sClassName)
	{
				var pattern = new RegExp("(^|\\s)"+sClassName+"(\\s|$)");
				
				var c = oNode['className'];
				
				if(pattern.test(c))
				{
					oNode['className'] = c.replace( pattern, '');
				};
	};

	this.hasClassName = function(oNode,sClassName)
	{
			var pattern = new RegExp("(^|\\s)"+sClassName+"(\\s|$)");
			return pattern.test(oNode['className'])
	};



	this.getStyle = function(oNode,sProperty)
	{
				
		var el = oNode;
		var property = sProperty;
		var value = null;
		var dv = document.defaultView;			

		if (el.style[property])
		{
			value = el.style[property];    
		}
		else if (el.currentStyle && el.currentStyle[property]) {
			value = el.currentStyle[property];
		}
		else if (el.currentStyle && property.indexOf('-') != -1) /* IE (usually) wants camelCase instead of hyphen */
		{
			property = property.split('-');
			for (var i = 1; i < property.length; ++i)
			{
				property[i] = property[i].toUpperCase().charAt(0) + property[i].substr(1);
			}

			property = property.join('');
			value = el.currentStyle[property];
		}
		else if ( dv && dv.getComputedStyle && dv.getComputedStyle(el, '').getPropertyValue(property) )
		{
			value = dv.getComputedStyle(el, '').getPropertyValue(property);
		};

		return value;
	};


	this.setStyle = function(oNode,sProperty,sValue) 
	{
			var el = oNode;
			var property = sProperty;
			var value = sValue;
			switch(property)
			{
				case 'opacity' :
				
					el.style.filter = 'alpha(opacity=' + value * 100 +')';
					el.style.opacity = value;
					el.style['-moz-opacity'] = value;
					el.style['-khtml-opacity'] = value;
				
				break;
				default :
					el.style[property] = value;
				break;
			}
	};		





};