/*
------------------
Funzioni Login.php
------------------
*/
           
function Controlla() {
                     var Nickname = document.getElementById("Nickname").value;
                     var Password = document.getElementById("Password").value;
                     var Messaggio = "";
					 if (Nickname.search(/^[a-zA-z]{2,10}$/gi) == -1) {
															          Messaggio = "Nickname inserito non valido<br/>"; 
                                                                      }                     
                     if (Password.length == 0) {
                                               Messaggio += "Non hai inserito la Password";
                                               }
                     if (Messaggio != "") {
                                          document.getElementById("Avviso").innerHTML = Messaggio;
                                          return false;
                                          }
                     return true;
                     }
					 
function CreaLogin() {
                     document.getElementById("DatiLogin").style.display = 'block';
				     }  
					 
function CancellaLogin() {
					     document.getElementById("Nickname").value = "";
						 document.getElementById("Password").value = "";
						 return false;
					     }
                     
/*
-------------------------
Funzioni per l'Iscrizione
-------------------------
*/

function Crea() {
                document.getElementById("Dati").style.display = 'block';
				}                   
 
function Controllo() {
                     var Stat1 = document.getElementById("Stat1").value * 1;
                     var Stat2 = document.getElementById("Stat2").value * 1;
                     var Stat3 = document.getElementById("Stat3").value * 1;
                     var Stat4 = document.getElementById("Stat4").value * 1;
					 var Nickname = document.getElementById("Nickname").value;
					 var E_Mail = document.getElementById("E_Mail").value;
					 var Errore = '<b>Errore!</b>';
					 if (Nickname.search(/^[a-zA-z]{2,10}$/gi) == -1) {
															          Errore += "<br/>Nickname inserito non valido";  
                                                                      }
					 if (E_Mail.search(/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/gi) == -1) {
																						            Errore += "<br/>E-Mail inserita non valida";  
																						            }															
                     if (Stat1 > 5 || Stat2 > 5 || Stat3 > 5 || Stat4 > 5 || Stat1 <= 0 || Stat2 <= 0 || Stat3 <= 0 || Stat4 <= 0) {
                                                                                                                                   Errore = "<br/> Statistiche inserite non valide";
                                                                                                                                   }
                     var Somma = Stat1 + Stat2 + Stat3 + Stat4;
                     if (Somma > 10) {
									 Errore += "<br/>Somma delle Statistiche maggiore di 10";                                     
                                     }
                     if (Somma < 10) {
									 Errore += "<br/>Somma delle Statistiche minore di 10";
                                     }
					 if (Errore != '<b>Errore!</b>') {
													  document.getElementById("Avviso").innerHTML = Errore;
													  return false;
													  }
					 return true;
                     }
                     
/*
------------------
Funzioni Generiche
------------------
*/

function Link(url) {
                   MappaChat.location.href=(url);
                   }
				   
function PopUp(url)  {
                     var altezza = window.screen.height;
                     var larghezza = (window.screen.width * 80) / 100;
                     larghezza = Math.round(larghezza);
                     var sinistra =  (window.screen.width - larghezza) / 2;
                     sinistra = Math.round(sinistra);
                     window.open(url,"HellDawnLondon","left="+sinistra+",top=0,width="+larghezza+",height="+altezza+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,fullscreen=no");
                     }
				   
function Descrizione(box) {
						  var testo = document.getElementById(box).innerHTML;
						  document.getElementById("Legenda").innerHTML = "Descrizione&nbsp;"+box;
						  document.getElementById("DescrizioneCorp").innerHTML = "<br/>"+testo;
						  } 
						  
function CancellaDescrizione() {
							   document.getElementById("Legenda").innerHTML = "Descrizione";
						       document.getElementById("DescrizioneCorp").innerHTML = "<br/>Per visualizzare la Descrizione di una Corporazione/Clan passa il mouse sopra il suo nome";
							   }
							   
function Cambia(box) {	
					 var display = document.getElementById(box).style.display;
					 if (display == 'none') {
										    document.getElementById(box).style.display = "block";
											var link = "Link"+box;
											document.getElementById(link).innerHTML = "<img src=\"Immagini/Sito/Off.png\" alt=\"Off\" title=\"Chiudi\"/>";
											} else {
											document.getElementById(box).style.display = "none";
											var link = "Link"+box;
											document.getElementById(link).innerHTML = "<img src=\"Immagini/Sito/On.png\" alt=\"On\" title=\"Visualizza\"/>";
											}
					 }					 
		 
function ControllaModifica () {
					         var password = document.getElementById('pass').value;
							 var email = document.getElementById('Email').value;
							 var Errore = '<b>Errore!</b>';
							 if (email.search(/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/gi) == -1) {
																						                   Errore += "<br/>E-Mail inserita non valida";  
																						                   }
							 if (password == '') {
												 Errore += "<br/>Password disinserita";  
												 }
							 if (Errore != '<b>Errore!</b>') {
													          document.getElementById("Avviso").innerHTML = Errore;
													          return false;
													          }							 					 
							 return true;
							 }
