function mS(listTarget,max){
	this.listTarget=listTarget;
	this.count=0;
	this.id=0;
	if(max){
		this.max=max;
	}
	else{
		this.max=-1;
	}
	this.addElement=function(element){
		if(element.tagName=='INPUT' && element.type=='file'){
			element.name='file_'+this.id++;
			element.multiSelector=this;
			element.onchange=function(){
				var newElement=document.createElement('input');
				newElement.type='file';
				this.parentNode.insertBefore(newElement,this);
				this.multiSelector.addElement(newElement);
				this.multiSelector.addListRow(this);
				this.style.position='absolute';
				this.style.left='-1000px';
			}
			if(this.max!=-1 && this.count>=this.max){
				element.disabled=true;
			}
			this.count++;
			this.currentElement=element;
		}
	}
	this.addListRow=function(element){
		var newRow=document.createElement('div');
		var newRowButton=document.createElement('input');
		var newRowLabel=document.createTextNode(element.value);
		newRowButton.type='button';
		newRowButton.value='Excluir';
		newRow.element=element;
		newRowButton.onclick=function(){
			this.parentNode.element.parentNode.removeChild(this.parentNode.element);
			this.parentNode.parentNode.removeChild(this.parentNode);
			this.parentNode.element.multiSelector.count--;
			this.parentNode.element.multiSelector.currentElement.disabled=false;
			return false;
		}
		newRow.appendChild(newRowButton);
		newRow.appendChild(newRowLabel);
		this.listTarget.appendChild(newRow);
	}
}

