﻿var currentCote = {};

/* mapping cote */
var cotationMapping = [
    { "id": "#txtDateMec", "property": "dateMec", "validationsRules": ["required", "date"] },
    { "id": "#txtKilometrage", "property": "mileAge", "validationsRules": ["required", "number"] },
    { "id": "#selectMakes", "property": "makeId", "validationsRules": ["required"] },
    { "id": "#selectModels", "property": "modelId", "validationsRules": ["required"] },
    { "id": "#selectVersions", "property": "versionId", "validationsRules": ["required"] },
    { "id": "#selectColors", "property": "colorId", "validationsRules": ["required"] }
];

currentSearch = {};
searchMethod = 'post';
rechercheMapping = [
	{ "id": "#txtAdBudgetMin", "property": "budgetMin", "validationsRules": ["required"] },
	{ "id": "#txtAdBudgetMax", "property": "budgetMax", "validationsRules": ["required"] },
	{ "id": "#selectAdLocalisation", "property": "localisationId"},
	{ "id": "#selectAdMakes", "property": "makeId" },
	{ "id": "#selectAdModels", "property": "modelId" }
];

	$(function() {

		/*****************************************************************************/
		/* Initialisation */
		/*****************************************************************************/

		/* Gestion du menu */
		$.HighLightMenu();

		/* Gestion du bouton déconnection */
		$.ShowBtnDeconnexion();

		//*********************************
		// GESTION DE LA COTE
		//*********************************
		/* Initialisation des combos */
		$.InitForm();
		$.InitAdForm();
		$.SetAnnoncesDuMoment();
		$("#txtDateMec").mask("99/99/9999");
		$("#gauche").hide();
		$("#principal").hide();
		$("#droite").hide();

		/*****************************************************************************/
		/* Evenementiel */
		/*****************************************************************************/

		//*********************************
		// GESTION DE LA COTE
		//*********************************

		/* datemec */
		$("#txtDateMec").bind("keyup", function(event) {
			$.TxtDateMecTextBlurCallback();
		});

		/* kilométrage */
		$("#txtKilometrage").bind("blur", function(event) {
			$.TxtKilometrageTextBlurCallback();
		});

		/* marque */
		$("#selectMakes").bind("change", function(event) {
			$.SelectMakesTextChangeCallback();
		});

		/* modele */
		$("#selectModels").bind("change", function(event) {
			$.SelectModelsTextChangeCallback();
		});

		/* version */
		$("#selectVersions").bind("change", function(event) {
			$.SelectVersionsTextChangeCallback();
		});

		/* coter */
		$("#Coter").bind("click", function(event) {
			$.ValidateCotation();
		});

		//********************************
		// GESTION DES ANNONCES
		//********************************

		/* marque */
		$("#selectAdMakes").bind("change", function(event) {
			$.SelectAdMakesTextChangeCallback();
		});

		/* rechercher */
		$("#Rechercher").bind("click", function(event) {
			$.ValidateAnnonce();
		});

	});
