// JavaScript Document

// plain JS and DOM version of language bubbles

Languages = {
	
	init: function(){
		this.tools = document.getElementById('tools');
		if (!this.tools) return;
		
		this.langs = this.tools.getElementsByTagName('li');
		
		this.count = this.langs.length;
		
		var items = new Array();
		
		for (var i = 0; i < this.count; i++){
		  (function(lang){
				var ok = true;	
				var item = {
					anchor: lang.getElementsByTagName('em'),
					link: lang.getElementsByTagName('a'),
					bubble: lang.getElementsByTagName('p')
				}
				if (item.anchor.length && item.link.length && item.bubble.length){
					item.anchor = item.anchor[0];
					item.link = item.link[0];
					item.bubble = item.bubble[0];
				} else {
					ok = false;
				}
				
				// everything ready
				if (ok){
					// click event
					item.anchor.onclick = function(){ window.location = item.link.href; };
					
					// mouseover event
					lang.onmouseover = function(){
						item.bubble.style.display = 'block';
					}
					lang.onmouseout = function(){
						item.bubble.style.display = 'none';
					}
					
					// style fix
					item.bubble.style.paddingTop = '14px';
					item.bubble.style.top = '12px';
					item.bubble.style.backgroundPosition = '0px 2px';
				}
			})(this.langs[i])
		}
		
	}
	
};

//jQuery initialization
$(document).ready(function(){

 Languages.init();

});