var current = 1
 

function delRow(el) {
// destroying element
this.getParent().destroy();
}

function addRow() {
// ID of div element that was clicked, with 'div_' removed
clickID = parseInt(this.getParent().get('id').replace('div_',''));
// Generate ID of element to be created
newID = (clickID+1);
// Creating and adding new element
newClone = $('div_'+clickID).clone().injectAfter('div_'+clickID);
// Setting new div's element id
newClone.set('id', 'div_'+newID)
// Making sure the new field does not have a value carried from clone
newClone.getFirst('input').set('value', '');
// Setting new input text id
newClone.getFirst('input').set('id', 'materiales'+newID);
// Adding click event on button, it will call addRow function
newClone.getFirst('input').getNext('input').set('value', '').getNext('input').addEvent('click', addRow);

// Changing value of the button that was clicked
this.set('value', '-');
// removing current event that is used to addrow
this.removeEvent('click', addRow);
// adding event to remove row
this.addEvent('click', delRow);

//adding autosugges property
var options = {
	script: "get_materiales.php?limit=6&",
	varname: "materiales",
	json:false,
	maxresults:10,
 timeout:9999999,
	noresults:'Ingresar nuevo material a la base de datos'
};
var as3 = new bsn.AutoSuggest('materiales'+newID, options);

}

