﻿var _currentElement=null;var _rowHeight=12;var modalBack=null;var img=null;function SetDisabled(gvSrc){var height=gvSrc.scrollHeight;var width=gvSrc.scrollWidth;var pos=FindPos(gvSrc);modalBack=document.createElement("div");img=document.createElement("img");img.src="/common/images/loading.gif";img.style.position='absolute';img.style.zIndex=10001;img.style.left=(pos[0]+width/2-60)+"px";img.style.top=(pos[1]+height/2-6)+"px";img.style.width="120px";img.style.height="13px";modalBack.style.display='';modalBack.style.position='absolute';modalBack.style.zIndex=10000;modalBack.style.width=width+"px";modalBack.style.height=height+"px";modalBack.style.left=pos[0]+"px";modalBack.style.top=pos[1]+"px";modalBack.style.backgroundColor="Gray";modalBack.style.filter="alpha(opacity=30)";modalBack.style.opacity="0.3";gvSrc.parentNode.appendChild(modalBack);gvSrc.parentNode.appendChild(img);}function GridView_getHiddenFieldContents(arg){SetDisabled(this.panelElement);return arg+"|"+this.stateField.value;}function GridView_OnCallback(result,context){if(modalBack!=null){modalBack.parentNode.removeChild(modalBack);img.parentNode.removeChild(img);}var value=new String(result);var valsArray=value.split("|");var innerHtml=valsArray[4];for(var i=5;i<valsArray.length;i++){innerHtml+="|"+valsArray[i];}context.panelElement.innerHTML=innerHtml;context.stateField.value=createPropertyStringFromValues_GridView(valsArray[0],valsArray[1],valsArray[2],valsArray[3]);}function FindPos(obj){var curleft=curtop=0;if(obj.offsetParent){curleft=obj.offsetLeft;curtop=obj.offsetTop;while(obj=obj.offsetParent){curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}}return[curleft,curtop];}function GetRowHeight(rowElement){var currentHeight=0;var maxHeight=0;var nodeCount=rowElement.childNodes.length;for(rc=0;rc<nodeCount;rc++){if(rowElement.childNodes[rc].childNodes.length>0){if(rowElement.childNodes[rc].childNodes[0].childNodes.length>0){currentHeight=rowElement.childNodes[rc].childNodes[0].scrollHeight;if(currentHeight>maxHeight)maxHeight=currentHeight;}}}return maxHeight;}function SetRowHeight(rowElement,newVal){var nodeCount=rowElement.childNodes.length;rowElement.style.height=newVal+'px';for(rc=0;rc<nodeCount;rc++){if(rowElement.childNodes[rc].childNodes.length>0){if(rowElement.childNodes[rc].childNodes[0].childNodes.length>0){rowElement.childNodes[rc].childNodes[0].style.height=newVal+'px';}}}}function ExpandAll(rowElement){var expand=false;var expandAllUrl='';if(rowElement.state==undefined)rowElement.state='Expand';if(rowElement.state=='Expand'){rowElement.state='Collapse';expand=true;expandAllUrl='../Common/Images/collapseall.gif';}else if(rowElement.state=='Collapse'){rowElement.state='Expand';expandAllUrl='../Common/Images/expandall.gif';}tableElement=rowElement.parentNode.parentNode;for(i=1;i<tableElement.childNodes.length;i++){if(expand){SetRowHeight(tableElement.childNodes[i],GetRowHeight(tableElement.childNodes[i]));tableElement.childNodes[i].state='Expanded';}else{SetRowHeight(tableElement.childNodes[i],_rowHeight);tableElement.childNodes[i].state='Collapsed';}SetRowExpandedState(tableElement.childNodes[i],expand);}if(tableElement.childNodes[0].childNodes[0].childNodes[0]){tableElement.childNodes[0].childNodes[0].childNodes[0].src=expandAllUrl;}else{tableElement.childNodes[0].childNodes[1].childNodes[0].src=expandAllUrl;}}function SetRowExpandedState(rowElement,expanded){var imgUrl='../Common/Images/collapse.gif';if(!expanded)imgUrl='../Common/Images/expand.gif';if(rowElement.childNodes[0]){if(rowElement.childNodes[0].childNodes[0]){rowElement.childNodes[0].childNodes[0].src=imgUrl;}else{rowElement.childNodes[1].childNodes[0].src=imgUrl;}}}function ExpandRow(rowElement){var nodeCount=rowElement.childNodes.length;var maxHeight=0;var currentHeight=0;_currentElement=rowElement;if(rowElement.state==undefined){rowElement.state='Collapsed';}if(rowElement.state=='Collapsed'){rowElement.state='Expanding';}else if(rowElement.state=='Expanded'){rowElement.state='Collapsing';}else{return 0;}for(i=0;i<nodeCount;i++){if(rowElement.childNodes[i].childNodes.length>0){if(rowElement.childNodes[i].childNodes[0].childNodes.length>0){className=rowElement.childNodes[i].childNodes[0].className;currentHeight=rowElement.childNodes[i].childNodes[0].scrollHeight;if(currentHeight>maxHeight)maxHeight=currentHeight;}}}if(rowElement.state=='Expanding'){setTimeout('ExpandTo( '+maxHeight+', '+_rowHeight+')',50);}else{setTimeout('ExpandTo( '+_rowHeight+', '+maxHeight+')',50);}}function ExpandTo(toHeight,currentHeight){var newVal=0;if(toHeight!=_rowHeight){newVal=currentHeight+20;if(newVal>=toHeight){newVal=toHeight;_currentElement.state='Expanded';if(_currentElement.childNodes[0].childNodes[0]){_currentElement.childNodes[0].childNodes[0].src='../Common/Images/collapse.gif';}else{_currentElement.childNodes[1].childNodes[0].src='../Common/Images/collapse.gif';}}}else{newVal=currentHeight-20;if(newVal<=toHeight){newVal=toHeight;_currentElement.state='Collapsed';if(_currentElement.childNodes[0].childNodes[0]){_currentElement.childNodes[0].childNodes[0].src='../Common/Images/expand.gif';}else{_currentElement.childNodes[1].childNodes[0].src='../Common/Images/expand.gif';}}}var nodeCount=_currentElement.childNodes.length;_currentElement.style.height=newVal+'px';for(i=0;i<nodeCount;i++){if(_currentElement.childNodes[i].childNodes.length>0){if(_currentElement.childNodes[i].childNodes[0].childNodes.length>0){_currentElement.childNodes[i].childNodes[0].style.height=newVal+'px';}}}if(newVal!=toHeight){setTimeout('ExpandTo( '+toHeight+','+newVal+' )',50);}}