// 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
	 if(IsEmpty("deposit2") || IsEmpty("balance2"))
	 {
		 InitDeposit();
	 }
	
	//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 : 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 : 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 : 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_total").innerHTML = Math.round(l_intTotalPackage * 100)/100 + "&euro;" ;//Moved from top on 07-06-2007
}


/** Prototype : intval()
  * Purpose : Recupérer partie entière
  * History : Created by JULIO on 23-10-2009
**/
function intval (mixed_var, base) {
var tmp;
var type = typeof( mixed_var );
 
	if (type === 'boolean') {
		return (mixed_var) ? 1 : 0;
	} else if (type === 'string') {
		tmp = parseInt(mixed_var, base || 10);
		return (isNaN(tmp) || !isFinite(tmp)) ? 0 : tmp;
	} else if (type === 'number' && isFinite(mixed_var) ) {
		return Math.floor(mixed_var);
	} else {
		return 0;
	}
}


/** Prototype : initYear(context_year)
  * Purpose : To init the year of bombaron scraper
  * History : Created by JULIO on 05-11-2009
**/

function initYear(context_year)
{
    var dt_datetime = new Date();
	var current_day = dt_datetime.getDate();		 
	var current_month_org = dt_datetime.getMonth();
	var current_month = current_month_org +1; 			//DECALAGE DE 1 DANS LES MOIS EN JAVASCRIPT !!!!!
	var current_year = dt_datetime.getFullYear();
	
	//var selected_month_object = document.getElementById('month');
	var selected_month_object = document.getElementById('month_scraper'); // MODIFIED FOR BOMBARON SCRAPER
	var selected_month = selected_month_object.value;
	
	//var defined_year_object = document.getElementById('year');
	var defined_year_object = document.getElementById('year_scraper'); // MODIFIED FOR BOMBARON SCRAPER
	
		
	if(selected_month < current_month)
	{
	  defined_year_object.value = current_year+1;
	}
	else if(selected_month >= current_month && context_year > current_year)
	{
	  defined_year_object.value = current_year;		
	}
	else
	{
	  defined_year_object.value = context_year;
	}
	
	
}



/** Prototype : UpdateDays()
  * Purpose : To valid the dates
  * History : Created by JULIO on 10-07-2009
**/

function UpdateDays()
{
    
  //var year_selector_object = document.getElementById("year");
  var year_selector_object = document.getElementById("year_scraper"); // MODIFIED FOR BOMBARON SCRAPER
  var selected_year = year_selector_object.value;
  //var month_selector_object = document.getElementById("month");
  var month_selector_object = document.getElementById("month_scraper"); // MODIFIED FOR BOMBARON SCRAPER
  //var day_selector_objet = document.getElementById("day");
  var day_selector_objet = document.getElementById("day_scraper"); // MODIFIED FOR BOMBARON SCRAPER
  var selected_month =  month_selector_object.value;
  	
 if((selected_year/4) == (intval((selected_year/4)))){    //ANNEE BISSEXTILE

	if(selected_month == 2) // FEVRIER
 {
	  if(day_selector_objet.options[day_selector_objet.options.length-1].value == 31)
	  {
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
	  }
	  else if(day_selector_objet.options[day_selector_objet.options.length-1].value == 30)
	  {
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
	  }
	  else if(day_selector_objet.options[day_selector_objet.options.length-1].value == 28)
	  {
	  	day_selector_objet.options[day_selector_objet.options.length] = new Option(29,29);
	  }
 }
 else
 {
 	if(selected_month != 2 && selected_month < 7 && selected_month %2 == 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 31) // AVRIL, JUIN
  	{
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
  	}
 	else if(selected_month != 2 && selected_month > 7 && selected_month %2 != 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 31)// SEPTEMBRE, NOVEMBRE
  	{
 		day_selector_objet.options[day_selector_objet.options.length-1] = null;
  	}
 	else if(selected_month != 2 && selected_month <= 7 && selected_month %2 != 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 30) // JANVIER, MARS, MAI, JUILLET
  	{
	   	day_selector_objet.options[day_selector_objet.options.length] = new Option(31,31);
  	}
 	else if(selected_month != 2 && selected_month >= 8 && selected_month %2 == 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 30) // AOUT, OCTOBRE, DECEMBRE 
  	{
	   	day_selector_objet.options[day_selector_objet.options.length] = new Option(31,31);
  	}
 	
	else if(selected_month != 2 && selected_month < 7 && selected_month %2 == 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 29) // AVRIL, JUIN
	{
		day_selector_objet.options[day_selector_objet.options.length] = new Option(30,30);
  	}
    else if(selected_month != 2 && selected_month > 7 && selected_month %2 != 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 29)// SEPTEMBRE, NOVEMBRE
	{
		day_selector_objet.options[day_selector_objet.options.length] = new Option(30,30);
  	}
	
	else if(selected_month != 2 && selected_month <= 7 && selected_month %2 != 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 29) // JANVIER, MARS, MAI, JUILLET
	{
		day_selector_objet.options[day_selector_objet.options.length] = new Option(30,30);
		day_selector_objet.options[day_selector_objet.options.length] = new Option(31,31);
  	}
    else if(selected_month != 2 && selected_month >= 8 && selected_month %2 == 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 29) // AOUT, OCTOBRE, DECEMBRE 
	{
		day_selector_objet.options[day_selector_objet.options.length] = new Option(30,30);
		day_selector_objet.options[day_selector_objet.options.length] = new Option(31,31);
  	}
 }
	
}else{    											//ANNEE NON BISSEXTILE

	if(selected_month == 2) // FEVRIER
 {
	  if(day_selector_objet.options[day_selector_objet.options.length-1].value == 31)
	  {
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
	  }
	  else if(day_selector_objet.options[day_selector_objet.options.length-1].value == 30)

	  {
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
	  }
	  else if(day_selector_objet.options[day_selector_objet.options.length-1].value == 29)
	  {
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
	  }
 }
 else
 {
 	if(selected_month != 2 && selected_month < 7 && selected_month %2 == 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 31) // AVRIL, JUIN
  	{
	  	day_selector_objet.options[day_selector_objet.options.length-1] = null;
  	}
 	else if(selected_month != 2 && selected_month > 7 && selected_month %2 != 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 31)// SEPTEMBRE, NOVEMBRE
  	{
 		day_selector_objet.options[day_selector_objet.options.length-1] = null;
  	}
 	else if(selected_month != 2 && selected_month <= 7 && selected_month %2 != 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 30) // JANVIER, MARS, MAI, JUILLET
  	{
	   	day_selector_objet.options[day_selector_objet.options.length] = new Option(31,31);
  	}
 	else if(selected_month != 2 && selected_month >= 8 && selected_month %2 == 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 30) // AOUT, OCTOBRE, DECEMBRE 
  	{
	   	day_selector_objet.options[day_selector_objet.options.length] = new Option(31,31);
  	}
 	
	else if(selected_month != 2 && selected_month < 7 && selected_month %2 == 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 28) // AVRIL, JUIN
	{
	   	day_selector_objet.options[day_selector_objet.options.length] = new Option(29,29);
		day_selector_objet.options[day_selector_objet.options.length] = new Option(30,30);
  	}
    else if(selected_month != 2 && selected_month > 7 && selected_month %2 != 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 28)// SEPTEMBRE, NOVEMBRE
	{
	   	day_selector_objet.options[day_selector_objet.options.length] = new Option(29,29);
		day_selector_objet.options[day_selector_objet.options.length] = new Option(30,30);
  	}
	
	else if(selected_month != 2 && selected_month <= 7 && selected_month %2 != 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 28) // JANVIER, MARS, MAI, JUILLET
	{
	   	day_selector_objet.options[day_selector_objet.options.length] = new Option(29,29);
		day_selector_objet.options[day_selector_objet.options.length] = new Option(30,30);
		day_selector_objet.options[day_selector_objet.options.length] = new Option(31,31);
  	}
    else if(selected_month != 2 && selected_month >= 8 && selected_month %2 == 0 && day_selector_objet.options[day_selector_objet.options.length-1].value == 28) // AOUT, OCTOBRE, DECEMBRE 
	{
	   	day_selector_objet.options[day_selector_objet.options.length] = new Option(29,29);
		day_selector_objet.options[day_selector_objet.options.length] = new Option(30,30);
		day_selector_objet.options[day_selector_objet.options.length] = new Option(31,31);
  	}
 }
 
  
}
  
  
}
