// JavaScript Document
function dEI(obj){
	return document.getElementById(obj);	
}
var running = false;
var cur = '';

function killMenu(){
	if(cur != ''){
		if(dEI(cur).style.display == "block"){ 
			dEI(cur).style.display = "none"; 
			running = false;
		}
	}
	cur = '';
	running = false;
}

function showMenu(obj){
	if(running == false){
		running = true;
		cur = obj;
		if(dEI(obj).style.display == "none"){ dEI(obj).style.display = "block";}
		clearInterval(hold);
		sleep(function (){ if(dEI(obj).style.display == "block"){ dEI(obj).style.display = "none"; running = false;}}, 5000);
		cur = obj;
	} else {
		if(cur != obj){
			dEI(cur).style.display = "none";
			if(dEI(obj).style.display == "none"){ dEI(obj).style.display = "block";}
			clearInterval(hold);
			sleep(function (){ if(dEI(obj).style.display == "block"){ dEI(obj).style.display = "none"; running = false;}}, 5000);
			cur = obj;
		} else {
			// do nothing, otherwise menu get's buggy
		}
	}
}
var hold = 0;
function sleep(func, time){
	hold = setTimeout(func, time);	
}

function buildButtons(){
	dEI('widget_core_coll_search_form').onclick = function(){
		if(dEI('search_options').style.display == "none"){
			dEI('search_options').style.display = "block";
			dEI('blog_search_btn').style.display = "block";
			dEI('search_options').style.height = "auto";
			dEI('blog_search_btn').style.height = "auto";
		} else if(dEI('search_options').style.display == "block" && dEI('blog_search').value == ""){
			dEI('search_options').style.display = "none";
			dEI('blog_search_btn').style.display = "none";
			dEI('search_options').style.height = "0px";
			dEI('blog_search_btn').style.height = "0px";
		}
	}
	dEI('widget_core_coll_search_form').onblur = function(){
		if(dEI('search_options').style.display == "block" && dEI('blog_search').value == ""){
			dEI('search_options').style.display = "none";
			dEI('blog_search_btn').style.display = "none";	
		}	
	}
															 
												
}