         /* Insert your key */
         VMAPI.registerKey("JSGP20080507164917238922838944");
         VMAPI.setLanguage("gbr");

         /* Transform user start address into a geographical point */
         function search_start_location(){
            document.getElementById('result_action').style.display = 'none';
            document.getElementById('youritidiv').style.display = 'none';
            Start_geocoder = new VMGeocoder();
            Start_myaddress = new VMAddress();

            var elements_formulaires =
               document.forms['itisearch_form'].elements;

            Start_myaddress.address = elements_formulaires['form_Start_address'].value;
            Start_myaddress.zipCode = elements_formulaires['form_Start_CP'].value;
            Start_myaddress.city = elements_formulaires['form_Start_city'].value;
            Start_myaddress.countryVMCode = elements_formulaires['form_Start_country'].value;


            Start_geocoder.addEventHandler("onCallBack",search_stop_location);
            Start_geocoder.search(Start_myaddress);
         }

          /* Transform user stop address into a geographical point */
         function search_stop_location(){
            Stop_geocoder = new VMGeocoder();
            Stop_myaddress = new VMAddress();

            var elements_formulaire =
                  document.forms['itisearch_form'].elements;

            Stop_myaddress.address = elements_formulaire['form_Stop_address'].value;
            Stop_myaddress.zipCode = elements_formulaire['form_Stop_CP'].value;
            Stop_myaddress.city = elements_formulaire['form_Stop_city'].value;
            Stop_myaddress.countryVMCode = elements_formulaire['form_Stop_country'].value;


            Stop_geocoder.addEventHandler("onCallBack",search_step_location);
            Stop_geocoder.search(Stop_myaddress);
         }

         /* Transform user step address into a geographical point */
         function search_step_location(){
            if (document.forms['itisearch_form'].elements['form_Step_address'].value != "" || document.forms['itisearch_form'].elements['form_Step_CP'].value != "" || document.forms['itisearch_form'].elements['form_Step_city'].value != ""){
               Step_geocoder = new VMGeocoder();
               Step_myaddress = new VMAddress();

               var elements_formulaire =
                  document.forms['itisearch_form'].elements;

               Step_myaddress.address = elements_formulaire['form_Step_address'].value;
               Step_myaddress.zipCode = elements_formulaire['form_Step_CP'].value;
               Step_myaddress.city = elements_formulaire['form_Step_city'].value;
               Step_myaddress.countryVMCode = elements_formulaire['form_Step_country'].value;

               Step_geocoder.addEventHandler("onCallBack",search_iti);
               Step_geocoder.search(Step_myaddress);
            } else {
               search_iti();
            }
         }

         /* Itinary search configuration */
         function search_iti(){
            myiti = new VMItinerary();
            myiti.addStopOver(Start_geocoder.result);

            var elements_formulaire =
               document.forms['itisearch_form'].elements;

            if (elements_formulaire['form_Step_address'].value != ""
               || elements_formulaire['form_Step_CP'].value != ""
               || elements_formulaire['form_Step_city'].value != ""){
               myiti.addStopOver(Step_geocoder.result);
            }
            myiti.addStopOver(Stop_geocoder.result);


            myiti.addEventHandler("onCallBack",iti_found);
            myiti.search();
         }

         function iti_found(){

            display_onmap();
            display_roadsheet();
         }

         /* Display itinary as a text */
         function display_roadsheet(){
            if (typeof(myiti)!="undefined"){
               document.getElementById('youritidiv').innerHTML = myiti.roadSheet.getHTML(mymap);
               document.getElementById('youritidiv').style.display = '';
            } else {
               alert('No Itinerary loaded');
            }
         }

         /* Display itinary on the map */
         function display_onmap(){
            if (typeof(myiti)!="undefined"){
               if (typeof(mymap)!="undefined"){
                  document.getElementById('yourmapdiv').style.display = '';
                  document.getElementById('yourmapdiv').innerHTML = "";
                  mymap = new VMMap(document.getElementById("yourmapdiv"));
                  mymap.addLayer(myiti.getItiAsVMComplexLayer("#FF0000",7,0.5));
                  mymap.drawMapFromLayers();
               } else {
                  document.getElementById('yourmapdiv').style.display = '';
                  mymap = new VMMap(document.getElementById("yourmapdiv"));
                  mymap.addLayer(myiti.getItiAsVMComplexLayer("#FF0000",7,0.5));
                  mymap.drawMapFromLayers();
               }
               mymap.addLayer(myiti.roadSheet.getLayer());
               mymap.showMapTools(3);
            } else {
               alert('No Itinerary loaded');
            }
         }

         /* Display some itinary informations */
         function display_informations(){
            strHTML =
                    "Total distance in meters:"
                    +myiti.getTotalDistance()+"m<br>"
                    + "Distance covered on motorway: "
                    +myiti.getDistanceOnMotorway()+"m<br>"
                    + "Total time in seconds: "
                    +myiti.getTotalTime()+"s<br>"
                    + "Time on motorway:"
                    +myiti.getTimeOnMotorway()+"s<br>"
                    + "Fuel cost:"
                    +myiti.getTotalGasConsumption()+"&euro;<br>"
                    + " Motorway toll cost:"
                    +myiti.getTollCost()+"&euro;<br>"
                    + "Label cost:"
                    +myiti.getRoadTaxCost()+"&euro;<br>";

            document.getElementById('youritiresumediv').style.display = '';
            document.getElementById('youritiresumediv').innerHTML = strHTML;
         }

         /* Display the countries list */
         function load_country(){
            VMCountryUtil.addEventHandler(
               "onCallBack",
               function(){
                  document.getElementById("div_country_start").innerHTML =
                     VMCountryUtil.getSelectHTMLString("form_Start_country","CHE");
                  document.getElementById("div_country_stop").innerHTML =
                     VMCountryUtil.getSelectHTMLString("form_Stop_country","FRA");
                  document.getElementById("div_country_step").innerHTML =
                     VMCountryUtil.getSelectHTMLString("form_Step_country","FRA");
               }
            );
            VMCountryUtil.loadCountryLabels();
         }
         
