// Author: ifé/Creator: MappetizerCore 12.1.4 by uismedia (http://www.uismedia.de); 09/10/2016 21:17:29
var mv_Query = null;
try {
dojo.require("dijit.TitlePane");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Textarea");
dojo.require("dojo.parser");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.Select");
dojo.require("dijit.Toolbar");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.CheckBox");
} catch (e) {
  if (e.number == -2146827850) {
    aText = "This browser does not allow local usage of html5/ajax solutions. Use a web server instead.";
    try {
      mv_alert(aText);
    } catch (e) {
      alert(aText);
    }
  }
}
// our fancy preloader-hider-function:
var hideLoader = function(){
  dojo.fadeOut({
    node:"MVpreloader",
    duration:1500,
    onEnd: function(){
      dojo.style("MVpreloader", "display", "none");
    }
  }).play();
}

dojo.addOnLoad(function() {
  //Do not delete or change this function
  if (!dojo.isFF) {
    var aText;
    if (mv_localUsage()) {
      if (mv_oExists(dojo.isIE) && dojo.isIE < 9) {
          aText = "Microsoft support for your InternetExplorer has ended. If you haven't already, consider installing and using a modern browser to get the best of this application";
      } else if (mv_isIE() || mv_isEdge()) {
          aText = "This browser does not allow local usage of html5/ajax solutions. Use a web server instead.";
      } else if (dojo.isChrome) {
          aText = "Chrome does not allow local usage of html5/ajax solutions. Use a web server instead or start Chrome with the command line switch --allow-file-access-from-files.";
      }
    }
    if (aText) {
      try {
        mv_alert(aText);
      } catch (e) {
        alert(aText);
      }
    }
  }
  var leg;
  leg = mv_embedSVGNode(dojo.doc,"MVlegendth0Doc","36px","17px","embfiles/legendth0.svg");
  dojo.byId("th0Legend").appendChild(leg);
  leg = mv_imgSVGNode(dojo.doc,"MVlegendth1Doc","36px","18px","embfiles/legendth1.svg");
  dojo.byId("th1Legend").appendChild(leg);
  leg = mv_imgSVGNode(dojo.doc,"MVlegendth2Doc","281px","97px","embfiles/legendth2.svg");
  dojo.byId("th2Legend").appendChild(leg);
  leg = mv_imgSVGNode(dojo.doc,"MVlegendth3Doc","318px","98px","embfiles/legendth3.svg");
  dojo.byId("th3Legend").appendChild(leg);
  leg = mv_imgSVGNode(dojo.doc,"MVlegendth4Doc","176px","66px","embfiles/legendth4.svg");
  dojo.byId("th4Legend").appendChild(leg);
  leg = mv_imgSVGNode(dojo.doc,"MVlegendth5Doc","183px","66px","embfiles/legendth5.svg");
  dojo.byId("th5Legend").appendChild(leg);
  leg = mv_imgSVGNode(dojo.doc,"MVlegendth6Doc","226px","50px","embfiles/legendth6.svg");
  dojo.byId("th6Legend").appendChild(leg);
  leg = mv_imgSVGNode(dojo.doc,"MVlegendth7Doc","317px","18px","embfiles/legendth7.svg");
  dojo.byId("th7Legend").appendChild(leg);

  mv_mobileHandleWidgets("Vue","MVtoolsContainer");
  if (dojo.byId("MVoverview") != null) {
    var over = mv_embedSVGNode(dojo.doc,"MVoverviewDoc","150px","75px","embfiles/overview.svg");
    dojo.byId("MVoverview").appendChild(over);
    var overFrame = dojo.byId("MVoverviewFrame");
    overFrame.setAttribute("style","width:auto;height:auto;");
  }

  var map = mv_embedSVGNode(dojo.doc,"MVmapDoc","auto","auto","embfiles/map.svg");
  dojo.byId("MVmap").appendChild(map);

  // Add functions to toolbar
  dojo.connect(dojo.byId("MVtoolbar.zoomin"),"onclick",mv_zoomInTool);
  dojo.connect(dojo.byId("MVtoolbar.zoomout"),"onclick",mv_zoomOutTool);
  dojo.connect(dojo.byId("MVtoolbar.fullextent"),"onclick",mv_fullExtent);
  dojo.connect(dojo.byId("MVtoolbar.fullscreen"),"onclick",mv_fullScreen);
  dojo.connect(dojo.byId("MVtoolbar.previousextent"),"onclick",mv_zoomPreviousExtentTool);
  dojo.connect(dojo.byId("MVtoolbar.nextextent"),"onclick",mv_zoomNextExtentTool);
  dojo.connect(dojo.byId("MVtoolbar.query"),"onclick",mv_queryTool);
  dojo.connect(dojo.byId("MVtoolbar.print"),"onclick",mv_print);
  dojo.connect(dojo.byId("MVtoolbar.legend"),"onclick",mv_showLegendInFP);
  dojo.connect(dojo.byId("body"),"onresize",mv_resizeMap);
  mv_watchSplitter(dijit.byId("MVborderContainer"));

  mv_checkLoaded();
  if (mv_isIE() && mv_localUsage()) {
    _mv_setIELocalStore();
  }
});

function mv_DocSettings() {
  //Do not delete or change this function;
  mv_Doc.Language = "fr-FR";
  mv_Doc.userSettings("white","#F7F6F6","yellow","orangered","#F7F6F6",true,true);
  mv_Doc.Texts["IESupport"] = "";
  mv_Doc.Texts["Flicker"] = "Highlight object";
  mv_Doc.Texts["Close"] = "Fermer la fenêtre";
  mv_Doc.Texts["Hyperlink"] = "D'autres informations";
  mv_Doc.Texts["QueryNoRec"] = "Aucun enregistrement trouve";
  mv_Doc.Texts["ExportExcel"] = "Export to Excel";
  mv_Doc.Texts["QueryRec1"] = " sur ";
  mv_Doc.Texts["QueryRec2"] = " sélectionnés:";
  mv_Doc.Texts["QueryRec3"] = "Jeux de donnees";
  mv_Doc.Texts["QueryHead"] = "Résultat de la requête";
  mv_Doc.Texts["QueryHelpTable"] = "Note: Bouger le curseur sur les lignes pour le sélectionner sur la carte.";
  mv_Doc.Texts["QueryStatus1"] = "Le tableau est en chargement, veuillez patientez ...";
  mv_Doc.Texts["QueryStatus2"] = "Le tableau est chargé.";
  mv_Doc.Texts["RecNo"] = "N°";
  mv_Doc.Texts["QueryBack"] = "Générateur de requêtes";
  mv_Doc.Texts["ZoomTo"] = "Zoom to object";
  mv_Doc.Texts["Print"] = "Imprimer";
  mv_Doc.Texts["Identify"] = "Information objet";
  mv_Doc.CheckStatus = "w35uML3";
}

function mv_MapSettings() {
  //Do not delete or change this function;
  //Villes
  var l = new MV.Layer("th0",{TurnedOn:false,Visible:false,Layertype:"TileLayer"});

  new MV.SVGTileRules({X:139.378,Y:326.869,Width:9832.096,Height:4666.334,XTilesNum:4,YTilesNum:2,Ext:"svg"},"th0",2458.024,0);

  //Pays
  var l = new MV.Layer("th1");

  //Principaux parallèles de la Terre
  var l = new MV.Layer("th2",{TurnedOn:false,Visible:false,Layertype:"TileLayer",TxtIds:"txt0"});

  new MV.SVGTileRules({X:6.796,Y:0,Width:9986.499,Height:4993.204,XTilesNum:1,YTilesNum:1,Ext:"svg"},"th2",9986.499,0);

  //Moyenne des précipitations annuelles 1961-1990
  var l = new MV.Layer("th3",{TurnedOn:false,Visible:false,Layertype:"TileLayer"});

  new MV.SVGTileRules({X:6.796,Y:499.066,Width:9986.408,Height:3579.672,XTilesNum:3,YTilesNum:2,Ext:"svg"},"th3",3328.803,2);

  //Energie solaire
  var l = new MV.Layer("th4",{TurnedOn:false,Visible:false,Layertype:"TileLayer"});

  new MV.SVGTileRules({X:28.628,Y:231.195,Width:9936.836,Height:3763.923,XTilesNum:10,YTilesNum:4,Ext:"svg"},"th4",993.684,4);

  //Climats chauds
  var l = new MV.Layer("th5",{TurnedOn:false,Visible:false,Layertype:"TileLayer"});

  new MV.SVGTileRules({X:0,Y:160.272,Width:10000,Height:4839.728,XTilesNum:5,YTilesNum:3,Ext:"svg"},"th5",2000,3);

  //Climats tempérés
  var l = new MV.Layer("th6",{TurnedOn:false,Visible:false,Layertype:"TileLayer"});

  new MV.SVGTileRules({X:0,Y:160.272,Width:10000,Height:4839.728,XTilesNum:5,YTilesNum:3,Ext:"svg"},"th6",2000,3);

  //Climats froids
  var l = new MV.Layer("th7",{TurnedOn:false,Visible:false,Layertype:"TileLayer"});

  new MV.SVGTileRules({X:0,Y:160.272,Width:10000,Height:4839.728,XTilesNum:5,YTilesNum:3,Ext:"svg"},"th7",2000,3);

  //Relief
  var l = new MV.Layer("th8",{InLegend:false,Layertype:"TileLayer"});

  new MV.DeepZoomRules({X:6.796,Y:0,Width:9986.408,Height:4993.204,Ext:"png"},"th8",256,14,10800,5400);

  mv_Map.userSettings(-5000,2496.602,10.2459016393443,27.740020902985,3,true,377284635,"");
  mv_Map.Scalebar = false;
}

function mv_initializeLegend() {
  //Do not delete or change this function;
}

function mv_ScalebarSettings() {
  //Do not delete or change this function;
}

function mv_initializeSettings() {
  //Do not delete or change this function;
  mv_declareClassIdentifyObject();
  mv_declareClassIdentifyMW();
  mv_declareClassIdentifyTP();

  mv_declareClassQueryBuilder();
  mv_Query = new MV.QueryBuilder();
  mv_Query.Doc = document; 
  mv_Query.layerSelect("th0");
  mv_Query.txtHelp = "Pour construire une expression, cliquez successivement sur\nle champ qui vous intéresse, sur un opérateur et enfin sur la\nvaleur de référence de votre requête.\nVous pouvez aussi écrire directement votre requête.\nLes noms de champ doivent être entre parenthèses.\n\n[NumericField] = 123.45\n\nDans vos requêtes, les caractères de type texte doivent\ntoujours être entre doubles guillemets.\n\n[TextField] = \"This is a text\"\n\nUtilisez l'opérateur LIKE pour les\nrecherches effectuées à l'aide des caractères génériques (ou jokers).\n\"%\" remplace un nombre quelconque de caractères.\n\n[TextField] like \"This is%\"\n\nVous pouvez combiner les opérateurs AND et OR dans une requête.\n\n[NumericField] >= 123.45 or [TextField] = \"This is a text\"";

  mv_Doc.Toolbars = new MV.List();
  mv_declareClassToolbar();
  mv_createToolbar();
}

function mv_initializeSettings2() {
 //Do not delete or change this function;
  hideLoader();
}


function mv_userInit() {
//This function is for your own scripts, it will be called on loading, do not delete it
//  mv_alert("function mv_userInit()");
}

function mv_userMVDocToolbar(objButton) {
//This function is for your own toolbar buttons, do not delete it
//  switch(objButton.id) {
//      case "MVtoolbar.mybutton":
//          objButton.Function = "testFunc('hier',2)";
//          objButton.State = 1;  //this button is a radio button
//          break;
//  }
}

