if(typeof com == 'undefined') com = new Object();
if(typeof com.tiso == 'undefined') com.tiso = new Object();
if(typeof com.tiso.classes == 'undefined') com.tiso.classes = new Object();
if(typeof document.loadHooks == 'undefined') document.loadHooks = [];

com.tiso.classes.QuickLinks = function()
{
	this.linksHolder = null;
}
com.tiso.classes.QuickLinks.prototype.ondocumentloaded = function()
{
	var links, b, i, h3, ul, li, c;
	
	if(!(this.linksHolder = document.getElementById('quicklinks-holder'))) return;
	links = Shine.getElementsByClass(document, 'h3', 'quick-anchor');
	if(!links || !links.length) return;
	Shine.setAttribute(this.linksHolder, 'class', 'expert_sidebar');
	b = Shine.createHTMLElement('div');
	i = Shine.createHTMLElement('div');
	Shine.setAttribute(i, 'class', 'sidebar-inner-block');
	Shine.setAttribute(b, 'class', 'sidebar-block');
	h3 = Shine.createHTMLElement('h3');
	h3.appendChild(document.createTextNode('Quick links'));
	Shine.setAttribute(h3, 'class', 'quick-links');
	i.appendChild(h3);
	b.appendChild(i);
	this.linksHolder.appendChild(b);
	ul = Shine.createHTMLElement('ul');
	i.appendChild(ul);
	for(c = 0; c < links.length; c++)
	{
		li = Shine.createHTMLElement('li');
		if(c + 1 == links.length)
		{
			Shine.setAttribute(li, 'class', 'last');
		}
		else if(!c)
		{
			Shine.setAttribute(li, 'class', 'first');
		}
		a = Shine.createHTMLElement('a');
		if(links[c].textContent)
		{
			a.appendChild(document.createTextNode(links[c].textContent));
		}
		else if(links[c].innerText)
		{
			a.appendChild(document.createTextNode(links[c].innerText));
		}
		else
		{
			a.appendChild(document.createTextNode(links[c].firstChild.nodeValue));
		}
		Shine.setAttribute(a, 'href', '#' + links[c].id);
		li.appendChild(a);
		ul.appendChild(li);
	}
}
com.tiso.quicklinks = new com.tiso.classes.QuickLinks();
document.loadHooks.push(function() { com.tiso.quicklinks.ondocumentloaded(); });

