﻿/* Automatic retrieval of cities */
function getCities(countryId, width){
    $.ajax({
        type: "POST",
        url: "../XMLGetCities.ashx",
        beforeSend: function(xhr) {xhr.setRequestHeader("Cookie","ASP.NET_SessionId=<%= HttpContext.Current.Session.SessionID %>");},
        data: "CountryId=" + countryId,
        datatype: "xml",
        success: function(xml){onSuccess_getCities(xml, width);},
        error: function(){onError_getCities(width);}
    });
}

function onSuccess_getCities(xml, width){
    var options = ""
    $(xml).find("cities").children().each(function(){
        options += "<option value=\"" + $(this).attr("textEnc") + "\"" + ">" + $(this).attr("text") + "</option>";
    });
    $("#Cities").html("<select style=\"width:" + width + "px;\" id=\"city\" name=\"city\">" + options + "</select>");
}
function onError_getCities(width) { $("#Cities").html("<select style=\"width:" + width + "px\" id=\"city\" name=\"city\"></select>"); }

//Create marker-icon
function createServicepointIcon(){
    icon = new GIcon();
    icon.image = "../pics/ServicepuntenLogo.png";
    icon.iconSize = new GSize(40, 40);
    icon.iconAnchor = new GPoint(19, 37);
    icon.infoWindowAnchor = new GPoint(19, 19);
}
//Create marker and set up event window
function createMarker(point,html,icon){
    var marker = new GMarker(point,icon);
    GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(html);
        });
    return marker;
}


