function mon(str) {
 window.status = str
}
function mout() {
 window.status = "MyBari - Copyright 2007"
}

function chkvals() {
 var warn = ""
 ret_val = true
   if (document.forms['Registra'].cognome.value.length <= 0) warn += " Cognome\r"
   if (!(document.forms['Registra'].sesso[0].checked) && !(document.forms['Registra'].sesso[1].checked)) warn += " Sesso\r"
   if ((document.forms['Registra'].giorno.value.length <= 0) && (document.forms['Registra'].mese.value.length <= 0) && (document.forms['Registra'].anno.value.length <= 0)) warn += " Data di nascita\r"
   if (document.forms['Registra'].prov.value.length <= 0) warn += " Provincia\r"
   if (document.forms['Registra'].email.value.length <= 0) warn += " Email\r"
   if (document.forms['Registra'].email_re.value.length <= 0) warn += " Ripeti e-mail\r"
   if (document.forms['Registra'].nick.value.length <= 0) warn += " Nickname\r"
   if (document.forms['Registra'].psw_nick.value.length <= 0) warn += " Password\r"
   if (document.forms['Registra'].nick_ok.value == 1) warn += " Nickname esistente devi modificarlo\r"
   if (!(document.forms['Registra'].privacy[0].checked) && !(document.forms['Registra'].privacy[1].checked)) warn += " Consenso per il trattamento dei dati\r"
   //if (!(document.forms['Registra'].consenso.checked)) warn += " Consenso Privacy\r"
   //warn += " Consenso privacy\r"


//alert(document.forms[0].pag[1].value.checked)
//   if (document.forms[0].pag[0].checked) warn += " Inserisci la modalita di pagamento\r"

  if (warn.length >= 1) {
  alert_str = "Hai dimenticato i seguenti campi:\r" + warn
  alert(alert_str)
  ret_val = false
  //alert(ret_val)
 }
 else {
  e_ad = document.forms['Registra'].email.value;
  e_ad_l = document.forms['Registra'].email.value.length - 2
  var at_pos_l = e_ad.indexOf('@');
  var at_pos_r = e_ad.lastIndexOf('@');
  var atdot_pos = e_ad.indexOf('@.');
  var warn = "";
  if (atdot_pos >= 0) warn += " - Sequenza '@.' non valida\r"
  else {
   if (at_pos_l <= -1) warn += " - Manca il carattere @\r"
   else {
    if (at_pos_l != at_pos_r) warn += " - Ha piu' di un carattere @\r"
    else {
     if (at_pos_l <= 0) warn += " - Almeno un carattere prima dell'@\r"
     else {
      if (at_pos_l >= e_ad_l) warn += " - Almeno due caratteri dopo l'@\r"
     }
    }
   }
  }
  if (warn.length >= 1) {
   alert_str = "Errori nell'indirizzo e-mail:\r " + e_ad + "\r" + warn
   alert_str += "\rEsempi di indirizzi validi:\r";
   alert_str += "- nome.cognome@provider.it\r";
   alert_str += "- user@net.a.com\n";
   alert_str += "N.B. Verificare anche i caratteri maiuscoli e minuscoli\n"
   alert(alert_str);
   ret_val = false
  }
 }
 return ret_val
 alert(ret_val)
}

function ctrl_email(){
 if (document.forms['Registra'].email.value != document.forms['Registra'].email_re.value) {
  alert("E-mail non corrispondente");
  document.forms['Registra'].email.value= "";
  document.forms['Registra'].email_re.value= "";
 }
}

function getRequestBody(oForm){
 var aParams = new Array();
 for (var i=0;i<oForm.elements.length;i++){
  var sParam = encodeURIComponent(oForm.elements[i].name);
  sParam +="=";
  sParam +=encodeURIComponent(oForm.elements[i].value);
  aParams.push(sParam);
 }
 return aParams.join("&");
}
var oXmlHttp;
var last;
function sendRequest(nomeForm,valore) { if (valore>=5 && valore<=10) {  var s = document.getElementById("messaggio");  s.innerHTML = "<img src='../entity/indicatore.gif'> Richiesta in corso..."; }
 var oForm = document.forms[nomeForm];
 //alert(oForm.name);
 //alert(valore);
 //alert("getDati.php?ctrl="+valore);
 //alert(oForm.id.value);
 var sBody = getRequestBody(oForm);
 //alert(sBody)
// Passaggio per XmlHttp
oXmlHttp = zXmlHttp.createRequest();
oXmlHttp.open("post","../pvt_area/getDati.php?ctrl="+valore, true);
oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

 if (valore==5 || valore==8 || valore ==9) { 	oXmlHttp.onreadystatechange = visualizzaUtenti;
 	if (valore==5)
 	 last = 5;
 	else
 	 last = 8; }
 else {
  oXmlHttp.onreadystatechange = function (){
  if (oXmlHttp.readyState == 4) {
   if (oXmlHttp.status == 200) {
    //displayCustomerInfo(oXmlHttp.responseText);
    //alert(oXmlHttp.responseText); //per vedere cosa restituisce la chiamata al file php
    if (oXmlHttp.responseText == 1){
     document.all["nickname"].style.display="block";
     document.forms["Registra"].nick_ok.value="1";
    }
    if (oXmlHttp.responseText == 2){
     location.replace("video_mod.php");
    }
    if (oXmlHttp.responseText == 4){
     alert("reindirizzo la pagina");
     location.replace("app_mod.php");
    }
    if (oXmlHttp.responseText == 6 || oXmlHttp.responseText == 7){     s.innerHTML = "";
     //alert(valore);
     if (last==5)      sendRequest("formVis","5");
     else
      sendRequest("formVis","8");
     return;
    }
    if (oXmlHttp.responseText == 10){
     s.innerHTML = "";
     //alert(valore);
     sendRequest("classifica","9");
     return;
    }
    //document.forms['DatiAccesso'].id.value = oXmlHttp.responseText
    //alert(document.forms['DatiAccesso'].id.value)
   }
  else {
   //displayCustomerInfo("An error occured: "+oXmlHttp.statusText);
   alert("errore nel salvataggio dei dati: "+oXmlHttp.statusText);
  }
 }
}
};
oXmlHttp.send(sBody);
}

function visualizzaUtenti() {	if (oXmlHttp.readyState == 4) {	  //alert(oXmlHttp.responseText);      var s = document.getElementById("messaggio");	  s.innerHTML = "";
 	  var R = document.getElementById("visualizza");
      R.innerHTML = oXmlHttp.responseText;	}}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

function x() { return; }

function insertEmoticon(addSmilie) {
    var addSmilie; var revisedMessage;
    var currentMessage = document.form1.body.value;
    revisedMessage = currentMessage+ ' ' +addSmilie+' ';
    document.form1.body.value=revisedMessage;
    document.form1.body.focus();
}

function insertemoticon(addSmilie) {
// inserts smilie text
    document.cform.message.value += thesmilie+" ";
    document.cform.message.focus();
}










