// JavaScript Document

function GridView(dTable){

	this.dTable=dTable||null;

	html=document.createElement('TABLE');

	this.control= Control;

	this.control(html);

	

	this.html.width='100%';

	this.html.border=0;

	this.html.cellPadding=0;

	this.html.cellSpacing=1;

	this.html.className=this.styleClassName='gridView';	

	this.addRow=function(dRow){

		var gRow=new GridViewRow();

		gRow.parent=this;

		if(dRow){

			gRow.bind(dRow);

			gRow.state='Normal';

			gRow.type='GridViewRow_Data';

		}

		else{

			if(this.controls.last().type=='GridViewRow_New' || !this.dTable.allowAdd) return false;

			gRow.state='Insert';

			gRow.type='GridViewRow_New';

		}

		gRow.construct();

		this.controls.add(gRow);

		this.html.tBodies[0].appendChild(gRow.html);

		if(gRow.type=='GridViewRow_New')	setActionCellPosition(gRow.controls._('Actions'));

		return gRow;

	};//this.addRow End

	this.addHeader=function(){

		var gHRow=new GridViewHRow();

		gHRow.parent=this;

		gHRow.construct();

		this.controls.add(gHRow);

		this.html.tHead.appendChild(gHRow.html);

		this.header=gHRow;

		//setActionCellPosition(gHRow.controls._('Actions'));

	};//this.addHeader End

	this.addFooter=function(){

		this.html.createTFoot();

		if(this.dTable.allowAdd){

			var r=document.createElement("TR");

			this.html.tFoot.appendChild(r);

			var c=document.createElement("TD");

			r.appendChild(c);		

			l=new Link('Add','Add New');

			l.onClick=this.startAdd.fasten(this);

			l.construct();

			c.appendChild(l.html);

		}

	};//this.addFooter End

	this.construct=function(){

		if(this.html.tBodies.length<1){this.html.appendChild(document.createElement('TBODY'))};

		//	this.html.tBodies[0].className='gridBody';

		if(!this.html.tHead){this.html.createTHead()}

		this.addHeader();

		for(var dx in this.dTable.dRows){

			this.addRow(this.dTable.dRows[dx]);

		}

		//if(!this.html.tFoot)this.addFooter();

		if(this.dTable.allowAdd){

			this.lnkAddNew=new Link('Add','Add New');

			this.lnkAddNew.onClick=this.startAdd.fasten(this);

			this.lnkAddNew.construct();

		}

	

	};//this.construct End

	this.update=function(Sender){

		if(Sender.tableName != this.dTable.tableName)return;

		this.dTable=Sender;

		this.controls.moveFirst();

		for(;!this.controls.atEnd();this.controls.moveNext()){

			this.controls.current().destruct();

		}

		this.controls.clear();

		this.construct();

	};//this.update End

	this.bind=function(dTable){

		if(!dTable){alert("GridView.bind Error:can't bind to a null dTable");return false}

		this.dTable=dTable;

		this.name=dTable.tableName;

		this.dTable.Events.addListener('DataTableChanged',this.name,this.update.fasten(this));

		this.dTable.Events.addListener('DataRowInserted',this.name,this.onDRowInserted.fasten(this));

		return true;

	};//this.bind End

	

	this.createHideShowColsControl=function(){

		if(!this.header){alert("no header");return}

		

		this.hldHSControl=new Control(document.createElement("DIV"));

		this.header.controls.moveFirst();

		for(;!this.header.controls.atEnd();this.header.controls.moveNext()){

			this.hldHSControl.controls.append(new Lable(this.header.controls.current().name,this.header.controls.current().name));

			var cbTemp=new CheckBox(this.header.controls.current().name,'1');

			cbTemp.onChange=this.toggleColVisibility.fasten(this);

		  	this.hldHSControl.controls.append(cbTemp);

			this.hldHSControl.html.appendChild(document.createElement('BR'));

			cbTemp.updateHtml();

			

		}

	}//this.createHideShowColsControls End

	this.toggleColVisibility=function(Sender){

		this.controls.moveFirst();

		for(;!this.controls.atEnd();this.controls.moveNext()){

			if(this.controls.current().type!='GridViewRow_Header' && this.controls.current().type!='GridViewRow_Data') continue;

			if(Sender.html.checked)

				this.controls.current().controls._(Sender.name).show();

			else

				this.controls.current().controls._(Sender.name).hide();

		}

		

	};//this.toggleColVisibility End

	this.setupActionCells=function(){

		this.controls.moveFirst()

		for(;!this.controls.atEnd();this.controls.moveNext()){

			//if(this.controls.current().type=='GridViewRow_Data')

			setActionCellPosition(this.controls.current().controls._('Actions'));

		}

	}

//--------------------< Handlers >-------------------------\\	

	this.startAdd=function(){

		this.addRow();

	};

	this.onDRowInserted=function(Sender){
	
		//this.dTable.removeListener('DataRowInserted',this.name);

		this.controls._('New').stopAdd();

		this.addRow(Sender.dRows[Sender.dRows.length-1]);

	};

//--------------------< ++++++ >--------------------------\\



};//GridView Class End

//----------------------------------------------

function GridViewHRow(){

	var html=document.createElement('TR');

	this.control= Control;

	this.control(html);

	this.type="GridViewRow_Header";

	this.styleClassName='gridHeader';

	this.html.className=this.styleClassName;

	

	this.construct=function(){

		var dCols=this.parent.dTable.dCols;

		this.name=this.parent.name+"Header";

		

		for(var dx=0;dx<dCols.length;dx++){

			var dCol=dCols[dx];

			if(dCol.isVisible){

				cell=new GridViewCell(dCol.columnName);

				cell.type='GridViewCell_Header';

				cell.controls.append(new Lable('Read',dCol.header));

				this.controls.append(cell);

				cell.html.noWrap="nowrap";

				if(this.parent.hldHSControl)

					if(this.parent.hldHSControl.controls._(cell.name))

						if(this.parent.hldHSControl.controls._(cell.name).text=='1')

							cell.show();

						else

							cell.hide();

				//header separator

				var sepCell=document.createElement("TD");

				sepCell.innerHTML="&nbsp;";

				sepCell.className='gridHeaderCellsSeparator';

				this.html.appendChild(sepCell);

				sepCell.onmousedown=Drag.start.fasten(Drag);

			}

		}

		var emptyCell=document.createElement("TD");

		emptyCell.width='100%';

		emptyCell.innerHTML="&nbsp;";

		this.html.appendChild(emptyCell);

		

		if(this.parent.dTable.readOnly)return;

		

		actionsCell=new GridViewCell('Actions');

		actionsCell.controls.append(new Lable('Actions',' --Actions-- '));

		this.controls.append(actionsCell);

		actionsCell.html.noWrap="nowrap";

		if(this.parent.hldHSControl)

			if(this.parent.hldHSControl.controls._(actionsCell.name))

				if(this.parent.hldHSControl.controls._(actionsCell.name).text=='1')

					actionsCell.show();

				else

					actionsCell.hide();

	};

};

//----------------------------------------------

function GridViewRow(){

	this.dRow=null;

	var html=document.createElement('TR');

	this.control= Control;

	this.control(html);

	

	this.type="GridViewRow_Data";

	this.construct=function(){

		var dCols=this.parent.dTable.dCols;

		if(this.dRow){

			this.name=this.dRow.ordinal;

			this.styleClassName=(this.dRow.ordinal%2)==0 ?'gridRowEven':'gridRowOdd';

		}

		else{

			this.name='New';

			this.styleClassName='gridRowNew';

		}

		this.html.className=this.styleClassName;

		for(var dx=0;dx<dCols.length;dx++){

			var dCol=dCols[dx];

			if(dCol.isVisible){

				cell=new GridViewCell(dCol.columnName);

				cell.type='GridViewCell_Data';

				if(dCol.indParentRelation!=-1){//child--->parent  relation

					var PDT=this.parent.dTable.parentRelations[dCol.indParentRelation].parentTable;

					if(this.dRow){//this gRow Represents dRow;

						var PDR= PDT.getRow(this.dRow.dItems[dx].value);

						if(!PDR) {

							alert("GridView Obdxect Error:can't find parent data row with Key=("+this.dRow.dItems[dx].value+") in Data Table=("+PDT.tableName+")");

							return false;

						}

						cell.controls.append(new Lable('Read',PDR.dItems[PDT.indListText].value));//Read GUI Control

						if(!dCol.readOnly && this.parent.dTable.allowEdit){

							var s=this.parent.dTable.tableName+cell.name+'_Write'+this.name;

							var lbTemp=new ListBox('Write',this.dRow.dItems[dx].value,PDT,true,s,parseInt(PDT.indActivePassiveCol));

							cell.controls.append(lbTemp);

						}//Write GUI control

						cell.bind(this.dRow.dItems[dx]);

					}

					else if(dCol.allowAdd && !dCol.readOnly && this.parent.dTable.allowAdd){//this gRow new;

						var s=this.parent.dTable.tableName+cell.name+'_Write'+this.name;

						var lbTemp=new ListBox('Write',null,PDT,true,s,parseInt(PDT.indActivePassiveCol));

						cell.controls.append(lbTemp);

					}

				}

				else if(dCol.indChildRelation!=-1){//parent---->child relation

					if(this.dRow){//this gRow Represents dRow;

						var lnk=new Link('Read',this.dRow.dItems[dx].value);
						lnk.html.style.color='blue';
						lnk.onClick=this.manageChildren.fasten(this);

						cell.controls.append(lnk);

						if(!dCol.readOnly && this.parent.dTable.allowEdit){cell.controls.append(new TextBox('Write',this.dRow.dItems[dx].value))};

						cell.bind(this.dRow.dItems[dx]);

					}

					else	if(dCol.allowAdd && !dCol.readOnly && this.parent.dTable.allowAdd)

						cell.controls.append(new TextBox('Write',''));

				}

				else{//no relations

					tb=null;

					if(this.dRow){

						cell.controls.append(new Lable('Read',this.dRow.dItems[dx].value));

						cell.bind(this.dRow.dItems[dx]);

						if(!dCol.readOnly && this.parent.dTable.allowEdit){

							if(dCol.dataType=="tinyint" && dCol.maxLength==1)

								tb=new CheckBox('Write',this.dRow.dItems[dx].value);

							else if(dCol.dataType=="date"){

								if(!document.calender){document.calender=new Calender();document.body.appendChild(document.calender.html);}

								tb=new DateBox('Write',this.dRow.dItems[dx].value,document.calender);

							}

							else

								tb=new TextBox('Write',this.dRow.dItems[dx].value);

						}

					}

					else	if(dCol.allowAdd && !dCol.readOnly && this.parent.dTable.allowAdd){

						if(dCol.dataType=="tinyint" && dCol.maxLength==1)

							tb=new CheckBox('Write',0);

						else if(dCol.dataType=="date"){

								if(!document.calender){document.calender=new Calender();document.body.appendChild(document.calender.html);}

								tb=new DateBox('Write','',document.calender);

						}

						else

							tb=new TextBox('Write','');

					}

					if(tb){

						tb.uniqe=dCol.uniqe;

						tb.maxLength=dCol.maxLength;

						tb.defaultValue=dCol.defaultValue;

						tb.dataType=dCol.dataType;	

						cell.controls.append(tb);

						if(tb.type=='CheckBox')tb.updateHtml();

					}

				}

				this.controls.append(cell);

				//alert(cell.name+" has been added, cell type="+cell.type);

				this.controls.last().onStateChanged();

				if(this.parent.hldHSControl && this.dRow)

					if(this.parent.hldHSControl.controls._(cell.name))

						if(this.parent.hldHSControl.controls._(cell.name).text=='1')

							cell.show();

						else

							cell.hide();

				//separator

				var sepCell=document.createElement("TD");

				sepCell.className='gridCellsSeparator';

				this.html.appendChild(sepCell);

			}

		}

		var emptyCell=document.createElement("TD");

		emptyCell.width='100%';

		emptyCell.innerHTML="&nbsp;";

		this.html.appendChild(emptyCell);

		

		if(this.parent.dTable.readOnly)return;

		actionsCell=new GridViewCell('Actions');

		actionsCell.type='GridViewCell_Actions';

		actionsCell.styleClassName='gridRowAction';

		actionsCell.html.className=actionsCell.styleClassName;

					

		if(this.parent.dTable.allowEdit){

			l=new Link('Edit','Edit');

			l.onClick=this.startEdit.fasten(this);

			actionsCell.controls.append(l);

			

			l=new Link('StopEdit','cancel');

			l.onClick=this.stopEdit.fasten(this);

			actionsCell.controls.append(l);

			

			l=new Link('Update','update');

			l.onClick=this.startUpdate.fasten(this);

			actionsCell.controls.append(l);

		}

		if(this.parent.dTable.allowAdd){

			l=new Link('StopAdd','cancel');

			l.onClick=this.stopAdd.fasten(this);

			actionsCell.controls.append(l);

			

			l=new Link('Save','save');

			l.onClick=this.startSave.fasten(this);

			actionsCell.controls.append(l);

		}

		if(this.parent.dTable.allowDelete){

			l=new Link('Delete','Delete');

			l.onClick=this.startDelete.fasten(this);

			actionsCell.controls.append(l);

		}

		l=new Lable('Waiting','communicating...');

		actionsCell.controls.append(l);

		

		this.controls.append(actionsCell);

		this.controls.last().onStateChanged();

		

		if(this.parent.hldHSControl && this.dRow)

			if(this.parent.hldHSControl.controls._(actionsCell.name))

				if(this.parent.hldHSControl.controls._(actionsCell.name).text=='1')

					actionsCell.show();

				else

					actionsCell.hide();

	};

	this.viewErrors=function(Data){

		alert(Data.text);

		this.update();

	};

	this.update=function(Sender){
		
		this.controls.moveFirst();

		for(;!this.controls.atEnd();this.controls.moveNext()){

			if(this.controls.current().type==="GridViewCell_Data"){

				//this.controls.current().dItem=Sender.dItems[this.controls.current().dItem.ordinal];

				this.controls.current().update();

			}

		}

		if(this.state=='Waiting')	this.changeState('Normal');

		//else alert(this.state);

	};

	this.bind=function(dRow){

		this.dRow=dRow;

		this.name=dRow.ordinal;

		this.bound=true;

		this.dRow.Events.addListener('DataRowChanged',this.parent.name+'_r'+this.name,this.update.fasten(this));

		this.dRow.Events.addListener('DataRowDeleted',this.parent.name+'_r'+this.name,this.onDRowDeleted.fasten(this));

	};

	this.startEdit=function(){this.changeState('Edit');};

	this.stopEdit=function(){this.changeState('Normal');};

	this.startUpdate=function(){

		keyIdx=this.parent.dTable.getCol(this.parent.dTable.keyName).ordinal;

		var data=new Array();

		var errors='';

		this.controls.moveFirst();

		for(;!this.controls.atEnd();this.controls.moveNext()){

			if(this.controls.current().controls._('Write')){

				name=this.parent.name+'_'+this.controls.current().name+'-id'+this.dRow.dItems[keyIdx].value;

				value=this.controls.current().controls._('Write').text;

				data.push({name:name,value:value});

				if(!this.controls.current().controls._('Write').validate()) errors+=this.controls.current().controls._('Write').errors+'\n';

			}

		}

		if(errors){alert(errors);return}

		if(this.parent.dTable.parentKeyName && this.parent.dTable.parentKeyValue){

			data.push({name:this.parent.name+'_'+this.parent.dTable.parentKeyName+'-id'+this.dRow.dItems[keyIdx].value,value:this.parent.dTable.parentKeyValue});

		}

		this.changeState('Waiting');

		var passCode=Server.passcode?Server.passcode:(document.cookie).substring(9,document.cookie.indexOf(";",0));

		data.push({name:'passcode',value:passCode});

		data.push({name:'dRowOrdinal',value:this.dRow.ordinal});

		var pAction=this.dRow.parent.updateRow.fasten(this.dRow.parent);

		var nAction=this.viewErrors.fasten(this);

		Server.handleRequest(new Request(pAction,nAction,data,Server.address,'POST',-1,this.dRow.parent.tableName+'Update'));
	

	};

	this.updated=function(subset){
		if(subset.error){alert(subset.error);}

		else{

			if(this.parent.dTable.updateRow(subset.dRow)){

				this.dRow=subset.dRow;

			}

			else	alert('Problem with updating dRow');

		}

		this.update();

	};

	

	this.stopAdd=function(){

		this.parent.controls.Delete(this);

	};

	this.startSave=function(){

		keyIdx=this.parent.dTable.getCol(this.parent.dTable.keyName).ordinal;

		var data=new Array();

		var errors='';

		this.controls.moveFirst();

		for(;!this.controls.atEnd();this.controls.moveNext()){

			if(this.controls.current().controls._('Write')){

				this.controls.current().controls._('Write').htmlUpdate();

				name=this.parent.name+'_'+this.controls.current().name+'-sn';

				value=this.controls.current().controls._('Write').text;

				data.push({name:name,value:value});

				if(!this.controls.current().controls._('Write').validate()) errors+=this.controls.current().controls._('Write').errors+'\n';

			}

		}

		if(errors){alert(errors);return}

		if(this.parent.dTable.parentKeyName && this.parent.dTable.parentKeyValue){

			data.push({name:this.parent.name+'_'+this.parent.dTable.parentKeyName+'-sn',value:this.parent.dTable.parentKeyValue});

		}

		this.changeState('Waiting');

		//data.push({name:'dRowOrdinal',value:this.dRow.ordinal});

		var passCode=Server.passcode?Server.passcode:(document.cookie).substring(9,document.cookie.indexOf(";",0));

		data.push({name:'passcode',value:passCode});

		var pAction=this.parent.dTable.insertRow.fasten(this.parent.dTable);

		var nAction=this.viewErrors.fasten(this);

		Server.handleRequest(new Request(pAction,nAction,data,Server.address,'POST',-1,this.parent.dTable.tableName+'Add'));

	};

	this.startDelete=function(){

		var data=new Array();

		var id=this.dRow.dItems[this.dRow.parent.getCol(this.dRow.parent.keyName).ordinal].value;

		data.push({name:this.dRow.parent.tableName+'_'+this.dRow.parent.keyName+'-id'+id,value:id});

		data.push({name:'dRowOrdinal',value:this.dRow.ordinal});

		var passCode=Server.passcode?Server.passcode:(document.cookie).substring(9,document.cookie.indexOf(";",0));

		data.push({name:'passcode',value:passCode});

		var pAction=this.dRow.parent.deleteRow.fasten(this.dRow.parent);

		var nAction=this.update.fasten(this);

		Server.handleRequest(new Request(pAction,nAction,data,Server.address,'POST',-1,this.parent.dTable.tableName+'Delete'));


	};

	this.changeState=function(strState){

		oldState=this.state;

		switch(strState){

			case'Normal':this.state='Normal';break;

			case'Insert':this.state='Insert';break;

			case'Edit':this.state='Edit';break;

			case'Waiting':this.state='Waiting';break;

		}

		this.controls.moveFirst();

		for(;!this.controls.atEnd();this.controls.moveNext()){	this.controls.current().onStateChanged();}

	

	};

	this.manageChildren=function(Sender){

		var rootObj= document.Root;

		var dCol=this.parent.dTable.dCols[Sender.parent.dItem.ordinal];

		var childDTableName=this.parent.dTable.childRelations[dCol.indChildRelation].childTableName;

		var dxKey=this.parent.dTable.getCol(this.parent.dTable.keyName).ordinal;

		var passCode=Server.passcode?Server.passcode:(document.cookie).substring(9,document.cookie.indexOf(";",0));

		var Params=[{'name':'PHPSESSID','value':Server.sessionId},{'name':'passcode','value':passCode},{'name':this.parent.dTable.keyName,'value':this.dRow.dItems[dxKey].value}];

		Params.type='RequestParameters';

		if(rootObj[childDTableName+'Holder']){

			rootObj[childDTableName+'Holder'].show();

			rootObj[childDTableName+'Holder'].gridNav.fetchData(Params);

		}

		else{

			var op=this.parent.dTable.readOnly?'View':'Manage';

			objR=new Request(this.manageChildren_response.fasten(this),viewErrors,Params,Server.address,'POST',-1,childDTableName+op);

			Server.handleRequest(objR);
	

		}

	};

	//--------------------------<Event Handlers>---------------------------------\\

	this.onDRowDeleted=function(Sender){

		this.parent.controls.Delete(this);

	};

	this.manageChildren_response=function(objSubSet){

		dSet.Update(objSubSet);

		var rootObj=document.Root;

		var dxKey=this.parent.dTable.getCol(this.parent.dTable.keyName).ordinal;

		var childDTable=this.parent.dTable.readOnly?dSet.getTable(objSubSet.name.substr(0,objSubSet.name.length-4)):dSet.getTable(objSubSet.name.substr(0,objSubSet.name.length-6));

		

		var childrensHolder=new Holder(childDTable.tableName,childDTable.tableTitle,0);

		childDTable.Events.addListener('DataTableChanged',childDTable.tableName+'Holder',childrensHolder.setTitle.fasten(childrensHolder));

		rootObj.appendChild(childrensHolder.html);

		rootObj[childDTable.tableName+"Holder"]=childrensHolder;

		

		var gridNav=new GridNavigator();

		gridNav.bind(childDTable);

		gridNav.construct();

		var passCode=Server.passcode?Server.passcode:(document.cookie).substring(9,document.cookie.indexOf(";",0));

		gridNav.additionalData=[{'name':'PHPSESSID','value':Server.sessionId},{'name':'passcode','value':passCode},

								{'name':this.parent.dTable.keyName,'value':this.dRow.dItems[dxKey].value}]

	

		childrensHolder.gridNav=gridNav;

		childrensHolder.html.Cpanel.appendChild(gridNav.html);

	

		var gridView=new GridView();

		gridView.parent=childrensHolder.html.Body;

		childrensHolder.gridView=gridView;

		childrensHolder.html.Body.appendChild(gridView.html);

		gridView.bind(childDTable);

		gridView.construct();

		if(gridView.lnkAddNew)		childrensHolder.html.Foot.appendChild(gridView.lnkAddNew.html);

	};

	//--------------------------------------------------------------------------\\

};

//------------------------------------------\\

function GridViewCell(strName){

	var html=document.createElement('TD');

	this.control= Control;

	this.control(html);

	this.name=strName||'anonymouse';

	this.html.Body=document.createElement('DIV');

	this.html.Body.className='gridCell';

	this.html.appendChild(this.html.Body);

	//this.html.className=this.styleClassName='gridCell';

	this.controls.append=function(objControl){

		if(!objControl){alert('Control.append() Fetal Error:atempt to append a null object');return false;}

		objControl.parent=this.owner;

		objControl.construct();

		if(!objControl) {alert(this.name+'.append('+objControl+')');return;}

		this.add(objControl);

		this.owner.html.Body.appendChild(objControl.html);

		return true;

	}

	

	this.construct=function(){};

	this.update=function(){

		//this.dItem=this.parent.dRow.dItems[this.dItem.ordinal];

		var w=this.controls._('Write');

		var r=this.controls._('Read');

		

		var dCol=this.parent.parent.dTable.dCols[this.dItem.ordinal];

		if(dCol.indParentRelation!=-1){

			var PDT=this.parent.parent.dTable.parentRelations[dCol.indParentRelation].parentTable;

			var PDR= PDT.getRow(this.dItem.value);

			if(r)	{r.text=PDR.dItems[PDT.indListText].value;}

		}

		else{

			if(r)	{r.text=this.dItem.value;}

		}

		if(w){w.text=this.dItem.value;w.updateHtml();w.enable();}

		if(r){r.enable();r.updateHtml();}

	};

	this.bind=function(dItem){

		if(!dItem)alert("HHHHHHHHHHHHHHHHHHOOOOOOO");

		this.dItem=dItem;

		

	};

	this.onStateChanged=function(){

		//alert(this.parent.state);

		if(this.name!='Actions' && this.name!='SN')

		switch(this.parent.state){

			case'Normal':

					if(this.controls._('Read'))this.controls._('Read').show();

					if(this.controls._('Write'))this.controls._('Write').hide();

			break;

			case'Edit':

					if(this.controls._('Read'))this.controls._('Read').hide();

					if(this.controls._('Write')){this.controls._('Write').show();}

			break;

			case'Waiting':

					if(this.controls._('Write') && this.controls._('Write').visible)this.controls._('Write').disable();

			break;

		}

		else if(this.name=='Actions'){

			this.controls.moveFirst();

			switch(this.parent.state){

				case'Normal':

					for(;!this.controls.atEnd();this.controls.moveNext()){

						if(this.controls.current().name=='Edit' || this.controls.current().name=='Delete') this.controls.current().show();

						else	this.controls.current().hide();

					}

				break;

				case'Edit':

					for(;!this.controls.atEnd();this.controls.moveNext()){

						if(this.controls.current().name=='StopEdit' || this.controls.current().name=='Update') this.controls.current().show();

						else	this.controls.current().hide();

					}

				break;

				case'Insert':

					for(;!this.controls.atEnd();this.controls.moveNext()){

						if(this.controls.current().name=='StopAdd' || this.controls.current().name=='Save') this.controls.current().show();

						else	this.controls.current().hide();

					}

				break;

				case'Waiting':

					for(;!this.controls.atEnd();this.controls.moveNext()){

						if(this.controls.current().name=='Waiting')this.controls.current().show();

						else	this.controls.current().hide();

					}

				break;

			}

		}

		return;

	};

};

//----------------------------------------------

function setActionCellPosition(cell){

	return;

	var rootObj=cell.parent.parent.parent;

	cell.html.style.position='absolute';

	//cell.html.style.zIndex=zIndex++;

	/*if(window.navigator.appName!="Microsoft Internet Explorer")

		cell.html.style.left=(rootObj.offsetWidth+(outerWidth-innerWidth))+'px';

	else

		cell.html.style.left=(rootObj.offsetWidth+parseInt(document.body.leftMargin))+'px';*/

	var tempX=0;var tempY=0;var currentNode=cell.html.previousSibling;

	while(currentNode && currentNode.tagName!='HTML'){

		tempX+=currentNode.offsetLeft;

		tempY+=currentNode.offsetTop;

		currentNode=currentNode.offsetParent;

	}

	cell.html.style.top=cell.parent.type!='GridViewRow_Header' ?Math.abs((cell.html.previousSibling.clientHeight-cell.html.clientHeight)/2)+tempY+'px':tempY+'px';

	var tempX=0;var tempY=0;var currentNode=rootObj;

	while(currentNode && currentNode.tagName!='HTML'){

		tempX+=currentNode.offsetLeft;

		tempY+=currentNode.offsetTop;

		currentNode=currentNode.offsetParent;

	}

	cell.html.style.left=tempX+rootObj.clientWidth;

	if(cell.parent.type=='GridViewRow_Header'){

		cell.html.style.backgroundColor="#950A00";

		cell.html.style.width='auto';

		cell.html.style.height=cell.html.parentNode.clientHeight+'px';

	}

}


