<!--
function popupwh(scelta,w,h){
	finestra = window.open(scelta,'IlCipresso','scrollbars=yes,resizable=NO,width='+w+',height='+h+',status=no,location=no,toolbar=no,left=50,top=50');
	finestra.focus();
}


function checkMail(mail){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(mail)){
		return true;
	}else{
		return false;
	}
}


var counterForm=0
function openRegForm(myCompany,copyData){
  $('titleSummary').innerHTML=$('companyId').value
  $('addOptionChoiceRegCont').show();
  $('partecipantsFormCont').hide();
  if (copyData=="True") {
    new Ajax.Request('/comboData/loadCompanyData.asp?company='+myCompany, {
      onSuccess: function(response) {
        var myResponse=response.responseText.split("|||")
        if (myResponse[11]=="1") {
          $('companyNameId').value=myResponse[1]
          $('companyEmailId').value=myResponse[2]
          $('companyPhoneId').value=myResponse[3]
          $('companyFaxId').value=myResponse[4]
          $('companyAddressId').value=myResponse[5]
          $('companyCityId').value=myResponse[6]
          $('companyZipId').value=myResponse[7]
          $('companyCountryId').value=myResponse[8]
          //$('companyCountryId2').innerHTML=myResponse[8]
          $('associationID').value=myResponse[9]
          $('companyVatId').value=myResponse[10]
        }
      } 
    }); 
  }
}
function confirmPayment() {
  if ($('acceptCondition').checked) {
    $('confirmationForm').submit()
  } else {
    $('acceptCondition').addClassName('error')
    alert($('acceptCondition').value)
  }
}
function reloadPartecipantData(numDest) {
  counterForm=0
  if (numDest!=undefined) {
    new Ajax.Updater("partecipantNote_"+numDest,"/comboData/reloadDataDetail.asp?forUser="+numDest, {
          method: "post",
          evalScripts: true,
          parameters:Form.serialize("detailsForm"),
          onComplete: function() {loadMyTotal(true)}
        });
  } else {
    for (var i=1;i<=parseInt($('qtId').value);i++) {
      if ($("qtaDays_"+i+"Id_2")!=undefined) {
        var numGiorni=parseInt($("qtaDays_"+i+"Id_2").value)
        for (k=0;k<numGiorni;k++){
          checkOther($('userId_'+i+'Id').value,k)
          //$("daysPermanence"+$("partecipantsConv__"+idCall+"Id_2").value+"Id"+i).checked=$("daysPermanence"+idCall+"Id"+i).checked
        }
      }
      new Ajax.Updater("partecipantNote_"+i,"/comboData/reloadDataDetail.asp?forUser="+i, {
          method: "post",
          evalScripts: true,
          parameters:Form.serialize("detailsForm"),
          onComplete: function() {counterForm++;loadMyTotal()}
        });
    }
  }
}
function loadMyTotal(directly) {
      if (directly || counterForm>=parseInt($('qtId2').value)) {
        //alert("cazzo")
        new Ajax.Updater("totalPriceForAll","/comboData/reloadTotal.asp", {
            method: "post",
            evalScripts: true,
            parameters:Form.serialize("pricesForm")
          });
      }
    
}
function unlockOtherUser(idDest,idCall) {
    //alert(idDest)
  if (idDest!=undefined && idDest.length>0) {
    $("roomChoose"+idDest+"Id_2").hide()
    $("roomChoose"+idDest+"Id").show()
    $("selectedAccomodation"+idDest+"ID_1").checked=true
    $("selectedAccomodation"+idDest+"ID_2").checked=false
    $("roomShare"+idDest+"Id").value=0
    var realId=$("position_"+idDest+"Id").value
    //alert(realId)
    $("partecipantsConv__"+realId+"Id").value=0
    $("partecipantsConv__"+realId+"ChoosenId").value=0
    $("partecipantsConv__"+idDest+"Id_2").value=0
    $("partecipantsConv__"+realId+"Id2").innerHTML=''
  } else {
    $("roomChoose"+idCall+"Id_2").hide()
    $("roomChoose"+idCall+"Id").show()
    $("selectedAccomodation"+idCall+"ID_1").checked=true
    $("selectedAccomodation"+idCall+"ID_2").checked=false
    $("roomShare"+idCall+"Id").value=0
    var realId=$("position_"+idCall+"Id").value
    //alert(realId)
    $("partecipantsConv__"+realId+"Id").value=0
    $("partecipantsConv__"+realId+"ChoosenId").value=0
    $("partecipantsConv__"+idCall+"Id_2").value=0
    $("partecipantsConv__"+realId+"Id2").innerHTML=''
    $("partecipantsConv__"+realId+"Id_Cont").hide()
  }
}
function lockOtherUser(idDest,idCall,thisName) {
  if ($("partecipantsConv__"+idDest+"Id_2").value>0 && $("partecipantsConv__"+idDest+"Id_2").value!=idCall) {
    alert($("jsPersonName_"+idDest).innerHTML+ " is already booked into a room with "+$("jsPersonName_"+$("partecipantsConv__"+idDest+"Id_2").value).innerHTML+"")
    unlockOtherUser(undefined,idCall)
  } else {
    if ($("partecipantsConv__"+idCall+"Id_2").value>0) {
      unlockOtherUser($("partecipantsConv__"+idCall+"Id_2").value,idCall)
    }
    $("roomShare"+idDest+"Id").value=idCall
    $("roomChoose"+idDest+"Id_2").show()
    $("roomChoose"+idDest+"Id").hide()
    $("roomMate"+idDest+"Id").innerHTML=thisName
    $("selectedAccomodation"+idDest+"ID_2").checked=true
    $("partecipantsConv__"+idDest+"Id_2").value=idCall
    $("partecipantsConv__"+idCall+"Id_2").value=idDest
    var numGiorni=parseInt($("qtaDays_"+idCall+"Id").value)
    for (i=0;i<numGiorni;i++){
      checkOther(idCall,i)
      //$("daysPermanence"+$("partecipantsConv__"+idCall+"Id_2").value+"Id"+i).checked=$("daysPermanence"+idCall+"Id"+i).checked
    }
  }
}
function saveFormReg() {
	if ($("categoryChoosenId").value==3) {
		$("associationID").value=$("companyAssociationChoosenId").value
	}
	
  new Ajax.Updater("addOptionChoiceReg","/comboData/saveCompany.asp", {
        method: "post",
        evalScripts: true,
        parameters:Form.serialize("addOptionChoiceRegForm")
      });
}
function checkOther(myId,myDate) {
  if ($("partecipantsConv__"+myId+"Id_2")!=undefined && $("partecipantsConv__"+myId+"Id_2").value>0 && $("daysPermanence"+$("partecipantsConv__"+myId+"Id_2").value+"Id"+myDate)!=undefined) {
   $("daysPermanence"+$("partecipantsConv__"+myId+"Id_2").value+"Id"+myDate).checked=$("daysPermanence"+myId+"Id"+myDate).checked
  }

}
function savePartecipants() {
  var myError=false
  var myTextError = 'Please fill the following fields : \n\n';
  //----------------controllo se è stato inserito un partecipante--------------
  if ($('numberPartecipantsId').value.length<=0) {
    $('numberPartecipantsId2').addClassName('error')
      myTextError =  myTextError + 'How many participants \n';
    myError=true
  }
  if (!myError) {
    for (i=1;i<=parseInt($('qtId').value);i++) {
      if (i==1) {
       
        if (!checkMail($('companyUserEmailId_'+i).value)) {
          $('companyUserEmailId_'+i).addClassName('error')
          myError=true
          myTextError =  myTextError + 'Invalid E-mail address - Participant ' + i + ') \n';
        }
        if ($('companyUserTelephoneId_'+i).value.length<=0) {
          $('companyUserTelephoneId_'+i).addClassName('error')
          myTextError =  myTextError + 'Telephone - Participant ' + i + ') \n'; 
          myError=true
        }
        if ($('companyUserFaxId_'+i).value.length<=0) {
          $('companyUserFaxId_'+i).addClassName('error')
          myTextError =  myTextError + 'Fax - Participant ' + i + ') \n';
          myError=true
        }
        if ($('companyUserAddressId_'+i).value.length<=0) {
          $('companyUserAddressId_'+i).addClassName('error')
          myTextError =  myTextError + 'Address - Participant ' + i+ ' \n';
          myError=true
        }
        if ($('companyUserCityId_'+i).value.length<=0) {
          $('companyUserCityId_'+i).addClassName('error')
          myTextError =  myTextError + 'City - Participant ' + i+ ') \n';
          myError=true
        }
        if ($('companyUserZipId_'+i).value.length<=0) {
          $('companyUserZipId_'+i).addClassName('error')
          myTextError =  myTextError + 'Postcode - Participant ' + i+ ') \n';
          myError=true
        }
      }
      if ($('companyUserPositionId_'+i).value.length<=0) {
        $('companyUserPositionId_'+i).addClassName('error')
        myTextError =  myTextError + 'Position - Participant ' + i+ ' \n';
        myError=true
      }
      if ($('companyUserCountry_'+i+'Id').value<=0) {
        //$('companyUserCountry_'+i+'Id2').addClassName('error')
        $('companyUserCountry_'+i+'Id').addClassName('error')
        myTextError =  myTextError + 'Country - Participant ' + i+ ') \n';
        myError=true
      }
      if ($('companyUserNameId_'+i).value.length<=0) {
        $('companyUserNameId_'+i).addClassName('error')
          myTextError =  myTextError + 'Name - Participant ' + i+ ') \n';
        myError=true
      }
      if ($('companyUserSurnameId_'+i).value.length<=0) {
        $('companyUserSurnameId_'+i).addClassName('error')
          myTextError =  myTextError + 'Surname - Participant ' + i+ ') \n';
        myError=true
      }
    }
  }
  //-------------controllo i dati company---------------------
  if ($('companyNameId').value.length<=0) {
    $('companyNameId').addClassName('error')
      myTextError =  myTextError + 'Name - Company \n';
    myError=true
  }
  if (!checkMail($('companyEmailId').value)) {
    $('companyEmailId').addClassName('error')
      myTextError =  myTextError + 'Invalid E-mail address - Company \n';
    myError=true
  }
  if ($('companyPhoneId').value.length<=0) {
    $('companyPhoneId').addClassName('error')
      myTextError =  myTextError + 'Telephone - Company \n';
    myError=true
  }
  if ($('companyFaxId').value.length<=0) {
    $('companyFaxId').addClassName('error')
      myTextError =  myTextError + 'Fax - Company \n';
    myError=true
  }
  if ($('companyAddressId').value.length<=0) {
    $('companyAddressId').addClassName('error')
      myTextError =  myTextError + 'Address - Company \n';
    myError=true
  }
  if ($('companyCityId').value.length<=0) {
    $('companyCityId').addClassName('error')
      myTextError =  myTextError + 'City - Company \n';
    myError=true
  }
  if ($('companyZipId').value.length<=0) {
    $('companyZipId').addClassName('error')
      myTextError =  myTextError + 'Postcode - Company \n';
    myError=true
  }
  if ($('companyCountryId').value<=0) {
    $('companyCountryId').addClassName('error')
      myTextError =  myTextError + 'Country - Company \n';
    myError=true
  }
  if ($('companyVatReqId').value=="1" && $('companyVatId').value.length<=0) {
    $('companyVatId').addClassName('error')
      myTextError =  myTextError + 'VAT number - Company \n';
    myError=true
  }
  if (!myError) {
    $('partecipantsForm').submit()
  } else {
 		alert(myTextError);
    return false;
  }
}
function highlightMyRow(myId,myActivity) {
  if ($('selectedActivity'+myId+'ID_'+myActivity).checked) {
    $('lightMyRow'+myId+'Id_'+myActivity).style.backgroundColor='#DDD'
  } else {
    $('lightMyRow'+myId+'Id_'+myActivity).style.backgroundColor=null
  }
}
function saveDetails() {
	var error=0
	var totalPrice=0
	var optionalError=''
	for (i=1;i<=parseInt($("qtId").value);i++) {
	 if ($("userId_"+i)!=undefined) {
     if ($("somethingSelected"+i).value<=0){
      error=i
      i=$("qtId").value+1
  	 } else {
      totalPrice+=parseFloat($("userTotal"+i).value)
     }
   }
	}
	var optionalError=''
	for (var i2=1;i2<=parseInt($("qtId").value);i2++) {
	  if ($("userId_"+i2)!=undefined) {
      optionalError=checkOptionalData(i2)
      if (optionalError.length>0) {
       error=i2
       i2=$("qtId").value+1
      }
    }
  }
	if (error<=0) {
//  	if (totalPrice<=0) {
//      alert("Total price cannot be 0,00")
//    } else {
      $('detailsForm').submit()
//    }
  } else {
    var myName=$('personName_'+error).innerHTML
    if (optionalError.length>0) {
      alert("Check the booking data for "+myName+':\n'+optionalError)
    } else {
      alert(myName+ " must select at least one item \n")
    }
  }
  
}
function checkOptionalData(myId){
	var myTextError = '';
  if ($('reqSpecRequired'+myId+'Id').value.length>0) {
    var checkValues=$('reqSpecRequired'+myId+'Id').value.split(",")
  	var error=0
    for (var i=0;i<checkValues.length;i++) {
      //alert($($(checkValues[i]+'CheckBox').value).checked)
      if ($(checkValues[i]).value.length<=0 && $($(checkValues[i]+'CheckBox').value).checked) {
        $(checkValues[i]).addClassName('error')
        myTextError =  myTextError +'The field "'+$(checkValues[i]+'Text').innerHTML+ '" has not been filled\n';
        error=true
      }
    }
  }
  return myTextError
}
function callOldNamesRecord(myId) {
  var nameOfUser=$('companyUserNameId_'+myId).value
  var surnameOfUser=$('companyUserSurnameId_'+myId).value
  var proc=false
  if ($('companyAssChoosenId')!=null) {
    var companyOfUser=$('companyAssChoosenId').value
    proc=true
  } else if ($('companyChoosenId')!=null) {
    var companyOfUser=$('companyChoosenId').value
    proc=true
  }
  if (proc && nameOfUser!='undefined' && surnameOfUser!=undefined && nameOfUser!='' && surnameOfUser!='') {
    new Ajax.Request('/comboData/loadUserData.asp?name='+escape(nameOfUser)+'&surname='+escape(surnameOfUser)+'&company='+companyOfUser, {
      onSuccess: function(response) {
        var myResponse=response.responseText.split("|||")
        if (myResponse[10]=="1") {
          if (confirm(myResponse[0])) {
            $('companyUserEmailId_'+myId).value=myResponse[1]
            $('companyUserTelephoneId_'+myId).value=myResponse[2]
            $('companyUserFaxId_'+myId).value=myResponse[3]
            $('companyUserAddressId_'+myId).value=myResponse[4]
            $('companyUserCityId_'+myId).value=myResponse[5]
            $('companyUserZipId_'+myId).value=myResponse[6]
            $('companyUserCountry_'+myId+'Id').value=myResponse[7]
            //$('companyUserCountry_'+myId+'Id2').innerHTML=myResponse[7]
            $('companyUserLoadedId_'+myId).value=myResponse[8]
            $('companyUserPositionId_'+myId).value=myResponse[9]
          }
        }
      } 
    }); 
        
  }     
}       
function loadMy(cosa,keepOpen,forceClose,parameters,pageToLoad) {
  var formLoad=$(cosa+"Id")
  var divLoad=$("winCombo_"+cosa)
  if (parameters!=undefined && parameters.length>0) {
    var myParameters=parameters.split(";")
  } else {
    var myParameters=new Array()
  }     
  if (!forceClose && (divLoad.style.display=="none" || keepOpen)) {
    if (pageToLoad!=undefined && pageToLoad.length>0) {
      var pageLoad=pageToLoad
    } else {
      var pageLoad=cosa
    }   
    if (keepOpen) {
      var myUrl="/comboData/"+pageLoad+".asp?data="+formLoad.value
    } else {
      var myUrl="/comboData/"+pageLoad+".asp?1=1"
    }
    for (i=0;i<myParameters.length;i++) {
      myUrl+="&"+myParameters[i]+"="+$(myParameters[i]+'Id').value
    }
    myUrl+="&comboName="+cosa
    new Ajax.Updater(divLoad, myUrl ,
  						{
  							asynchronous:true,
  							evalScripts:true,
  							encoding:'UTF-8',
  							onComplete: function(){divLoad.show();}
  						}
  					);
	} else {
    divLoad.hide()
  }
}
function funcAddPartecipant(howMany,myOldId,mySpost) {
  $('partecipantsFormCont').show();
  $('partecipantsForm').show();
  var myVar=""
  if (myOldId!=undefined){
    myVar+="&myId="+myOldId
  }
  if (mySpost!=undefined){
    myVar+="&sPost="+mySpost
  }
  new Ajax.Updater("addOptionPartecipants", "/comboData/partecipants.asp?qt="+howMany+myVar ,
    						{
    							asynchronous:true,
    							evalScripts:true,
    							encoding:'UTF-8'
    						}
    					);
}
function copyAllMyData() {
  $('companyUserEmailId_1').value=$('companyEmailId').value
  $('companyUserTelephoneId_1').value=$('companyPhoneId').value
  $('companyUserFaxId_1').value=$('companyFaxId').value
  $('companyUserAddressId_1').value=$('companyAddressId').value
  $('companyUserCityId_1').value=$('companyCityId').value
  $('companyUserZipId_1').value=$('companyZipId').value
  $('companyUserCountry_1Id').value=$('companyCountryId').value
}
function funcAddOption(myId,funcToLaunch,listMember) {
  $('companyNameId').value='';
  $('companyEmailId').value='';
  $('companyPhoneId').value='';
  $('companyFaxId').value='';
  $('companyAddressId').value='';
  $('companyCityId').value='';
  $('companyZipId').value='';
  $('companyCountryId').value='';
  //$('companyCountryId2').innerHTML='';
  $('associationID').value='';
  $('companyVatId').value='';
  if (listMember=="True") {
    $('addOptionChoice').show();
    $('addOptionChoiceRegCont').hide();
    new Ajax.Updater("addOptionChoice", "/comboData/optionChoice1.asp" ,
    						{
    							asynchronous:true,
    							evalScripts:true,
    							encoding:'UTF-8',
    							onComplete: function(){funcToLaunch()}
    						}
    					);
    $('numberPartecipantsFormContainer').hide();
  } else {
    $('numberPartecipantsFormContainer').show();
    $('addOptionChoiceRegCont').show();
    $('addOptionChoice').hide();
  }
  $('partecipantsFormCont').hide();
  $('numberPartecipantsId').value='';
  $('numberPartecipantsChoosenId').value='';
  $('numberPartecipantsId2').innerHTML='';
}
function selItem(dove,cosa,functionToLauch,idSel) {
  var formLoad2=$(dove+"Id2")
  var formLoad=$(dove+"Id")
  formLoad2.innerHTML=cosa
  formLoad.value=cosa
  $('winCombo_'+dove).hide()
  $(dove+'ChoosenId').value=idSel
  if (functionToLauch!='undefined') {
    functionToLauch()
  }
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
return true
}

function apriChiudiForm(){
	if($('formWald').style.display=='none'){
		new Effect.SlideDown('formWald', { duration: 0.5 });
	}else{
		new Effect.SlideUp('formWald', { duration: 0.5 });
	}
}

function controlla(obbligatorio,nome,campo_data,campo_numero,campo_user,campo_pwd){
	var sAgent = navigator.userAgent.toLowerCase() ;
	var elemento = document.getElementById(nome)
	len =elemento.elements.length;
	var i=0;
	var campo=' I seguenti campi obbligatori sono stati lasciati vuoti o il loro contenuto non e\' valido.:\n'
	var passa=true
	campo=campo+'_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\n\t\t '
	for( i=0 ; i<len ; i++) {
		if (elemento.elements[i].name.length > 0)
		{
			if (elemento.elements[i].name.indexOf(obbligatorio)>0 & elemento.elements[i].value.length<=0 ) {
				campo=campo+' # '+elemento.elements[i].title+' # \n\n\t\t '
				passa=false
			} else if (elemento.elements[i].name.indexOf(campo_user)>0 & elemento.elements[i].value.length<=5) {
				campo=campo+' # '+elemento.elements[i].title+' # \n\n\t\t '
				passa=false
			} else if (elemento.elements[i].name.indexOf(campo_pwd)>0 & elemento.elements[i].value.length<=5) {
				campo=campo+' # '+elemento.elements[i].title+' # \n\n\t\t '
				passa=false
			} else {
				if (elemento.elements[i].name.indexOf(campo_data) > 0 & !isDate(elemento.elements[i].value) &  elemento.elements[i].value.length > 0) {
						alert(elemento.elements[i].value + ' - ' + elemento.elements[i].name);
					campo=campo+' # '+elemento.elements[i].title+ ' - ' + elemento.elements[i].name+' # \n\n\t\t '
					passa=false
				}else if (elemento.elements[i].name.indexOf(campo_numero)>0 & isNaN(elemento.elements[i].value.replace(',','.')) & elemento.elements[i].value.length > 0) {
					campo=campo+' # '+elemento.elements[i].title+' # \n\n\t\t '
					passa=false
				}
			}
		}
	}
	campo=campo+'\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ '
	if (passa){
		return true;
	}else{ 
		alert(campo)
		return false;
	}
}
//-->

