//für die navigationsleuste, wenn man auf "fachgebiete"klickt
//wenn vorhanden wird ein submenü angezeigt, statt auf neue seite zu gehen


function showNavigationSubmenu(elementID,insertAfterID,menuTitle){


	//$(insertAfterID).insert("HIER");
	//var menuTitle="bla";
	setMenuTitle(insertAfterID, menuTitle);

	if($(insertAfterID).next('.klappmenuFloat')){
		$(insertAfterID).next('.klappmenuFloat').hide();
	}
	//alert ("_insert "+elementID +" after "+insertAfterID);
	/*
	if($(insertAfterID).next('.klappmenuFloat').next('.klappmenuFloat')){
		$(insertAfterID).next('.klappmenuFloat').next('.klappmenuFloat').hide();
	}
	if($(insertAfterID).next('.klappmenuFloat').next('.klappmenuFloat').next('.klappmenuFloat')){
		$(insertAfterID).next('.klappmenuFloat').next('.klappmenuFloat').next('.klappmenuFloat').hide();
	}*/


	var myInsert="<div id='new_in' class='klappmenuFloat klappmenuFloatOpen' style='display:block;'>"+$(elementID).innerHTML+ "<\/div>";
	//alert(myInsert);
	new Insertion.After($(insertAfterID),myInsert );






	new Effect.Highlight('new_in',{
			duration:2,
			startcolor: "#333333",
			endcolor: "#ffffff",
			transition: Effect.Transitions.sinoidal
	});
	$('new_in').morph('background:#080;color:#3f0');
	$('new_in').show();

	var myHiddenLists = $$('#new_in ul');
	myHiddenLists.each(function(item){
		//alert(item.innerHTML);
		item.setStyle({display:'block'});
		item.show();

	});
}





function openPopUp(url,windowname){
	//alert("popup");
	fenster=window.open(url, windowname, "right=10,width=800,height=480,scroll=no,status=yes,scrollbars=no,resizable=yes");
 	fenster.focus();
 	/*
 	var tmp = fenster.document;
	tmp.write('<html><head><title>'+windowname+'...[lädt]</title>');
	tmp.write('<link rel="stylesheet" href="stylesheets/allgemein.css">');
	tmp.write('</head><body><p>this is  a popup.</p>');
	tmp.write('<p><a href="javascript:alert(self.location.href)">view location</a>.</p>');
	tmp.write('<p><a href="javascript:self.close()">close</a> the popup.</p>');
	tmp.write('</body></html>');
	tmp.close();
	*/
 	return false;

}

function setMenuTitle(menuID, title){
	var myTitles = $$('#'+menuID+' a.menuTitel');
	myTitles[0].innerHTML=title;

}


//	alert("see_proto.js ist eingebunden!");

	function updateAjaxElement(myobject,myaction,myform){
		//alert("ajax");
		if(myform){
			var params = Form.serialize($(myform));
			//alert(params);
			new Ajax.Updater(myobject, '?Action='+myaction, {
				asynchronous:true,
				parameters:params

			});

		}else{

			new Ajax.Updater(myobject, '?Action='+myaction, {
				asynchronous:true
			});

			//ACHTUNG: war initFilesList() kuki 28.8.07
			//alert("ajax gestartet");

		}



	}

	function expandProjectBalken(balkenID, projectID){
		//alert("expand"+ balkenID);

		//updateAjaxElement(balkenID,'ajax_showProject&projectID='+projectID,false);
		new Ajax.Updater(balkenID, '?Action='+'ajax_showProject&projectID='+projectID, {
				asynchronous:true,
				onComplete:function(){
					//new Effect.Highlight(balkenID);
					$(balkenID).className='selected';
					//myLightbox.updateImageList();
					Shadowbox.init(),
					Shadowbox.setup()
					//alert("reinit");
				}

		});



	}

	function collapseProjectBalken(balkenID, projectID){
		//alert("expand"+ balkenID);

		//updateAjaxElement(balkenID,'ajax_showProject&projectID='+projectID,false);
		new Ajax.Updater(balkenID, '?Action='+'ajax_showProject_balken&projectID='+projectID, {
				asynchronous:true,
				onComplete:function(){
					//new Effect.Highlight(balkenID);
					$(balkenID).className='unselected';
				}

		});
	}

	function updateAjaxForm(myobject,myaction,myform){
		//alert("ajax");
		if(myform){
			var params = Form.serialize($(myform));
			//alert(params);
			new Ajax.Updater(myobject, '?Action='+myaction, {
				asynchronous:true,
				parameters:params

			});

		}else{

			new Ajax.Updater(myobject, '?Action='+myaction, {
				asynchronous:true
			});

			//ACHTUNG: war initFilesList() kuki 28.8.07
			//alert("ajax gestartet");

		}

	}



function styleNavigation(){
	//hole alle selects der klasse navigation_menu
	var mySelects = $$('select.navigation_menu');
	mySelects.each(function(item){
		newtext = "<select><option>HALLO</option></select>";
		item.replace(newtext);

	});
}

//styleNavigation();


function showHideElement(divID){
	if(! $(divID).visible()){			//display
		//alert("show");
		$(divID).show();
	}else{ 							//hide
		//alert("hide");
		$(divID).hide();
	}
	return false;
}


function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id

	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}


function fensterweite() {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}


//##################### cookie funktionen
function createCookie(name, value, days)
{
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}

function eraseCookie(name)
{
  createCookie(name, "", -1);
}
//#####################################################################################
