function OXGroupwareHover() {}
OXGroupwareHover.references=new Object();
OXGroupwareHover.start = function () {
	if(!OXGroupwareHover.references["core_attachments_template"]) {
		var tmpnode=$("template_calendar_hover_attachments"); //.cloneNode(true);
		//$("template_calendar_hover_attachments").parentNode.removeChild($("template_calendar_hover_attachments"));
		tmpnode.id="";
		OXGroupwareHover.references["core_attachments_template"]=tmpnode;
	}
	/*
	if(!OXGroupwareHover.references["core_links_template"]) {
		var tmpnode=$("template_calendar_hover_links"); //.cloneNode(true);
		//$("template_calendar_hover_links").parentNode.removeChild($("template_calendar_hover_links"));
		tmpnode.id="";
		OXGroupwareHover.references["core_links_template"]=tmpnode;
	}
	*/
	if(!OXGroupwareHover.references["core_content_full"]) {
		var tmpnode=$("template_calendar_hover_page_content_full"); //.cloneNode(true);
		//$("template_calendar_hover_page_content_full").parentNode.removeChild($("template_calendar_hover_page_content_full"));
		tmpnode.id="";
		OXGroupwareHover.references["core_content_full"]=tmpnode;
	}
	if(!OXGroupwareHover.references["core_content"]) {
		var tmpnode=$("template_calendar_hover_page_content"); //.cloneNode(true);
		//$("template_calendar_hover_page_content").parentNode.removeChild($("template_calendar_hover_page_content"));
		tmpnode.id="";
		OXGroupwareHover.references["core_content"]=tmpnode;
	}
}

OXGroupwareHover.openAttachedFile = function(folderid,objectid,filename,rtfflag,attachmentid,module) {
	return function() {
		if(rtfflag) { return; }
		var sURL = AjaxRoot + "/attachment/" + filename + "?action=document&session=" + session + "&attached=" + objectid  +
			 "&module="+module+"&folder=" + folderid + "&id=" + attachmentid;
		newWindow(sURL, getWindowOptions(null, null, "scrollbars=yes"));
	}
};
OXGroupwareHover.saveAttachedFile = function(folderid,objectid,filename,rtfflag,attachmentid,module) {
	return function() {	
		if(rtfflag) return;
		var sContentType = 'application%2Foctet-stream';	
		var sURL = 	AjaxRoot + "/attachment/" + filename + "?action=document&session="+ session + "&attached=" + objectid  + 
		"&module="+module+"&folder="+ folderid + "&id=" + attachmentid + "&content_type=" +sContentType;
		var frame = $ALL("dlIframe") ? getFrameElement('dlIframe') : parent.frames['dlIframe'];
		frame.location.href = sURL;
	}
};
OXGroupwareHover.followLink = function (module,folder,id) {
	return function() {
		triggerEvent("OX_Direct_Linking",module,{ folder : folder , id : id });
	}
}

OXGroupwareHover.fillAttachments = function(Hover) {

	Hover.accordion.removeComponent("Attachments");
	var attachmentfirst=
	newnode("tr",{},{},[
		newnode("td",{ width: "25px", paddingTop:"12px", lineHeight : "0px"},{ className: "notclickable"},[
			newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[]) 
		]),
		newnode("td",{ paddingTop:"12px"},{ className : "contenttext notclickable"},[]),
		newnode("td",{ width: "25px", paddingTop:"12px" , lineHeight : "0px"},{ className: "clickable" },[
			newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[]),
			newnode("img",{ display:"none" },{ src: getFullImgSrc("img/menu/attachment_open.gif") },[])
		]),
		newnode("td",{ width: "25px", paddingTop:"12px" , lineHeight : "0px"},{ className: "clickable"},[
			newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[]),
			newnode("img",{ display:"none" },{ src: getFullImgSrc("img/menu/attachment_save.gif") },[])
		])
	]);
	var attachmentsecond=
	newnode("tr",{},{},[
		newnode("td",{ width: "25px"},{ className: "notclickable"},[
			newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[])
		]),
		newnode("td",{},{ className : "contenttext notclickable"},[]),
		newnode("td",{ width: "25px"},{ className: "notclickable"},[]),
		newnode("td",{ width: "25px"},{ className: "notclickable"},[])
	]);
	var attachmentmain=OXGroupwareHover.references["core_attachments_template"].cloneNode(true);
	var attachbody=attachmentmain.getElementsByTagName("tbody")[0];
	if(!(Hover.actualobject.number_of_attachments>0)) {
		var tmp=newnode("tr",{},{},[
			newnode("td",{ width: "25px"},{},[
				newnode("img",{ className: "notclickable" },{ src: getFullImgSrc("img/dummy.gif") },[])
			]),
			newnode("td",{},{ colspan : 4 , className : "contenttext notclickable" },[
				document.createTextNode(_("No attachments available")) /*i18n*/
			])		
		]);
		attachbody.appendChild(tmp);
	} else {
		(new JSON()).get(AjaxRoot + "/attachment?action=all&session=" + session + "&folder=" + Hover.actualobject.folder_id +
			"&attached=" + Hover.actualobject.id + "&module="+Hover.moduleint+"&columns=1,801,802,803,804,805,806&sort=803&order=asc",null,
			function(attachments) {				
				attachments=attachments.data || [];
				
				var _txt = _("Attachments") + " (" + attachments.length + ")";
				switch(Hover.actualmodule) {
					case "calendar":
						OXAppointmentHover.slider.getTabById("attachments").setTitle(_txt);
						break;
					case "tasks":
						OXTaskHover.slider.getTabById("attachments").setTitle(_txt);
						break;
					case "contacts":
						OXContactHover.slider.getTabById("attachments").setTitle(_txt);
						break;
				}
				
				for(var i=0;i<attachments.length;i++) {
					var node=attachmentfirst.cloneNode(true);
					var node2=attachmentsecond.cloneNode(true);
					var attachmentid=attachments[i][0];
					var module=attachments[i][2];
					var image=getMimeImage(attachments[i][5]);
					var imagetitle=attachments[i][5];
					var bytesize=attachments[i][4];
					var attachmentname=attachments[i][3];
					var imagertf=attachments[i][6]
					node.getElementsByTagName("img")[0].src=image; 
					node.getElementsByTagName("img")[0].title=imagetitle;
					if(!imagertf) {						
						node.getElementsByTagName("td")[1].appendChild(document.createTextNode(attachmentname));
						node.getElementsByTagName("img")[1].style.display="none";
						node.getElementsByTagName("img")[2].style.display="";
						node.getElementsByTagName("img")[2].title=_("Open attachment"); /*i18n*/
						addDOMEvent(node.getElementsByTagName("img")[2],"click",OXGroupwareHover.openAttachedFile(Hover.actualobject.folder_id,Hover.actualobject.id,attachmentname,imagertf,attachmentid,module));
						node.getElementsByTagName("img")[3].style.display="none";
						addDOMEvent(node.getElementsByTagName("img")[4],"click",OXGroupwareHover.saveAttachedFile(Hover.actualobject.folder_id,Hover.actualobject.id,attachmentname,imagertf,attachmentid,module));
						node.getElementsByTagName("img")[4].style.display="";
						node.getElementsByTagName("img")[4].title=_("Save attachment"); /*i18n*/
					} else {	
						node.getElementsByTagName("td")[1].appendChild(document.createTextNode(attachmentname));
					}
					node2.getElementsByTagName("td")[1].appendChild(document.createTextNode(OXGroupwareHover.getShortByteString(bytesize)));
					node2.getElementsByTagName("td")[1].title=OXGroupwareHover.getShortByteString(bytesize,true);
					attachbody.appendChild(node);
					attachbody.appendChild(node2);
				}
				Hover.accordion.checkComponentHeight("Attachments");
			}
		);
	}

	Hover.accordion.addComponent("Attachments",attachmentmain,false);
}
OXGroupwareHover.getShortByteString=function(int1,onlybytes) {
	return bytesToString(int1);
}
				
function OXOperationHover() {}
OXOperationHover.start = function() {
	if(!OXOperationHover.references["core_participants_participant_template"]) {
		var tmpnode=$("template_calendar_hover_participants"); //.cloneNode(true);
		//$("template_calendar_hover_participants").parentNode.removeChild($("template_calendar_hover_participants"));
		tmpnode.id="";
		OXOperationHover.references["core_participants_participant_template"]=tmpnode;
	}
	if(!OXOperationHover.references["core_participants_groupparticipants_template"]) {
		var tmpnode=$("template_calendar_hover_groupparticipants"); //.cloneNode(true);
		//$("template_calendar_hover_groupparticipants").parentNode.removeChild($("template_calendar_hover_groupparticipants"));
		tmpnode.id="";
		OXOperationHover.references["core_participants_groupparticipants_template"]=tmpnode;
	}
	if(!OXOperationHover.references["core_participants_confirmdialog_template"]) {
		var tmpnode=$("template_calendar_participants_confirmdialog"); //.cloneNode(true);
		//$("template_calendar_participants_confirmdialog").parentNode.removeChild($("template_calendar_participants_confirmdialog"));
		tmpnode.id="";
		OXOperationHover.references["core_participants_confirmdialog_template"]=tmpnode;
	}
}
OXOperationHover.references=new Object();
OXOperationHover.decline= function(Hover) {
	OXOperationHover.dialogRequest(2,Hover);
	OXOperationHover.hideDialog(Hover);
}
OXOperationHover.tentiative= function(Hover) {
	OXOperationHover.dialogRequest(3,Hover);
	OXOperationHover.hideDialog(Hover);
}
OXOperationHover.accept= function(Hover) {
	OXOperationHover.dialogRequest(1,Hover);
	OXOperationHover.hideDialog(Hover);
}	
OXOperationHover.dialogRequest = function(confirmstatus,Hover) {
	(new JSON).put(AjaxRoot + "/"+Hover.actualmodule+"?session="+session
			+"&action=confirm&id="+Hover.actualobject.id+"&folder="+Hover.actualobject.folder_id, 
		{ "confirmation": confirmstatus, "confirmmessage": Hover.references["ConfirmDialogInput"].value  },
		null,
		function(reply) {
			Hover.refillContent(Hover.actualobject.id,Hover.actualobject.folder_id,Hover.actualobject.recurrence_position); 
		});
}
OXOperationHover.hideDialog= function(Hover) {
	Hover.accordion.hideExtraContent("ConfirmDialog");
	Hover.confirmdialogshown=false;
}
OXOperationHover.getParticipantsString= function(Hover) {
	var tmpstring="ParticipantsUsers";
	for(var i=0;i<Hover.references.allGroups.length;i++) {
		tmpstring+=","+Hover.references.allGroups[i];
	}
	return tmpstring;
}	
OXOperationHover.fillParticipants = function(Hover) {
	Hover.accordion.removeComponent("ConfirmDialog");
	Hover.accordion.removeComponent("ParticipantsUsers")
	var participants=Hover.actualobject.participants;
	var users=Hover.actualobject.users;
	var confirmations = Hover.actualobject.confirmations;
	var confMap = {};
	if (confirmations) {
    	for (var i = 0; i < confirmations.length; i++) {
    	    confMap[confirmations[i].mail] = confirmations[i];
    	};
	}
	
	var confirmationClasses = {
	    1: "appointmentACCEPTED",
	    2: "appointmentDECLINED",
	    3: "appointmentTENTATIVE"
	};
	
	var tmp_participants=new Array();
	var checked_confirm=new Object();
	for(var i=0;i<participants.length;i++) {
		if(participants[i].type!=5) {
			tmp_participants.push(participants[i]);
		}
	}
	for(var i=0;i<users.length;i++) {
		if(users[i].id) {
			checked_confirm[users[i].id]={ confirm : users[i].confirmation , message : users[i].confirmmessage };
		}
	}
	internalCache.getObjects(tmp_participants,function(data) {
		var tmp_node=newnode("tr", null, null, [
			newnode("td", { width: "25px", whiteSpace: "nowrap" }, { className: "notclickable" }, []),
			newnode("td", { width: "35%", whiteSpace: "nowrap", paddingLeft: "5px" }, { className: "contenttextnocolor notclickable"},[]),
			newnode("td", 0, { className: "notclickable" }, [ newnode("div", { overflow: "hidden", whiteSpace: "nowrap", paddingLeft: "7px"}, { className : "contenttextnocolor" }, []) ])
		]);
		var tmp_node2=newnode("tr",null,null,[
			newnode("td",{ width: "25px" },{className : "notclickable"},[
			]),
			newnode("td",{ width: "25px" },{className : "clickable"},[
				newnode("img",{},{ src: getFullImgSrc("img/plus.gif") },[])
			]),
			newnode("td",0,{ className : "contenttextnocolor notclickable"},[])
		]);
		
		var tmp_users=new Array();
		var tmp_groups=new Array();
		var tmp_ressources=new Array();
		var tmp_external=new Array();
		for(var i=0;i<participants.length;i++) {
			switch(participants[i].type) {
				case 1:
					var tmpvalue=data[participants[i].id];
					tmpvalue.confirm=checked_confirm[tmpvalue.id].confirm || 0;
					tmpvalue.message=checked_confirm[tmpvalue.id].message || "";
					tmp_users.push(tmpvalue);					
					break;	
				case 2:
					var tmpvalue=data[participants[i].id];
					tmp_groups.push(tmpvalue);
					break;
				case 3:
					var tmpvalue=data[participants[i].id];
					tmp_ressources.push(tmpvalue);
					break;
				case 5:
					tmp_external.push(participants[i]);
					break;
				
			}
		}
		
		tmp_users.sort(function(a,b){
			if (a.display_name && b.display_name) {
				return a.display_name.toLowerCase() < b.display_name.toLowerCase() ? -1 : 1;
			} else {
				return -1;
			}
		});
		
		var usersnode=OXOperationHover.references["core_participants_participant_template"].cloneNode(true);
		var node=usersnode.getElementsByTagName("tbody")[0];
		node.appendChild(
			newnode("tr",{ fontWeight: "bold"}, { className: "contenttext notclickable" },[
				newnode("td",{ paddingTop:"7px" },{colSpan : 2, className: "notclickable" }, [
					addTranslated(_("Participants"))
				]),
				newnode("td",{ width : "30px", paddingTop:"7px" , paddingRight: "10px" },{ colSpan: 2, title : _("Change confirmation") , className: "clickable"}, [
					newnode("img",{},{ src : getFullImgSrc("img/menu/global_confirmation_change.gif") })
				])
			])	
		);
		Hover.confirmdialogshown=false;
		addDOMEvent(node.getElementsByTagName("td")[1],"click",function() {
			if(Hover.confirmdialogshown) {
				Hover.accordion.hideExtraContent("ConfirmDialog");
				Hover.confirmdialogshown=false;
			} else {
				Hover.accordion.showExtraContent("ConfirmDialog");
				Hover.confirmdialogshown=true;
			}
		});
		if(checked_confirm[configGetKey("identifier")] && !Hover.disableConfirmation) {
			node.getElementsByTagName("td")[1].style.display="";
			var personalnode=OXOperationHover.references["core_participants_confirmdialog_template"].cloneNode(true);
			Hover.references["ConfirmDialogInput"]=personalnode.getElementsByTagName("input")[0];
			Hover.references["ConfirmDialogInput"].value=checked_confirm[configGetKey("identifier")].message || "";
			var newtd=personalnode.getElementsByTagName("td")[2];
			addDOMEvent(newtd.getElementsByTagName("td")[0],"click",function() { OXOperationHover.accept(Hover)} );
			addDOMEvent(newtd.getElementsByTagName("td")[1],"click",function() { OXOperationHover.decline(Hover)} );
			addDOMEvent(newtd.getElementsByTagName("td")[2],"click",function() { OXOperationHover.tentiative(Hover)} );
			Hover.accordion.addComponent("ConfirmDialog",personalnode,false);
		} else {
			node.getElementsByTagName("td")[1].style.display="none";
		}
		
		//USERS
		for(var i=0;i<tmp_users.length;i++) {
			var tmpn1=tmp_node.cloneNode(true);
			if(i==0) {
				tmpn1.getElementsByTagName("td")[0].style.paddingTop="10px";
				tmpn1.getElementsByTagName("td")[1].style.paddingTop="10px";
				tmpn1.getElementsByTagName("td")[2].style.paddingTop="10px";
			}
			tmpn1.getElementsByTagName("td")[0].appendChild(newnode("img",null,{src: getFullImgSrc("img/calendar/user.gif") },[]))
			tmpn1.getElementsByTagName("td")[1].appendChild(document.createTextNode(tmp_users[i].display_name));
			tmpn1.getElementsByTagName("td")[1].className="notclickable";
			switch(tmp_users[i].confirm) {
				case 1: 
					tmpn1.className="appointmentACCEPTED";
					break;
				case 2: 
					tmpn1.className="appointmentDECLINED";
					break;
				case 3: 
					tmpn1.className="appointmentTENTATIVE";
					break;
			}
			if(tmp_users[i].message) {
				tmpn1.title=tmp_users[i].message;
			}
			tmpn1.getElementsByTagName("td")[2].firstChild.appendChild(document.createTextNode(tmp_users[i].message || ""));
			node.appendChild(tmpn1);
		}
		if(participants.length==0) {
			var tmp=newnode("tr",{},{},[
				newnode("td",{ width: "25px"},{ className : "notclickable"},[
					newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[])
				]),
				newnode("td",{},{ colspan : 4 , className : "contenttext notclickable" },[
					document.createTextNode(_("No participants available")) /*i18n*/
				])		
			]);
			node.appendChild(tmp);
		}
		Hover.accordion.addComponent("ParticipantsUsers",usersnode,false);
		for(var i=0;i<Hover.references.allGroups.length;i++){
			Hover.accordion.removeComponent(i);	
		}
		for(var i in Hover.references.allGroupsParticipants.length){
			Hover.accordion.removeComponent(i);	
		}
		Hover.references.allGroups=new Array();
		Hover.references.allGroupsParticipants=new Object();
		
		//GROUPS
		for(var i=0;i<tmp_groups.length;i++) {
			var accordionnode=OXOperationHover.references["core_participants_participant_template"].cloneNode(true);
			var tmpn1=tmp_node2.cloneNode(true);
			if(i==0) {
				tmpn1.getElementsByTagName("td")[0].style.paddingTop="10px";
				tmpn1.getElementsByTagName("td")[1].style.paddingTop="10px";
				tmpn1.getElementsByTagName("td")[2].style.paddingTop="10px";
			}
			tmpn1.getElementsByTagName("td")[0].appendChild(newnode("img",null,{src: getFullImgSrc("img/calendar/group.gif") },[]))
			tmpn1.getElementsByTagName("td")[2].appendChild(document.createTextNode(tmp_groups[i].display_name));
			tmpn1.getElementsByTagName("td")[2].className="notclickable";
			accordionnode.getElementsByTagName("tbody")[0].appendChild(tmpn1);
			Hover.accordion.addComponent("ParticipantsGroups"+i,accordionnode,false);
			Hover.references.allGroups.push("ParticipantsGroups"+i);
			
			//MEMBERS IN GROUPS
            var accordionnode2=OXOperationHover.references["core_participants_groupparticipants_template"].cloneNode(true);
            Hover.accordion.addComponent("ParticipantsGroupUsers"+i+"members",accordionnode2,false);
            Hover.references.allGroupsParticipants["ParticipantsGroupUsers"+i+"members"]=new Object();
            Hover.references.allGroupsParticipants["ParticipantsGroupUsers"+i+"members"].active=false;
	
			internalCache.getUsers(tmp_groups[i].members,(
			function(mynode,mynode2,mynode2name,tmpn1) { return function(cb) { 
				addDOMEvent(mynode,"click",function() {
					if(Hover.references.allGroupsParticipants[mynode2name]) {
						if(Hover.references.allGroupsParticipants[mynode2name].active) {
							mynode.getElementsByTagName("img")[0].src= getFullImgSrc("img/plus.gif");
							Hover.accordion.hideExtraContent(mynode2name);
							Hover.references.allGroupsParticipants[mynode2name].active=false;
						} else {
							mynode.getElementsByTagName("img")[0].src= getFullImgSrc("img/minus.gif");
							Hover.accordion.showExtraContent(mynode2name);
							Hover.references.allGroupsParticipants[mynode2name].active=true;
						}
					}
				});
				
				var node1=mynode2.getElementsByTagName("td")[1];
				removeChildNodes(node1);
				
				var count=0;
				var tmpstring =_("No Members");
				for (var i in cb) {
					if (count==0) {
						tmpstring = cb[i].display_name;
						count++;
					} else {
						tmpstring = "; " + cb[i].display_name;
						count++;
					}
					var mNode = newnode("span", 0, { className: "notclickable" }, []);
					for (var u in users) {
						if (users[u].id == cb[i].id) {
							switch(users[u].confirmation) {
								case 1: 
									mNode.className="appointmentACCEPTED";
									break;
								case 2: 
									mNode.className="appointmentDECLINED";
									break;
								case 3: 
									mNode.className="appointmentTENTATIVE";
								break;
							}
							mNode.title = users[u].confirmmessage || "";
							break;
						}
					}
					mNode.appendChild(document.createTextNode(tmpstring))
					node1.appendChild(mNode);
				}
			} })(tmpn1.getElementsByTagName("td")[1],accordionnode2,"ParticipantsGroupUsers"+i+"members"));
		}
		if(tmp_ressources.length) {
			for(var i=0;i<tmp_ressources.length;i++) {
				var accordionnode=OXOperationHover.references["core_participants_participant_template"].cloneNode(true);
				var tmpn1=tmp_node.cloneNode(true);
				if(i==0) {
					tmpn1.getElementsByTagName("td")[0].style.paddingTop="10px";
					tmpn1.getElementsByTagName("td")[1].style.paddingTop="10px";
				}
				tmpn1.getElementsByTagName("td")[0].appendChild(newnode("img",null,{src: getFullImgSrc("img/calendar/ressourcen.gif")},[]))
				tmpn1.getElementsByTagName("td")[1].appendChild(document.createTextNode(tmp_ressources[i].display_name));
				tmpn1.getElementsByTagName("td")[1].className="notclickable";
				accordionnode.getElementsByTagName("tbody")[0].appendChild(tmpn1);
				Hover.accordion.addComponent("ParticipantsRessources"+i,accordionnode,false);
				Hover.references.allGroups.push("ParticipantsRessources"+i);		
			}
		}	
		if(tmp_external.length) {
			for(var i=0;i<tmp_external.length;i++) {
				var accordionnode=OXOperationHover.references["core_participants_participant_template"].cloneNode(true);
				var tmpn1=tmp_node.cloneNode(true);
				if(i==0) {
					tmpn1.getElementsByTagName("td")[0].style.paddingTop="10px";
					tmpn1.getElementsByTagName("td")[1].style.paddingTop="10px";
                    tmpn1.getElementsByTagName("td")[2].style.paddingTop="10px";
				}
				tmpn1.getElementsByTagName("td")[0].appendChild(newnode("img",null,{src: getFullImgSrc("img/calendar/user_extern.gif")},[]))
				tmpn1.getElementsByTagName("td")[1].appendChild(document.createTextNode(tmp_external[i].display_name || tmp_external[i].mail || _("Unknown")));
				tmpn1.getElementsByTagName("td")[1].className="notclickable";
                if (confirmations) {
                    var conf = confMap[tmp_external[i].mail];
				    tmpn1.className = confirmationClasses[conf.status] || "";
				    tmpn1.getElementsByTagName("td")[2].firstChild.appendChild(
				        document.createTextNode(conf.message || ""));
                }
				accordionnode.getElementsByTagName("tbody")[0].appendChild(tmpn1);
				Hover.accordion.addComponent("ParticipantsExternal"+i,accordionnode,false);
				Hover.references.allGroups.push("ParticipantsExternal"+i);		
			}
		}	
	});
}
function OXContactHover() {}
OXContactHover.actualmodule="contacts";
OXContactHover.moduleint=7;
OXContactHover.hoverWidth = 400;
OXContactHover.contentobject;
OXContactHover.actualobject;
OXContactHover.actualHover=null;
OXContactHover.accordion;
OXContactHover.references=new Object();
OXContactHover.start = function() {
	if(!OXContactHover.references["core_contact_template"]) {
		var tmpnode=$("contactHovertmpl").cloneNode(true);
		$("contactHovertmpl").parentNode.removeChild($("contactHovertmpl"));
		tmpnode.id="";
		OXContactHover.references["core_contact_template"]=tmpnode;
	}
	if(!OXContactHover.references["core_contact_template2"]) {
		var tmpnode=$("contactHovertmpl2").cloneNode(true);
		$("contactHovertmpl2").parentNode.removeChild($("contactHovertmpl2"));
		tmpnode.id="";
		OXContactHover.references["core_contact_template2"]=tmpnode;
	}
}
OXContactHover.getContent = function() {
	if(OXContactHover.contentobject) { 
		return OXContactHover.contentobject;
	}
	var element=createHoverContent(null,null,null,null,1);
	OXContactHover.accordion=new Accordion(450,OXContactHover.hoverWidth);	
	var contentnode=OXContactHover.references["core_contact_template"].cloneNode(true);
	var contentnode2=OXContactHover.references["core_contact_template2"].cloneNode(true);
	OXContactHover.accordion.addComponent("Contact_General",contentnode,false);
	OXContactHover.accordion.addComponent("Contact_Additional",contentnode2,false);
		
	OXContactHover.references["core_content_small"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXContactHover.accordion.addComponent("NoteSmall",OXContactHover.references["core_content_small"],200);
	var tmptds=OXContactHover.references["core_content_small"].getElementsByTagName("td");
	OXContactHover.references["notesmall"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXContactHover.accordion.showContent('Contact_General,NoteMiddle'); });
	
	OXContactHover.references["core_content_middle"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXContactHover.accordion.addComponent("NoteMiddle",OXContactHover.references["core_content_middle"],200);
	var tmptds=OXContactHover.references["core_content_middle"].getElementsByTagName("td");
	OXContactHover.references["notemiddle"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXContactHover.accordion.showContent('Contact_General,NoteFull'); });
	
	OXContactHover.references["core_content_full"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXContactHover.accordion.addComponent("NoteFull",OXContactHover.references["core_content_full"],200);
	var tmptds=OXContactHover.references["core_content_full"].getElementsByTagName("td");
	OXContactHover.references["notefull"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXContactHover.accordion.showContent('Contact_General,NoteSmall'); });
		
	var tabs = new Tabbing("1");
	tabs.addTab(
			new Tab("general", _("General"), 
				function() { 
					OXContactHover.accordion.showContent("Contact_General,NoteSmall")
				}
			)
	);
	tabs.addTab(
			new Tab("addresses", _("Addresses"),
				function() { 
					OXContactHover.accordion.showContent("Contact_Additional");
				}
			)
	);
	tabs.addTab(
			new Tab("additional", _("Additional"),
				function() { 
					OXContactHover.accordion.showContent("Contact_Additional");
				}
			)
	);
	tabs.addTab(
			new Tab("attachments", _("Attachments"),
				function() { 
					OXContactHover.accordion.showContent("Attachments");
				}
			)
	);
	
	OXContactHover.slider = tabs;
	
	var node = OXContactHover.accordion.getDomNode();
	var d = newnode("div",{ padding:"0px" , overflow:"hidden"},{className : "tabbing_tab"},[
		newnode("table",{ height : "22px "},{cellPadding : 0, cellSpacing : 0, border : 0, width : "100%"},[
			newnode("tbody",{},{},[
			    tabs.getDOMNode()
			])
		])
	]);	
	
	element.body.appendChild(d);
	element.body.appendChild(node);
	element.node.display="none";
	body.appendChild(element.node);
	OXContactHover.contentobject = element;
	
	return OXContactHover.contentobject;    
}

OXContactHover.fillGeneral = function(id, folder) {
	function fillContent(type,value,titletext,clear,show) {
		if(clear) { removeChildNodes(OXContactHover.references[type]); }
		if(value) { OXContactHover.references[type].appendChild(value); }
		if(titletext) { OXContactHover.references[type].title=titletext; }
		if(show) { OXContactHover.references[type].style.display=""; }
	}
	function fillText(type,text,titletext,clear) {
		if(clear) { removeChildNodes(OXContactHover.references[type]); }
		if(text) { OXContactHover.references[type].appendChild(document.createTextNode(text)); }
		if(titletext) { OXContactHover.references[type].title=titletext; }
	}
	

	var hoverTemplate=OXContactHover.references["core_contact_template"].cloneNode(true);
	var hoverTemplate2=OXContactHover.references["core_contact_template2"].cloneNode(true);

				function newLineBreak() {
					return newnode("br", {}, {className: "cleaner"});
				}				
				clearCardHoverFields();
				var nameHeadline = objContactCardFunctions.getHeadline(OXContactHover.actualobject);
				var classLine = "hoverContactline";
				if(OXContactHover.actualobject.contains_image1 && OXContactHover.actualobject.contains_image1 > 0) {
					classLine = "hoverContactline";					
					hoverTemplate.appendChild(newnode("div", {paddingLeft: "7px",width:"70px"}, {className: "cardHoverImg"}, [newnode("img", {width:"4em"}, {src: OXContactHover.actualobject.image1_url + "&timestamp=" + (OXContactHover.actualobject.image_last_modified || 0) })]));
				} else if(!OXContactHover.actualobject.mark_as_distributionlist) {	
					classLine = "hoverContactlineSmallImage";
					hoverTemplate.appendChild(newnode("div", {paddingLeft: "7px",width:"40px"}, {className: "cardHoverImg"}, [newnode("img", {}, {src: getFullImgSrc("img/contacts/dummypicture_small.gif")})]));
				} else {
					classLine = "hoverContactlineSmallImage";
					hoverTemplate.appendChild(newnode("div", {paddingLeft: "7px",width:"40px"}, {className: "cardHoverImg"}, [newnode("img", {}, {src: getFullImgSrc("img/contacts/distributionlist34x34_n.gif")})]));
				}
				 
				var nameDiv = newnode("div", {fontWeight:"bold",fontSize:"11pt",paddingLeft: "7px"}, {className: classLine, title: (nameHeadline)?nameHeadline:""}, [document.createTextNode(nameHeadline?nameHeadline:"")]);
				
				hoverTemplate.appendChild(nameDiv);
				/*
				if (OXContactHover.actualobject.number_of_attachments) {
					hoverTemplate.appendChild(newnode("div", {}, {className: "cardHoverIconRight"}, [newnode("img", {}, {src: getFullImgSrc("img/mail/attachment.gif")})]));					
				}	
				*/			
				var attributPaddingR = "15px";
				if (OXContactHover.actualobject.color_label) {
					hoverTemplate.appendChild(newnode("div", {paddingRight: attributPaddingR}, {className: "cardHoverIconRight"}, [newnode("img", {}, {src: getFullImgSrc("img/menu/tag_"+OXContactHover.actualobject.color_label+".gif")})]));
					attributPaddingR = "3px";
				}
				if (OXContactHover.actualobject.private_flag) {
					hoverTemplate.appendChild(newnode("div", {paddingRight: attributPaddingR}, {className: "cardHoverIconRight"}, [newnode("img", {}, {src: getFullImgSrc("img/private_flag.gif")})]));
				} 
				if(OXContactHover.actualobject.mark_as_distributionlist) {	
					var emails = "";
                    if (OXContactHover.actualobject.distribution_list)
					for(var n=0; n<OXContactHover.actualobject.distribution_list.length;n++) {
						emails += (n>0) ? ", " : "";
						emails += OXContactHover.actualobject.distribution_list[n].mail;												
					}
					var sendToAll = newnode("div", {cursor: "pointer"}, {className: "cardHoverIconRight"}, [newnode("img", {paddingRight: "10px"}, {src: getFullImgSrc("img/mail/mail.gif"), title:"Send E-Mail to all"/*i18n*/})]);
					addDOMEvent(sendToAll, "click", function() { sendMailToContactMail(emails) });
					hoverTemplate.appendChild(sendToAll);
				}
				nameDiv.appendChild(newLineBreak());
				if (OXContactHover.actualobject.company) {
					nameDiv.appendChild(newnode("div", {fontWeight:"normal",fontSize:"9pt"}, {className: "hoverContactline"}, [document.createTextNode(OXContactHover.actualobject.company)]));					
				}
				hoverTemplate.appendChild(nameDiv);
				hoverTemplate.appendChild(newLineBreak());
				
				if(OXContactHover.actualobject.mark_as_distributionlist) {
					OXContactHover.slider.getTabById("addresses").show(false);
					OXContactHover.slider.getTabById("additional").show(true);
					
                    if (OXContactHover.actualobject.distribution_list)
					for(var k=0; k<OXContactHover.actualobject.distribution_list.length;k++) {
						(function(m) {
							hoverTemplate.appendChild(newnode("div", {}, {className: "cardHoverIcon"}, [newnode("img", {}, {src: getFullImgSrc("img/mail/unread.gif")})]));
							var emailAdress = OXContactHover.actualobject.distribution_list[m].mail;
							var mailNode = newnode("div", {cursor: "pointer"}, {className: "hoverContactline2", title: emailAdress}, [document.createTextNode(emailAdress)]);
							addDOMEvent(mailNode, "click", function() { sendMailToContactMail(emailAdress) });
							hoverTemplate.appendChild(mailNode);				
							hoverTemplate.appendChild(newLineBreak());
							
							var addDLNode = newnode("div", {flt:"left", fontWeight:"bold", paddingLeft:"7px"}, {}, [document.createTextNode(OXContactHover.actualobject.distribution_list[m].display_name + ":\xa0")]);
							var tmpnode=addDLNode.cloneNode(true);
							tmpnode.style.display="block";
							tmpnode.style.zIndex=-1;
							body.appendChild(tmpnode);
							var tmpDivwidth=tmpnode.offsetWidth;
							body.removeChild(tmpnode);
							var diff = OXContactHover.hoverWidth - tmpDivwidth - 30;
							hoverTemplate2.appendChild(addDLNode);	
							var mailNode2 = newnode("div", {flt:"left",cursor: "pointer", overflow:"hidden", width: diff + "px"}, {title: emailAdress}, [document.createTextNode(emailAdress)])
							
							var tmpnode2=addDLNode.cloneNode(true);
							tmpnode2.style.display="block";
							tmpnode2.style.zIndex=-1;
							body.appendChild(tmpnode2);
							var tmpDivwidth2=tmpnode2.offsetWidth;
							body.removeChild(tmpnode2);
							
							addDOMEvent(mailNode2, "click", function() { sendMailToContactMail(emailAdress) });
							hoverTemplate2.appendChild(mailNode2);		
							
							
							if(tmpDivwidth2 > diff) {
								hoverTemplate2.appendChild(document.createTextNode("\xa0..."))
							}
									
							hoverTemplate2.appendChild(newLineBreak());								
						})(k)						
					}					
				} else {					
					OXContactHover.slider.getTabById("addresses").show(true);
					OXContactHover.slider.getTabById("additional").show(false);
					
					var contactPhones = [];
					var contactPhonesDesc = [];
					var contactMobiles = [];
					var contactMobilesDesc = [];
					var contactMails = [];
					var contactMailsDesc = [];
					var contactFax = [];
					var contactFaxDesc = [];
					
					for (idfield in OXContactHover.actualobject) {
					
							if (!OXContactHover.actualobject[idfield]) {
								continue;
							}
									
						(function(idfields) {
							if(idfields.indexOf("telephone_business1") != -1) {
								contactPhones.push(OXContactHover.actualobject[idfields]);
								contactPhonesDesc.push(_("Phone (business):"));
							} else if(idfields.indexOf("telephone_company") != -1) {
								contactPhones.push(OXContactHover.actualobject[idfields]);
								contactPhonesDesc.push(_("Phone (company):"));
							}
							else if(idfields.indexOf("telephone_home1") != -1) {
								contactPhones.push(OXContactHover.actualobject[idfields]);
								contactPhonesDesc.push(_("Phone (private):"));
							}
							else if(idfields.indexOf("telephone_other") != -1) {
								contactPhones.push(OXContactHover.actualobject[idfields]);
								contactPhonesDesc.push(_("Phone (other):"));
							}
							else if(idfields.indexOf("cellular_telephone1") != -1) {
								contactMobiles.push(OXContactHover.actualobject[idfields]);
								contactMobilesDesc.push(_("Mobile:"));
							}
							else if(idfields.indexOf("cellular_telephone2") != -1) {
								contactMobiles.push(OXContactHover.actualobject[idfields]);
								contactMobilesDesc.push(_("Mobile (private):"));
							}
							else if(idfields.indexOf("email1") != -1) {
								contactMails.push(OXContactHover.actualobject[idfields]);
								contactMailsDesc.push(_("E-Mail (business):"));
							}
							else if(idfields.indexOf("email2") != -1) {
								contactMails.push(OXContactHover.actualobject[idfields]);
								contactMailsDesc.push(_("E-Mail (private):"));
							}
							else if(idfields.indexOf("email3") != -1) {
								contactMails.push(OXContactHover.actualobject[idfields]);
								contactMailsDesc.push(_("E-Mail (other):"));
							}
							else if(idfields.indexOf("fax_business") != -1) {
								contactFax.push(OXContactHover.actualobject[idfields]);
								contactFaxDesc.push(_("Fax (business):"));
							}
							else if(idfields.indexOf("fax_home") != -1) {
								contactFax.push(OXContactHover.actualobject[idfields]);
								contactFaxDesc.push(_("Fax (private):"));
							}
							else if(idfields.indexOf("fax_other") != -1) {
								contactFax.push(OXContactHover.actualobject[idfields]);
								contactFaxDesc.push(_("Fax (other):"));
							}
						})(idfield)						
					}
					
					if(contactMobiles && contactMobiles.length>0) {
						for(var s=0; s< contactMobiles.length; s++) {
							hoverTemplate.appendChild(newnode("div", {}, {className: "cardHoverLabel"}, [document.createTextNode(contactMobilesDesc[s])]));
							hoverTemplate.appendChild(newnode("div", {}, {className: "hoverContactline"}, [document.createTextNode(contactMobiles[s])]));				
							hoverTemplate.appendChild(newLineBreak());
						}						
					}
					
					if(contactPhones && contactPhones.length>0) {
						for(var s=0; s< contactPhones.length; s++) {
							hoverTemplate.appendChild(newnode("div", {}, {className: "cardHoverLabel"}, [document.createTextNode(contactPhonesDesc[s])]));
							hoverTemplate.appendChild(newnode("div", {}, {className: "hoverContactline"}, [document.createTextNode(contactPhones[s])]));				
							hoverTemplate.appendChild(newLineBreak());
						}						
					}
					
					if(contactMails && contactMails.length>0) {
						for(var s=0; s< contactMails.length; s++) {
							(function(t) {
								hoverTemplate.appendChild(newnode("div", {}, {className: "cardHoverLabel"}, [document.createTextNode(contactMailsDesc[t])]));
								var emailAdressContact = contactMails[t];
								//hoverTemplate.appendChild(newnode("div", {}, {className: "cardHoverIcon"}, [newnode("img", {}, {src: getFullImgSrc("img/mail/unread.gif")})]));
								var mailNode3 = newnode("div", {cursor: "pointer"}, {className: "hoverContactline", title: emailAdressContact}, [document.createTextNode(emailAdressContact)]);
								addDOMEvent(mailNode3, "click", function() { sendMailToContactMail(emailAdressContact) });
								hoverTemplate.appendChild(mailNode3);				
								hoverTemplate.appendChild(newLineBreak());
							})(s)
						}						
					}
						
					if(contactFax && contactFax.length>0) {
						for(var s=0; s< contactFax.length; s++) {
							hoverTemplate.appendChild(newnode("div", {}, {className: "cardHoverLabel"}, [document.createTextNode(contactFaxDesc[s])]));
							hoverTemplate.appendChild(newnode("div", {}, {className: "hoverContactline"}, [document.createTextNode(contactFax[s])]));				
							hoverTemplate.appendChild(newLineBreak());
						}						
					}
					
					// CATEGORIES
					if (OXContactHover.actualobject.categories) {
						var crby = newnode("div", { width:"100%", padding: "0 3px 0 7px" });
						hoverTemplate.appendChild(crby);
						hoverTemplate.appendChild(newLineBreak());
						ox.categories.ui.drawCategoriesList(ox.categories.getByString(OXContactHover.actualobject.categories), crby);
					}
					
					var crby = newnode("div", { width:"100%", paddingTop:"12px" }, {className: "cardHoverLabel"});	
					hoverTemplate.appendChild(crby);
					hoverTemplate.appendChild(newLineBreak());
					if (OXContactHover.actualobject.created_by) {
						internalCache.getUsers([OXContactHover.actualobject.created_by],function(response) {
							try {
								var created_by = response[OXContactHover.actualobject.created_by].display_name || "";
								var created_on = formatDate(OXContactHover.actualobject.creation_date, "datetime") || "";
								//#. %1$s is the creation date.
								//#. %2$s is the name of the creator.
								//#, c-format
								var txt = format(_("Created on %1$s by %2$s"), [created_on, created_by]);
								crby.appendChild(document.createTextNode(txt));
							} catch(n) {}
						});
					}
					
					var chby = newnode("div", { width:"100%" }, {className: "cardHoverLabel"});
					hoverTemplate.appendChild(chby);
					hoverTemplate.appendChild(newLineBreak());
					if (OXContactHover.actualobject.modified_by) {
						internalCache.getUsers([OXContactHover.actualobject.modified_by],function(response) {
							try {
								var changed_by = response[OXContactHover.actualobject.modified_by].display_name || "";
								var changed_on = formatDate(OXContactHover.actualobject.last_modified, "datetime") || "";
								//#. %1$s is the last modification date.
								//#. %2$s is the name of the last editor.
								//#, c-format
								var txt = format(_("Last changed on %1$s by %2$s"), [changed_on, changed_by]);
								chby.appendChild(document.createTextNode(txt));
							} catch(n) {}
						});
					}
					
					var oMyAddresses2 = new BuildAddresses(OXContactHover.actualobject);
					var AdressesO = {};
					
					var businessAddrArray2	= oMyAddresses2.buildAddress("business");	
					var privateAddrArray2	= oMyAddresses2.buildAddress("home");		
					var otherAddrArray2	= oMyAddresses2.buildAddress("other");
					var noAddressFound = true;			
					if(businessAddrArray2[0] && businessAddrArray2[0] != "") {
						hoverTemplate2.appendChild(newnode("div", {fontWeight:"bold"}, {className: "hoverContactline2"}, [document.createTextNode(_("Business"))]));				
						hoverTemplate2.appendChild(newLineBreak());
						if (OXContactHover.actualobject.company) {
							hoverTemplate2.appendChild(newnode("div", {paddingLeft:"7px"},{}, [document.createTextNode(OXContactHover.actualobject.company)]));
						}
						hoverTemplate2.appendChild(newnode("div", {paddingLeft:"7px"},{}, [businessAddrArray2[0]]));		
						hoverTemplate2.appendChild(newLineBreak());
						noAddressFound = false;
					}
					if(privateAddrArray2[0] && privateAddrArray2[0] != "") {
						hoverTemplate2.appendChild(newnode("div", {fontWeight:"bold"}, {className: "hoverContactline2"}, [document.createTextNode(_("Private"))]));				
						hoverTemplate2.appendChild(newLineBreak());
						hoverTemplate2.appendChild(newnode("div", {paddingLeft:"7px"},{}, [privateAddrArray2[0]]));	
						hoverTemplate2.appendChild(newLineBreak());
						noAddressFound = false;
					}	
					if(otherAddrArray2[0] && otherAddrArray2[0] != "") {
						hoverTemplate2.appendChild(newnode("div", {fontWeight:"bold"}, {className: "hoverContactline2"}, [document.createTextNode(_("Additional"))]));				
						hoverTemplate2.appendChild(newLineBreak());
						hoverTemplate2.appendChild(newnode("div", {paddingLeft:"7px"},{}, [otherAddrArray2[0]]));				
						hoverTemplate2.appendChild(newLineBreak());
						noAddressFound = false;
					}
					if(noAddressFound) {
						hoverTemplate2.appendChild(newnode("div", {fontWeight:"bold", padding: "7px"}, {className: "hoverContactline2"}, [document.createTextNode(_("No addresses available"))]));
					}

				}
			
			fillContent("notesmall", getDivforTextContent(OXContactHover.actualobject.note || "",5),null,true);
			fillContent("notemiddle", getDivforTextContent(OXContactHover.actualobject.note || "",10),null,true);
			fillContent("notefull", getDivforTextContent(OXContactHover.actualobject.note || ""),null,true);
			
			OXContactHover.accordion.addComponent("Contact_General",hoverTemplate,false);
			OXContactHover.accordion.addComponent("Contact_Additional",hoverTemplate2,false);
			OXContactHover.accordion.addComponent("NoteSmall",OXContactHover.references["core_content_small"],200)
			OXContactHover.accordion.addComponent("NoteMiddle",OXContactHover.references["core_content_middle"],200)
			OXContactHover.accordion.addComponent("NoteFull",OXContactHover.references["core_content_full"],200)	
}


OXContactHover.refillContent = function(id, folder, callback) {
	function fillContent(type,value,titletext,clear,show) {
		if(clear) { removeChildNodes(OXContactHover.references[type]); }
		if(value) { OXContactHover.references[type].appendChild(value); }
		if(titletext) { OXContactHover.references[type].title=titletext; }
		if(show) { OXContactHover.references[type].style.display=""; }
	}
	function fillText(type,text,titletext,clear) {
		if(clear) { removeChildNodes(OXContactHover.references[type]); }
		if(text) { OXContactHover.references[type].appendChild(document.createTextNode(text)); }
		if(titletext) { OXContactHover.references[type].title=titletext; }
	}
	
	var collection={};
    collection.objects=collection.objects=[OXContactMapping.createKeyFromObject({"module" : "contacts" ,"folder_id" : folder, id : id})];;
    collection.columns=null;
    
    OXContactHover.oxCacheRequest=OXCache.newRequest(null,"contacts",collection,null,
    function(daten) {
        if (daten.objects[0]) {
			OXContactHover.actualobject=daten.objects[0];
	        OXContactHover.actualobject.id=id;
	        OXContactHover.actualobject.folder_id=folder;
	        OXContactHover.fillGeneral(id, folder);
			
	        OXContactHover.slider.getTabById("attachments").setTitle(_("Attachments") + " (0)");
			OXGroupwareHover.fillAttachments(OXContactHover);
			
			OXContactHover.slider.selectTabById("general");
			
			if (callback) callback();
		}
	});	
}


function OXTaskHover() {}
OXTaskHover.actualmodule="tasks";
OXTaskHover.moduleint=4;
OXTaskHover.contentobject;
OXTaskHover.actualobject;
OXTaskHover.references=new Object();
OXTaskHover.references.allGroups=new Array();
OXTaskHover.references.allGroupsParticipants=new Object();
OXTaskHover.getContent = function() {
	if(OXTaskHover.contentobject) { 
		return OXTaskHover.contentobject;
	}
	var element=createHoverContent(null,null,null,null,2);
	OXTaskHover.accordion=new Accordion(450,400);	
	refillImages("template_tasks_hover_page1");
	var contentnode=$("template_tasks_hover_page1"); //.cloneNode(true);
	//$("template_tasks_hover_page1").parentNode.removeChild($("template_tasks_hover_page1"));
	contentnode.id="";
	OXTaskHover.references["core"]=contentnode;
	OXTaskHover.accordion.addComponent("Task_General",contentnode,false);
		
	var tmptds=OXTaskHover.references["core"].getElementsByTagName("td");
	OXTaskHover.references["title"]=tmptds[1];
	OXTaskHover.references["coreimg1"]=tmptds[2];
	OXTaskHover.references["coreimg2"]=tmptds[3];
	OXTaskHover.references["coreimg3"]=tmptds[4];
	OXTaskHover.references["status"]=tmptds[5];
	OXTaskHover.references["priority"]=tmptds[6];
	OXTaskHover.references["start_time"]=tmptds[8];
	OXTaskHover.references["end_time"]=tmptds[10];
	OXTaskHover.references["categories"]=tmptds[11];
	OXTaskHover.references["created_by"]=tmptds[12];
	OXTaskHover.references["changed_by"]=tmptds[13];
	
	OXTaskHover.references["core_content_small"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXTaskHover.accordion.addComponent("NoteSmall",OXTaskHover.references["core_content_small"],200);
	var tmptds=OXTaskHover.references["core_content_small"].getElementsByTagName("td");
	OXTaskHover.references["notesmall"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXTaskHover.accordion.showContent('Task_General,NoteMiddle'); });
	
	OXTaskHover.references["core_content_middle"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXTaskHover.accordion.addComponent("NoteMiddle",OXTaskHover.references["core_content_middle"],200);
	var tmptds=OXTaskHover.references["core_content_middle"].getElementsByTagName("td");
	OXTaskHover.references["notemiddle"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXTaskHover.accordion.showContent('Task_General,NoteFull'); });
	
	OXTaskHover.references["core_content_full"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXTaskHover.accordion.addComponent("NoteFull",OXTaskHover.references["core_content_full"],200);
	var tmptds=OXTaskHover.references["core_content_full"].getElementsByTagName("td");
	OXTaskHover.references["notefull"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXTaskHover.accordion.showContent('Task_General,NoteSmall'); });
		
	
	var tabs = new Tabbing("2");
	tabs.addTab(
			new Tab("general", _("General"), 
				function() { 
					OXTaskHover.accordion.showContent("Task_General,NoteSmall");
				}
			)
	);
	tabs.addTab(
			new Tab("participants", _("Participants"),
				function() { 
					var tmpstring=OXOperationHover.getParticipantsString(OXTaskHover);
					OXTaskHover.accordion.showContent(tmpstring);
					// re-position of old group/participant state if switching back to this tab
					for (var i in OXTaskHover.references.allGroupsParticipants) {
		        		var group = OXTaskHover.references.allGroupsParticipants[i];
		        		if (group.active) {
		        			OXTaskHover.accordion.showExtraContent(i);
		        		}		        		
		        	}
				}
			)
	);
	tabs.addTab(
			new Tab("attachments", _("Attachments"),
				function() { 
					OXTaskHover.accordion.showContent("Attachments");
				}
			)
	);
	
	OXTaskHover.slider = tabs;
	
	var node = OXTaskHover.accordion.getDomNode();
	var d = newnode("div",{ padding:"0px" , overflow:"hidden"},{className : "tabbing_tab"},[
		newnode("table",{ height : "22px "},{cellPadding : 0, cellSpacing : 0, border : 0, width : "100%"},[
			newnode("tbody",{},{},[
			    tabs.getDOMNode()
			])
		])
	]);	
	
	element.body.appendChild(d);
	element.body.appendChild(node);
	element.node.display="none";
	body.appendChild(element.node);
	OXTaskHover.contentobject = element;
	
	return OXTaskHover.contentobject; 
}
OXTaskHover.refillContent = function(id,folder) {


	var collection={};
    collection.objects=collection.objects=[OXTaskMapping.createKeyFromObject({"module" : "tasks" ,"folder_id" : folder, id : id})];;
    collection.columns=null;

    OXTaskHover.oxCacheRequest=OXCache.newRequest(null,"tasks",collection,null,
    function(daten) {
        if(daten.objects[0]) {	        	        
			OXTaskHover.actualobject=daten.objects[0];
			OXTaskHover.fillGeneral();
			OXOperationHover.fillParticipants(OXTaskHover);
			OXGroupwareHover.fillAttachments(OXTaskHover);         	
			OXTaskHover.slider.selectTabById("general");
        }           
    });
};
OXTaskHover.fillGeneral= function() {
	function fillContent(type,value,titletext,clear,show) {
		if(clear) { removeChildNodes(OXTaskHover.references[type]); }
		if(value) { OXTaskHover.references[type].appendChild(value); }
		if(titletext) { OXTaskHover.references[type].title=titletext; }
		if(show) { OXTaskHover.references[type].style.display=""; }
	}
	function fillText(type,text,titletext,clear) {
		if(clear) { removeChildNodes(OXTaskHover.references[type]); }
		if(text) { OXTaskHover.references[type].appendChild(document.createTextNode(text)); }
		if(titletext) { OXTaskHover.references[type].title=titletext; }
	}
	function getStatusTaskNode(status,percent_completed) {
		var statstr=_("unknown");
		switch(status) {
			case null:
			case 1: statstr=_("Not started"); break;
			case 2: statstr=_("In progress"); break;
			case 3: statstr=_("Done"); break;
			case 4: statstr=_("Waiting"); break;
			case 5: statstr=_("Deferred"); break;
		}
		fillText("status",statstr,percent_completed +" " +
		_("% completed") /*i18n*/,true);	
	}
	function getPrioNode(priority,count) {
		//OXTaskHover.references["priority"].colspan=count || 1;
		var statstr=_("unknown"); /*i18n*/
		switch(priority) {
			case 1: statstr=_("Low"); /*i18n*/ break;			
			case 3: statstr=_("High"); /*i18n*/ break;
			default:
				priority = 2;
				statstr=_("Normal"); /*i18n*/ 
			break;
		}
		fillContent("priority",newnode("img",{},{ src: getFullImgSrc("img/tasks/taskprio"+priority+".gif")},[]),statstr,true,true);
	}
	var object=OXTaskHover.actualobject;
//TITLE
	fillText("title",object.title ? object.title : "",object.title ? object.title : "",true);
	var count=0;
	//PRIVATE FLAG OR GROUP APPOINTMENT
	if(object.private_flag) {
		fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/private_flag.gif")},[]),_("Private task"),true,true);
		count++;
	}
	//RECURRENCE APPOINTMENT
	if(object.recurrence_type && object.recurrence_type != 0) {
		fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/tasks/sequence.gif")},[]),_("Series task"),true,true);
		count++;
	}
	//FLAGS
	if(object.color_label && object.color_label!=0) {
		fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/menu/tag_"+object["color_label"]+".gif")},[]),null,true,true);
		count++;
	}
	getPrioNode(object.priority,count)
	
	for(;count<3;count++) {
		if(count<2) {
			fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/dummy.gif")},[]),null,true,true);			
		} else {
			OXTaskHover.references["coreimg"+(count+1)].style.display="none";
		}
	}
	getStatusTaskNode(object.status,object.percent_completed);
	//DATE AND TIME
	if(object.start_date) {
		fillText("start_time", formatDate(object.start_date,"date"),formatDate(object.start_date,"date"),true);
	} else {
		fillText("start_time", _("Not set"), "", true);
	}
	if(object.end_date) {
		fillText("end_time", formatDate(object.end_date,"date"),formatDate(object.end_date,"date"),true);
	} else {
		fillText("end_time", _("Not set"), "", true);
	}
	
	if (object.created_by) {
		internalCache.getUsers([object.created_by],function(response) {
			try {
				var created_by = response[object.created_by].display_name || "";
				var created_on = formatDate(object.creation_date, "datetime") || "";
                //#. %1$s is the creation date.
                //#. %2$s is the name of the creator.
                //#, c-format
				var txt = format(_("Created on %1$s by %2$s"), [created_on, created_by]);
				fillText("created_by", txt, txt, true);	
			} catch(n) {}
		});
	} else {
		fillText("created_by", "", "",true);
	}
	
	if (object.modified_by) {
		internalCache.getUsers([object.modified_by],function(response) {
			try {
				var changed_by = response[object.modified_by].display_name || "";
				var changed_on = formatDate(object.last_modified, "datetime") || "";
                //#. %1$s is the last modification date.
                //#. %2$s is the name of the last editor.
                //#, c-format
				var txt = format(_("Last changed on %1$s by %2$s"), [changed_on, changed_by]);
				fillText("changed_by", txt, txt, true);	
			} catch(n) {}
		});
	} else {
		fillText("changed_by", "", "",true);
	}
	
	// CATEGORIES
	if (OXTaskHover.actualobject.categories) {
		var node = newnode("div");
		ox.categories.ui.drawCategoriesList(ox.categories.getByString(OXTaskHover.actualobject.categories), node);		
		fillContent("categories",node,null,true,true);
		OXTaskHover.references["categories"].parentNode.style.display="";
	} else {
		removeChildNodes(OXTaskHover.references["categories"]);
		OXTaskHover.references["categories"].parentNode.style.display="none";
	}

	//NOTE
	if(!object.note) { object.note="" }
	
	
	OXTaskHover.slider.getTabById("participants").setTitle(_("Participants") + " (" + OXTaskHover.actualobject.participants.length + ")");
	OXTaskHover.slider.getTabById("attachments").setTitle(_("Attachments") + " (0)");
		
	fillContent("notesmall", getDivforTextContent(object.note,5),null,true);
	fillContent("notemiddle", getDivforTextContent(object.note,10),null,true);
	fillContent("notefull", getDivforTextContent(object.note),null,true);
	OXTaskHover.accordion.checkComponentHeight("Task_General");
	OXTaskHover.accordion.checkComponentHeight("NoteSmall");
	OXTaskHover.accordion.checkComponentHeight("NoteMiddle");
	OXTaskHover.accordion.checkComponentHeight("NoteFull");
};
OXTaskHover.fillOthers=function() {	
}


function OXInfostoreHover() {}
OXInfostoreHover.actualmodule="infostore";
OXInfostoreHover.moduleint=137;
OXInfostoreHover.contentobject;
OXInfostoreHover.actualobject;
OXInfostoreHover.references=new Object();
OXInfostoreHover.references.allVersions=new Array();
OXInfostoreHover.references.allVersionComments=new Object();
OXInfostoreHover.getVersionsString= function(Hover) {
	var tmpstring="Versions";
	for(var i=0;i<Hover.references.allVersions.length;i++) {
		tmpstring+=","+Hover.references.allVersions[i];
	}
	return tmpstring;
}	

OXInfostoreHover.getContent = function() {
	if(OXInfostoreHover.contentobject) { 
		return OXInfostoreHover.contentobject;
	}
	var element=createHoverContent(null,null,null,null,3);
	OXInfostoreHover.accordion=new Accordion(450,400);	
	
	refillImages("template_infostore_hover_page1");
	var contentnode=$("template_infostore_hover_page1"); //.cloneNode(true);
	//$("template_infostore_hover_page1").parentNode.removeChild($("template_infostore_hover_page1"));
	contentnode.id="";
	OXInfostoreHover.references["core"]=contentnode;
	OXInfostoreHover.accordion.addComponent("Infostore_General",contentnode,false);
		
	var tmptds=OXInfostoreHover.references["core"].getElementsByTagName("td");
	OXInfostoreHover.references["title"]=tmptds[1];
	OXInfostoreHover.references["coreimg1"]=tmptds[2];
	OXInfostoreHover.references["coreimg2"]=tmptds[3];
	OXInfostoreHover.references["coreimg3"]=tmptds[4];
	OXInfostoreHover.references["categories"]=tmptds[6];
	OXInfostoreHover.references["created_by"]=tmptds[7];
	OXInfostoreHover.references["changed_by"]=tmptds[8];
	OXInfostoreHover.references["url"]=tmptds[10];
	OXInfostoreHover.references["attachment"]=tmptds[11];
	OXInfostoreHover.references["attachment_version"]=OXInfostoreHover.references["attachment"].getElementsByTagName("td")[0];
	OXInfostoreHover.references["attachment_mimetype"]=OXInfostoreHover.references["attachment"].getElementsByTagName("td")[1];
	OXInfostoreHover.references["attachment_filename"]=OXInfostoreHover.references["attachment"].getElementsByTagName("td")[2];
	OXInfostoreHover.references["attachment_openfile"]=OXInfostoreHover.references["attachment"].getElementsByTagName("td")[3];
	OXInfostoreHover.references["attachment_savefile"]=OXInfostoreHover.references["attachment"].getElementsByTagName("td")[4];
	
	
	OXInfostoreHover.references["core_content_small"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXInfostoreHover.accordion.addComponent("NoteSmall",OXInfostoreHover.references["core_content_small"],200);
	var tmptds=OXInfostoreHover.references["core_content_small"].getElementsByTagName("td");
	OXInfostoreHover.references["notesmall"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXInfostoreHover.accordion.showContent('Infostore_General,NoteMiddle'); });
	
	OXInfostoreHover.references["core_content_middle"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXInfostoreHover.accordion.addComponent("NoteMiddle",OXInfostoreHover.references["core_content_middle"],200);
	var tmptds=OXInfostoreHover.references["core_content_middle"].getElementsByTagName("td");
	OXInfostoreHover.references["notemiddle"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXInfostoreHover.accordion.showContent('Infostore_General,NoteFull'); });
	
	OXInfostoreHover.references["core_content_full"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXInfostoreHover.accordion.addComponent("NoteFull",OXInfostoreHover.references["core_content_full"],200);
	var tmptds=OXInfostoreHover.references["core_content_full"].getElementsByTagName("td");
	OXInfostoreHover.references["notefull"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXInfostoreHover.accordion.showContent('Infostore_General,NoteSmall'); });
	
	
	var tabs = new Tabbing("3");
	tabs.addTab(
			new Tab("general", _("General"), 
				function() { 
					OXInfostoreHover.accordion.showContent("Infostore_General,NoteSmall");
				}
			)
	);
	tabs.addTab(
			new Tab("versions", _("Versions"),
				function() { 
					OXInfostoreHover.accordion.showContent(OXInfostoreHover.getVersionsString(OXInfostoreHover));					
					// re-position of old version comment state if switching back to this tab
					for (var i in OXInfostoreHover.references.allVersionComments) {
		        		var ver = OXInfostoreHover.references.allVersionComments[i];
		        		if (ver.active) {
		        			OXInfostoreHover.accordion.showExtraContent(i);
		        		}		        		
		        	}
				}
			)
	);
	
	OXInfostoreHover.slider = tabs;
	
	var node = OXInfostoreHover.accordion.getDomNode();
	var d = newnode("div",{ padding:"0px" , overflow:"hidden"},{className : "tabbing_tab"},[
		newnode("table",{ height : "22px "},{cellPadding : 0, cellSpacing : 0, border : 0, width : "100%"},[
			newnode("tbody",{},{},[
			    tabs.getDOMNode()
			])
		])
	]);	
	
	element.body.appendChild(d);
	element.body.appendChild(node);
	element.node.display="none";
	body.appendChild(element.node);
	OXInfostoreHover.contentobject = element;
	
	return OXInfostoreHover.contentobject; 
}
OXInfostoreHover.refillContent = function(id,folder) {

	var collection={};
    collection.objects=collection.objects=[OXInfoStoreMapping.createKeyFromObject({"module" : "infostore" ,"folder_id" : folder, id : id})];;
    collection.columns=null;

    OXInfostoreHover.oxCacheRequest=OXCache.newRequest(null,"infostore",collection,null,
    function(daten) {
        if(daten.objects[0]) {	        	        
	    	OXInfostoreHover.actualobject=daten.objects[0];
	    	
			OXInfostoreHover.slider.getTabById("versions").setTitle(_("Versions") + " ("+OXInfostoreHover.actualobject.number_of_versions+")");
			
			OXInfostoreHover.fillGeneral();
			OXInfostoreHover.fillVersions(OXInfostoreHover);	
			OXInfostoreHover.accordion.checkComponentHeight("Infostore_General");
			OXInfostoreHover.accordion.checkComponentHeight("NoteFull");
			OXInfostoreHover.accordion.checkComponentHeight("NoteMiddle");
			OXInfostoreHover.accordion.checkComponentHeight("NoteSmall");
			
			OXInfostoreHover.slider.selectTabById("general");
        }           
    });
    

    
}
OXInfostoreHover.fillVersions = function(Hover) {
	for(var i in OXInfostoreHover.references.allVersions) {
		OXInfostoreHover.accordion.removeComponent(i);
	}
	
	OXInfostoreHover.slider.getTabById("versions").setTitle(_("Versions") + " ("+Hover.actualobject.number_of_versions+")");
	
	OXInfostoreHover.references.allVersions=new Array();
	OXInfostoreHover.references.allVersionComments=new Array();
	var usersnode=OXOperationHover.references["core_participants_participant_template"].cloneNode(true);
	var node=usersnode.getElementsByTagName("tbody")[0];
	node.appendChild(
		newnode("tr",{ fontWeight: "bold"}, { className: "contenttext notclickable" },[
			newnode("td",{ paddingTop:"7px" },{colSpan : 2 }, [
				document.createTextNode(_('Versions')) /*i18n*/
			])
		])		
	);
	if(!Hover.actualobject.filename || Hover.actualobject.filename == "") {
		var tmp=newnode("tr",{},{},[
			newnode("td",{ width: "25px"},{ className: "notclickable"},[
				newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[])
			]),
			newnode("td",{},{ colspan : 4 , className : "contenttext notclickable" },[
				document.createTextNode(_("No versions available")) /*i18n*/
			])		
		]);
		node.appendChild(tmp);
	}
	Hover.accordion.addComponent("Versions",usersnode,false);
	var columns="705,2,4,702,703,704,709"
	var sReq = AjaxRoot + "/infostore?action=versions&id=" + Hover.actualobject.id + "&columns="+columns+"&session=" + session;
	(new JSON()).get(sReq, null,
	function(versions) {
		versions=versions.data;
		var attachmentfirst=
			newnode("tr",{},{},[
				// EXPAND
				newnode("td",{ width: "20px", paddingTop:"12px", lineHeight : "0px"},{ className : "clickable"},[
					newnode("img",{},{ src: getFullImgSrc("img/plus.gif") },[]) 
				]),
				// Version
				newnode("td",{ width: "40px", paddingTop:"12px", textAlign:"center"},{ className : "notclickable"},[ 
				]),
				//TYPE
				newnode("td",{ width: "20px", paddingTop:"12px", lineHeight : "0px"},{ className : "notclickable"},[
					newnode("img",{ height: "16px" , width : "16px"},{ src: getFullImgSrc("img/dummy.gif") },[]) 
				]),
				
				//TEXT
				newnode("td",{ paddingTop:"12px", overflow: "hidden"},{ colSpan : 2 , className : "contenttext notclickable"},[]),
				//OPEN
				newnode("td",{ width: "20px", paddingTop:"12px" , lineHeight : "0px"},{ className : "clickable"},[
					newnode("img",{},{ src: getFullImgSrc("img/menu/attachment_open.gif") },[])
				]),
				//SAVE
				newnode("td",{ width: "20px", paddingTop:"12px" , lineHeight : "0px"},{ className : "clickable"},[
					newnode("img",{},{ src: getFullImgSrc("img/menu/attachment_save.gif") },[])
				])
			]);
		var attachmentsecond=
			newnode("tr",{},{},[
				newnode("td",{ fontWeight: "bold", width: "20px", paddingLeft : "3px" , paddingRight:"7px" },{ className : "contenttext notclickable"},[
				]),
				newnode("td",{},{ className : "contenttext notclickable"},[
				])
			]);
		var attachmentthird=
			newnode("tr",{},{ className : "notclickable" },[
				newnode("td",{ paddingLeft: "7px"},{ colSpan : 2 },[
				])
			]);
		
		for(var i=0;i<versions.length;i++) {
			var versionnode=OXOperationHover.references["core_participants_participant_template"].cloneNode(true);
			versionnode.getElementsByTagName("table")[0].style.tableLayout="fixed";
			var versionbody=versionnode.getElementsByTagName("tbody")[0];
			var versionfirst=attachmentfirst.cloneNode(true);
			versionfirst.getElementsByTagName("td")[1].appendChild(document.createTextNode(_("Nr:")+" "+versions[i][0]));
			versionfirst.getElementsByTagName("img")[1].src=getMimeImage(versions[i][4]);
			versionfirst.getElementsByTagName("img")[1].title=versions[i][4];
			versionfirst.getElementsByTagName("td")[3].appendChild(document.createTextNode(versions[i][3]))
			versionfirst.getElementsByTagName("img")[2].title=_("Open version") /*i18n*/;
			
			addDOMEvent(versionfirst.getElementsByTagName("img")[2],"click",OXInfostoreHover.openAttachedFile(Hover.actualobject.id,versions[i][3],versions[i][0]));
			versionfirst.getElementsByTagName("img")[3].title=_("Save version") /*i18n*/;
			
			addDOMEvent(versionfirst.getElementsByTagName("img")[3],"click",OXInfostoreHover.saveAttachedFile(Hover.actualobject.id,versions[i][3],versions[i][0]));
			
			addDOMEvent(versionfirst.getElementsByTagName("td")[0],"click",(function(name,td) {
					return function() {
						if(Hover.references.allVersionComments[name]) {
							if(Hover.references.allVersionComments[name].active) {
								Hover.accordion.hideExtraContent(name);
								Hover.references.allVersionComments[name].active=false;
								td.getElementsByTagName("img")[0].src=getFullImgSrc("img/plus.gif");
							} else {
								Hover.accordion.showExtraContent(name);
								Hover.references.allVersionComments[name].active=true;
								td.getElementsByTagName("img")[0].src=getFullImgSrc("img/minus.gif");
							}
						}
					}})("VersionComment_"+i,versionfirst.getElementsByTagName("td")[0])
				);
			
			versionbody.appendChild(versionfirst);
			Hover.accordion.addComponent("Version_"+i,versionnode,false);
			Hover.references.allVersions.push("Version_"+i);
			var versioncommentnode=OXOperationHover.references["core_participants_participant_template"].cloneNode(true);
			var versioncommentbody=versioncommentnode.getElementsByTagName("tbody")[0];
			var versionsecond=attachmentsecond.cloneNode(true);
			versionsecond.getElementsByTagName("td")[0].appendChild(document.createTextNode(_("Size:")));
			versionsecond.getElementsByTagName("td")[1].appendChild(document.createTextNode(OXGroupwareHover.getShortByteString(versions[i][5],false)));
			versionsecond.getElementsByTagName("td")[1].title=OXGroupwareHover.getShortByteString(versions[i][5],true);
			versioncommentbody.appendChild(versionsecond);
			var versionsecond=attachmentsecond.cloneNode(true);
			versionsecond.getElementsByTagName("td")[0].appendChild(document.createTextNode(_("Creation date:")));
			versionsecond.getElementsByTagName("td")[1].appendChild(document.createTextNode(formatDate(versions[i][2],"datetime")));
			versioncommentbody.appendChild(versionsecond);
			var versionsecond=attachmentsecond.cloneNode(true);
			versionsecond.getElementsByTagName("td")[0].appendChild(document.createTextNode(_("Created by:")));
			internalCache.getUsers([versions[i][1]],(function (node,id) {
				return function(cb) {
					node.appendChild(document.createTextNode(cb[id].display_name));	
				};	
			})(versionsecond.getElementsByTagName("td")[1],versions[i][1]));
			versioncommentbody.appendChild(versionsecond);						
			
			
			if(versions[i][6]) {
				var versionsecond=attachmentsecond.cloneNode(true);
				versionsecond.getElementsByTagName("td")[0].appendChild(document.createTextNode(_("Comment:")));
				versioncommentbody.appendChild(versionsecond);	
				var versionthird=attachmentthird.cloneNode(true);
				versionthird.getElementsByTagName("td")[0].appendChild(getDivforTextContent(versions[i][6],null,true));
				versioncommentbody.appendChild(versionthird);
			}
			Hover.accordion.addComponent("VersionComment_"+i,versioncommentnode,200);
			Hover.references.allVersionComments["VersionComment_"+i]= { active : false }	
		}
	});	
}
OXInfostoreHover.fillGeneral = function() {
	function fillContent(type,value,titletext,clear,show) {
		if(clear) { removeChildNodes(OXInfostoreHover.references[type]); }
		if(value) { OXInfostoreHover.references[type].appendChild(value); }
		if(titletext) { OXInfostoreHover.references[type].title=titletext; }
		if(show) { OXInfostoreHover.references[type].style.display=""; }
	}
	function fillText(type,text,titletext,clear) {
		if(clear) { removeChildNodes(OXInfostoreHover.references[type]); }
		if(text) { OXInfostoreHover.references[type].appendChild(document.createTextNode(text)); }
		if(titletext) { OXInfostoreHover.references[type].title=titletext; }
	}
	var object=OXInfostoreHover.actualobject;
	//TITLE
	fillText("title",object.title ? object.title : "",object.title ? object.title : "",true);
	
	if (object.created_by) {
		internalCache.getUsers([object.created_by],function(response) {
			try {
				var created_by = response[object.created_by].display_name || "";
				var created_on = formatDate(object.creation_date, "datetime") || "";
                //#. %1$s is the creation date.
                //#. %2$s is the name of the creator.
                //#, c-format
				var txt = format(_("Created on %1$s by %2$s"), [created_on, created_by]);
				fillText("created_by", txt, txt, true);	
			} catch(n) {}
		});
	} else {
		fillText("created_by", "", "",true);
	}
	
	if (object.modified_by) {
		internalCache.getUsers([object.modified_by],function(response) {
			try {
				var changed_by = response[object.modified_by].display_name || "";
				var changed_on = formatDate(object.last_modified, "datetime") || "";
                //#. %1$s is the last modification date.
                //#. %2$s is the name of the last editor.
                //#, c-format
				var txt = format(_("Last changed on %1$s by %2$s"), [changed_on, changed_by]);
				fillText("changed_by", txt, txt, true);	
			} catch(n) {}
		});
	} else {
		fillText("changed_by", "", "",true);
	}
	
	// CATEGORIES
	if (object.categories && object.categories.length) {
		var node = newnode("div");
		var cat = object.categories;
		if (Object.prototype.toString.call(cat) == "[object Array]") {
			 cat = cat.join(", ");
		}
		ox.categories.ui.drawCategoriesList(ox.categories.getByString(cat), node);		
		fillContent("categories",node,null,true,true);
		OXInfostoreHover.references["categories"].parentNode.style.display="";
	} else {
		removeChildNodes(OXInfostoreHover.references["categories"]);
		OXInfostoreHover.references["categories"].parentNode.style.display="none";
	}
	
	var count=0;
	//LOCKED
	if(object.locked_until && object.locked_until != 0) {
		actcount=count;
		internalCache.getUsers([object.modified_by],function(reply) {
			fillContent("coreimg"+(actcount+1),newnode("img",{},{ src: getFullImgSrc("img/folder/document_locked.gif")},[]),_("locked by")+" "+reply[object.modified_by].display_name,true,true);			
		});
		count++;
	}
	//FLAGS
	if (object.color_label && object.color_label!=0) {
		fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/menu/tag_"+object["color_label"]+".gif")},[]),null,true,true);
		count++;
	}
	//ATTACHMENT
	if (object.filename && object.filename!="") {
		OXInfostoreHover.references["attachment"].parentNode.style.display="";
		OXInfostoreHover.references["attachment"].colSpan=count+2 || 2;		
		var filemimetype=getMimeImage(object.file_mimetype);
		fillText("attachment_version",_("Nr:")+" "+object.version,"",true);
		OXInfostoreHover.references["attachment_mimetype"].getElementsByTagName("img")[0].src=filemimetype; 
		OXInfostoreHover.references["attachment_mimetype"].getElementsByTagName("img")[0].title=object.file_mimetype;
		fillContent("attachment_openfile",newnode("img",{},{src:getFullImgSrc("img/menu/attachment_open.gif")},[]),_("Open attachment"),true,true);
		addDOMEvent(OXInfostoreHover.references["attachment_openfile"].getElementsByTagName("img")[0],"click",OXInfostoreHover.openAttachedFile(object.id,object.filename));
		fillContent("attachment_savefile",newnode("img",{},{src:getFullImgSrc("img/menu/attachment_save.gif")},[]),_("Save attachment"),true,true);
		addDOMEvent(OXInfostoreHover.references["attachment_savefile"].getElementsByTagName("img")[0],"click",OXInfostoreHover.saveAttachedFile(object.id,object.filename));
		fillText("attachment_filename",object.filename,object.version_comment,true);
	} else {
		OXInfostoreHover.references["attachment"].parentNode.style.display="none";
	}
	/*
	if(count == 0) {
		OXInfostoreHover.references["created_by_empty"].style.display="none";
	} else {
		OXInfostoreHover.references["created_by_empty"].colSpan=count;
	}
	*/
	for(;count<3;count++) {
		OXInfostoreHover.references["coreimg"+(count+1)].style.display="none";
	}
	//URL
	if(object.url && object.url!="") {
		OXInfostoreHover.references["url"].parentNode.style.display="";
		fillContent("url",newnode("a",{},{ href: object.url , target:"_blank" },[document.createTextNode(object.url)]),null,true,true);
	} else {
		OXInfostoreHover.references["url"].parentNode.style.display="none";
	}
	//NOTE
	if(!object.description) { object.description="" }
	fillContent("notesmall", getDivforTextContent(object.description,5),null,true);
	fillContent("notemiddle", getDivforTextContent(object.description,10),null,true);
	fillContent("notefull", getDivforTextContent(object.description),null,true);
}
OXInfostoreHover.openAttachedFile = function(id,filename,version) {
	return function() {
		var sURL = AjaxRoot + "/infostore/" + encodeURIComponent(filename)
				+ "?action=document&session=" + session 
				+ "&id=" + encodeURIComponent(id)
		if (version) {
			sURL=sURL+"&version="+version;
		}
		newWindow(sURL,"width=780px,height=640px,left=50,top=50,resizable=yes,menubar=no,toolbar=no,status=no,scrollbars=yes");
	}
}
OXInfostoreHover.saveAttachedFile = function(id,filename,version) {
	return function() {
		var sContentType = 'application/octet-stream';	
		var sURL = AjaxRoot + '/infostore/' 
					+ encodeURIComponent(filename) 
					+ '?action=document&session=' + session
					+ '&content_type=' + encodeURIComponent(sContentType) 
					+ '&id=' + encodeURIComponent(id);
		if (version) { 
			sURL=sURL+"&version="+version; 
		}
		var frame = $ALL("dlIframe") ? getFrameElement('dlIframe') : parent.frames['dlIframe'];
		frame.location.href = sURL;
	}
}
function OXAppointmentHover() {}
OXAppointmentHover.actualmodule="calendar";
OXAppointmentHover.moduleint=1;
OXAppointmentHover.contentobject;
OXAppointmentHover.actualobject;
OXAppointmentHover.confirmdialogshown=false;
OXAppointmentHover.references=new Object();
OXAppointmentHover.references.allGroups=new Array();
OXAppointmentHover.references.allGroupsParticipants=new Object();
OXAppointmentHover.fillOthers = function() {
	var othersmain=OXAppointmentHover.references["core_others_template"].cloneNode(true);
	ox.api.folder.getPathString({
	    folder: OXAppointmentHover.actualobject.folder_id,
	    success: function (resp) {
		    othersmain.getElementsByTagName("td")[3].appendChild(document.createTextNode(resp));
	    }
	});
	internalCache.getUsers([OXAppointmentHover.actualobject.modified_by],function(response) {
		othersmain.getElementsByTagName("td")[11].appendChild(document.createTextNode(response[OXAppointmentHover.actualobject.modified_by].display_name || ""));		
	});
	internalCache.getUsers([OXAppointmentHover.actualobject.created_by],function(response) {
		othersmain.getElementsByTagName("td")[7].appendChild(document.createTextNode(response[OXAppointmentHover.actualobject.created_by].display_name || ""));		
	});
		
	OXAppointmentHover.accordion.addComponent("AppointmentOthers",othersmain,false);
}
OXAppointmentHover.accordion=null;
OXAppointmentHover.actualHover=null;
OXAppointmentHover.actualobject=null;
OXAppointmentHover.getContent = function() {
	if(OXAppointmentHover.contentobject) { 
		return OXAppointmentHover.contentobject;
	}
	var element=createHoverContent(null,null,null,null,4);
	OXAppointmentHover.accordion=new Accordion(450,400);
	refillImages("template_calendar_hover_page1");
	refillImages("template_calendar_hover_attachments");
	refillImages("template_calendar_hover_others");
	var contentnode=$("template_calendar_hover_page1");
	contentnode.id="";
	OXAppointmentHover.references["core"]=contentnode;
	OXAppointmentHover.accordion.addComponent("AppointmentCore",contentnode,false);
	
	OXAppointmentHover.references["core_content_small"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXAppointmentHover.accordion.addComponent("NoteSmall",OXAppointmentHover.references["core_content_small"],200);
	var tmptds=OXAppointmentHover.references["core_content_small"].getElementsByTagName("td");
	OXAppointmentHover.references["notesmall"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXAppointmentHover.accordion.showContent('AppointmentCore,NoteMiddle'); });
	
	OXAppointmentHover.references["core_content_middle"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXAppointmentHover.accordion.addComponent("NoteMiddle",OXAppointmentHover.references["core_content_middle"],200);
	var tmptds=OXAppointmentHover.references["core_content_middle"].getElementsByTagName("td");
	OXAppointmentHover.references["notemiddle"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXAppointmentHover.accordion.showContent('AppointmentCore,NoteFull'); });
	
	OXAppointmentHover.references["core_content_full"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXAppointmentHover.accordion.addComponent("NoteFull",OXAppointmentHover.references["core_content_full"],200);
	var tmptds=OXAppointmentHover.references["core_content_full"].getElementsByTagName("td");
	OXAppointmentHover.references["notefull"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXAppointmentHover.accordion.showContent('AppointmentCore,NoteSmall'); });
	
	var tmptds=OXAppointmentHover.references["core"].getElementsByTagName("td");
	OXAppointmentHover.references["title"]=tmptds[1];
	OXAppointmentHover.references["coreimg1"]=tmptds[2];
	OXAppointmentHover.references["coreimg2"]=tmptds[3];
	OXAppointmentHover.references["coreimg3"]=tmptds[4];
	OXAppointmentHover.references["location"]=tmptds[5];
	OXAppointmentHover.references["start_time"]=tmptds[7];
	OXAppointmentHover.references["end_time"]=tmptds[9];
	OXAppointmentHover.references["categories"]=tmptds[10];
	OXAppointmentHover.references["created_by"]=tmptds[11];
	OXAppointmentHover.references["changed_by"]=tmptds[12];	
	
	var contentnode=$("template_calendar_hover_others");
	OXAppointmentHover.references["core_others_template"]=contentnode;
	OXAppointmentHover.accordion.addComponent("AppointmentOthers",contentnode,false);
	
	var tabs = new Tabbing("4");
	tabs.addTab(
			new Tab("general", _("General"), 
				function() { 
					OXAppointmentHover.accordion.showContent("AppointmentCore,NoteSmall");
				}
			)
	);
	tabs.addTab(
			new Tab("participants", _("Participants"),
				function() { 
			 		var tmpstring=OXOperationHover.getParticipantsString(OXAppointmentHover);
			 		OXAppointmentHover.accordion.showContent(tmpstring);
			 		// re-position of old group/participant state if switching back to this tab
					for (var i in OXAppointmentHover.references.allGroupsParticipants) {
		        		var group = OXAppointmentHover.references.allGroupsParticipants[i];
		        		if (group.active) {
		        			OXAppointmentHover.accordion.showExtraContent(i);
		        		}		        		
		        	}
				}
			)
	);
	tabs.addTab(
			new Tab("attachments", _("Attachments"),
				function() { 
			 		OXAppointmentHover.accordion.showContent("Attachments");
				}
			)
	);
	tabs.addTab(
			new Tab("others", _("Others"),
				function() { 
					OXAppointmentHover.accordion.showContent("AppointmentOthers");
				}
			)
	);
	
	OXAppointmentHover.slider = tabs;
	
	var node = OXAppointmentHover.accordion.getDomNode();
	var d = newnode("div",{ padding:"0px" , overflow:"hidden"},{className : "tabbing_tab"},[
		newnode("table",{ height : "22px "},{cellPadding : 0, cellSpacing : 0, border : 0, width : "100%"},[
			newnode("tbody",{},{},[
			    tabs.getDOMNode()
			])
		])
	]);
	
	element.body.appendChild(d);
	element.body.appendChild(node);
	element.node.display="none";
	body.appendChild(element.node);
	OXAppointmentHover.contentobject = element;
	
	return OXAppointmentHover.contentobject;
}

OXAppointmentHover.fillContent = function(type,value,titletext,clear,show) {
	if(clear) { removeChildNodes(OXAppointmentHover.references[type]); }
	if(value) { OXAppointmentHover.references[type].appendChild(value); }
	if(titletext) { OXAppointmentHover.references[type].title=titletext; }
	if(show) { OXAppointmentHover.references[type].style.display=""; }
}
OXAppointmentHover.fillText = function(type,text,titletext,clear) {
	if(clear) { removeChildNodes(OXAppointmentHover.references[type]); }
	if(text) { OXAppointmentHover.references[type].appendChild(document.createTextNode(text)); }
	if(titletext) { OXAppointmentHover.references[type].title=titletext; }
}

OXAppointmentHover.refillContent = function(id, folder, recurrence_position) {
	// can't use the oxcache here as there are bugs on the backend right now ... 
	// e.g. field 104 is always null :-|
	/*
	var collection={};
    collection.objects = [ OXCalendarMapping.createKeyFromObject( { module: "calendar", folder_id: folder, id: id, recurrence_position: (recurrence_position || 0) } )];
    collection.columns = null;
    OXAppointmentHover.oxCacheRequest = OXCache.newRequest(null, "calendar", collection, null,
	    function(daten) {
	        if (daten.objects[0]) {	        	
				OXAppointmentHover.actualobject = daten.objects[0];
				OXAppointmentHover.drawContent(OXAppointmentHover.actualobject);				
	        }           
	    }, true
    );
    */
	var reqstr=AjaxRoot + "/calendar?action=get&session=" + session +"&id="+ id + "&folder="+folder;
	if(recurrence_position) { reqstr+="&recurrence_position="+recurrence_position; }
	(new JSON()).get(reqstr,null,function(object) {
		OXAppointmentHover.actualobject = object.data;
		OXAppointmentHover.drawContent(OXAppointmentHover.actualobject);
	});
	
}

OXAppointmentHover.refillContentByObject = function(object) {
	OXAppointmentHover.actualobject=object;
	OXAppointmentHover.drawContent(object);
}

OXAppointmentHover.drawContent = function(object) {
	//TITLE
	OXAppointmentHover.fillText("title",object.title ? object.title : "",object.title ? object.title : "",true);
	var count=0;
	//PRIVATE FLAG OR GROUP APPOINTMENT
	if(object.private_flag) {
		OXAppointmentHover.fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/private_flag.gif")},[]),_("Private appointment"),true,true); /*i18n*/
		count++;
	} else if(object.participants && object.participants.length>1) {
		OXAppointmentHover.fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/calendar/group.gif")},[]),_("Group appointment"),true,true); /*i18n*/
		count++;
	}
	//RECURRENCE APPOINTMENT
	if(object.recurrence_type && object.recurrence_type != 0) {
		OXAppointmentHover.fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/calendar/calendar_series.gif")},[]),_("Series appointment"),true,true); /*i18n*/
		count++;
	}
	//FLAGS
	if(object.color_label && object.color_label!=0) {
		OXAppointmentHover.fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/menu/tag_"+object["color_label"]+".gif")},[]),null,true,true);
		count++;
	}
	for(;count<3;count++) {
		OXAppointmentHover.references["coreimg"+(count+1)].style.display="none";
	}
	//LOCATION
	OXAppointmentHover.fillText("location",object.location ? object.location : "",object.location ? object.location : "",true);
	var startdate=new Date(object.start_date);
	var enddate=new Date(object.end_date);
	
	//DATE AND TIME
	if(object.full_time) {
		enddate.setUTCDate(enddate.getUTCDate()-1);
		OXAppointmentHover.fillText("start_time", formatDate(startdate,"date"),formatDate(startdate,"date"),true);
		OXAppointmentHover.fillText("end_time", formatDate(enddate,"date"),formatDate(enddate,"date"),true);
	} else {
		OXAppointmentHover.fillText("start_time", formatDate(startdate,"datetime"),formatDate(startdate,"datetime"),true);
		OXAppointmentHover.fillText("end_time", formatDate(enddate,"datetime"),formatDate(enddate,"datetime"),true);
	}
	
	if (OXAppointmentHover.actualobject.created_by) {
		internalCache.getUsers([OXAppointmentHover.actualobject.created_by],function(response) {
			try {
				var created_by = response[OXAppointmentHover.actualobject.created_by].display_name || "";
				var created_on = formatDate(OXAppointmentHover.actualobject.creation_date, "datetime") || "";
				var txt = "";
				if (!OXAppointmentHover.actualobject.creation_date) {
                    //#. %s is the name of the creator.
                    //#, c-format
					txt = format(_("Created by %s"), [created_by]);
				} else {
                    //#. %1$s is the creation date.
                    //#. %2$s is the name of the creator.
                    //#, c-format
					txt = format(_("Created on %1$s by %2$s"), [created_on, created_by]);
				}
				OXAppointmentHover.fillText("created_by", txt, txt, true);	
			} catch(n) {}
		});
	} else {
		OXAppointmentHover.fillText("created_by", "", "",true);
	}
	
	if (OXAppointmentHover.actualobject.modified_by) {
		internalCache.getUsers([OXAppointmentHover.actualobject.modified_by],function(response) {
			try {
				var changed_by = response[OXAppointmentHover.actualobject.modified_by].display_name || "";
				var changed_on = formatDate(OXAppointmentHover.actualobject.last_modified, "datetime") || "";
                //#. %1$s is the creation date.
                //#. %2$s is the name of the creator.
                //#, c-format
				var txt = format(_("Last changed on %1$s by %2$s"), [changed_on, changed_by]);
				OXAppointmentHover.fillText("changed_by", txt, txt, true);	
			} catch(n) {}
		});
	} else {
		OXAppointmentHover.fillText("changed_by", "", "",true);
	}
	
	// CATEGORIES
	if (OXAppointmentHover.actualobject.categories) {
		var node = newnode("div");
		ox.categories.ui.drawCategoriesList(ox.categories.getByString(OXAppointmentHover.actualobject.categories), node);		
		OXAppointmentHover.fillContent("categories",node,null,true,true);
		OXAppointmentHover.references["categories"].parentNode.style.display=""
	} else {
		removeChildNodes(OXAppointmentHover.references["categories"]);
		OXAppointmentHover.references["categories"].parentNode.style.display="none";
	}
	
	// NOTE
	if (!object.note) { 
		object.note = "";
	}
	OXAppointmentHover.fillContent("notesmall", getDivforTextContent(object.note,5),null,true);
	OXAppointmentHover.fillContent("notemiddle", getDivforTextContent(object.note,10),null,true);
	OXAppointmentHover.fillContent("notefull", getDivforTextContent(object.note),null,true);
		
	if (OXAppointmentHover.actualobject.participants && OXAppointmentHover.actualobject.participants.length) {
		OXAppointmentHover.slider.getTabById("participants").setTitle(_("Participants") + " ("+OXAppointmentHover.actualobject.participants.length+")");	
		OXOperationHover.fillParticipants(OXAppointmentHover);
	}
		
	if (OXAppointmentHover.actualobject.folder_id && OXAppointmentHover.actualobject.id) {
		OXAppointmentHover.slider.getTabById("attachments").setTitle(_("Attachments") + " (0)");
		OXGroupwareHover.fillAttachments(OXAppointmentHover);
		OXAppointmentHover.fillOthers();
	}
	
	OXAppointmentHover.accordion.checkComponentHeight("AppointmentCore");
	OXAppointmentHover.accordion.checkComponentHeight("NoteSmall");
	OXAppointmentHover.accordion.checkComponentHeight("NoteMiddle");
	OXAppointmentHover.accordion.checkComponentHeight("NoteFull");
	OXAppointmentHover.slider.selectTabById("general");
	
}


register("Loaded",function() {
	OXGroupwareHover.start();
	OXOperationHover.start();
	OXContactHover.start();	
})

function OXMailHover() {}
OXMailHover.actualmodule="mail";
OXMailHover.moduleint=19;
OXMailHover.contentobject;
OXMailHover.actualobject;
OXMailHover.actualHover=null;
OXMailHover.accordion;
OXMailHover.references=new Object();

OXMailHover.getContent = function() {
	if(OXMailHover.contentobject) {
		return OXMailHover.contentobject;
	}
	var element=createHoverContent(null,null,null,null,5);
	OXMailHover.accordion=new Accordion(450,400);
	
	refillImages("template_mail_hover_page1");
	var contentnode=$("template_mail_hover_page1");
	contentnode.id="";
	OXMailHover.references["core"]=contentnode;
	OXMailHover.accordion.addComponent("Mail_General",contentnode,false);
		
	var tmptds=OXMailHover.references["core"].getElementsByTagName("td");
	OXMailHover.references["subject"]=tmptds[1];
	OXMailHover.references["coreimg1"]=tmptds[2];
	OXMailHover.references["coreimg2"]=tmptds[3];
	OXMailHover.references["coreimg3"]=tmptds[4];
	OXMailHover.references["from"]=tmptds[5];
	
	OXMailHover.references["core_content_small"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXMailHover.accordion.addComponent("Mail_MailText_Small",OXMailHover.references["core_content_small"],200);
	var tmptds=OXMailHover.references["core_content_small"].getElementsByTagName("td");
	OXMailHover.references["mailtextsmall"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXMailHover.accordion.showContent('Mail_General,Mail_MailText_Middle'); });
		
	OXMailHover.references["core_content_middle"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXMailHover.accordion.addComponent("Mail_MailText_Middle",OXMailHover.references["core_content_middle"],200);
	var tmptds=OXMailHover.references["core_content_middle"].getElementsByTagName("td");
	OXMailHover.references["mailtextmiddle"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXMailHover.accordion.showContent('Mail_General,Mail_MailText_Full'); });
	
	OXMailHover.references["core_content_full"]=OXGroupwareHover.references["core_content_full"].cloneNode(true);
	OXMailHover.accordion.addComponent("Mail_MailText_Full",OXMailHover.references["core_content_full"],200);
	var tmptds=OXMailHover.references["core_content_full"].getElementsByTagName("td");
	OXMailHover.references["mailtextfull"]=tmptds[0];
	addDOMEvent(tmptds[0],"click",function() { OXMailHover.accordion.showContent('Mail_General,Mail_MailText_Small'); });
		
	var tabs = new Tabbing("5");
	tabs.addTab(
			new Tab("general", _("General"), 
				function() { 
					OXMailHover.accordion.showContent("Mail_General,Mail_MailText_Small")
				}
			)
	);
	tabs.addTab(
			new Tab("attachments", _("Attachments"),
				function() { 
					OXMailHover.accordion.showContent("Attachments")
				}
			)
	);
	
	OXMailHover.slider = tabs;
	
	var node = OXMailHover.accordion.getDomNode();
	var d = newnode("div",{ padding:"0px" , overflow:"hidden"},{className : "tabbing_tab"},[
		newnode("table",{ height : "22px "},{cellPadding : 0, cellSpacing : 0, border : 0, width : "100%"},[
			newnode("tbody",{},{},[
			    tabs.getDOMNode()
			])
		])
	]);
	
	element.body.appendChild(d);
	element.body.appendChild(node);
	element.node.display="none";
	body.appendChild(element.node);
	OXMailHover.contentobject = element;
	
	return OXMailHover.contentobject;
}

OXMailHover.refillContent = function(id,folder) {
	var collection={};
    collection.objects=collection.objects=[OXMailMapping.createKeyFromObject({"module" : "mail" ,"folder_id" : folder, id : id})];;
    collection.columns=OXMailMapping.GETPLAIN;
    /*
     * adding field unseen to collection which indicates that the server
     * shouldn't flag the message as seen. this is only required when requesting
     * hover information. see also bug #11894
     */
    collection.columns.push("unseen");

    OXMailHover.oxCacheRequest=OXCache.newRequest(null,"mail",collection,null,
    function(daten) {
        if(daten.objects[0]) {
	        OXMailHover.actualobject=daten.objects[0];
	        OXMailHover.actualobject.id=id;
	        OXMailHover.actualobject.folder_id=folder;
	        OXMailHover.fillGeneral();
	        OXMailHover.accordion.checkComponentHeight("Mail_General");
	        OXMailHover.accordion.checkComponentHeight("Mail_MailText_Small");
	        OXMailHover.accordion.checkComponentHeight("Mail_MailText_Middle");
	        OXMailHover.accordion.checkComponentHeight("Mail_MailText_Full");

			OXMailHover.slider.getTabById("attachments").setTitle(_("Attachments") + " (0)")			
	        OXMailHover.fillAttachments(OXMailHover);
			OXMailHover.slider.selectTabById("general");
        }           
    });
}

OXMailHover.getMailTextandStatus =function(object) {
	var retobj=new Object();
	retobj.mailtextstatus="notext";
	retobj.mailtext=_("No text");
	for (var i = 0; i < object["attachments_plain"].length; i++) {
		var part = object["attachments_plain"][i];
		if (part.disp == "attachment") continue;
		switch (part.content_type.toLowerCase()) {
			case "text/plain": 
				retobj.mailtextstatus="text"; 
				retobj.mailtext=part.content;
				return retobj;
			case "text/html": 
				retobj.mailtextstatus="html"; 
				retobj.mailtext=_("HTML-only mail"); 
				break;
		}
	}
	return retobj;	
}

OXMailHover.fillGeneral = function() {
	function fillContent(type,value,titletext,clear,show) {
		if(clear) { removeChildNodes(OXMailHover.references[type]); }
		if(value) { OXMailHover.references[type].appendChild(value); }
		if(titletext) { OXMailHover.references[type].title=titletext; }
		if(show) { OXMailHover.references[type].style.display=""; }
	}
	function fillText(type,text,titletext,clear) {
		if(clear) { removeChildNodes(OXMailHover.references[type]); }
		if(text) { OXMailHover.references[type].appendChild(document.createTextNode(text)); }
		if(titletext) { OXMailHover.references[type].title=titletext; }
	}
	object=OXMailHover.actualobject;
	fillText("subject",object.subject ? object.subject : "",object.subject ? object.subject : "",true);
	//FROM
	fillText("from",object.from ? getAdressString(object.from,true): "",object.from ?  getAdressString(object.from,false) : "",true);

	var count=0;
	//MAIL FLAGS
	if(object.flags || object.flags==0) {
		var img=getFullImgSrc("img/mail/unread.gif");
		var imgtitle="Unread";
		if(object.flags) {
			if(object.flags % 2 >= 1) {
				img=getFullImgSrc("img/mail/reply.gif"); 
				imgtitle="Answered"; 
			} else if(object.flags % 64 >= 32) {
				img=getFullImgSrc("img/mail/read.gif"); 
				imgtitle="Read"; 
			}
		}
		fillContent("coreimg"+(count+1),newnode("img",{},{ src: img , title : _(imgtitle)},[]),null,true,true);	
		count++	
					
	}
	//PRIORITY
	if(object.priority && object.priority!=3) {
		var img=getFullImgSrc("img/dummy.gif");
		var imgtitle=_("Unknown"); /*i18n*/
		switch(object.priority) {
			case 1: img=getFullImgSrc("img/mail/email_priohigh.gif"); imgtitle=_("Very high") /*i18n*/ ;break;
			case 2: img=getFullImgSrc("img/mail/email_priohigh.gif"); imgtitle=_("High") /*i18n*/ ;break;
			case 4: img=getFullImgSrc("img/mail/email_priolow.gif"); imgtitle=_("Low") /*i18n*/ ;break;
			case 5: img=getFullImgSrc("img/mail/email_priolow.gif"); imgtitle=_("Very low") /*i18n*/ ;break;
		}
		fillContent("coreimg"+(count+1),newnode("img",{},{ src: img , title : imgtitle},[]),null,true,true);	
		count++;
	}
	//COLOR_LABEL
	if(object.color_label && object.color_label!=0) {
		fillContent("coreimg"+(count+1),newnode("img",{},{ src: getFullImgSrc("img/menu/tag_"+object["color_label"]+".gif")},[]),null,true,true);
		count++;
	}
	for(;count<3;count++) {
		OXMailHover.references["coreimg"+(count+1)].style.display="none";
	}
	// MAIL TEXT
	var mailtextobj=OXMailHover.getMailTextandStatus(object);
	
	fillContent("mailtextsmall", parseDirectLinksInMails(getDivforMailContent(mailtextobj.mailtext.split(/<br\s*\/?>/, 5).join('<br>'))),"",true,true)
	fillContent("mailtextmiddle", parseDirectLinksInMails(getDivforMailContent(mailtextobj.mailtext.split(/<br\s*\/?>/, 10).join('<br>'))),"",true,true)
	fillContent("mailtextfull", parseDirectLinksInMails(getDivforMailContent(mailtextobj.mailtext.split(/<br\s*\/?>/).join('<br>'))),"",true,true);	

}
OXMailHover.fillAttachments = function(Hover) {
	var attachmentCounterForTab = 0;
	var attachmentfirst=
	newnode("tr",{},{},[
		newnode("td",{ width: "25px", paddingTop:"12px", lineHeight : "0px"},{ className : "notclickable"},[
			newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[]) 
		]),
		newnode("td",{ paddingTop:"12px"},{ className : "contenttext notclickable"},[]),
		newnode("td",{ width: "25px", paddingTop:"12px" , lineHeight : "0px"},{},[
			newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[]),
			newnode("img",{ display:"none" },{ src: getFullImgSrc("img/menu/attachment_open.gif") , className : "notclickable"},[])
		]),
		newnode("td",{ width: "25px", paddingTop:"12px" , lineHeight : "0px"},{},[
			newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[]),
			newnode("img",{ display:"none" },{ src: getFullImgSrc("img/menu/attachment_save.gif") , className : "notclickable"},[])
		])
	]);
	var attachmentsecond=
	newnode("tr",{},{},[
		newnode("td",{ width: "25px"},{ className : "notclickable"},[
			newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[])
		]),
		newnode("td",{},{ className : "contenttext notclickable"},[]),
		newnode("td",{ width: "25px"},{ className : "notclickable" },[]),
		newnode("td",{ width: "25px"},{ className : "notclickable" },[])
	]);
	
	var hasAttachments=false;
	var object=Hover.actualobject;
	var attachmentmain=OXGroupwareHover.references["core_attachments_template"].cloneNode(true);
	var attachbody=attachmentmain.getElementsByTagName("tbody")[0];
	
	for(var i=0;i<object["attachments_plain"].length;i++) {
		var myAttachment=object["attachments_plain"][i];
		if(myAttachment.filename) {
			hasAttachments=true;
			attachmentCounterForTab++;
			var node=attachmentfirst.cloneNode(true);
			var node2=attachmentsecond.cloneNode(true);			
			node.getElementsByTagName("img")[0].src=getMimeImage(myAttachment.content_type.split(";")[0].toLowerCase()); 
			node.getElementsByTagName("img")[0].title=myAttachment.content_type.split(";")[0].toLowerCase();
			node.getElementsByTagName("td")[1].appendChild(document.createTextNode(myAttachment.filename));		
			node.getElementsByTagName("img")[1].style.display="none";
			node.getElementsByTagName("img")[2].style.display="";
			node.getElementsByTagName("img")[2].title=_("Open attachment"); /*i18n*/
			addDOMEvent(node.getElementsByTagName("img")[2],"click",Hover.openAttachedFile(Hover.actualobject.folder_id,Hover.actualobject.id,myAttachment.id));
			node.getElementsByTagName("img")[3].style.display="none";
			addDOMEvent(node.getElementsByTagName("img")[4],"click",Hover.saveAttachedFile(Hover.actualobject.folder_id,Hover.actualobject.id,myAttachment.id));
			node.getElementsByTagName("img")[4].style.display="";
			node.getElementsByTagName("img")[4].title=_("Save attachment"); /*i18n*/
			node2.getElementsByTagName("td")[1].appendChild(document.createTextNode(OXGroupwareHover.getShortByteString(myAttachment.size)));
			node2.getElementsByTagName("td")[1].title=OXGroupwareHover.getShortByteString(myAttachment.size,true);
			attachbody.appendChild(node);
			attachbody.appendChild(node2);
		}
	}
    
    for (var i = 0; object.nested_msgs && i < object.nested_msgs.length; i++) {
        var msg = object.nested_msgs[i];
        attachmentCounterForTab++;
        hasAttachments = true;
        var node = attachmentfirst.cloneNode(true);
        var images = node.getElementsByTagName("img");
        images[0].src = images[0].title = getFullImgSrc("img/mail/unread.gif");
        node.getElementsByTagName("td")[1].appendChild(
            document.createTextNode(msg.subject));
        images[1].style.display = "none";
        images[2].style.display = "";
        images[2].title = _("Open attachment");
        var nested = [msg];
        nested.sid = object.nested_msgs.length; // yup, it's a bug
        addDOMEvent(images[2], "click", Hover.openAttachedMail(object, nested));
        attachbody.appendChild(node);
    }
    
	if(!hasAttachments) {
		var tmp=newnode("tr",{},{ className : "notclickable"},[
			newnode("td",{ width: "25px"},{},[
				newnode("img",{},{ src: getFullImgSrc("img/dummy.gif") },[])
			]),
			newnode("td",{},{ colspan : 4 , className : "contenttext notclickable" },[
				document.createTextNode(_("No attachments available")) /*i18n*/
			])		
		]);
		attachbody.appendChild(tmp);
	}
	
	OXMailHover.slider.getTabById("attachments").setTitle(_("Attachments") + " ("+attachmentCounterForTab+")");
	
	Hover.accordion.addComponent("Attachments",attachmentmain,false);	
};
    
OXMailHover.openAttachedMail = function(message, detailNestedMessage) {
    return function() {
        var detailMail=newWindow("detailMail.html#type='isNestedMessage'&id="
            + encodeURIComponent(message.id)
            + "&folder=" + encodeURIComponent(message.folder || message.folder_id)
            + "&sid=" + encodeURIComponent(detailNestedMessage.sid),          
            getWindowOptions(), 
            { "id": encodeURIComponent(detailNestedMessage.sid), "folder": encodeURIComponent(message.folder || message.folder_id) });
        detailMail.window.oNestedMessage = detailNestedMessage;
        detailMail.oNestedMessage = detailNestedMessage;
        if(detailMail)
            detailMail.focus();
    };
};

OXMailHover.openAttachedFile = function(folderid,objectid,attachmentid) {
	return function() {
		//if(rtfflag) { return; }
		var sURL = AjaxRoot + '/mail?action=attachment&session=' + session +'&folder=' + encodeURIComponent(folderid)
		 + '&id=' + encodeURIComponent(objectid)+ '&attachment=' +attachmentid+"&save=0";
		newWindow(sURL, getWindowOptions());
	}
};
OXMailHover.saveAttachedFile = function(folderid,objectid,attachmentid) {
	return function() {	
		//if(rtfflag) return;	
		var sURL = AjaxRoot + '/mail?action=attachment&session=' + session +'&folder=' + encodeURIComponent(folderid)
		 + '&id=' + encodeURIComponent(objectid)+ '&attachment=' +attachmentid+"&save=1";
		var frame = $ALL("dlIframe") ? getFrameElement('dlIframe') : parent.frames['dlIframe'];
		frame.location.href = sURL; 
	}
};

function setHoverDelay() {
	switch(configGetKey("gui.effects.hover.speed")) {
		case 1: Hover.initial_delay = 500;
			break;
		case 2: Hover.initial_delay = 1000;
			break;
		case 3: Hover.initial_delay = 2000;
			break;
		default: Hover.initial_delay = 1000;
			break;
	}
}
register("OX_Configuration_Loaded_Complete",function() {
	setHoverDelay();
});
register("OX_Configuration_Changed",function(arg) {
	if(arg=="configuration/settings") {
		setHoverDelay();
	}
});
function getDivforTextContent(content,maxlines,removebreaks) {

	var mydiv=newnode("div",{},{},[]);
	var splited=content.split("\n");

	for(var i=0;i<splited.length;i++) {
		if(!removebreaks) { if(i!=0) { mydiv.appendChild(document.createElement("br")); } }
		else { mydiv.appendChild(document.createTextNode(" ")); }
		mydiv.appendChild(document.createTextNode(splited[i]));
		if(maxlines && i>=maxlines-1) {
			break;
		}
	}
	return mydiv;
};
function getDivforMailContent(content) {
	var mydiv=newnode("div",{},{},[]);
	mydiv.innerHTML=content;
	return mydiv;
}
