var skip_hide;

function nothing(){
	// Nothing
}
    
function toggle_menu(id){
	if (document.getElementById){
		if(document.getElementById(id).style.display == "block"){
			document.getElementById(id).style.display = "none";
		}else{
			skip_hide = id;
			document.getElementById(id).style.display = "block";
		}
	}
}
function hide_all(){
	if (document.getElementById){
		if(skip_hide != "choosecats"){
			document.getElementById("choosecats").style.display = "none";
		}
		if(skip_hide != "chooseuni"){
			document.getElementById("chooseuni").style.display = "none";
		}
		/*if(skip_hide != "menu_tools"){
			document.getElementById("menu_tools").style.display = "none";
		}*/
	}
	skip_hide = "";
}

function getRect (o){
    var r = { top:0, left:0, width:0, height:0 };
 
    if(!o) return r;
    else if(typeof o == 'string' ) o = document.getElementById(o);
 
    if( typeof o != 'object' ) return r;
 
    if(typeof o.offsetTop != 'undefined')    {
         r.height = o.offsetHeight;
         r.width = o.offsetWidth;
         r.left = r.top = 0;
         while (o && o.tagName != 'BODY')         {
              r.top  += parseInt( o.offsetTop );
              r.left += parseInt( o.offsetLeft );
              o = o.offsetParent;
         }
    }
    return r;
}

function toggle_choosecats(id){
	if (document.getElementById){
		if(document.getElementById("choosecats").style.display == "block"){
			document.getElementById("choosecats").style.display = "none";
		}else{
			if(id != ""){
				var r = getRect(id);
				
				document.getElementById("choosecats").style.top = r.top + 15 + "px";
				document.getElementById("choosecats").style.left = (r.left + r.width - 320) + "px";
			}else{
				document.getElementById("choosecats").style.top = "165px";
				document.getElementById("choosecats").style.left = "660px";
			}

			document.getElementById("choosecats").style.display = "block";
			
			skip_hide = "choosecats";
		}
	}
}

function toggle_chooseuni(id){
	if (document.getElementById){
		if(document.getElementById("chooseuni").style.display == "block"){
			document.getElementById("chooseuni").style.display = "none";
		}else{
			if(id != ""){
				var r = getRect(id);
				
				document.getElementById("chooseuni").style.top = r.top + 15 + "px";
				document.getElementById("chooseuni").style.left = (r.left + r.width - 205) + "px";
			}else{
				document.getElementById("chooseuni").style.top = "165px";
				document.getElementById("chooseuni").style.left = "165px";
			}

			document.getElementById("chooseuni").style.display = "block";
			
			skip_hide = "chooseuni";
		}
	}
}

function toggle_box(id, text){
	if (document.getElementById){
		if(document.getElementById(id).value == text){
			document.getElementById(id).value = "";
		}else if(document.getElementById(id).value == ""){
			document.getElementById(id).value = text;
		}
	}
}

function show_feedback(){
	if (document.getElementById){
		document.getElementById("form_feedback").style.display = "block";
		document.getElementById("link_feedback").style.display = "none";
	}
}

function toggle_element(id){
	if(document.getElementById(id).style.display == "block"){
			document.getElementById(id).style.display = "none";
		}else{
			skip_hide = id;
			document.getElementById(id).style.display = "block";
		}
}

function addSearchPlugin()
{
  if ((typeof window.sidebar == "object") && (typeof
  window.sidebar.addSearchEngine == "function"))
  {
    window.sidebar.addSearchEngine(
      "http://www.ubfm.de/downloads/searchplugins/ubfm.src",
      "http://www.ubfm.de/downloads/searchplugins/ubfm.gif",
      "ubfm.de Suche",
      "General" );
  }
  else
  {
    alert("Das hinzufügen der Suche ist leider nicht möglich!");
  }
}
