
addEvent(window, "load", function(){
	var wHash = window.location.hash;
	if(wHash.length > 1){
		request_txt(wHash.substr(1));
		return;
	}else{
		//request_txt("");
	}/*
	new PeriodicalExecuter(function(){
		if(window.location.hash != wHash){
			wHash = window.location.hash;
			request_txt(wHash.substr(1));
		}
	}, .5);
*/
});	

function click_hash(){
	var nodes = document.getElementById("user_left_side");
	if(nodes){
		nodes = nodes.getElementsByClassName("sf-with-ul");
		for(var x=0; x<nodes.length; x++){
			nodes[x].onclick = function(){
				alert("AVIKKEN");
			}
		}
	}
}

function nav_hover(){
	var nodes = document.getElementById("user_left_side");
	if(nodes){
		nodes = nodes.getElementsByTagName("div");
		for(var x=0; x<nodes.length; x++){
			nodes[x].onmouseover = function(){
				this.className += " on_hover";
				this.getElementsByTagName("ul")[0].style.display="block";
			}
			nodes[x].onmouseout = function(){
				this.className = this.className.replace(" on_hover", "");
				this.getElementsByTagName("ul")[0].style.display="none";
			}
		}
	}
}

	function request_txt(url){
		set_hash(url);
		var url1 = url + ".php?no_head=yes";
		new Ajax.Request(url1, {
			method: "get",
			onSuccess: function(holder){
				var data = holder.responseText;
				update_element("#main_middle", data);
				unset(url1);
				return;
			},
			onFailure: function(){ alert('Failed!') }
		});
	}
	
	function update_element(obj, response){
		if(response){
			var obj = "#main_middle";
			$(obj).html(response);
		}
		return false;
	}
	
function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}


addEvent(window, "load", nav_hover);
addEvent(window, "load", click_hash);
//addEvent(window, "load", request_txt("profile"));


