/*
© 2008 Designit Media Corp. All Rights Reserved.
Written By: Daniel J. Dahan

Title: Component List
-------
Notes:
*/
/*
	Button: $btn();
		- Creates new item elements 
		
		Properties
			- item: Holds all list items
			- active: Holds the active link
			- type: Type of list
			- onclick: The onclick function
			- tab: Holds the tab corners
			- group: Holds the group corners
			- on,off,press: Are states of the button element
			- count: Is used to add unique qualities to the session var that handles the active tab
			- img: The path to the image server
			
		Functions
			- open: Creates the list
			- _q: A helper function to generate the list
			- _p: A helper function that sets the parameters of the items
			0 btn: creates the buttons
			
*/
function $btn(o){
	var _={
		item:[],
		active:0,
		onclick:null,
		open:function(o){
			var c=__21(),n='button',m='';
				if((/^group$/i).test(o.type)){
					n+=' group';
					m='last-child';
				}else if((/^tab$/i).test(o.type)){
					n+=' tab';
					m='last-child';
				}
				_.onclick=o.onclick;
				_.item=o.item;
				_._q(c,m);
			_.target.appendChild($('ul',{className:n,append:c}));
			return _;
		},
		_q:function(c,m){
			var e,i=0,l=_.item.length-1;
			for(;i<=l;i++){
				e=_.item[i];
				e.onclick?'':e.onclick=_.onclick;
				c.appendChild($('li',{append:_.btn(e),className:i==l?m:''}));
			}
		},
		btn:function(o){
			var c=__21(),e,m,n,d,k;
				c.appendChild(e=$('div',{id:o.id?o.id:'',innerHTML:o.value?o.value:'Button'}));
				if(o.active){
					e.className='rel active';
					_.active=e;
				}else
					e.className='rel';
				e.appendChild(d=$('div',{className:'btn'}));
				__46(d,'click',function(){_.active.className='rel';e.className='rel active';_.active=e;});
				__46(d,'mousedown',function(){e.className='rel press';});
				__46(d,'mouseup',function(){e.className='rel';});
				if(typeof o.onclick=='function'){
					__46(d,'click',function(){o.onclick(o);});
				}
				return c;
		}
	};
	o=__23(o);
	if(_.target=__17(o.target))
		_.open(o);
	return _;
}