
function UserTeam_view()
{
	/*
	 * lista di pedine
	 */
	this.pawnList = new Array();
	
	/*
	 * lista delle posizioni attualmente occupate dalla pedine
	 */
	this.occupationList = new Array();
	
	
	/*
	 * aggiunge una pedina alla lista delle pedine
	 */
	this.addPawns = function(pawnNumber, pawnName){
	
		this.pawnList[pawnNumber] = pawnName;
		
	};
	
	/*
	 * aggiunge una cella all'array di occupazione
	 */
	this.addCell = function(posX, posY){
		
		var elem = posX+"-"+posY;
		
		this.occupationList.push(elem);
		
	};
	
	/*
	 * stampa html contentente le info della pedina nel tag html (cella) individuata in base alla posX e posY
	 */
	this.setPosition = function(posX,posY,pawnNumber)
	{
		//prelevo l'oggetto html in base al suo id
		var cell = document.getElementById(posX+"-"+posY);
		
		//informazioni della pedina
		var pawnName = this.pawnList[pawnNumber];
		
		//rimuovo i doppi apici
		
		//inserisco nome e numero della pedina come contenuto html 
		cell.innerHTML = '<div>'+pawnNumber+'</div><input onkeypress="systemMessage.setVisible();" name="pawnN'+pawnNumber+'" type="text" value="'+pawnName+'" maxlength="35" >';
		
		//aggiungo la cella occupata alla lista di occupazione
		this.addCell(posX, posY);
	};
	
	/*
	 * stampa html contentente le info della pedina del portiere nel tag html (cella) individuata in base alla posX e posY
	 * la maglia del portiere ha una colorazione diversa
	 */
	this.setPositionGoalkeeper = function(posX,posY,pawnNumber)
	{
		//prelevo l'oggetto html in base al suo id
		var cell = document.getElementById(posX+"-"+posY);
		
		//informazioni della pedina
		var pawnName = this.pawnList[pawnNumber];
		
		//rimuovo i doppi apici
		
		//inserisco nome e numero della pedina come contenuto html 
		cell.innerHTML = '<div id="goalKeeper">'+pawnNumber+'</div><input onkeypress="systemMessage.setVisible();" name="pawnN'+pawnNumber+'" type="text" value="'+pawnName+'" maxlength="35" >';
		
		//aggiungo la cella occupata alla lista di occupazione
		this.addCell(posX, posY);
	};
	
	/*
	 * rimuove dallo schermo l'attuale formazione e reinizializza la lista delle celle occupate
	 */
	this.clearFormation = function()
	{
		var i = 0;
	
		//alert(this.occupationList.length);
		
		while(this.occupationList.length != 0)
		{
			var idCell = this.occupationList.pop();
			//alert(idCell);
			//prelevo l'oggetto html in base al suo id
			var cell = document.getElementById(idCell);
			
			//svuoto il contenuto html della cella
			cell.innerHTML = '';
		}
		
	};
	
	/*
	 * setta la formazione selezionata nell'input del form
	 */
	this.setFormation = function(formation)
	{
		document.forms['teamForm'].elements['formation'].value = formation;
	};
	
	/*
	 * formazione 442
	 */
	this.set442Formation = function()
	{
		//rimuovo la vecchia formazione
		this.clearFormation();
		
		this.setFormation(442);
		
		//portiere
		this.setPositionGoalkeeper(23, 7, 1);
		
		//difesa
			
		this.setPosition(19, 2, 2);
		this.setPosition(19, 5, 3);
		this.setPosition(19, 8, 4);
		this.setPosition(19, 11, 5);
		
		//centrocampo
		this.setPosition(15, 2, 6);
		this.setPosition(15, 5, 7);
		this.setPosition(15, 8, 8);
		this.setPosition(15, 11, 9);
		
		
		//attacco
		this.setPosition(12, 2, 10);
		this.setPosition(12, 11, 11);
		
	};
	
	/*
	 * formazione 433
	 */
	this.set433Formation = function()
	{
		//rimuovo la vecchia formazione
		this.clearFormation();
		
		this.setFormation(433);
		
		//portiere
		this.setPositionGoalkeeper(23, 7, 1);
		
		//difesa
		this.setPosition(19, 2, 2);
		this.setPosition(19, 5, 3);
		this.setPosition(19, 8, 4);
		this.setPosition(19, 11, 5);	
		
		
		//centrocampo
		this.setPosition(16, 3, 6);
		this.setPosition(16, 6, 7);
		this.setPosition(16, 10, 8);
		
		//attacco
		this.setPosition(12, 0, 9);
		this.setPosition(14, 10, 10);
		this.setPosition(12, 13, 11);
		
	}; 
	
	/*
	 * formazione 343
	 */
	this.set343Formation = function()
	{
		//rimuovo la vecchia formazione
		this.clearFormation();
		
		this.setFormation(343);
		
		//portiere
		this.setPositionGoalkeeper(23, 7, 1);

		//difesa
		this.setPosition(19, 3, 2);
		this.setPosition(19, 6, 3);	
		this.setPosition(19, 10, 4);
		
		//centrocampo
		this.setPosition(15, 2, 5);
		this.setPosition(15, 5, 6);
		this.setPosition(15, 8, 7);
		this.setPosition(15, 11, 8);
		
		
		//attacco
		this.setPosition(12, 0, 9);
		this.setPosition(12, 11, 10);
		this.setPosition(12, 13, 11);
		
	};
	
	/*
	 * formazione 352
	 */
	this.set352Formation = function()
	{
		//rimuovo la vecchia formazione
		this.clearFormation();
		
		this.setFormation(352);
		
		//portiere
		this.setPositionGoalkeeper(23, 7, 1);
	
		//difesa
		this.setPosition(19, 3, 2);
		this.setPosition(19, 6, 3);	
		this.setPosition(19, 10, 4);
		
		//centrocampo
		this.setPosition(16, 2, 5);
		this.setPosition(15, 4, 6);
		this.setPosition(16, 7, 7);
		this.setPosition(15, 9, 8);
		this.setPosition(16, 11, 9);
		
		//attacco
		this.setPosition(12, 2, 10);
		this.setPosition(12, 11, 11);
		
	}; 
	
	/*
	 * formazione 532
	 */
	this.set532Formation = function()
	{
		//rimuovo la vecchia formazione
		this.clearFormation();
		
		this.setFormation(532);
		
		//portiere
		this.setPositionGoalkeeper(23, 7, 1);
		
		//difesa
		this.setPosition(18, 2, 2);	
		this.setPosition(19, 4, 3);
		this.setPosition(19, 6, 4);
		this.setPosition(19, 9, 5);
		this.setPosition(18, 11, 6);
		
		//centrocampo
		this.setPosition(16, 3, 7);
		this.setPosition(16, 6, 8);
		this.setPosition(16, 10, 9);
		
		//attacco
		this.setPosition(12, 2, 10);
		this.setPosition(12, 11, 11);
		
	}; 

}
