var app={el:null, http_host:"",width:0,height:0,currentStyle:4,currentLanguage:1,init:function(){this.el=document.getElementById("app");__initCanvas();if(window.ActiveXObject&&document.namespaces){document.getElementById("logo").style.background="";var logo=new Image();logo.onload=function(){document.getElementById("logo").getContext("2d").drawImage(logo,0,0,logo.width,logo.height);};logo.src="images/layout/logo_manipede_small_2.png";}this.width=parseInt(this.el.style.width.replace(/px/gi,""));this.height=parseInt(this.el.style.height.replace(/px/gi,""));main.init();this.updateCSS();window.onresize=this.updateCSS;var xmlhttp=httpRequest("scripts/php/main.php","cmd=getConfig");xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){eval("var config="+xmlhttp.responseText);if(config){app.http_host=config.http_host;return;}}else alert(xmlhttp.responseText);}}},destroy:function(){GUnload();},clear:function(){
this.closeInfo();project.cancelCreatingEntry();user.cancelLogin();},info:function(id,langID){if(!id) return;if(langID) this.currentLanguage=langID;var xmlhttp=httpRequest("scripts/php/main.php","cmd=allgemeineInfo&id="+id+"&lang_id="+this.currentLanguage);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){document.getElementById("infoContent").innerHTML=xmlhttp.responseText;document.getElementById("info").style.display="block";return;}else alert(xmlhttp.responseText);}}},participants:function(){var xmlhttp=httpRequest("scripts/php/main.php","cmd=participants");xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){document.getElementById("infoContent").innerHTML=xmlhttp.responseText;document.getElementById("info").style.display="block";return;}else alert(xmlhttp.responseText);}}},artist:function(id,langID){if(!id) return;this.currentLanguage=langID?langID:1;
var xmlhttp=httpRequest("scripts/php/main.php","cmd=artist&id="+id+"&langID="+this.currentLanguage);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){document.getElementById("infoContent").innerHTML=xmlhttp.responseText;document.getElementById("info").style.display="block";return;}else alert(xmlhttp.responseText);}}},closeInfo:function(){document.getElementById("infoContent").innerHTML="";document.getElementById("info").style.display="none";},updateCSS:function(){var windowWidth=parseInt(document.getElementById("bottomRight").offsetLeft)+1;var windowHeight=parseInt(document.getElementById("bottomRight").offsetTop)+1;var style=app.currentStyle;if(app.width > windowWidth&&app.height > windowHeight) style=1;else if(app.width > windowWidth&&app.height <=windowHeight) style=2;else if(app.width <=windowWidth&&app.height > windowHeight) style=3;else style=4;if(style!=app.curentStyle){switch(style){case 1:
app.el.style.margin="0px";app.el.style.top="0px";app.el.style.left="0px";break;case 2:app.el.style.margin="-"+(app.height/2)+"px 0px 0px 0px";app.el.style.top="50%";app.el.style.left="0px";break;case 3:app.el.style.margin="0px 0px 0px -"+(app.width/2)+"px";app.el.style.top="0px";app.el.style.left="50%";break;default:app.el.style.margin="-"+(app.height/2)+"px 0px 0px -"+(app.width/2)+"px";app.el.style.top="50%";app.el.style.left="50%";}app.currentStyle=style;}},error:function(message){alert(message);}};var main={el:null,projects:null,map:null,init:function(){app.clear();project.cancelCreatingEntry();if(this.map){GUnload();this.map=null;}project.unload();document.getElementById("mainContent").innerHTML="";document.getElementById("mainContent").style.backgroundColor="transparent";document.getElementById("mainContent").style.backgroundImage="url('images/layout/pixel.gif')";this.el=document.getElementById("main");
if(!this.projects){var xmlhttp=httpRequest("scripts/php/main.php","cmd=loadProjects");xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){eval("main.projects=" + xmlhttp.responseText);main.loadMenu();return;}alert(xmlhttp.responseText);}}}else this.loadMenu();this.el.style.display="block";document.getElementById("mainContent").innerHTML='<div style="position:absolute;left:70px;top:15px"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="500"><param name="movie" value="manipede.swf"><param name="quality" value="high"><param name="wmode" value="transparent"><embed src="manipede.swf" width="500" height="500" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed></object></div>';},loadMenu:function(){if(!this.projects) return;var menu;
menu='<table border="0" cellpadding="0" cellspacing="0">';for (var i=0;i<this.projects.length;++i){menu +='<tr><td style="width:10px;height:18px;background-image:url(\'images/layout/icons/'+(i==(this.projects.length-1)?'lastNode.gif':'node.gif')+'\');"></td><td><a class="menuSub" href="javascript:main.subMenu('+this.projects[i].id+')" onclick="project.load('+this.projects[i].id+')">'+this.projects[i].name+'</a></td></tr><tr id="projectSub'+this.projects[i].id+'" style="display:none"><td style="width:10px;'+(i<(this.projects.length-1)?' background-image:url(\'images/layout/icons/line.gif\');':'')+'"></td><td><table border="0" cellpadding="0" cellspacing="0"><tr><td style="width:10px;height:18px;background-image:url(\'images/layout/icons/'+(this.projects[i].schools.length?'node.gif':'lastNode.gif')+'\');"></td><td><a class="menuSub" href="javascript:main.projectInfo('+this.projects[i].id+');" title="'+this.projects[i].name+' Info">Info</a></td></tr>';
for (var j=0;j<this.projects[i].schools.length;++j){menu +='<tr><td style="width:10px;height:18px;background-image:url(\'images/layout/icons/'+(j<(this.projects[i].schools.length-1)?'node.gif':'lastNode.gif')+'\');"></td><td><a class="menuSub" href="javascript:main.schoolInfo('+this.projects[i].schools[j].id+','+this.projects[i].schools[j].countryCode+')" title="'+this.projects[i].schools[j].name+'">'+this.projects[i].schools[j].name+'</a></td></tr><tr><td style="width:10px;'+(j<(this.projects[i].schools.length-1)?' background-image:url(\'images/layout/icons/line.gif\');':'')+'"></td><td><table border="0" cellpadding="0" cellspacing="0"><tr><td style="width:10px;height:18px;background-image:url(\'images/layout/icons/node.gif\');"></td><td><a class="menuSub" href="javascript:main.teamInfo('+this.projects[i].id+','+this.projects[i].schools[j].id+','+this.projects[i].schools[j].countryCode+')" title="Team '+this.projects[i].schools[j].name+'">Team</a></td></tr><tr><td style="width:10px;height:18px;background-image:url(\'images/layout/icons/lastNode.gif\');"></td><td><a class="menuSub" href="javascript:main.cityInfo('+this.projects[i].schools[j].id+','+this.projects[i].schools[j].countryCode+')" title="City '+this.projects[i].schools[j].name+'">City</a></td></tr></table></td></tr>';
}menu +='</table></td></tr>';}document.getElementById("menuProjectList").innerHTML=menu;},subMenu:function(projectID){var current=this.getSelectedProject();var project;if(current&&(!projectID||projectID!=current.id)){document.getElementById("projectSub"+current.id).style.display='none';current.selected=false;}if(projectID&&(project=this.getProject(projectID))&&document.getElementById("projectSub"+projectID)){document.getElementById("projectSub"+projectID).style.display=(navigator.appName=="Microsoft Internet Explorer")?'block':'table-row';project.selected=true;}},loadMap:function(projectID){app.clear();if (GBrowserIsCompatible()){project.unload();document.getElementById("mainContent").innerHTML="";document.getElementById("mainContent").style.backgroundImage="url('images/layout/pixel.gif')";this.map=new GMap2(document.getElementById("mainContent"),{mapTypes:[G_PHYSICAL_MAP,G_NORMAL_MAP,G_SATELLITE_MAP]});
var currentProject=this.getProject(projectID);if(currentProject){var points=new Array();var lat=0;var lng=0;for(var i=0;i<currentProject.schools.length;++i){lat +=currentProject.schools[i].lat;lng +=currentProject.schools[i].lng;points.push(new GLatLng(currentProject.schools[i].lat,currentProject.schools[i].lng));}var bounds=new GPolyline(points);this.map.setCenter(new GLatLng(lat/currentProject.schools.length,lng/currentProject.schools.length),(this.map.getBoundsZoomLevel(bounds.getBounds())));}else this.map.setCenter(new GLatLng(48.261713,16.406708),6);this.map.addControl(new GLargeMapControl());this.map.addControl(new GMapTypeControl());this.map.enableScrollWheelZoom();this.map.enableContinuousZoom();this.map.enableGoogleBar();window.setTimeout("main.loadMarker()",80);}},loadMarker:function(){var schoolIcon=new GIcon();schoolIcon.image=app.http_host+"/images/layout/icons/school.png";schoolIcon.shadow=app.http_host+"/images/layout/icons/schoolShadow.png";
schoolIcon.iconSize=new GSize(20,15);schoolIcon.shadowSize=new GSize(26,21);schoolIcon.iconAnchor=new GPoint(13,20);var teamIcon=new GIcon();teamIcon.image=app.http_host+"/images/layout/icons/team.png";teamIcon.shadow=app.http_host+"/images/layout/icons/teamShadow.png";teamIcon.iconSize=new GSize(16,16);teamIcon.shadowSize=new GSize(20,20);teamIcon.iconAnchor=new GPoint(17,2);var cityIcon=new GIcon();cityIcon.image=app.http_host+"/images/layout/icons/city.png";cityIcon.shadow=app.http_host+"/images/layout/icons/cityShadow.png";cityIcon.iconSize=new GSize(20,22);cityIcon.shadowSize=new GSize(26,28);cityIcon.iconAnchor=new GPoint(-1,7);for (var i=0;i<this.projects.length;++i){var points=new Array();for (var j=0;j<this.projects[i].schools.length;++j){point=new GLatLng(this.projects[i].schools[j].lat,this.projects[i].schools[j].lng);
this.projects[i].schools[j].schoolMarker=new GMarker(point,{icon:schoolIcon,title:this.projects[i].schools[j].name});this.projects[i].schools[j].teamMarker=new GMarker(point,{icon:teamIcon,title:"Team "+this.projects[i].schools[j].name});this.projects[i].schools[j].cityMarker=new GMarker(point,{icon:cityIcon,title:"City "+this.projects[i].schools[j].name});eval('GEvent.addListener(main.projects['+i+'].schools['+j+'].schoolMarker,"click",function(){main.schoolInfo(main.projects['+i+'].schools['+j+'].id,main.projects['+i+'].schools['+j+'].countryCode);});');eval('GEvent.addListener(main.projects['+i+'].schools['+j+'].teamMarker,"click",function(){main.teamInfo(main.projects['+i+'].id,main.projects['+i+'].schools['+j+'].id,main.projects['+i+'].schools['+j+'].countryCode);});');eval('GEvent.addListener(main.projects['+i+'].schools['+j+'].cityMarker,"click",function(){main.cityInfo(main.projects['+i+'].schools['+j+'].id,main.projects['+i+'].schools['+j+'].countryCode);});');
this.map.addOverlay(this.projects[i].schools[j].schoolMarker);this.map.addOverlay(this.projects[i].schools[j].teamMarker);this.map.addOverlay(this.projects[i].schools[j].cityMarker);points.push(point);}this.projects[i].polyline=new GPolyline(points,"#CE1B1B",2,0.9);this.projects[i].polylineSelected=new GPolyline(points,"#2E6616",3,0.9);this.map.addOverlay(this.projects[i].polyline);}},projectInfo:function(id,langID){if(!id) return;if(!langID) langID=1;var xmlhttp=httpRequest("scripts/php/main.php","cmd=projectInfo&id="+id+"&langID="+langID);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){document.getElementById("infoContent").innerHTML=xmlhttp.responseText;document.getElementById("info").style.display="block";return;}app.error(xmlhttp.responseText);}}},schoolInfo:function(schoolID,langID){if(!schoolID) return;if(!langID) langID=1;this.panToSchool(schoolID);
var xmlhttp=httpRequest("scripts/php/main.php","cmd=loadSchoolInfo&schoolID="+schoolID+"&langID="+langID);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){document.getElementById("infoContent").innerHTML=xmlhttp.responseText;document.getElementById("info").style.display="block";return;}app.error(xmlhttp.responseText);}}},panToSchool:function(schoolID){if(this.map){for(var i=0;i<this.projects.length;++i) for(var j=0;j<this.projects[i].schools.length;++j) if(this.projects[i].schools[j].id==schoolID){this.map.panTo(new GLatLng(this.projects[i].schools[j].lat,this.projects[i].schools[j].lng));return;}}},teamInfo:function(projectID,schoolID,langID){if(!projectID||!schoolID) return;if(!langID) langID=1;this.panToSchool(schoolID);var xmlhttp=httpRequest("scripts/php/main.php","cmd=loadTeam&id="+projectID+"&schoolID="+schoolID+"&langID="+langID);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){
if(xmlhttp.status==200){document.getElementById("infoContent").innerHTML=xmlhttp.responseText;document.getElementById("info").style.display="block";return;}app.error(xmlhttp.responseText);}}},cityInfo:function(schoolID,langID){if(!schoolID) return;if(!langID) langID=1;this.panToSchool(schoolID);var xmlhttp=httpRequest("scripts/php/main.php","cmd=loadCityInfo&schoolID="+schoolID+"&langID="+langID);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){document.getElementById("infoContent").innerHTML=xmlhttp.responseText;document.getElementById("info").style.display="block";return;}app.error(xmlhttp.responseText);}}},getProject:function(projectID){if(!projectID) return null;for (var i=0;i<this.projects.length;++i) if (this.projects[i].id==projectID) return this.projects[i];return null;},getSelectedProject:function(){for (var i=0;i<this.projects.length;++i) if (this.projects[i].selected) return this.projects[i];
return null;}};var project={id:null,name:"",mapFile:"",entries:null,dragEntryCtrl:null,entryTimeCtrl:null,firstEntryTime:0,lastEntryTime:0,curEntryTime:0,updateEntryTimeInterval:null,newEntry:false,load:function(id){if(!id) return;app.clear();if(main.map){GUnload();main.map=null;}document.getElementById("projectLoginCtrl").style.display="block";document.getElementById("projectTimeSliderCtrl").style.display="block";if(user.loggedIn) document.getElementById("projectHelp").style.display="block";project.entryTimeCtrl=document.getElementById("timeSliderCtrl");project.entryTimeCtrl.style.left="146px";project.dragEntryCtrl=document.getElementById("projectNewEntryCtrl");project.dragEntryCtrl.style.display="block";project.dragEntryCtrl.onmousedown=function(){project.newEntry=true;document.onmousemove=project.dragEntry;document.onmouseup=project.createEntry;};var xmlhttp=httpRequest("scripts/php/main.php","cmd=loadProject&id="+id);
xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){eval(xmlhttp.responseText);GUnload();var content=document.getElementById("mainContent");content.style.backgroundColor="transparent";if(project.mapFile) content.style.backgroundImage="url('images/projects/"+project.mapFile+"')";else content.style.backgroundColor="white";content.innerHTML="";project.curEntryTime=project.lastEntryTime;window.setTimeout("project.loadEntries()",10);project.updateDisplayTime();return;}alert(xmlhttp.responseText);}}},unload:function(){document.getElementById("projectLoginCtrl").style.display="none";document.getElementById("projectTimeSliderCtrl").style.display="none";document.getElementById("projectHelp").style.display="none";if(this.dragEntryCtrl){project.dragEntryCtrl.onmousedown=null;project.dragEntryCtrl.style.display="none";}this.id=null;this.name="";this.mapFile="";this.entries=null;this.dragEntryCtrl=null;
this.newEntry=false;},loadEntries:function(){var xmlhttp=httpRequest("scripts/php/main.php","cmd=loadProjectEntries&id="+project.id);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){eval("project.entries="+xmlhttp.responseText+";");if(project.entries.length){var content=document.getElementById("mainContent");for(i=0;i<project.entries.length;++i) content.innerHTML +='<a id="entry'+project.entries[i].id+'" href="javascript:project.showEntry('+project.entries[i].id+');" style="position:absolute;display:none;left:'+(project.entries[i].x-12)+'px;top:'+(project.entries[i].y-10)+'px;"><img src="'+app.http_host+'/images/layout/icons/entry2.gif" border="0" alt="" title="'+project.entries[i].title+'" /></a>';project.updateEntries();}return;}alert(xmlhttp.responseText);}}},updateEntries:function(){var showPrivate=user.projectAuthorization(this.id);
for(i=0;i<project.entries.length;++i) document.getElementById("entry"+project.entries[i].id).style.display=((showPrivate||project.entries[i].public)&&project.entries[i].time <=project.curEntryTime?"block":"none");},showEntry:function(id){if(!id) return;var xmlhttp=httpRequest("scripts/php/main.php","cmd=showEntry&id="+id+"&authentification="+user.authentification);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){document.getElementById("infoContent").innerHTML=xmlhttp.responseText;document.getElementById("info").style.display="block";return;}if(xmlhttp.status==400){app.error(xmlhttp.responseText);document.getElementById("entry"+id).style.display="none";for(var i=0;i<project.entries.length;++i) if(project.entries[i].id==id) project.entries.splice(i,1);return;}app.error(xmlhttp.responseText);}}},dragEntry:function(e){if(!e) e=window.event;
project.dragEntryCtrl.style.left=(e.clientX-app.el.offsetLeft-12)+"px";project.dragEntryCtrl.style.top=(e.clientY-app.el.offsetTop-10)+"px";},createEntry:function(e){project.newEntry=false;document.onmousemove=null;document.onmouseup=null;project.dragEntryCtrl.style.top="559px";project.dragEntryCtrl.style.left="325px";if(!e) e=window.event;var pinBoard=document.getElementById("mainContent");var pinBoardX=parseInt(pinBoard.style.left.replace(/px/gi,""));var pinBoardY=parseInt(pinBoard.style.top.replace(/px/gi,""));var pinBoardWidth=parseInt(pinBoard.style.width.replace(/px/gi,""));var pinBoardHeight=parseInt(pinBoard.style.height.replace(/px/gi,""));var x=e.clientX-app.el.offsetLeft-pinBoardX;var y=e.clientY-app.el.offsetTop-pinBoardY;if(x>0&&x<pinBoardWidth&&y>0&&y<pinBoardHeight){if(!user.loggedIn){user.login();return;}if(user.projectAuthorization(project.id)){document.newEntryForm.reset();
document.getElementById("newEntryTitle").innerHTML="Create Entry";document.newEntryForm.action="scripts/php/main.php";document.newEntryForm.cmd.value="saveEntry";document.newEntryForm.x.value=x;document.newEntryForm.y.value=y;document.newEntryForm.projectID.value=project.id;document.newEntryForm.id.value=0;document.newEntryForm.authentification.value=user.authentification;document.newEntryForm.deleteEntry.style.display="none";document.getElementById("newEntry").style.display="block";}else app.error("You are not authorized for this project!");}},deleteEntry:function(){if(!user||!document.newEntryForm.id.value) return;var entryID=document.newEntryForm.id.value;if(confirm("Delete "+document.newEntryForm.title.value+"?")){var xmlhttp=httpRequest("scripts/php/main.php","cmd=deleteEntry&id="+entryID+"&authentification="+user.authentification);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){document.getElementById("entry"+entryID).style.display="none";
for(var i=0;i<project.entries.length;++i) if(project.entries[i].id==entryID) project.entries.splice(i,1);project.cancelCreatingEntry();return;}app.error(xmlhttp.responseText);}}}},editEntry:function(entryID){if(!entryID) return;var xmlhttp=httpRequest("scripts/php/main.php","cmd=getEntry&id="+entryID+"&authentification="+user.authentification);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){eval("var entry="+xmlhttp.responseText+";");if(entry){app.clear();document.getElementById("newEntryTitle").innerHTML="Edit Entry";document.newEntryForm.action="scripts/php/main.php";document.newEntryForm.cmd.value="saveEntry";document.newEntryForm.id.value=entryID;document.newEntryForm.projectID.value=project.id;document.newEntryForm.authentification.value=user.authentification;document.newEntryForm.title.value=entry.title;document.newEntryForm.text.value=entry.text.replace(/(<br([^>]+)>)/ig,"\n");
document.newEntryForm.link.value=entry.link;document.newEntryForm.linkText.value=entry.linkText;document.getElementById("currentEImage").innerHTML=entry.image+(entry.image.replace(/ /g,"").length?'&nbsp;<a href="javascript:project.deleteMediaFile(1)">delete</a>':'');document.getElementById("currentEAudio").innerHTML=entry.audio+(entry.audio.replace(/ /g,"").length?'&nbsp;<a href="javascript:project.deleteMediaFile(2)">delete</a>':'');document.getElementById("currentEVideo").innerHTML=entry.video+(entry.video.replace(/ /g,"").length?'&nbsp;<a href="javascript:project.deleteMediaFile(3)">delete</a>':'');document.newEntryForm.deleteEntry.style.display="inline";document.getElementById("newEntry").style.display="block";return;}}app.error(xmlhttp.responseText);}}},cancelCreatingEntry:function(){document.newEntryForm.reset();document.getElementById("newEntryTitle").innerHTML="";document.getElementById("currentEImage").innerHTML="";document.getElementById("currentEAudio").innerHTML="";
document.getElementById("currentEVideo").innerHTML="";document.getElementById("newEntry").style.display="none";},downloadMediaFile:function(id,type){if(!id||!type) return;request.location.href=app.http_host+"/scripts/php/main.php?cmd=downloadMediaFile&id="+id+"&type="+type+"&authentification="+user.authentification;},deleteMediaFile:function(type){switch(type){case 1:document.newEntryForm.deleteMediaFileImg.value=1;document.getElementById("currentEImage").innerHTML="";break;case 2:document.newEntryForm.deleteMediaFileAudio.value=1;document.getElementById("currentEAudio").innerHTML="";break;case 3:document.newEntryForm.deleteMediaFileVideo.value=1;document.getElementById("currentEVideo").innerHTML="";break;}},swapImage:function(id){var el;var ctrl=document.getElementById("imageCtrl"+id);if(el=document.getElementById("image"+id)){if(el.src.search(/_tn_big_/)!=-1){el.src=el.src.replace(/_tn_big_/,"_tn_med_");
ctrl.src="images/layout/icons/maximize.gif";ctrl.title="Maximize Image";}else if(el.src.search(/_tn_med_/)!=-1){el.src=el.src.replace(/_tn_med_/,"_tn_big_");ctrl.src="images/layout/icons/minimize.gif";ctrl.title="Minimize Image";}}},updateEntryTime:function(direction){if((direction<0&&project.curEntryTime==project.firstEntryTime)||(direction > 0&&project.curEntryTime==project.lastEntryTime)){if(project.updateEntryTimeInterval) window.clearInterval(project.updateEntryTimeInterval);return;}var step=Math.round((project.lastEntryTime-project.firstEntryTime)/146);var sliderPos=parseInt(project.entryTimeCtrl.style.left.replace(/px/g,""));if(direction<0){project.curEntryTime=(project.curEntryTime-step)>=project.firstEntryTime?project.curEntryTime-step:project.firstEntryTime;project.entryTimeCtrl.style.left=(sliderPos > 0?--sliderPos:0)+"px";}else{
project.curEntryTime=(project.curEntryTime+step)<=project.lastEntryTime?project.curEntryTime+step:project.lastEntryTime;project.entryTimeCtrl.style.left=(sliderPos<146?++sliderPos:146)+"px";}project.updateEntries();project.updateDisplayTime();if(!project.updateEntryTimeInterval){project.updateEntryTimeInterval=window.setInterval("project.updateEntryTime("+direction+");",100);document.getElementById("time"+(direction > 0?"Forward":"Back")+"Ctrl").onmouseout=function(){if(project.updateEntryTimeInterval){window.clearInterval(project.updateEntryTimeInterval);document.onmouseup=null;project.updateEntryTimeInterval=null;}};document.onmouseup=function(){if(project.updateEntryTimeInterval){window.clearInterval(project.updateEntryTimeInterval);document.onmouseup=null;project.updateEntryTimeInterval=null;}};}},initEntryTimeSlider:function(slider){document.onmousemove=project.moveEntryTimeSlider;document.onmouseup=function(){document.onmousemove=null;};
return false;},moveEntryTimeSlider:function(e){if(!e) var e=window.event;var pos=e.clientX-(getElementPos(project.entryTimeCtrl.offsetParent).left+2);if(pos<0||pos > (parseInt(project.entryTimeCtrl.offsetParent.style.width.replace(/px/g,""))-4)){if(pos<0) project.entryTimeCtrl.style.left="0px";else project.entryTimeCtrl.style.left=(parseInt(project.entryTimeCtrl.offsetParent.style.width.replace(/px/g,""))-4)+"px";document.onmousemove=null;}else project.entryTimeCtrl.style.left=pos+"px";project.curEntryTime=project.firstEntryTime+(Math.round((project.lastEntryTime-project.firstEntryTime)/146)*parseInt(project.entryTimeCtrl.style.left.replace(/px/g,"")));project.updateDisplayTime();project.updateEntries();return false;},updateDisplayTime:function(){var time=new Date();time.setTime(project.curEntryTime*1000);var d=time.getDate();d=d<10?"0"+d:d;var m=time.getMonth()+1;m=m<10?"0"+m:m;var h=time.getHours();h=h<10?"0"+h:h;
var i=time.getMinutes();i=i<10?"0"+i:i;document.getElementById("sliderTimeDisplay").innerHTML="to: "+d+"."+m+"."+time.getFullYear()+" "+h+":"+i;}};var user={id:null,rights:0,authentification:"",projects:null,loggedIn:false,login:function(submit){if(this.loggedIn){this.id=null;this.authentification="";this.loggedIn=false;document.getElementById("projectLoginCtrl").innerHTML="login";document.getElementById("projectLoginCtrl").title="Login";document.getElementById("projectHelp").style.display="none";project.updateEntries();}else{if(!submit){app.clear();document.getElementById("userLogin").style.display="block";document.getElementById("userName").focus();return;}else{this.authentification=MD5(document.getElementById("userName").value.toLowerCase())+MD5(document.getElementById("userPassword").value.toLowerCase());var xmlhttp=httpRequest("scripts/php/main.php","cmd=login&authentification="+this.authentification);xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){if(xmlhttp.status==200){eval("var login="+xmlhttp.responseText);if(login){user.id=login.id;user.rights=login.rights;user.projects=login.projects;user.loggedIn=true;document.getElementById("projectLoginCtrl").innerHTML="logout";document.getElementById("projectLoginCtrl").title="Logout";document.getElementById("projectHelp").style.display="block";project.updateEntries();user.cancelLogin();return;}}document.getElementById("userPassword").value=""; app.error(xmlhttp.responseText); } } } } },cancelLogin:function(){document.userLoginForm.reset(); document.getElementById("userLogin").style.display="none"; }, projectAuthorization:function(projectID){if(!projectID||!this.loggedIn) return false; if(this.rights==3) return true; for(var i=0; i<this.projects.length; ++i) if(projectID == this.projects[i]) return true; return false; } };