
var selected_land;

function on_land(land_element,hover_image_src) {
	
	//var land_element = document.getElementById(land_id);
	land_element.src = hover_image_src;
	//land_element.style.borderLeft = "1px solid red";
	//land_element.style.borderRight = "1px solid red";
	//land_element.style.borderBottom = "1px solid red";
}

function out_land(land_element,image_src) {
	land_element.src = image_src;
	var landBox = document.getElementById("landBox");
	if (landBox != null) {
		//landBox.style.display="none";
	}
}

function select_land(land_element) {
	selected_land = land_element.id;
	//land_element.style.border = "2px solid ";
}

function make_request(url) {

        var http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
        	
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
            
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = function() { set_map(http_request); };
        http_request.open('GET', url, true);
        http_request.send(null);

}

function set_map(http_request) {
	try {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
            		
            	Text = http_request.responseText;
            	
				try {
					document.getElementById('game_map').innerHTML = Text;
				} catch(e) {
					
				}
				
			
            } else {
                alert('There was a problem with the request.');
            }
        }
	} catch(e) {
			
	}

}
    

function get_map(cmd,x,y) {
	var url = "/get_map.php?action=" + cmd + "&pos_x=" + x + "&pos_y=" +y;
	make_request(url);
}
