// JavaScript Document

function attachTabEvents(){
	tabs = getElementsByClass('tabs');
	for(i=0;i<tabs.length;i++){
		curr_tab = tabs[i];
		if(curr_tab.getElementsByTagName('ul')[0]){
			sw = curr_tab.getElementsByTagName('ul')[0].scrollWidth;
			curr_tab.getElementsByTagName('ul')[0].style.width = sw + 'px';
			curr_tab.onmouseover = function(){
				this.getElementsByTagName('ul')[0].style.visibility = 'visible';
				this.getElementsByTagName('a')[0].style.backgroundPosition = 'bottom';
			}
			curr_tab.onmouseout = function(){
				this.getElementsByTagName('ul')[0].style.visibility = 'hidden';
				if(this.getElementsByTagName('a')[0].className.search(/current/) == -1){
					this.getElementsByTagName('a')[0].style.backgroundPosition = 'top';
				}
			}
		}
	}
}
function attachNavEvents(){
	nav = getElementsByClass('nav');
	for(i=0;i<nav.length;i++){
		curr_nav = nav[i];
		if(curr_nav.getElementsByTagName('ul')[0]){
			sw = curr_nav.getElementsByTagName('ul')[0].scrollWidth;
			curr_nav.getElementsByTagName('ul')[0].style.width = sw + 'px';
			curr_nav.getElementsByTagName('a')[0].style.background = 'url(i/nav_bg2.gif) no-repeat';
			curr_nav.onmouseover = function(){
				this.getElementsByTagName('ul')[0].style.visibility = 'visible';
				this.getElementsByTagName('a')[0].style.backgroundPosition = 'left bottom';
			}
			curr_nav.onmouseout = function(){
				this.getElementsByTagName('ul')[0].style.visibility = 'hidden';
				if(this.getElementsByTagName('a')[0].className.search(/current/) == -1){
					this.getElementsByTagName('a')[0].style.backgroundPosition = 'left top';
				}
			}
		}
	}
}

/************** FOR CONTENT LINKS ***************/
function attachLinksEvents(){
	link_ent = getElementsByClass('links_entry');
	links_cen = getElementsByClass('links_cen');
	for(i=0;i<link_ent.length;i++){
		curr_link = link_ent[i];
		curr_link.onmouseover = function(){
			this.getElementsByTagName('div')[0].style.backgroundPosition = 'bottom';
			this.getElementsByTagName('div')[1].style.backgroundPosition = 'bottom';
			this.getElementsByTagName('div')[2].style.backgroundPosition = 'bottom';
		}
		curr_link.onmouseout = function(){
			this.getElementsByTagName('div')[0].style.backgroundPosition = 'top';
			this.getElementsByTagName('div')[1].style.backgroundPosition = 'top';
			this.getElementsByTagName('div')[2].style.backgroundPosition = 'top';
		}
		
		link_relay = document.createElement('div');
		document.body.appendChild(link_relay);
		link_relay.innerHTML = links_cen[i].getElementsByTagName('a')[0].innerHTML;
		link_relay.style.display = 'inline';
		link_relay.style.fontWeight = 'bold';
		curr_link.style.width = link_relay.scrollWidth+16;
		document.body.removeChild(link_relay);
	}
}