// Fichier JScript
/**
* Prototype :
* Purpose :
* History :
*/
function nightChange()
{
UpdateTotal();
}

/**
* Prototype :
* Purpose :
* History :
*/
function UpdateTotal()
{
// on vÃ©rifie que le nombre de nuits est correct.
//nbnights = document.getElementById ("numberofnights").options[document.getElementById("numberofnights").selectedIndex].value;

// parcourir les chambres
var room_id = 0;
var total_room_object = document.getElementById("total_room_"+room_id);
var l_intTotalStay = 0.0;

while((total_room_object = document.getElementById("total_room_" + room_id)) != null)
{
total_room_object = document.getElementById("total_room_" + room_id);
selector_room_object = document.getElementById("selector_room_" + room_id);
var room_selected = selector_room_object.options[selector_room_object.selectedIndex].value;


l_intTotalStay += room_selected * parseFloat(total_room_object.value.replace(',','.'))/1;

room_id++;
}

document.getElementById ("sum" ).innerHTML = Math.round(l_intTotalStay * 100)/100 + "&euro;" ;//Moved from top on 07-06-2007

}



/**
* Prototype :
* Purpose :
* History :
*/
function SearchDispoSubmit()
{
//alert ("SearchDispoSubmit" + document.getElementById ("ctl00_Main_TextBoxStart" ).value);
//Get start date
var l_obj = document.getElementById ("ctl00_Main_TextBoxStart");
if (l_obj == null)  return;
var l_startdate = l_obj.value;

//Get end date
l_obj = document.getElementById ("ctl00_Main_TextBoxEnd");
if (l_obj == null)  return;
var l_enddate = l_obj.value;

//Get Pax
l_obj = document.getElementById ("ctl00_Main_DropDownListPax");
if (l_obj == null)  return;
var l_pax = l_obj.value;

//Get Child Pax
l_obj = document.getElementById ("ctl00_Main_DropDownListChildPax");
if (l_obj == null)  return;
var l_child_pax = l_obj.value;

//Get Promocode
l_obj = document.getElementById ("ctl00_Main_TextBoxPromo");
if (l_obj == null)  return;
var l_promo = l_obj.value;

//2DO Check dates entries 
//Modified by PMAB on 24-05-2007 window.open("propositions.aspx?startdate="+l_startdate+ "&enddate="+l_enddate /*+"&startday="+l_startday*/); 
document.location.href = "propositions.aspx?startdate="+l_startdate+ "&enddate="+l_enddate+"&pax="+l_pax+"&child_pax="+l_child_pax+"&promo_code="+l_promo;

}


/**
* Prototype : HasRoomSelection
* Purpose :
* History :
*/
function HasRoomSelection()
{

// parcourir les chambres
var room_id = 0;
var total_room_object = document.getElementById("total_room_"+room_id);
var l_intTotalStay = 0;

l_sFormURL = "";
l_sroomtypeid = "0";
l_sroomcount = "0";
l_sroomtotal = "0";
room_sequential_id = 0;
while((total_room_object = document.getElementById("total_room_" + room_id)) != null)
{
total_room_object = document.getElementById("total_room_" + room_id);
selector_room_object = document.getElementById("selector_room_" + room_id);
var room_selected = selector_room_object.options[selector_room_object.selectedIndex].value;

if (room_selected > 0)
{
room_sequential_id++;

l_sroomtypeid = l_sroomtypeid + "|" +  selector_room_object.name;
l_sroomcount = l_sroomcount + "|" +  room_selected;
l_sroomtotal = l_sroomtotal + "|" +  total_room_object.value;

room_sequential_id++;
}
room_id++;
}

if (room_sequential_id == 0)
alert(GetValue("dico_room_required"));

return (room_sequential_id > 0);
}






/**
* Prototype :
* Purpose :
* History :
*/
function RoomSelectionSubmit()
{
//alert ("SearchDispoSubmit" + document.getElementById ("ctl00_Main_TextBoxStart" ).value);
//Chexk user selelection


// on vÃ©rifie que le nombre de nuits est correct.
//nbnights = document.getElementById ("numberofnights").options[document.getElementById("numberofnights").selectedIndex].value;

// parcourir les chambres
var room_id = 0;
var total_room_object = document.getElementById("total_room_"+room_id);
var l_intTotalStay = 0;
//var obj = document.getElementById("__EVENTTARGET");
//alert(total_room_object.value);

l_sFormURL = "";
l_sroomtypeid = "0";
l_sroomcount = "0";
l_sroomtotal = "0";
room_sequential_id = 0;
while((total_room_object = document.getElementById("total_room_" + room_id)) != null)
{
total_room_object = document.getElementById("total_room_" + room_id);
selector_room_object = document.getElementById("selector_room_" + room_id);
var room_selected = selector_room_object.options[selector_room_object.selectedIndex].value;

if (room_selected > 0)
{
room_sequential_id++;

l_sroomtypeid = l_sroomtypeid + "|" +  selector_room_object.name;
l_sroomcount = l_sroomcount + "|" +  room_selected;
l_sroomtotal = l_sroomtotal + "|" +  total_room_object.value;

room_sequential_id++;
}
room_id++;
}

/**/
l_sFormURL = "agora_formulaire.php?p=0"
+ "&roomtypeid=" + l_sroomtypeid
+ "&roomcount="+ l_sroomcount
+ "&roomtotal=" + l_sroomtotal
+ GetHiddenFieldsAsUrl();
/**/

alert(l_sFormURL);

return 	l_sFormURL;

if (room_sequential_id > 0)
document.location.href = l_sFormURL;
else
alert("Vous devez sélectionner au moins une chambre !!!!");
}


/**
* Prototype : IsEmpty()
* Purpose :
* History : Created on 14-01-2008
*			Focus managment added by PMAB on 03-05-2008
*/
function IsEmpty(p_sObjectName)
{
var l_objSelector = document.getElementById(p_sObjectName);
var l_boolIsEmpty;

if (l_objSelector == null) return true;
l_boolIsEmpty = (l_objSelector.value.length == 0);
if (l_boolIsEmpty) l_objSelector.focus();
return l_boolIsEmpty;
}



/**
* Prototype : IsChecked()
* Purpose : return true if checkbox is checked
* History : Created on 09-10-2008
*			Focus managment added by PMAB on 03-05-2008
*/
function IsChecked(p_sObjectName)
{
var l_objSelector = document.getElementById(p_sObjectName);
var l_boolIsChecked;

if (l_objSelector == null) return false;
l_boolIsChecked = (l_objSelector.checked);
if (!l_boolIsChecked) l_objSelector.focus();
return l_boolIsChecked;
}


/**
* Prototype : GetValue()
* Purpose :
* History : Created on 17-02-2008
*/
function GetValue(p_sObjectName)
{
var l_objSelector = document.getElementsByName(p_sObjectName)[0];
if (l_objSelector == null) return "<Not Found in dico>";
return (l_objSelector.value);
}

/**
* Prototype : IsEmpty()
* Purpose :
* History : Created on 14-01-2008
*/
/**
* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/

function IsEmailValid(p_sObjectName) {

var l_objSelector = document.getElementById(p_sObjectName);
if (l_objSelector == null) return false;
var str = l_objSelector.value;

var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
var err_message=GetValue("dico_email_invalid");


if (str.indexOf(at)==-1){
alert(err_message)
return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert(err_message)
return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert(err_message)
return false
}

if (str.indexOf(at,(lat+1))!=-1){
alert(err_message)
return false
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert(err_message)
return false
}

if (str.indexOf(dot,(lat+2))==-1){
alert(err_message)
return false
}

if (str.indexOf(" ")!=-1){
alert(err_message)
return false
}

return true					
}


/*
* PROTOTYPE : getSelector
* PURPOSE : return input parameter value
* HISTORY : CREATED BY PMAB on 14-01-2008
*/
function getSelector(p_sSelectorName)
{
var l_objInput = document.getElementById (p_sSelectorName);
if (l_objInput == null) return;
return l_objInput.value;
}


/**
* Prototype : OwnerFormSubmit()
* Purpose :
* History :  Invalid Email Focus management added by PMAB on 03-05-2008
*			 Name and firstname are no more required, PMAB on 09-10-2008
*			 CGV checkbox acceptation added by PMAB on 09-10-2008
*/
function OwnerFormSubmit()
{
//Check deposit and balance, added by PMAB on 03-11-2008
//nom
if(IsEmpty("nom"))
{
alert(GetValue("dico_name_required"));
return false;
}

//prenom
/* disabled by PMAB on 09-10-2008	
if(IsEmpty("prenom"))
{
alert(GetValue("dico_firstname_required"));
return false;
}

//adresse
if(IsEmpty("adresse"))
{
alert(GetValue("dico_address_required"));
return false;
}
*/	 
//tel
if(IsEmpty("tel"))
{
alert(GetValue("dico_phone_required"));
return false;
}

//Email
if(IsEmpty("mail"))
{
alert(GetValue("dico_email_required"));
return false;
}

//Email validation
if (!IsEmailValid("mail"))
{
document.getElementById("mail").focus();//Added by PMAB on 03-05-2008
return false;
}

//CGV checked accepted
if (!IsChecked("cgv"))
{
document.getElementById("cgv").focus();//Added by PMAB on 09-10-2008
alert(GetValue("dico_cgv_required"));
return false;
}


return true;
}




/**
* Prototype : OwnerFormSubmit2()
* Purpose :  Check the ATEL form data
* History :  Copied by JULIO from OwnerFormSubmit() on 02-04-2009
*/
function OwnerFormSubmit2()
{
//nom
if(IsEmpty("nom"))
{
alert(GetValue("dico_name_required"));
return false;
}

//prenom

if(IsEmpty("prenom"))
{
alert(GetValue("dico_firstname_required"));
return false;
}

//adresse
if(IsEmpty("adresse"))
{
alert(GetValue("dico_address_required"));
return false;
}


//Zipcode
if(IsEmpty("zipcode"))
{
alert(GetValue("dico_zipcode_required"));
return false;
}

//tel
if(IsEmpty("tel"))
{
alert(GetValue("dico_phone_required"));
return false;
}

//Email
if(IsEmpty("mail"))
{
alert(GetValue("dico_email_required"));
return false;
}

//Email validation
if (!IsEmailValid("mail"))
{
document.getElementById("mail").focus();//Added by PMAB on 03-05-2008
return false;
}



//CreditCardHolder
if(IsEmpty("creditCardHolder"))
{
alert(GetValue("dico_creditCardHolder_required"));
return false;
}

//CreditCardType
if(IsEmpty("creditCardType"))
{
alert(GetValue("dico_creditCardType_required"));
return false;
}

//CreditCardNumber
if(IsEmpty("creditCardNumber"))
{
alert(GetValue("dico_creditCardNumber_required"));
return false;
}


//CreditCardEndDate
if(IsEmpty("creditCardEndDate"))
{
alert(GetValue("dico_creditCardEndDate_required"));
return false;
}

//Cryptogramme
if(IsEmpty("cryptogramme"))
{
alert(GetValue("dico_cryptogramme_required"));
return false;
}	



return true;
}


/**
* Prototype : OwnerFormSubmit_Booking_form()
* Purpose :   Check the booking demand form, without CGV
* History :  Copied by JULIO from OwnerFormSubmit on 14-12-2009
*/
function OwnerFormSubmit_Booking_form()
{
//Check deposit and balance, added by PMAB on 03-11-2008
//nom
if(IsEmpty("nom"))
{
alert(GetValue("dico_name_required"));
return false;
}

//tel
if(IsEmpty("tel"))
{
alert(GetValue("dico_phone_required"));
return false;
}

//Email
if(IsEmpty("mail"))
{
alert(GetValue("dico_email_required"));
return false;
}

//Email validation
if (!IsEmailValid("mail"))
{
document.getElementById("mail").focus();//Added by PMAB on 03-05-2008
return false;
}

//Room selection
/*DIFFERENT TREATMENT FOR THIS*/
var flag_selected_room_booking_object = document.getElementById("flag_selected_room_booking");

if(flag_selected_room_booking_object.value == "")
{
alert(GetValue("dico_room_required"));
return false; 
}

return true;
}


/**
* Prototype : CorporateFormSubmit()
* Purpose : Like ownerformSubmit with enterprise check
* History : Created by PMAB on 09-03-2008
*/
function CorporateFormSubmit()
{
//nom
if(IsEmpty("enterprise"))
{
alert(GetValue("dico_enterprise_required"));
return false;
}

//nom
if(IsEmpty("nom"))
{
alert(GetValue("dico_name_required"));
return false;
}

//prenom
if(IsEmpty("prenom"))
{
alert(GetValue("dico_firstname_required"));
return false;
}

//adresse
if(IsEmpty("adresse"))
{
alert(GetValue("dico_address_required"));
return false;
}

//tel
if(IsEmpty("tel"))
{
alert(GetValue("dico_phone_required"));
return false;
}

//Email
if(IsEmpty("mail"))
{
alert(GetValue("dico_email_required"));
return false;
}

//Bookings/Years
if(IsEmpty("bookings_year"))
{
alert(GetValue("dico_bookings_year"));
return false;
}

//Stay length
if(IsEmpty("stay_length"))
{
alert(GetValue("dico_stay_length"));
return false;
}


//Email validation
if (!IsEmailValid("mail"))
return false;

return true;

}


/**
* Prototype :
* Purpose :
* History :
*/
function OnNightSelectorClick()
{
//Compute end date 
//var dt_datetime = new Date('06/12/2007');
var l_objStartDate = document.getElementById ("ctl00_Main_TextBoxStart");
var l_objEndDate   = document.getElementById ("ctl00_Main_TextBoxEnd");
if (l_objStartDate == null)  return;
var l_startdate = l_objStartDate.value;

//	var dt_datetime = new Date(l_startdate);
var dt_datetime = new Date();

var l_intDebug = 0;
//Debug	
var l_sday = l_startdate.substr(0,2);
var l_smonth = l_startdate.substr(3,2);
var l_syear = l_startdate.substr(6,4);

if (l_sday.substr(0,1)=="0") l_sday=l_sday.substr(1,1);//Remove first zero
if (l_smonth.substr(0,1)=="0") l_smonth=l_smonth.substr(1,1);//Remove first zero

if (l_intDebug == 1) alert(l_startdate + "=> l_sday=" + l_sday + " l_smonth = " + l_smonth + " l_syear=" + l_syear);
if (l_intDebug == 1) alert("ParseInt(09)=" + parseInt("09") +" ParseInt=" + parseInt(l_sday) + "/" + parseInt(l_smonth) + "/" + parseInt(l_syear));

dt_datetime.setDate(parseInt(l_sday));
dt_datetime.setMonth(parseInt(l_smonth));
dt_datetime.setFullYear(parseInt(l_syear));


//Retrieve nights selection
var l_objNightsSelector = document.getElementById ("SelectNights");
if (l_objNightsSelector == null) return;
var l_intNights = l_objNightsSelector.value;// .options[l_objNightsSelector.selectedIndex].value;

//Debug 
if (l_intDebug == 1) alert(l_intNights);
//Compute end date
if (l_intDebug == 1) alert('dt_datetime.getDate()='+dt_datetime.getDate()); 
if (l_intDebug == 1) alert('dt_datetime.getMonth()='+dt_datetime.getMonth()); 
if (l_intDebug == 1) alert('dt_datetime.getYear()='+dt_datetime.getYear()); 

dt_datetime.setDate(dt_datetime.getDate() + parseInt(l_intNights));

//Set new end date
l_objEndDate.value =
(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "/"
+ (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth()) + "/"
+ (dt_datetime.getFullYear());

}

/*
* PROTOTYPE : SearchDispoSubmit_combo
* PURPOSE : return stay parameters from combobox, Easier Way
* HISTORY : CREATED BY PMAB on 01-12-2007
*/
function getSelector(p_sSelectorName)
{
var l_objSelector = document.getElementById (p_sSelectorName);
if (l_objSelector == null) return;
return l_objSelector.value;// .options[l_objNightsSelector.selectedIndex].value;
}

/*
* PROTOTYPE : SearchDispoSubmit_combo
* PURPOSE : return stay parameters from combobox, Easier Way
* HISTORY : CREATED BY PMAB on 30-11-2007
*/
function SearchDispoSubmit_combo()
{
//Retrieve nights selection
var l_intNights = getSelector("SelectNights");// .options[l_objNightsSelector.selectedIndex].value;

//Retrieve day, month, year selection
var l_intDay = getSelector("SelectDay");// .options[l_objNightsSelector.selectedIndex].value;
var l_intMonth = getSelector("SelectMonth");// .options[l_objNightsSelector.selectedIndex].value;
var l_intYear = getSelector("SelectYear");// .options[l_objNightsSelector.selectedIndex].value;

//Get Pax
var l_pax = getSelector("SelectPax");

//Get Child Pax
var l_child_pax = getSelector("SelectChildPax");

//Get Promocode
l_obj = document.getElementById ("ctl00_Main_TextBoxPromo");
if (l_obj == null)  return;
var l_promo = l_obj.value;

//2DO Check dates entries 
//Modified by PMAB on 24-05-2007 window.open("propositions.aspx?startdate="+l_startdate+ "&enddate="+l_enddate /*+"&startday="+l_startday*/); 
//Modified by PMAB document.location.href = "propositions.aspx?startdate="+l_startdate+ "&enddate="+l_enddate+"&pax="+l_pax+"&child_pax="+l_child_pax+"&promo_code="+l_promo;
document.location.href = "propositions.aspx?startday="+l_intDay+ "&startmonth="+l_intMonth+ "&startyear="+l_intYear+"&pax="+l_pax+"&nights="+l_intNights+"&child_pax="+l_child_pax+"&promo_code="+l_promo;
}


/*
* PROTOTYPE : Get Hidden Fields
* PURPOSE : return stay parameters from combobox, Easier Way
* HISTORY : CREATED BY PMAB on 30-11-2007
*/
function GetHiddenFieldsAsUrl()
{
var l_sUrl = "";
var i;

if (document.persistent_form != null)
{
for(var i=0; i<document.persistent_form.length; ++i)
{
l_sUrl = l_sUrl + "&" + document.persistent_form.elements[i].name+ "=" + document.persistent_form.elements[i].value;
}
}

return l_sUrl;
/*
for(var i=0;i<document.persistent_form.length;++i)
{
document.write("<br>name: " + document.persistent_form.elements[i].name);
document.write(", type: " + document.persistent_form.elements[i].type);
document.write(", value: " + document.persistent_form.elements[i].value);
}
*/	
}


/**
* Prototype : serviceChange
* Purpose : compute package total as service selector is modified
* History : Created by PMAB on 22-08-2008
*/
function serviceChange()
{
UpdatePackageTotal();
}

/**
* Prototype : UpdatePackageTotal
* Purpose : compute package total as service selector is modified
* History : Created by PMAB on 22-08-2008
*/
function UpdatePackageTotal()
{
// parcourir les services
var service_id = 0;
var total_service_object = document.getElementById("sub_total_"+service_id);
var l_intSubTotal = 0.0;
var l_total_package_object = document.getElementById("base_rate");//Package base rate object
var l_intTotalPackage = parseFloat(l_total_package_object.value.replace(',','.'))/1; 

while((total_service_object = document.getElementById("sub_total_" + service_id)) != null)
{
l_intSubTotal = 0.0;
total_service_object = document.getElementById("sub_total_" + service_id);

//Retrieve current service rates
rate_per_pax_object = document.getElementById("rate_per_pax_" + service_id);
rate_per_child_object = document.getElementById("rate_per_child_" + service_id);
rate_per_stay_object = document.getElementById("rate_per_stay_" + service_id);
rate_per_pax_and_stay_object = document.getElementById("rate_per_pax_and_stay_" + service_id);
rate_per_child_and_stay_object = document.getElementById("rate_per_child_and_stay_" + service_id);

//retrieve current service selectors
selector_pax_object = document.getElementById("selector_pax_" + service_id);
var service_pax_selected = selector_pax_object.options[selector_pax_object.selectedIndex].value;

selector_stay_object = document.getElementById("selector_stay_" + service_id);
var service_stay_selected = selector_stay_object.options[selector_stay_object.selectedIndex].value;

selector_child_object = document.getElementById("selector_child_" + service_id);
var service_child_selected = selector_child_object.options[selector_child_object.selectedIndex].value;

//Compute cuurent service subtotal
/*
Tarif package = 
Base 
+ [pax * rate_per_pax ]
+ [nuitées * rate_per_nuitées ]
+ [pax * nuitées * (rate_per_pax_and_nuitées)]
+ [child * rate_per_child ]
+ [child * nuitées * (rate_per_child_and_nuitées)].
*/
l_intSubTotal+= service_pax_selected * parseFloat(rate_per_pax_object.value.replace(',','.'))/1;
l_intSubTotal+= service_stay_selected * parseFloat(rate_per_stay_object.value.replace(',','.'))/1;

l_intSubTotal+= service_pax_selected * service_stay_selected * parseFloat(rate_per_pax_and_stay_object.value.replace(',','.'))/1;

l_intSubTotal+= service_child_selected * parseFloat(rate_per_child_object.value.replace(',','.'))/1;
l_intSubTotal+= service_child_selected * service_stay_selected * parseFloat(rate_per_child_and_stay_object.value.replace(',','.'))/1;

//Set service subtotal
document.getElementById ("sub_total_" + service_id ).innerHTML = Math.round(l_intSubTotal * 100)/100 + "&euro;" ;//Moved from top on 07-06-2007

//Compute total package
l_intTotalPackage += l_intSubTotal;

//Next service
service_id++;
}

document.getElementById ("package_total2").innerHTML = Math.round(l_intTotalPackage * 100)/100 + "&nbsp;&euro;" ;//Moved from top on 07-06-2007
document.getElementById ("package_total").value = Math.round(l_intTotalPackage * 100)/100;//modified by JULIO on 15-12-2008
}



/**
* Prototype : CorporateFormSubmit2()
* Purpose : Like CorporateFormSubmit without Bookings/Years and stay len checks
* History : Created by PMAB on 09-03-2008
*/
function CorporateFormSubmit2()
{
//nom
if(IsEmpty("enterprise"))
{
alert(GetValue("dico_enterprise_required"));
return false;
}

//nom
if(IsEmpty("nom"))
{
alert(GetValue("dico_name_required"));
return false;
}

//prenom
if(IsEmpty("prenom"))
{
alert(GetValue("dico_firstname_required"));
return false;
}

//adresse
if(IsEmpty("adresse"))
{
alert(GetValue("dico_address_required"));
return false;
}

//tel
if(IsEmpty("tel"))
{
alert(GetValue("dico_phone_required"));
return false;
}

//Email
if(IsEmpty("mail"))
{
alert(GetValue("dico_email_required"));
return false;
}
/*	 
//Bookings/Years
if(IsEmpty("bookings_year"))
{
alert(GetValue("dico_bookings_year"));
return false;
}

//Stay length
if(IsEmpty("stay_length"))
{
alert(GetValue("dico_stay_length"));
return false;
}
*/

//Email validation
if (!IsEmailValid("mail"))
return false;

return true;
}


/**
* Prototype : UpdateDeposit
* Purpose : Recompute deposit
* History : Created by PMAB on 09-10-2008
*/
function UpdateDeposit(montant, percent)
{
// parcourir les chambres
var balance_object = document.getElementById("balance");
var deposit_object = document.getElementById("deposit");
var balance_object2 = document.getElementById("balance2");
var deposit_object2 = document.getElementById("deposit2");

var deposit = Math.round(montant * percent /100);
deposit_object.value = deposit;
balance_object.value = montant - deposit;

deposit_object2.value = deposit_object.value;
balance_object2.value = balance_object.value;
}

/**
* Prototype : InitDeposit
* Purpose : Recompute deposit
* History : Created by PMAB on 09-10-2008
*/
function InitDeposit()
{
var radio_object = document.getElementById("deposit_radio");
radio_object.click();
/*
var montant = 125;//2DO
var percent = 100;
// parcourir les chambres
var balance_object = document.getElementById("balance");
var deposit_object = document.getElementById("deposit");
var balance_object2 = document.getElementById("balance2");
var deposit_object2 = document.getElementById("deposit2");

var deposit = Math.round(montant * percent /100);
deposit_object.value = deposit;
balance_object.value = montant - deposit;

deposit_object2.value = deposit_object.value;
balance_object2.value = balance_object.value;
*/
}


/**
* Prototype : UpdateDepositFromSelector
* Purpose : Recompute stay and service deposit
* History : Created by PMAB on 07-12-2008
*/
function UpdateDepositFromSelector()
{

//retrieve total amount and services and deposit_percent 
var stay_and_service_total_object = document.getElementById("stay_and_service_total");
var montant = stay_and_service_total_object.value;
var selector_percent_object = document.getElementById("deposit_selector");
var percent = selector_percent_object.options[selector_percent_object.selectedIndex].value;

// retrieve element
var balance_object = document.getElementById("balance");
var deposit_object = document.getElementById("deposit");
var balance_object2 = document.getElementById("balance2");
var deposit_object2 = document.getElementById("deposit2");

var deposit = Math.round(montant * percent /100);
deposit_object.value = deposit;
balance_object.value = montant - deposit;

deposit_object2.value = deposit_object.value;
balance_object2.value = balance_object.value;
}

/**
* Prototype : UpdateDepositFromSelector2
* Purpose : Recompute stay deposit
* History : Copied by JULIO from UpdateDepositFromSelector on 05-01-2009
*/
function UpdateDepositFromSelector2()
{

//retrieve total amount and services and deposit_percent 
var total_stay_object = document.getElementById("total_stay");
var montant = total_stay_object.value;
var selector_percent_object = document.getElementById("deposit_selector");
var percent = selector_percent_object.options[selector_percent_object.selectedIndex].value;


/*document.getElementById("deposit2").innerHTML = Math.round(montant * percent /100) + " €";
document.getElementById("balance2").innerHTML = montant - Math.round(montant * percent /100) + " €";*/	

document.getElementById("deposit2").innerHTML = (montant * percent /100) + " €";
document.getElementById("balance2").innerHTML = montant - (montant * percent /100) + " €";

/*document.getElementById("deposit").value = Math.round(montant * percent /100) + " €";
document.getElementById("balance").value = montant - Math.round(montant * percent /100) + " €";*/

document.getElementById("deposit").value = (montant * percent /100) + " €";
document.getElementById("balance").value = montant - (montant * percent /100) + " €";
}


/**
* Prototype : UpdateDepositFromSelector3
* Purpose : Recompute stay deposit with 10% discount when selector value is 100%
* History : Copied by JULIO from UpdateDepositFromSelector2 on 17-04-2009
*/
function UpdateDepositFromSelector3(){var total_stay_object = document.getElementById("total_stay");var montant = total_stay_object.value;var selector_percent_object = document.getElementById("deposit_selector");var percent = selector_percent_object.options[selector_percent_object.selectedIndex].value;var reduction_percent_object = document.getElementById("reduction_percent");var reduction_percent_value = reduction_percent_object.value;var deposit_reduction = (montant * reduction_percent_value /100);if(percent == 100){document.getElementById("reduction_element").style.visibility ='visible';var deposit = (montant - deposit_reduction);document.getElementById("deposit2").innerHTML = deposit + " €";document.getElementById("balance2").innerHTML = montant - montant + " €";document.getElementById("deposit").value = deposit + " €";document.getElementById("balance").value = montant - montant + " €"; }else{document.getElementById("reduction_element").style.visibility='hidden';var deposit = (montant * percent /100);document.getElementById("deposit2").innerHTML = deposit + " €";document.getElementById("balance2").innerHTML = montant - deposit + " €";document.getElementById("deposit").value = deposit + " €";document.getElementById("balance").value = montant - deposit + " €";}}
function UpdateBookingServiceTotal(){var service_id = 0;var total_service_object = document.getElementById("sub_total_"+service_id);var l_intSubTotal = 0.0;var l_total_package_object = document.getElementById("base_rate");var l_intTotalPackage = parseFloat(l_total_package_object.value.replace(',','.'))/1; while((total_service_object = document.getElementById("sub_total_" + service_id)) != null){l_intSubTotal = 0.0;total_service_object = document.getElementById("sub_total_" + service_id);rate_per_pax_object = document.getElementById("rate_per_pax_" + service_id);rate_per_child_object = document.getElementById("rate_per_child_" + service_id);rate_per_stay_object = document.getElementById("rate_per_stay_" + service_id);rate_per_pax_and_stay_object = document.getElementById("rate_per_pax_and_stay_" + service_id);rate_per_child_and_stay_object = document.getElementById("rate_per_child_and_stay_" + service_id);selector_pax_object = document.getElementById("selector_pax_" + service_id);var service_pax_selected = selector_pax_object.options[selector_pax_object.selectedIndex].value;selector_stay_object = document.getElementById("selector_stay_" + service_id);var service_stay_selected = selector_stay_object.options[selector_stay_object.selectedIndex].value;selector_child_object = document.getElementById("selector_child_" + service_id);var service_child_selected = selector_child_object.options[selector_child_object.selectedIndex].value;l_intSubTotal+= service_pax_selected * parseFloat(rate_per_pax_object.value.replace(',','.'))/1;l_intSubTotal+= service_stay_selected * parseFloat(rate_per_stay_object.value.replace(',','.'))/1;l_intSubTotal+= service_pax_selected * service_stay_selected * parseFloat(rate_per_pax_and_stay_object.value.replace(',','.'))/1;l_intSubTotal+= service_child_selected * parseFloat(rate_per_child_object.value.replace(',','.'))/1;l_intSubTotal+= service_child_selected * service_stay_selected * parseFloat(rate_per_child_and_stay_object.value.replace(',','.'))/1;document.getElementById ("sub_total_" + service_id ).innerHTML = Math.round(l_intSubTotal * 100)/100 + "&euro;" ;l_intTotalPackage += l_intSubTotal;service_id++;}document.getElementById ("stay_and_service_total").value = Math.round(l_intTotalPackage * 100)/100;UpdateDepositFromSelector();}
function multiSearchFormSubmit (){if(IsEmpty("motsclefs") && IsEmpty("destination")){alert(GetValue("dico_searchParam_required"));return false;}else{return true;}}
function NbStar_flash(nbstar){inputHidden_NbStar_flash = document.getElementById("nbStar_flash");inputHidden_NbStar_flash.value = nbstar;}
function BudgetMin_flash(budgetmin){inputHidden_BudgetMin_flash = document.getElementById("budgetmin_flash");inputHidden_BudgetMin_flash.value = budgetmin;}
function BudgetMax_flash(budgetmax){inputHidden_BudgetMax_flash = document.getElementById("budgetmax_flash");inputHidden_BudgetMax_flash.value = budgetmax;}
function UpdateCityList(){var current_pageObject = document.getElementById("current_page");var current_page = current_pageObject.value;var search_buttonObject = document.getElementById("submit_search");var search_location_buttonObject = document.getElementById("submit_location_search");search_buttonObject.disabled='true';search_location_buttonObject.disabled='true';var country_listObject = document.getElementById("searchcountry");var selected_CountryCode = country_listObject.value;document.location.href =current_page+"?searchcountry=" + selected_CountryCode;}
function OnRequestFormSubmit(){if(IsEmpty("nom")){alert(GetValue("dico_name_required"));return false;}if(IsEmpty("prenom")){alert(GetValue("dico_firstname_required"));return false;}if(IsEmpty("mail")){alert(GetValue("dico_email_required"));return false;}if (!IsEmailValid("mail"))return false;if(IsEmpty("tel")){alert(GetValue("dico_phone_required"));return false;}if(IsEmpty("arrival_date")){alert(GetValue("dico_arrival_required"));return false;}if(IsEmpty("nights")){alert(GetValue("dico_nights_required"));return false;}if(IsEmpty("pax")){alert(GetValue("dico_pax_required"));return false;}if(IsEmpty("child_pax")){alert(GetValue("dico_childPax_required"));return false;}if(IsEmpty("commentaire")){alert(GetValue("dico_comment_required"));return false;}return true;}
function loading_search(num_build){document.getElementById('div_dispo'+num_build).style.visibility = 'visible';}
function onchange_selector(selector_object_name, input_object_name){var selector_value = document.getElementById(selector_object_name).value;document.getElementById(input_object_name).value = selector_value;}
function MultiCheckedItem(nbBoookingCriterionItem,element_name,hidden_element_name){var element_index = 1;var element_object = document.getElementById(element_name + element_index);var selected_element_object = document.getElementById(hidden_element_name);while((element_object = document.getElementById(element_name + element_index)) != null && element_object.checked != true || element_index == 1){var element_object_1 = document.getElementById(element_name + "1");if(element_index == nbBoookingCriterionItem && element_object_1.checked ==  true){selected_element_object.value ="Pas vide";}else if(element_index == nbBoookingCriterionItem){selected_element_object.value ="";}else{selected_element_object.value ="Pas vide";}element_index++;}}
function change_fond_tableau(classChange){var tableau_object = document.getElementById('change_fond_tableau');tableau_object.className = classChange;}
