My problem is that pointOnMap() runs before xmlPreparer() despite on order. I think it has something to do with using AJAX. parseXML creates object i need . So when i use pointOnMap() it already should be initialized.
On page is first that i see from pointOnMap - 0 and after that from parse ..So it is not in right order .
Thank you for your advices.
var mesta= new Array();
function init() {
    xmlPreparer();
    pointOnMap();   
}
//add source
function xmlPreparer() {   
    $.ajax({
    type: "GET",
    url: "./mesta.xml",
    dataType: "xml",
    success: parseXml
  });
}
function parseXml(xml) {
    var type;
    var name;
    var latitude;
    var longitude;
  $(xml).find("city").each(function()
  {
    type=$(this).find("type").text();
    name=$(this).find("name").text();
    latitude= $(this).find("latitude").text();
    longitude=$(this).find("longitude").text();
    var mesto = {type:type, name:name, latitude:latitude, longtitude:longitude};
    mesta.push(mesto);
  });
    alert(mesta.length);//this prints right size
}
//add source
function pointOnMap() {
alert(mesta.length);//for no reason prints 0 and runs before xmlparser?
$('#dot').css('top', YLatToPixel(0,$('#jpMapa')))
$('#dot').css('left', XLngToPixel(0,$('#jpMapa'))+'px');
}
function YLatToPixel(lat,elem){
var containerHeight=$(elem).height();
lat+=90;
var calculatedHeight=((lat*containerHeight)/180);
return $(elem).offset().top+($(elem).height()-calculatedHeight);
}
function XLngToPixel(lng,elem){
var containerWidth=($(elem).width());
lng=lng+180;
return $(elem).offset().left+((lng*containerWidth)/360);
}
 
    