var xmlhttp

function loadXMLDoc(url)
{
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=onResponse;
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function checkReadyState(obj)
{
  if(obj.readyState == 4)
  {
    if(obj.status == 200)
    {
      return true;
    }
    else
    {
      alert("Problem retrieving XML data");
    }
  }
}
/***map24 stuff ***/
function goMap24(){
  map = Map24.Webservices.getMap24Application({
     AppKey: myappkey,
    MapArea: document.getElementById( "maparea" ),
    MapWidth: 720,
    MapHeight: 720
  });
document.getElementById('wait').style.display='none'
}

function genDeclareMapGroup( group, id ){
  var MapGroup = new Map24.Webservices.MRC.DeclareMapObjectGroup({
    MapObjectGroupID: group,
    MapObjectIDs: new Array( group, id )
  });
  return MapGroup;	
}   

function centerOnObjectGroup(groupID){
  var mrcContainer = new Map24.Webservices.Request.MapletRemoteControl( map );
  mrcContainer.push( genSetMapView ( '', '', 15000, 20, groupID ) );
  map.Webservices.sendRequest( mrcContainer );
  	setProgressbar(0)
}  

function genSetMapView( Long, Lat, ClippingWidth, ClippingPercent, id ){
  var SetMapView = null;
  var Clip = new Array();
  if( ClippingWidth != '' ) 
    Clip['MinimumWidth'] = ClippingWidth;
  if( ClippingPercent != '' ) 
    Clip['ViewPercentage'] = ClippingPercent;
  if( Long != '' && Lat != '' )
  {
    SetMapView = new Map24.Webservices.MRC.SetMapView({
      Coordinates: new Map24.Coordinate( Long, Lat ),
      ClippingWidth: new Map24.Webservices.ClippingWidth( Clip )           
    });
  }
  else if ( id != '' ){
    SetMapView = new Map24.Webservices.MRC.SetMapView({
      ClippingWidth: new Map24.Webservices.ClippingWidth( Clip ),
      MapObjectIDs: id
    });
  }
  return SetMapView;	
}		

function getContinent(lon,lat) {
	if (lon>-1426 && lon< 3844 && lat>2076) return 'europe'
	if (lon>-7458 && lon< -3162 && lat>1005) return 'namerica'
	if (lon>-4793 && lon< -2092 && lat<636) return 'samerica'
	if (lon>6951 && lon< 10486 && lat<-903) return 'australia'
	if (lon>2337 && lon< 3515 && lat<1704 && lat>1214) return 'mi_east'
	return null

}

function changeMap(cont) {
if (cont.length==0) return
setProgressbar(1)
t=document.location.search; 
lc=document.location.href.replace(t,'')
lc=lc+'?'+'cont='+cont
document.location.href=lc
}

function changeBoundary(val) {
	lowBoundary=val;
	setProgressbar(1)
	removeLocs()
	addLocs()
}

function removeLocs() {
  var mrcContainer = new Map24.Webservices.Request.MapletRemoteControl( map );
  mrcContainer.push( new Map24.Webservices.MRC.RemoveMapObject( mygroup ) );
  map.Webservices.sendRequest( mrcContainer );	
		
}

function setContinent() {
	tmp1=document.location.search
	if (tmp1) {
		tmp=tmp1.split('&'); 
		for (i=0;i<tmp.length;i++) {
			if (tmp[i].indexOf('cont')>-1) {
				test1=tmp[i].split('=')[1]
				if (test1.length>0)
					continent=test1
			}
		}
	} 
}

function setControls() {
	document.getElementById('lowBoundaryValue').value=lowBoundary
	k=0
	switch (continent) {
		case 'europe':k=0;break;
		case 'namerica': k=1; break;
		case 'samerica': k=2; break;
		case 'australia': k=3; break;
		case 'mi_east':k=4;
	}
	document.getElementById('contValue').selectedIndex=k

}

function setProgressbar(n) {
	if (n)
		document.getElementById('progressbar').style.display=''
	else 
	document.getElementById('progressbar').style.display='none'
}

