var preimgurl;
var currIn = .20;
var fadeInt;

function preload () {
	if(opera || (gecko!=null && gecko < 1.8)) {
		//alert('aa='+gecko);
        loadingOff();
        document.getElementById('tabc_main_map').style.background = 'url('+preimgurl+') no-repeat';
	}
	else {
		http_preload.open("GET", preimgurl, true);
		http_preload.onreadystatechange = preload_done;
		http_preload.send(null);
		
	}
}

function preload_done () {
    if(http_preload.readyState == 4){
        loadingOff();

        document.getElementById('tabc_main_map').style.opacity = 0;
        document.getElementById('tabc_main_map').style.filter = 'alpha(opacity=0)';
        if(fadeInt != null){
            clearInterval(fadeInt);
        }

        fadeInt = setInterval(fadeIn, 50);

        document.getElementById('tabc_main_map').style.background = 'url('+preimgurl+') no-repeat';

        if(fe_data_scale != 0 && bm_data_x > 0 && bm_data_y > 0) {
		    pixelX = map_width / Math.abs((data_maxx - data_minx));
		    pixelY = map_height / Math.abs((data_maxy - data_miny));
		
		    document.getElementById('flag').style.left = findPosX('tabc_main_map')+(((bm_data_x-data_minx)*pixelX)-10)+'px';
		    document.getElementById('flag').style.top = findPosY('tabc_main_map')+(map_height-(((bm_data_y-data_miny)*pixelY))-19)+'px';
        }

        //document.getElementById('debug').innerHTML = preimgurl;
    }
}

function fadeIn () {
    currIn = currIn + .10;
    document.getElementById('tabc_main_map').style.opacity = currIn;
    document.getElementById('tabc_main_map').style.filter = 'alpha(opacity='+(currIn*100)+')';
    if(currIn >= 1){
        clearInterval(fadeInt);
        currIn = .20;
        document.getElementById('tabc_main_map_o').style.background = 'none';
    }

}
