<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   xmlns:common="port.common.*"
			   xmlns:AdvancedDataGrid="com.AdvancedDataGrid.*"
			   xmlns:SubClasses="com.AdvancedDataGrid.SubClasses.*"
			   width="400" height="210" borderVisible="false" close="closeWindow(event)" 
			    fontFamily="宋体" fontSize="12"  
			   skinClass="com.skins.tdt.TitleWinHighSkin" title='船舶明细 - {(!ship.name||ship.name=="null")?"":ship.name}({ship.mmsi})' >
	<fx:Declarations>
		<!-- 将非可视元素（例如服务、值对象）放在此处 --> 
	</fx:Declarations>
	
	<fx:Script>
		<![CDATA[
			import com.xt.hb.utils.AisUtils;
			import com.xt.hb.utils.CommonUtility;
			import com.xt.hb.utils.CommonUtils;
			import com.xt.hb.utils.MapUtils;
			
			import mx.core.FlexGlobals;
			import mx.events.CloseEvent;
			private var _ship:Object = null ;
			public static var locusPanel:LocusQueryPanel =  new LocusQueryPanel();
			 
			[Bindable]
			public function get ship():Object{
				return _ship;
			}
			public function set ship(value:Object):void{
				_ship = value;
				locusPanel.ship = value ;
				dispatchEvent(new Event("shipChanged"));
			}
			[Bindable(event="shipChanged")]
			public function shipType():String{
				var code:String =  ship["ship_type"] ;
				return AisUtils.getCbhwlxByCode(code.charAt(0));
			}
			[Bindable(event="shipChanged")]
			public function formatTime():String{
				var date:Date = new Date(Number(ship["time"])*1000);
				return CommonUtils.formatDate(date);
			}
			//查询并且显示轨迹和面板
			public static function queryAndViewLocusPanel(ship:Object,param:Object):void{
				locusPanel.ship = ship;
				//显示弹出层
				addLocusPanelToPopLayer();
				//小时查询
				if(param["type"]=="hour"){
					locusPanel.hourQuery(param);
				}else{
					locusPanel.dayQuery(param);
				}
			}
			protected function showTrace(event:MouseEvent):void{
				addLocusPanelToPopLayer();
			}
			
			public static function addLocusPanelToPopLayer():void{
				var x:int =FlexGlobals.topLevelApplication.width-850;
				var y:int =FlexGlobals.topLevelApplication.height-280 ;
				if(!locusPanel)
					locusPanel = new LocusQueryPanel();
				CommonUtility.showTitleWindow(locusPanel,false,x,y); 
			}
			
			protected function clearShipLocus(event:MouseEvent):void{
				if(locusPanel==null){
					return ;
				}
				locusPanel.clearLocusFeature();
				
			}
			protected function closeWindow(event:CloseEvent):void{
				MapUtils.getShipPopWin().removeAllChildren();
				//解除聚焦闪烁
				MapUtils.clearAISGraphic();
			}
		]]>
	</fx:Script>
	<mx:VBox width="100%" height="100%" backgroundColor="#F0F0F0"  borderVisible="false" horizontalGap="0" verticalGap="0">
		<s:Spacer width="8"/>
		<mx:VBox width="100%">	
			<mx:Grid width="100%" borderVisible="false" horizontalGap="0" verticalGap="0" >
				<mx:GridRow height="3" />
				<mx:GridRow height="16" >
					<mx:GridItem width="100"><s:Spacer width="2" /><s:Label  text="船舶名称：" /></mx:GridItem>
					<mx:GridItem width="100"><s:Label color="#3A00FF" text="{ship.name}" toolTip="{ship.name}" /></mx:GridItem>
					<mx:GridItem width="100"><s:Label  text="MMSI：" /></mx:GridItem>
					<mx:GridItem width="100"><s:Label color="#3A00FF"  text="{ship.mmsi}" /></mx:GridItem>
				</mx:GridRow>
				<mx:GridRow height="16">
					<mx:GridItem ><s:Spacer width="2" /><s:Label  text="是否危险品船舶：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF"  text='{ship.danger=="1"?"是":"否"}'/></mx:GridItem>
					<mx:GridItem ><s:Label text="船舶以及货物类型：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ shipType()}" /></mx:GridItem>
				</mx:GridRow>
				<mx:GridRow height="16">
					<mx:GridItem ><s:Spacer width="2" /><s:Label text="航行状态：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text='{ship.status}' /></mx:GridItem>
					<mx:GridItem ><s:Label  text="航行速度（kts）：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text='{ship.speed}' /></mx:GridItem>
				</mx:GridRow>
				<mx:GridRow height="16">

					<mx:GridItem ><s:Spacer width="2" /><s:Label  text="目的港：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ship.dest}" /></mx:GridItem>
					<mx:GridItem ><s:Label  text="预计到港时间：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text='{CommonUtils.formatETA(ship.eta)}' /></mx:GridItem>
					
				</mx:GridRow>
				<mx:GridRow height="16">
					<mx:GridItem ><s:Spacer width="2" /><s:Label  text="船长（米）：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ship.length}" /></mx:GridItem>
					<mx:GridItem ><s:Label   text="船宽（米）：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ship.width}" /></mx:GridItem>
				</mx:GridRow>
				<mx:GridRow height="16">
					<mx:GridItem ><s:Spacer width="2" /><s:Label  text="航迹向（度）：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ship.course}" /></mx:GridItem>
					<mx:GridItem ><s:Label  text="呼号：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ship.callsign}" /></mx:GridItem>
				</mx:GridRow>
				<mx:GridRow height="16">
					<mx:GridItem ><s:Spacer width="2" /><s:Label  text="船旗：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ship.flag}" /></mx:GridItem>
					<mx:GridItem ><s:Label   text="建造时间：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ship.build}" /></mx:GridItem>
				</mx:GridRow>
				<mx:GridRow height="16">
					<mx:GridItem ><s:Spacer width="2" /><s:Label   text="船籍港：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ship.port}" /></mx:GridItem>
					<mx:GridItem ><s:Label   text="船舶IMO：" /></mx:GridItem>
					<mx:GridItem ><s:Label  color="#3A00FF" text="{ship.imo}" /></mx:GridItem>
				</mx:GridRow>
				<mx:GridRow height="16">
					<mx:GridItem ><s:Spacer width="2" /><s:Label  text="信号时间：" /></mx:GridItem>
					<mx:GridItem colSpan="3" ><s:Label color="#3A00FF"  text="{formatTime()}" /></mx:GridItem>
				</mx:GridRow>
			</mx:Grid>
		</mx:VBox>
		<s:Group >
			<s:Line width="100%"  xFrom="0" xTo="400" yFrom="0" yTo="0"  >
				<s:stroke>
					<s:SolidColorStroke color="#4AA2DF" weight="1" caps="square"/>
				</s:stroke>
			</s:Line>				
		</s:Group>
		<mx:HBox width="100%" height="30" backgroundColor="#F0F0F0"   verticalAlign="middle" horizontalGap="5" verticalGap="0"  borderVisible="false">
			<s:Spacer width="200"/>
			<mx:LinkButton label="绘制轨迹"  fontWeight="bold" fontSize="14"    color="#2f6ea1"  rollOverColor="#FEB355" buttonMode="true" useHandCursor="true"  click="showTrace(event)" />
			<s:Spacer width="8"/>
			<mx:LinkButton label="清除轨迹" fontWeight="bold" fontSize="14"  color="#2f6ea1" rollOverColor="#FEB355" buttonMode="true" useHandCursor="true" click="clearShipLocus(event)" />
		</mx:HBox>	
	</mx:VBox>
</s:TitleWindow>
