function Global() {

    this.addToFavorite = function favori(phrase, lien) {
        if (window.sidebar) {
            window.sidebar.addPanel(phrase, lien, "");
        } else if (document.all) {
            window.external.AddFavorite(lien, phrase);
        } else {
            return true;
        }
    }
    
    this.setOnClickComputePrice = function setOnClickComputePrice(alertVehicule, 
                                                                  alertAgenceAller, 
                                                                  alertAgenceRetour,
                                                                  alertKms,
																  alertGammeInvalid,
																  alert_DateDepartInvalid,
																  alert_DateRetourInvalid,
                                                                  checkKmSettings) {
        $("#btResaValider").click(function() {
            mazedia.calculateur.alert_Vehicule = alertVehicule;
            mazedia.calculateur.alert_agenceAller = alertAgenceAller;
            mazedia.calculateur.alert_agenceRetour = alertAgenceRetour;
            mazedia.calculateur.alert_KmEnvisages = alertKms;
			mazedia.calculateur.alert_GammeInvalid = alertGammeInvalid;
            mazedia.calculateur.alert_DateDepartInvalid = alert_DateDepartInvalid;
            mazedia.calculateur.alert_DateRetourInvalid = alert_DateRetourInvalid;
            
            var idVehicule = $("#etapes_reservation #idGamme").val();
            var idAgenceDepart = $("#etapes_reservation #choixVilles_Departure").val();
            var idAgenceArrivee = $("#etapes_reservation #choixVilles_Arrival").val();
            var nbKms = $("#etapes_reservation #km_envisage").val();
            var dateDepart = $('#dateResaDebut').val();
			var dateArrivee = $('#dateResaRetour').val();
			var formResa = $(".resa_form").find('form');

            mazedia.calculateur.isValidKmsSettings = (checkKmSettings == "True");
            return mazedia.calculateur.checkParamsBeforeGoToDevisPage(idVehicule, idAgenceDepart, 
                                                                      idAgenceArrivee, nbKms,
																      dateDepart, dateArrivee, formResa);
        });
    };

    this.gestionResaRapide = function GestionResaRapide() {
        // resa_form
        $(".resa_form .mode_resa_vhlc").hide();
        $(".resa_form a.resa").click(function() {
            $(this).next(".mode_resa_vhlc").slideDown("fast");
            return false;
        });

        $(".resa_form a.closed").click(function() {
            $(".resa_form .mode_resa_vhlc").slideUp("fast");
            return false;
        });
    };

    this.setformatkilometrage = function Setformatkilometrage() {
        $(".resa_etape #km").change(function() {
            var km = $(this).val();
            $(this).val(km + " Km");
        });
    };

    this.addSelectOnlyOneCheckBox = function addSelectOnlyOneCheckBox() {
        // Check box
        $(".checkBoxOne").each(function() {
            var _this = $(this);
            $(this).find(".field_checkbox").click(function() {
                _this.find(".field_checkbox").attr("checked", false);
                $(this).attr("checked", true);
            });
        });
    };
    
    //TODO mettre en place pour la popup reservation
    this.setOnClickToH3CategorieVehicule = function SetOnClickToH3CategorieVehicule(specificID) {
        $("#resaLienAgenceRetour").click(function() {
            $("#agenceRetVisible").val("true");
            $("#resaLienAgenceRetour").hide();
            $("#Dv_resaAgenceRetour").show();
        });
    };
    
    this.addOnClickSelectedFirstAgency = function AddOnClickSelectedFirstAgency() {
        $("#choixVilles_Departure").change(function() {
            $("#choixVilles_Arrival").val($(this).val());    
        });
    };

    this.addDefaultTextToSelectAgencies = function addDefaultTextToSelectAgencies(text) {
//        var option = $('<option selected></option>').val("").html(text);
//        var optionBis = $('<option selected></option>').val("").html(text);

//        $("#choixVilles_Departure").prepend(option);
//        $("#choixVilles_Arrival").prepend(optionBis);
    };

    this.xToolTipOffset = -10; // ToolTip x distance from mouse
	this.yToolTipOffset = 10; // ToolTip y distance from mouse

	this.addToolTips = function AddToolTips() {
	    $(".vtip").unbind().hover(
	        function(e) {
	            this.t = this.title;
	            this.title = '';
	            this.top = (e.pageY + mazedia.ui.global.yToolTipOffset); this.left = (e.pageX + mazedia.ui.global.xToolTipOffset);

	            $('body').append('<p id="vtip">' + this.t + '</p>');
	            $('p#vtip').css("top", this.top + "px").css("left", this.left + "px").fadeIn("slow");

	        },
	        function() {
	            this.title = this.t;
	            $("p#vtip").fadeOut("slow").remove();
	        }
	    ).mousemove(
	        function(e) {
	            this.top = (e.pageY + mazedia.ui.global.yToolTipOffset);
	            this.left = (e.pageX + mazedia.ui.global.xToolTipOffset);

	            $("p#vtip").css("top", this.top + "px").css("left", this.left + "px");
	        }
	    );

	};

    this.initBlankOnClickField = function InitBlankOnClickField(fieldId) {
        var field = $("#" + fieldId);
        var value = field.val();
        field.click(function() {
            if ($(this).val() == value) $(this).val('');
        }).blur(function() {
            if ($(this).val() == '') $(this).val(value);
        });

    }
    
}
