function $get(id){return document.getElementById(id)}

// Select pan or zoom radio button
function dragmode(e)
{
    var targ;
    if (e.target) targ = e.target;
	else targ = e.srcElement;
	
    var dth = $get("DragTypeHidden"); //Settes i MapImage.cs
    var radioRubberband = $get("radioRubberband");
    var radioPan = $get("radioPan");
    
    if(targ == "radioRubberband"){
        radioRubberband.checked = 'true';
        radioPan.checked = 'false';
    }
    else if(targ == "radioPan"){
        radioRubberband.checked = 'false'; 
        radioPan.checked = 'true';
     }
    
	if (radioRubberband.checked) {
		dth.value = 0;
		$get('MapImage1').style.cursor = 'crosshair';
	}
	else {
		dth.value = 1;
		$get('MapImage1').style.cursor = 'pointer';
	}
	return true;
}

// onmouseover handler for poi AREA. Set in Code-behind - Render()
function poiMouseOver(x, y, id)
{
	var rubberband = $get("MapImage1_rubberBand");
	if(rubberband.style.visibility == 'visible')return true;

    var info = $get(id).getAttribute("info");
    var boxcontent = $get("BoxContent");
	var poimouseover = $get("PoiMouseover");
	var mapimage = $get("MapImage1");
	
	poimouseover.style.left = '0px';
	poimouseover.style.top = '0px';
	poimouseover.style.display = 'block';
	boxcontent.style.width = 'auto';
	boxcontent.style.height = 'auto';
	boxcontent.innerHTML = "<div>"+info+"</div>";
	
	var boxWidth = boxcontent.offsetWidth;
	var boxHeight = boxcontent.offsetHeight;
	var boxLeft;
	var boxTop;
	boxcontent.style.width = boxWidth + "px";
	boxcontent.style.height = boxHeight + "px";
	if((x+boxWidth+10) > mapimage.offsetWidth)
		boxLeft = (x-boxWidth)+10;
	else
		boxLeft = x+25;
	if((y+boxHeight+10) > mapimage.offsetHeight)
		boxTop = (y-boxHeight)+10;
	else
		boxTop = y+25;
		
	poimouseover.style.left = (boxLeft - mapimage.offsetLeft) + 'px';
	poimouseover.style.top = (boxTop - mapimage.offsetTop) + 'px';
}

// onmouseoout handler for poi AREA. Set in Code-behind - Render()
function poiMouseOut ()
{
	var poimouseover = $get ("PoiMouseover");
	poimouseover.style.display = "none";
}

// onmouseover handler for floating box div (set in MapForm.aspx).
function floatBoxMouseOver ()
{
	var poimouseover = $get ("PoiMouseover");
	poimouseover.style.display = "block";
}

// onmouseoout handler for floating box div (set in MapForm.aspx).
function floatBoxMouseOut ()
{
	poiMouseOut();
}

function setTarget(id){
    __doPostBack('MapImage1','poiclick(' + id + ')');
}

// Notify ScriptManager that this is the end of the script.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
