function salvaechiudi(m,p,c) {
document.write("<img style='display:none;' src='"+m+"'>");
document.write("<img style='display:none;' src='"+p+"'>");
document.write("<img style='display:none;' src='"+c+"'>");
//document.write("<input type='button' value='Chiudi Tutto!' class='buttonpreview' onClick='javascript:window.opener.close();window.close();'>");
alert ("Divisa correttamente salvata!");
window.opener.close(); 
window.close();
}

function PopupCentrata(file,nome,width,height) {
   var w = width;
   var h = height;
	 //var w = 400;
   //var h = 250;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
      //window.open("mioFile.htm","","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
			window.open(file,nome,"width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
 }



function VerificaPwd_divise() {
	var password = document.getElementById("pwd_divise").value;
	var crypted = Javacrypt.crypt("jd", password);
	var passwordvalide = 0;
	for (j=1;j<arrFantasquadre.length;j++) {
	if (crypted[0] == passwords[arrFantasquadre[j].ID]) {
	passwordvalide++
	document.getElementById("mister").innerHTML = (arrFantasquadre[j].Presidente);
	document.input.squadra.value = arrFantasquadre[j].Nome;
	document.input.id_squadra.value = arrFantasquadre[j].ID;
	document.input.mister.value = arrFantasquadre[j].Presidente;
	}
	}
	
	if (passwordvalide == 0) { 
	alert ("Password non riconosciuta!");
	document.getElementById("pwd_divise").value = '';
	return false;
	} else {
	popup2.style.visibility='Hidden';
	return true;
	}

  
} 

function aprichiudi( targetId ){
  if (document.getElementById){
    target = document.getElementById( targetId );
      if (target.style.display == "none"){
        target.style.display = "block";
      } else {
        target.style.display = "none";        
      }
   }
 } 
 
function vai(){
  if (document.getElementById("dd").value == 'img/divise/m0.gif'){
	alert("Devi ancora scegliere il tipo di maglia!");
  return false;
	} else if (document.getElementById("ddP").value == 'img/divise/p0.gif'){
	alert("Devi ancora scegliere il tipo di pantaloncini!");
	return false;
	} else if (document.getElementById("ddC").value == 'img/divise/c0.gif'){
	alert("Devi ancora scegliere il tipo di calzettoni!");
	return false;
	} 
	//window.open("", "NuovaWindow", "width=450,height=200");
	PopupCentrata("","NuovaWindow",450,200)
	document.input.submit();
	return true;
}

function elenco(){
	window.open("", "Elenco", "width=580,height=310");
return true;
}

function copia_m0(colore){
oggetto_m0 = colore;
document.getElementById('maglia_0').value = oggetto_m0;
}
function copia_m1(colore){
oggetto_m1 = colore;
document.getElementById('maglia_1').value = oggetto_m1;
}
function copia_m2(colore){
oggetto_m2 = colore;
document.getElementById('maglia_2').value = oggetto_m2;
}
function copia_p0(colore){
oggetto_p0 = colore;
document.getElementById('pantaloncini_0').value = oggetto_p0;
}
function copia_p1(colore){
oggetto_p1 = colore;
document.getElementById('pantaloncini_1').value = oggetto_p1;
}

function copia_c0(colore){
oggetto_c0 = colore;
document.getElementById('calzettoni_0').value = oggetto_c0;
}

function copia_c1(colore){
oggetto_c1 = colore;
document.getElementById('calzettoni_1').value = oggetto_c1;
}

function swapImage(){
	var image = document.getElementById("imageToSwap");
	dropd = document.getElementById("dd");
	image.src = dropd.value;	
  document.getElementById('tipomaglia').value = dropd.value;
};

function swapImageP(){
	var image = document.getElementById("imageToSwapP");
	var dropd = document.getElementById("ddP");
	image.src = dropd.value;
	document.getElementById('tipopantaloncini').value = dropd.value;	
};

function swapImageC(){
	var image = document.getElementById("imageToSwapC");
	var dropd = document.getElementById("ddC");
	image.src = dropd.value;
	document.getElementById('tipocalzettoni').value = dropd.value;		
};

function reset(){
	document.getElementById("imageToSwapC").value = "img/divise/c0.gif";	
	document.getElementById("imageToSwapP").value = "img/divise/p0.gif";
	document.getElementById("imageToSwap").value = "img/divise/m0.gif";	
	document.getElementById('dd').value = 'img/divise/m0.gif';
	document.getElementById('ddC').value = 'img/divise/c0.gif';
	document.getElementById('ddP').value = 'img/divise/p0.gif';
};
