function PSMainMenu(from_alias,from_project_alias) {
//	if (!alias) alert("Please convert index layout");
	this.from_alias=from_alias;
	this.from_project_alias=from_project_alias;
}

/*
	Suche ausführen, Suchestring wird aus psmainmenu_query Eingabe gelesen
*/
PSMainMenu.prototype.doSearch=function() {
	var input=document.getElementById("psmainmenu_query");
	var iframe=document.getElementById("psmainmenu_content");
	var winmenu=document.getElementById("psmainmenu_contentmenu");
	if (input.value.length==0) return;
	var query=escape(input.value);
	var pos=crossBrowserLib.getPageCoords(input);
	var x=pos.x;
	var y=pos.y+input.offsetHeight+4;
	winmenu.style.display="block";	
	iframe.style.display="block";	

	iframe.style.left=crossBrowserLib.scrollLeft()+x+"px";
	iframe.style.top=crossBrowserLib.scrollTop()+y+"px";	
	winmenu.style.left=crossBrowserLib.scrollLeft()+x+iframe.offsetWidth-winmenu.offsetWidth+"px";
	winmenu.style.top=crossBrowserLib.scrollTop()+y-winmenu.offsetHeight+"px";
	iframe.src="/ps/tools/send_msg.php?alias=ps&event=do_search&query="+query+"&phpscript=startmenu.php"+"&from_alias="+this.from_alias;
}

PSMainMenu.prototype.close=function() {
	var iframe=document.getElementById("psmainmenu_content");
	var winmenu=document.getElementById("psmainmenu_contentmenu");
	winmenu.style.display="none";	
	iframe.style.display="none";	
}
PSMainMenu.prototype.small=function() {
	var iframe=document.getElementById("psmainmenu_content");	
	var button_small=document.getElementById("psmainmenu_contentmenu_small");	
	var button_full=document.getElementById("psmainmenu_contentmenu_fullheight");
	button_small.style.display="none";
	button_full.style.display="inline";
	iframe.src="/ps/tools/send_msg.php?alias=ps&event=setheight&height=small&phpscript=startmenu.php"+"&from_alias="+this.from_alias;;
	
}
PSMainMenu.prototype.fullheight=function() {
	var iframe=document.getElementById("psmainmenu_content");	
	var button_small=document.getElementById("psmainmenu_contentmenu_small");	
	var button_full=document.getElementById("psmainmenu_contentmenu_fullheight");
	button_small.style.display="inline";
	button_full.style.display="none";
	iframe.src="/ps/tools/send_msg.php?alias=ps&event=setheight&height=full&phpscript=startmenu.php"+"&from_alias="+this.from_alias;;
	
}

PSMainMenu.prototype.setHeight=function(size) {
	var iframe=document.getElementById("psmainmenu_content");
	if (size) {
		var y=parseInt(iframe.style.top);
		var winh;
		if (window.innerHeight) winh=window.innerHeight;
		else winh=document.body.offsetHeight;
		var h=winh-y-5;
	} else {
		h=300;
	}
	iframe.style.height=h+"px";
}
/*

	In einem Modul navigieren
	Übergabe: 
		- Name (meistens Alias)
*/
PSMainMenu.prototype.browse=function(name) {
	var browse=document.getElementById("psmainmenu_browse");
	var iframe=document.getElementById("psmainmenu_content");
	var winmenu=document.getElementById("psmainmenu_contentmenu");
	var pos=crossBrowserLib.getPageCoords(browse);
	var x=pos.x;
	var y=pos.y+browse.offsetHeight;
	winmenu.style.display="block";	
	iframe.style.display="block";	

	iframe.style.left=crossBrowserLib.scrollLeft()+x+"px";
	iframe.style.top=crossBrowserLib.scrollTop()+y+"px";	
	winmenu.style.left=crossBrowserLib.scrollLeft()+x+iframe.offsetWidth-winmenu.offsetWidth+"px";
	winmenu.style.top=crossBrowserLib.scrollTop()+y-winmenu.offsetHeight+"px";
	iframe.src="/ps/tools/send_msg.php?alias=ps&event=browse&name="+name+"&phpscript=startmenu.php"+"&from_alias="+this.from_alias;;
}
/*
	Getval starten
	. Button- Node -> das zugehörige Formular wird abgeschickt
	. Breite
	. Höhe des Fensters
	. MDHash des Eventobjektes
*/
PSMainMenu.prototype.getval_start=function(buttonnode,w,h,mdhash,live) {
	var iframe=document.getElementById("psmainmenu_getval");
	var node=document.getElementById("psmainmenu_getval");
	var iframe=document.getElementById("psmainmenu_getval_iframe");
	var node_div=document.getElementById("psmainmenu_getval_div");
	var winInfo=crossBrowserLib.windowInfo();
	var x,y;
	this.getval_node=buttonnode;

	this.getval_mdhash=mdhash;
	x=parseInt((winInfo.width-w)/2);
	y=parseInt((winInfo.height-h)/2);
	node.style.left=x+crossBrowserLib.scrollLeft()+"px";
	node.style.top=y+crossBrowserLib.scrollTop()+"px";	
	node_div.style.width=w+"px";
	node_div.style.height=h+"px";
	w-=12;h-=24;
	iframe.style.width=w+"px";
	iframe.style.height=h+"px";
	node.style.display="block";
	if (!live) live="";
	iframe.src="/ps/tools/send_msg.php?mdhash_eobj="+mdhash+"&alias=ps&event=getval&phpscript=startmenu.php__qm__getval__eq__1__and__live__eq__"+live;
	
}
/*
	Formular neu laden
*/
PSMainMenu.prototype.getval_reload_form=function() {
	var form=crossBrowserLib.findParentElementByTagName(this.getval_node,"FORM"); 
	if (!form) {
		alert("Error: getval_reload_form - form not found");
		return;
	}
	var name="formsubmit_reload_md5_"+this.getval_mdhash;
	var submit=crossBrowserLib.addFormElement(form,top.document,"hidden",name,"true");
	if (form.onsubmit) form.onsubmit();

	form.submit();
}

/*
	Getval ALT
*/
PSMainMenu.prototype.getval=function(w,h,from_alias,name,instID,article_id,psmandantor,wakeup_event,from_project_alias) {
	var iframe=document.getElementById("psmainmenu_getval");
	var node=document.getElementById("psmainmenu_getval");
	var iframe=document.getElementById("psmainmenu_getval_iframe");
	var node_div=document.getElementById("psmainmenu_getval_div");
	var winH,winW;
	var winInfo=crossBrowserLib.windowInfo();
	winW=winInfo.width;
	winH=winInfo.height;	
	var x,y;
	x=(winW-w)/2;
	y=(winH-h)/2;
	node.style.left=x+"px";
	node.style.top=y+"px";	
	node_div.style.width=w+"px";
	node_div.style.height=h+"px";
	w-=12;
	h-=24;
	iframe.style.width=w+"px";
	iframe.style.height=h+"px";
	node.style.display="block";
	iframe.src="/ps/tools/send_msg.php?alias=ps&event=getval&wakeup_event="+wakeup_event+"&psmandantor="+psmandantor+"&from_article_id="+article_id+"&from_alias="+from_alias+"&name="+name+"&from_instance="+instID+"&phpscript=startmenu.php?getval=1"+"&from_alias="+this.from_alias+"&from_project_alias="+this.from_project_alias;
}

PSMainMenu.prototype.getvalClose=function() {
	var node=document.getElementById("psmainmenu_getval");
	node.style.display="none";
}
/*
	Benutzereinstellungen 

*/
PSMainMenu.prototype.settings=function() {
	var browse=document.getElementById("psmainmenu_browse");
	var iframe=document.getElementById("psmainmenu_content");
	var winmenu=document.getElementById("psmainmenu_contentmenu");
	if (browse) {
		var pos=crossBrowserLib.getPageCoords(browse);
		var x=pos.x;
		var y=pos.y+browse.offsetHeight;
	} else {
		var info=crossBrowserLib.windowInfo();
		var x=parseInt(info.width/2-250);	
		var y=20;
	}
	
	iframe.style.display="block";	

	iframe.style.left=crossBrowserLib.scrollLeft()+x+"px";
	iframe.style.top=crossBrowserLib.scrollTop()+y+"px";	
	winmenu.style.display="block";	
	winmenu.style.left=crossBrowserLib.scrollLeft()+x+iframe.offsetWidth-winmenu.offsetWidth+"px";
	winmenu.style.top=crossBrowserLib.scrollTop()+y-winmenu.offsetHeight+"px";
		
	iframe.src="/ps/tools/send_msg.php?alias=ps&event=settings&phpscript=startmenu.php"+"&from_alias="+this.from_alias+"&project_alias="+this.from_project_alias;
}
