var mapplet;
var departureIcon;
var destinationIcon;

function initMapplet(){
    mapplet=document.applets.mapplet;
}

function setCenter(lon,lat){
    if(''==lon||''==lat) return;
    mapplet.setCenter(lon,lat);
    mapplet.update();
}


function setDestination(lonText,latText){
    if(null!=destinationIcon)
        mapplet.removeIcon(destinationIcon);
    var lon=mapplet.getLongitude();
    var lat=mapplet.getLatitude();
    lonText.value=lon;
    latText.value=lat;
    destinationIcon=mapplet.setIcon('10002',lon,lat,'',null,true,false,4);
    mapplet.update();
}

function setRoute(x1,y1,x2,y2,xtype){
	
	if(null!=departureIcon)   mapplet.removeIcon(departureIcon);
    if(null!=destinationIcon) mapplet.removeIcon(destinationIcon);	
	destinationIcon=mapplet.setIcon('0',x2,y2,'',null,true,false,4);
	departureIcon=mapplet.setIcon('10005',x1,y1,'',null,true,false,4); 	
    mapplet.removeAllRoutes();
    mapplet.setRoute(departureIcon,'','',destinationIcon,'','','','','','',xtype,'',255,0,0);
    
    setCenter(x1,y1)
    
    mapplet.update();
}

function setRouteWalk(slon,slat,elon,elat){
    mapplet.removeAllRoutes();
    mapplet.setCenter(slon,slat);
    if(null!=departureIcon)
        mapplet.removeIcon(departureIcon);
    departureIcon=mapplet.setIcon('10005',slon,slat,'',null,true,false,4);
    if(null!=destinationIcon)
        mapplet.removeIcon(destinationIcon);
    destinationIcon=mapplet.setIcon('10006',elon,elat,'',null,true,false,4);
    mapplet.setRoute(departureIcon,'','',destinationIcon,'','','','','','',255,'',0,255,0);
    mapplet.update();
}

function aroundStation(){
    mapplet.removeAllIcons();
    mapplet.removeAllRoutes();
    mapplet.update();
    window.route.location.href='AroundStation.do?sx='+mapplet.getLongitude()+'&sy='+mapplet.getLatitude();
}

function cleanRoute(){
	mapplet.removeAllRoutes();
	mapplet.update();
}

function  sendMail(wwidth , hheight){
	
	var scale = mapplet.getScale();
	var zoom  = mapplet.getZoom() ;
    var lon=mapplet.getLongitude();
    var lat=mapplet.getLatitude();
	var mailurl ;
	
	mailurl = 'http://61.221.67.162/asp/lib/sendMail.html?' +  'scale='  + scale + '&zoom=' + zoom + '&lon=' + lon + '&lat=' + lat +'&h=' + hheight + '&w=' +wwidth  ;
 	
  	window.open(mailurl,'Mail','width=400,height=400');
	//alert ( mailurl) ;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

