function loadTask(taskId,componentId){$.ajax({url:getContext()+"/RAjaxProjectManagerServlet/dummy",data:{Action:"loadTask",TaskId:taskId,ComponentId:componentId},success:function(data){displayTask(taskId,data);collapseTreeNodeDisplay(taskId);updateNumbering();highlightResponsible()},error:function(){$("#ajaxLoadError").dialog()},dataType:"json"})}
function displayTask(taskId,data){var tasksSize=data.tasks.length-1;$.each(data.tasks,function(i,item){var newTaskId="taskRow"+item.id;var taskClass="";var statusName="";switch(item.status){case 0:taskClass="in_progress";statusName=$("#hiddenInProgressId").val();break;case 1:taskClass="frozen";statusName=$("#hiddenFrozenId").val();break;case 2:taskClass="lost";statusName=$("#hiddenCancelId").val();break;case 3:taskClass="done";statusName=$("#hiddenDoneId").val();break;case 4:taskClass="warning";statusName=
$("#hiddenWarningId").val();break;case 5:default:taskClass="not_started";statusName=$("#hiddenNotStartedId").val();break}if(item.level>1){taskClass+=" under_task level"+(item.level-1);if(i==tasksSize)taskClass+=" last_child"}else taskClass+=" task_row";var trHtml='\x3ctr id\x3d"'+newTaskId+'" class\x3d"'+taskClass+'" title\x3d"childOf_"\x3e';trHtml+='\x3ctd class\x3d"numerotation"\x3e\x3c/td\x3e';trHtml+='\x3ctd class\x3d"task_wording"\x3e\x3cdiv\x3e';if(item.containsSubTask==1){trHtml+="\x3ca href\x3d\"javascript:loadTask('"+
item.id+"', '"+data.componentId+'\');" class\x3d"linkSee"  id\x3d"taskLink'+item.id+'"\x3e';trHtml+='\x3cimg border\x3d"0" alt\x3d"+" src\x3d"'+$("#hiddenExpandTreeImgId").val()+'" id\x3d"taskLinkImg'+item.id+'"\x3e\x3c/img\x3e\x26#160;\x3c/a\x3e'}trHtml+='\x3ca title\x3d"'+$("#hiddenResponsibleId").val()+" : "+item.manager+'" href\x3d"ViewTask?Id\x3d'+item.id+'" class\x3d""\x3e'+item.name+"\x3c/a\x3e\x3c/div\x3e\x3c/td\x3e";trHtml+='\x3ctd class\x3d"state"\x3e\x3cp\x3e'+statusName+"\x3c/p\x3e\x3c/td\x3e";
trHtml+='\x3ctd class\x3d"percentage"\x3e\x3cp\x3e'+item.percentage+" %\x3c/p\x3e\x3c/td\x3e";var startDay=item.startDate;var endDay=item.endDate;$("#emptyDays td").each(function(index){var isTaskDay=false;var curDay=$(this).text();var classDay=$(this).attr("class");if(curDay==startDay&&curDay==endDay){classDay+=" lenght_oneDay task_start";isTaskDay=true}else if(curDay==startDay){classDay+=" task_start";isTaskDay=true}else if(curDay==endDay){classDay+=" task_end";isTaskDay=true}else if(curDay>startDay&&
curDay<endDay){classDay+=" task";isTaskDay=true}if(isTaskDay)for(keyVar in listHolidays)if(listHolidays[keyVar]==curDay){classDay+=" day_unworked";break}trHtml+='\x3ctd class\x3d"'+classDay+'"\x3e';if(isTaskDay)trHtml+="\x3cdiv\x3e\x26nbsp;\x3cdiv\x3e\x3cspan\x3ex\x3c/span\x3e\x3c/div\x3e\x3c/div\x3e";trHtml+="\x3c/td\x3e"});trHtml+="\x3c/tr\x3e";var newTaskRow=$(""+trHtml);$("#taskRow"+taskId).after(newTaskRow);taskId=item.id})}
function updateNumbering(){$("td .numerotation").each(function(index){$(this).text(index+1+".")})}function collapseTreeNodeDisplay(taskId){$("#taskLink"+taskId).attr("href","javascript:collapseTask('"+taskId+"','"+$("#hiddenComponentId").val()+"');");$("#taskLinkImg"+taskId).attr("src",$("#hiddenCollapseTreeImgId").val());$("#taskLinkImg"+taskId).attr("alt","-")}
function collapseTask(taskId,componentId){$.ajax({url:getContext()+"/RAjaxProjectManagerServlet/dummy",data:{Action:"collapseTask",TaskId:taskId,ComponentId:componentId},success:function(data){removeTask(data);expandTreeNodeDisplay(taskId)},error:function(){$("#ajaxLoadError").dialog()},dataType:"json"})}
function expandTreeNodeDisplay(taskId){$("#taskLink"+taskId).attr("href","javascript:loadTask('"+taskId+"','"+$("#hiddenComponentId").val()+"');");$("#taskLinkImg"+taskId).attr("src",$("#hiddenExpandTreeImgId").val());$("#taskLinkImg"+taskId).attr("alt","+")}function removeTask(data){$.each(data.tasks,function(i,item){$("#taskRow"+item.id).remove()})};