/*
	Copyright Interactive Co.,Ltd 2005;
	update : 2005-04-24;
*/
function cs_bagts(td,name)
{
	this.vname = name;
	this.vnum = 0;
	this.vcount1 = 0;
	this._td = td;
	this.vlang = new Array();
	this.vcode = new Array();
	this.vnamebg1 = new Array();
	this.vnamebg2 = new Array();
	this.vnamebg3 = new Array();
	this.vnamebg4 = new Array();
	this.vnamebg5 = new Array();
	this.vtitle = new Array();
	this.vorder = new Array();
	this.vptusuv = new Array();
	this.vworkdesc = new Array();
	this.vbuturl = new Array();
	this.vhide = new Array();
	this.vdelimg = new Array();
	this.vbr1 = new Array();
	this.vbr2 = new Array();
	this.vbr3 = new Array();
	this.vbr4 = new Array();
	this.vbr5 = new Array();
	this.vtreearray = new Array();
	this.vcode1 = '';
	this.vtitle1 = '';
	this.vorder1 = '';
	this.vptusuv1 = '';
	this.vworkdesc1 = '';
	
	this.bagtsname = function(vcode,vtitle,vorder,vptusuv,vworkdesc)
	{
		this.vcode1 = vcode;
		this.vtitle1 = vtitle;
		this.vorder1 = vorder;
		this.vptusuv1 = vptusuv;
		this.vworkdesc1 = vworkdesc;
		this.vaddinput();
	}
	
	this.vinput = function(vcode,vtitle,vorder,vptusuv,vworkdesc)
	{
		this.vcode1 = vcode;
		this.vtitle1 = vtitle;
		this.vorder1 = vorder;
		this.vptusuv1 = vptusuv;
		this.vworkdesc1 = vworkdesc;
		var vtd1 = document.getElementById( "vtdb1" );
		var vadd = document.createElement( '<input type="button" style="cursor:hand;" value="&nbsp;&nbsp;&nbsp;&nbsp;' + this.vlang['addbagts'] + '&nbsp;&nbsp;&nbsp;&nbsp;" class="butpro" onclick="' + this.vname + '.vaddinput()">' );
		vtd1.appendChild(vadd);
		var vadd1 = document.createElement( '<input type="text" size="1" value="" class="tit">' );
		vtd1.appendChild(vadd1);
	}

	this.vaddinput = function ()
	{
		this.vnum++;
		this.vcount1++;
		var vtd1 = document.getElementById( "vtdb1" );
		this.vdelimg[this.vnum] = document.createElement( '<input type="button" style="cursor:hand;" value="&nbsp;&nbsp;&nbsp;&nbsp;' + this.vlang['delbagts'] + '&nbsp;&nbsp;&nbsp;&nbsp;" class="butpro"  onclick="' + this.vname + '.vdelinput(' + this.vnum + ')">' );
		vtd1.appendChild(this.vdelimg[this.vnum]);
		var vsub = this.vnum - 1;
		//alert(this.vdelimg[vsub]);
	
		if( this.vdelimg[vsub] == '[object]' )
			vtd1.removeChild(this.vdelimg[vsub]);
			
		var vtd = document.getElementById( this._td );
		var	vsize = 85;
		
		this.vcode[this.vnum] = document.createElement( '<input id="vbagtsnum' + this.vnum + '"  name="vbagtsnum' + this.vnum + '" type="hidden" value="' + this.vcode1 + '">' );
		vtd.appendChild(this.vcode[this.vnum]);
		
		this.vnamebg1[this.vnum] = document.createElement( '<input size="30" class="tit" type="text" value="' + this.vlang['bagtsname'] + '-' + this.vcount1 + ':">' );
		vtd.appendChild(this.vnamebg1[this.vnum]);

		this.vtitle[this.vnum] = document.createElement( '<input id="vbagtsname' + this.vnum + '" size="' + vsize  + '"  name="vbagtsname' + this.vnum + '" type="text" value="' + this.vtitle1 + '">' );
		vtd.appendChild(this.vtitle[this.vnum]);
		
		this.vbr1[this.vnum] = document.createElement( '<br/>' );
		vtd.appendChild(this.vbr1[this.vnum]);
		
		this.vnamebg2[this.vnum] = document.createElement( '<input size="30" class="tit" type="text" value="' + this.vlang['bagtsid'] + '-' + this.vcount1 + ':">' );
		vtd.appendChild(this.vnamebg2[this.vnum]);

		this.vorder[this.vnum] = document.createElement( '<input id="vbagtsorder' + this.vnum + '" size="20" name="vbagtsorder' + this.vnum + '" type="text" value="' + this.vorder1 + '">' );
		vtd.appendChild(this.vorder[this.vnum]);
		
		this.vbr2[this.vnum] = document.createElement( '<br/>' );
		vtd.appendChild(this.vbr2[this.vnum]);
		
		this.vnamebg3[this.vnum] = document.createElement( '<input size="30" class="tit" type="text" value="' + this.vlang['tusuv'] + '-' + this.vcount1 + ':">' );
		vtd.appendChild(this.vnamebg3[this.vnum]);

		this.vptusuv[this.vnum] = document.createElement( '<input id="vbagtstusuv' + this.vnum + '" size="20" name="vbagtstusuv' + this.vnum + '" type="text" value="' + this.vptusuv1 + '">' );
		vtd.appendChild(this.vptusuv[this.vnum]);
		
		this.vbr3[this.vnum] = document.createElement( '<br/>' );
		vtd.appendChild(this.vbr3[this.vnum]);
		
		this.vnamebg4[this.vnum] = document.createElement( '<textarea rows="5" id="vw'+ this.vnum +'" cols="33" class="tit"></textarea>' );
		vtd.appendChild(this.vnamebg4[this.vnum]);
		document.getElementById("vw" + this.vnum).innerHTML = this.vlang['work'] + '-' + this.vcount1+':';
		
		this.vworkdesc[this.vnum] = document.createElement( '<textarea id="vbagtswork' + this.vnum + '" rows="5" cols="90" name="vbagtswork' + this.vnum + '"></textarea>' );
		vtd.appendChild(this.vworkdesc[this.vnum]);
		document.getElementById("vbagtswork" + this.vnum).innerHTML = this.vworkdesc1;
		
		this.vhide[this.vnum] = document.createElement( '<input name="vmaxbagts" id="vmaxtree" type="hidden" value="' + this.vnum + '">' );
		vtd.appendChild(this.vhide[this.vnum]);
		
		this.vbr4[this.vnum] = document.createElement( '<br/>' );
		vtd.appendChild(this.vbr4[this.vnum]);
		
		this.vbr5[this.vnum] = document.createElement( '<br/>' );
		vtd.appendChild(this.vbr5[this.vnum]);
		this.vcode1 = '';
		this.vtitle1 = '';
		this.vorder1 = '';
		this.vptusuv1 = '';
		this.vworkdesc1 = '';
		
	}
	
	this.vdelinput = function (vi)
	{
		this.vcount1--;
		this.vnum--;
		var vtd = document.getElementById( this._td );
		vtd.removeChild(this.vtitle[vi]);
		vtd.removeChild(this.vcode[vi]);
		vtd.removeChild(this.vnamebg1[vi]);
		vtd.removeChild(this.vnamebg2[vi]);
		vtd.removeChild(this.vnamebg3[vi]);
		vtd.removeChild(this.vnamebg4[vi]);
		vtd.removeChild(this.vorder[vi]);
		vtd.removeChild(this.vptusuv[vi]);
		vtd.removeChild(this.vworkdesc[vi]);
		vtd.removeChild(this.vhide[vi]);
		vtd.removeChild(this.vbr1[vi]);
		vtd.removeChild(this.vbr2[vi]);
		vtd.removeChild(this.vbr3[vi]);
		vtd.removeChild(this.vbr4[vi]);
		vtd.removeChild(this.vbr5[vi]);
		var vtd1 = document.getElementById( "vtdb1" );
		vtd1.removeChild(this.vdelimg[vi]);
		
		if( this.vnum >0 )
		{
			this.vdelimg[this.vnum] = document.createElement( '<input type="button" style="cursor:hand;" value="&nbsp;&nbsp;&nbsp;&nbsp;Багц хасах&nbsp;&nbsp;&nbsp;&nbsp;" class="butpro" onclick="' + this.vname + '.vdelinput(' + this.vnum + ')">' );
			vtd1.appendChild(this.vdelimg[this.vnum]);
		}
	}
	
	
}

