﻿function RecordListPanel(id,title,styleId)
{this.id=id;this.title=title;this.className=null;if(styleId)
this.styleId=styleId;this.parent=null;this.headerContent=new Array();this.childContent=null;this.width=null;this.spacerSize=10;this.siblingLeft=null;this.bottomPanel=false;this.siblingBelow=null;this.collapseDirection=RecordListPanel.statics.collapseDirection.vertical;this.onResize=new REvent();this.onScroll=new REvent();this.onExpandCollapse=new REvent();this.onPanelClick=new REvent();this.onExpandCollapse.addEventListener(new REventListener(this.expandCollapse,this));this.onPanelClick.addEventListener(new REventListener(this.horizontalExpand,this));RegisterControl.statics.getInstance().add(this);}
RecordListPanel.statics=new Object();RecordListPanel.statics.collapseDirection=new Object();RecordListPanel.statics.collapseDirection.vertical=0;RecordListPanel.statics.collapseDirection.horizontal=1;RecordListPanel.prototype.setTitle=function(title)
{this.title=title;}
RecordListPanel.prototype.setWidth=function(w)
{this.width=w;}
RecordListPanel.prototype.setBelowPanel=function(panel)
{this.bottomPanel=true;panel.siblingBelow=this;}
RecordListPanel.prototype.setLeftPanel=function(panel)
{this.siblingLeft=panel;}
RecordListPanel.prototype.setCollapseDirection=function(collapseDirection)
{this.collapseDirection=collapseDirection;}
RecordListPanel.prototype.GetCollapseDirection=function()
{return this.collapseDirection;}
RecordListPanel.prototype.addHeaderContent=function(content)
{this.headerContent.push(content);if(this.parent)
content.init(this);}
RecordListPanel.prototype.setChildContent=function(content)
{this.childContent=content;if(this.parent)
content.init(this);}
RecordListPanel.prototype.setPngIconSrc=function(img,src)
{if(browser.msie&&browser.majorVersion<7)
{img.src='/timesheet/WebResource.axd?d=djLaH47sOAKNk7WaoWvCi_RRTU6pSfwL94oFXgbC5k5o2xy33KPVs4jWGqvT1h2c1wv_nRcDd2c-wwzv0iXA5yxXfLzL5E9t1oI1TsqG9S0YFnQd-UqDpO7ay2ejjQvN0&t=633894763760000000&c=1';img.style.width='16px';img.style.height='16px';img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',sizingMethod='scale')";}
else
img.src=src;}
RecordListPanel.prototype.attach=function(node)
{var panel=document.createElement("div");panel.id=RegisterControl.statics.encodeId(this);panel.className="panel";if(this.styleId)
panel.className+=" "+this.styleId;node.appendChild(panel);var cap=document.createElement("div");cap.className='cap0';panel.appendChild(cap);cap=document.createElement("div");cap.className='cap1';panel.appendChild(cap);cap=document.createElement("div");cap.className='cap2';panel.appendChild(cap);var header=document.createElement("h2");header.id=RegisterControl.statics.encodeId(this,"header");if(RecordListPanel.statics.collapseDirection.horizontal==this.collapseDirection&&this.childContent&&this.childContent.isCollapsible())
{var img=document.createElement("img");img.id=RegisterControl.statics.encodeId(this,"expandCollapse");if(this.childContent.getCollapsed())
this.setPngIconSrc(img,'/timesheet/WebResource.axd?d=djLaH47sOAKNk7WaoWvCi_RRTU6pSfwL94oFXgbC5k5o2xy33KPVs4jWGqvT1h2c1wv_nRcDd2c-wwzv0iXA5yxXfLzL5E9t1oI1TsqG9S1k_XdEx9oTd04SBWyIl4V70&t=633894763760000000&c=1');else
this.setPngIconSrc(img,'/timesheet/WebResource.axd?d=djLaH47sOAKNk7WaoWvCi_RRTU6pSfwL94oFXgbC5k5o2xy33KPVs4jWGqvT1h2c1wv_nRcDd2c-wwzv0iXA5yxXfLzL5E9t1oI1TsqG9S3pvY6BUsxPQyoiz6XhXmxC0&t=633894763760000000&c=1');img.onclick=RecordListPanel.statics.onExpandCollapse;img.className='headerContent';header.appendChild(img);}
else if(this.bottomPanel&&this.childContent&&this.childContent.isCollapsible())
{var img=document.createElement("img");img.id=RegisterControl.statics.encodeId(this,"expandCollapse");if(this.childContent.getCollapsed())
this.setPngIconSrc(img,'/timesheet/WebResource.axd?d=djLaH47sOAKNk7WaoWvCi_RRTU6pSfwL94oFXgbC5k5o2xy33KPVs4jWGqvT1h2c1wv_nRcDd2c-wwzv0iXA5yxXfLzL5E9t1oI1TsqG9S1qdbYjzU8ksIMwmJEl4RNc0&t=633894763760000000&c=1');else
this.setPngIconSrc(img,'/timesheet/WebResource.axd?d=djLaH47sOAKNk7WaoWvCi_RRTU6pSfwL94oFXgbC5k5o2xy33KPVs4jWGqvT1h2c1wv_nRcDd2c-wwzv0iXA5yxXfLzL5E9t1oI1TsqG9S3BwQR8ufy7gYvTAPUUEInR0&t=633894763760000000&c=1');img.onclick=RecordListPanel.statics.onExpandCollapse;img.className='headerContent';header.appendChild(img);}
for(var i in this.headerContent)
{var div=document.createElement("div");div.className='headerContent';header.appendChild(div);this.headerContent[i].attach(div);}
var titleSpan=document.createElement("span");titleSpan.appendChild(document.createTextNode(this.title));header.appendChild(titleSpan);panel.appendChild(header);var content=document.createElement("div");content.id=RegisterControl.statics.encodeId(this,"content");content.onscroll=RecordListPanel.statics.onScroll;content.className="content";panel.appendChild(content);if(this.childContent)
{if(this.childContent.handlesScrolling())
content.style.overflow='hidden';this.childContent.attach(content);}}
RecordListPanel.prototype.init=function(parent)
{this.parent=parent;for(var i in this.headerContent)
{this.headerContent[i].init(this);}
if(this.childContent)
this.childContent.init(this);}
RecordListPanel.prototype.resize=function()
{var panel=document.getElementById(RegisterControl.statics.encodeId(this));panel.style.top=this.getTop(panel.parentNode)+"px";panel.style.left=this.getLeft(panel.parentNode)+"px";panel.style.width=this.getWidth(panel.parentNode)+"px";panel.style.height=this.getHeight(panel.parentNode)+"px";var content=document.getElementById(RegisterControl.statics.encodeId(this,"content"));var contentOffsetTop=content.offsetTop;var remainingHeight=parseInt(content.parentNode.offsetHeight)-contentOffsetTop-2;var remainingWidth=parseInt(content.parentNode.offsetWidth)-2;content.style.height=((0<remainingHeight)?remainingHeight:1)+"px";content.style.width=((0<remainingWidth)?remainingWidth:1)+"px";this.onResize.trigger();}
RecordListPanel.prototype.getTop=function(node)
{var parentPos=Coordinate.Statics.findPos(node);if(this.bottomPanel)
{var top=parentPos.y+Math.ceil((node.offsetHeight+this.spacerSize)/2);if(this.childContent)
{var requiredSize=this.childContent.getDesiredHeight();if((this.childContent.isCollapsible()&&this.childContent.getCollapsed())||0<requiredSize)
{var header=document.getElementById(RegisterControl.statics.encodeId(this,"header"));var top2=node.offsetHeight-this.spacerSize-header.offsetHeight-requiredSize;top2=(0<top2)?(parentPos.y+top2):(parentPos.y);if(0<requiredSize&&!(this.childContent.getCollapsed()))
return(top2<top)?top:top2;return top2;}
return top;}
else
{return top;}}
else
{return parentPos.y;}}
RecordListPanel.prototype.getLeft=function(node)
{if(this.siblingLeft)
return this.siblingLeft.getLeft(node)+this.siblingLeft.getWidth(node)+this.spacerSize;return Coordinate.Statics.findPos(node).x;}
RecordListPanel.prototype.getWidth=function(node)
{if(RecordListPanel.statics.collapseDirection.horizontal==this.collapseDirection&&this.childContent.getCollapsed())
return 85;if(this.width)
return this.width;var width=node.offsetWidth-this.getLeft(node)+Coordinate.Statics.findPos(node).x;if(0<width)
return width;return 1;}
RecordListPanel.prototype.getHeight=function(node)
{var parentPos=Coordinate.Statics.findPos(node);var height=0;if(this.siblingBelow)
{height=this.siblingBelow.getTop(node)-parentPos.y-this.spacerSize;}
else if(this.bottomPanel)
{height=parentPos.y+node.offsetHeight-this.getTop(node)-this.spacerSize;}
else
{height=node.offsetHeight-this.spacerSize;}
if(0<height)
return height;return 1;}
RecordListPanel.prototype.getId=function()
{return this.id;}
RecordListPanel.prototype.expandCollapse=function()
{var img=document.getElementById(RegisterControl.statics.encodeId(this,"expandCollapse"));this.childContent.setCollapsed(!this.childContent.getCollapsed());if(RecordListPanel.statics.collapseDirection.vertical==this.collapseDirection)
{if(img)
{if(this.childContent.getCollapsed())
this.setPngIconSrc(img,'/timesheet/WebResource.axd?d=djLaH47sOAKNk7WaoWvCi_RRTU6pSfwL94oFXgbC5k5o2xy33KPVs4jWGqvT1h2c1wv_nRcDd2c-wwzv0iXA5yxXfLzL5E9t1oI1TsqG9S1qdbYjzU8ksIMwmJEl4RNc0&t=633894763760000000&c=1');else
this.setPngIconSrc(img,'/timesheet/WebResource.axd?d=djLaH47sOAKNk7WaoWvCi_RRTU6pSfwL94oFXgbC5k5o2xy33KPVs4jWGqvT1h2c1wv_nRcDd2c-wwzv0iXA5yxXfLzL5E9t1oI1TsqG9S3BwQR8ufy7gYvTAPUUEInR0&t=633894763760000000&c=1');}}
else
{if(this.childContent.getCollapsed())
{if(img)
this.setPngIconSrc(img,'/timesheet/WebResource.axd?d=djLaH47sOAKNk7WaoWvCi_RRTU6pSfwL94oFXgbC5k5o2xy33KPVs4jWGqvT1h2c1wv_nRcDd2c-wwzv0iXA5yxXfLzL5E9t1oI1TsqG9S1k_XdEx9oTd04SBWyIl4V70&t=633894763760000000&c=1');}
else
{if(img)
this.setPngIconSrc(img,'/timesheet/WebResource.axd?d=djLaH47sOAKNk7WaoWvCi_RRTU6pSfwL94oFXgbC5k5o2xy33KPVs4jWGqvT1h2c1wv_nRcDd2c-wwzv0iXA5yxXfLzL5E9t1oI1TsqG9S3pvY6BUsxPQyoiz6XhXmxC0&t=633894763760000000&c=1');}}}
RecordListPanel.statics.eventDispatch=function(id,eventName,jsEvent)
{if(!jsEvent)
jsEvent=window.event;if(jsEvent)
{if(!jsEvent.target)
jsEvent.target=jsEvent.srcElement;}
var params=new Array();var instance=RegisterControl.statics.decodeId(id,params);instance[eventName].trigger(jsEvent);}
RecordListPanel.statics.onScroll=function(event){RecordListPanel.statics.eventDispatch(this.id,"onScroll",event);}
RecordListPanel.statics.onExpandCollapse=function(event){RecordListPanel.statics.eventDispatch(this.id,"onExpandCollapse",event);}
RecordListPanel.statics.onPanelClick=function(event){RecordListPanel.statics.eventDispatch(this.id,"onPanelClick",event);}
function IRecordListPanelChildContent()
{}
IRecordListPanelChildContent.prototype.init=function(parent)
{}
IRecordListPanelChildContent.prototype.handlesScrolling=function()
{return false;}
IRecordListPanelChildContent.prototype.isCollapsible=function()
{return false;}
IRecordListPanelChildContent.prototype.getCollapsed=function()
{return false;}
IRecordListPanelChildContent.prototype.setCollapsed=function(collapsed)
{}
IRecordListPanelChildContent.prototype.getDesiredHeight=function()
{return 0;}
function IRecordListPanelHeaderContent()
{}
IRecordListPanelHeaderContent.prototype.init=function(parent)
{}