// JavaScript Document
function rs_addRow() {
	if (this.identitys.length == 0) {
		this.setIntities();
	}
	
	this.numRows++;
	//this.identitys[this.numRows -1].className='visible';
	this.setVisable(this.identitys[this.numRows -1]);

	this.removeButton.style.visibility='visible';
	if(this.numRows==this.maxRows) {
		this.addButton.style.visibility='hidden';

	}
}

function rs_removeRow() {
	if (this.identitys.length == 0) {
		this.setIntities();
	}
	
	//this.identitys[this.numRows -1].className='hidden';
	this.setNotVisable(this.identitys[this.numRows -1]);
	this.numRows--;

	this.addButton.style.visibility='visible';
	//this.setVisable(this.addButton);
	if(this.numRows==this.minRows) {
		this.removeButton.style.visibility='hidden';
		//this.setNotVisable(this.removeButton);		
	}
}

function rs_setNotVisable(intity) {
	intity.style.visibility = 'hidden';
	intity.style.display = 'none';
}

function rs_setVisable(intity) {
	intity.style.visibility = 'visible';
	intity.style.display = 'block';
}

function rs_setIntities () {
	this.identitys = new Array(this.maxRows);
	
	for(var i = 0; i < this.maxRows; i++) {
	
			this.identitys[i] = document.getElementById(this.varName+i);
		
		if (i < this.minRows) {
			this.setVisable(this.identitys[i]);
		} else {
			this.setNotVisable(this.identitys[i]);
		}
	}

	this.removeButton = document.getElementById(this.removeButtonName);
	this.removeButton.style.visibility='hidden';
	
	this.addButton = document.getElementById(this.addButtonName);
	this.addButton.style.visibility='visible';
}

function rowShow(minrows,maxrows,varName, addButtonName, removeButtonName) {

	this.varName = varName;
	this.minRows = minrows;
	this.maxRows = maxrows;
	this.numRows=this.minRows;
	// functions
	this.addRow = rs_addRow;
	this.removeRow = rs_removeRow;
	this.setIntities = rs_setIntities;
	this.setNotVisable = rs_setNotVisable;
	this.setVisable = rs_setVisable;
	
	this.identitys = Array();

	this.addButtonName = addButtonName;
	this.removeButtonName = removeButtonName;
	this.removeButton = null;
	this.addButton = null;
	this.setIntities();
}
