;(function(z){if(!Renative){return}try{z=jQuery}catch(e){z=function(){}}var T=Renative.lang.Type;var D=T.define;var A=Renative.framework.Sys;var B=A.Web;var C=Packagetrackr;var E=C.Track;var F=E.PackageStatusCode;var G=C.Utility;var H=G.Track;var I=G.trycatch;var J=E.sub("Maps").def(function(){var s=null;var t=function(){this.init=T.Function.ID;this.rendering=T.Function.ID;this.updateContainer=T.Function.ID};this.IMapper=t;var u=D.Class(function(){var b=null,mapSettings=null;this.data=function(){if(arguments.length===0){return b}else{b=arguments[0]}};this.settings=function(){if(arguments.length===0){return mapSettings}else{mapSettings=arguments[0]}};this.ctor=function(a){mapSettings=a}});this.MapperBase=u;var v=D.Class(function(j){var k=this,settings,onRenderCompleted=null,gms,map,geocoder,current,mapZoomControl=null,largeMapZoomControl=null,smallMapZoomControl=null,container=null,addOverlaysRunning=false,smallMap=true;var m=function(a){if(!current){return}if(addOverlaysRunning){return}addOverlaysRunning=true;map.clearOverlays();var i=0,stations=current.stations,l=stations.length,sl=l,station,point=null,pmarker=null,loc=0,bounds=new gms.LatLngBounds(),polylines=[],markers=[];for(;i<l;i++){station=stations[i];if(station.point){polylines.push(station.point);bounds.extend(station.point);markers.push(station.marker);loc+=1}}if(a){map.setCenter(bounds.getCenter(),(loc==1)?6:map.getBoundsZoomLevel(bounds),G_NORMAL_MAP);map.savePosition()}var b=map.getZoom();var c=0.00008*Math.pow(2,(19-b));l=markers.length;for(i=0;i<l;i++){map.addOverlay(markers[i])}l=polylines.length;if(l>=1){if(current.statusCode===F.DL){point=polylines[l-1];pmarker=new gms.Marker(new gms.Point(point.x+c,point.y),{"icon":settings.icons["ppackage"].marker,"title":"Package"});map.addOverlay(pmarker);p(pmarker,stations[sl-1].info,sl-1,false)}else if(current.statusCode===F.EP){point=polylines[l-1];pmarker=new gms.Marker(new gms.Point(point.x+c,point.y),{"icon":settings.icons["exception"].marker,"title":"Expired"});map.addOverlay(pmarker);p(pmarker,stations[sl-1].info,sl-1,false)}else if(current.statusCode===F.RS){}else{var d=null;if(stations[sl-1].dest&&l>1){map.addOverlay(new gms.Polyline([polylines[l-1],polylines[l-2]],"#00bfff",5,0.7));bounds=new gms.LatLngBounds();bounds.extend(polylines[l-1]);bounds.extend(polylines[l-2]);if(a){map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds),G_NORMAL_MAP);b=map.getZoom();c=0.00008*Math.pow(2,(19-b))}if(current.statusCode!==F.AS&&current.statusCode!==F.WP){d=bounds.getCenter()}else{d=polylines[l-2];d=new gms.Point(d.x+c,d.y)}polylines.splice(l-1,1)}else{d=polylines[l-1];d=new gms.Point(d.x+c,d.y)}if(current.statusCode===F.WP){var e=new gms.Marker(d,{"icon":settings.icons.ppackage.marker,"title":"Package"});map.addOverlay(e);p(e,stations[sl-1].info,sl-2,false)}else if(current.statusCode!==F.DE&&current.statusCode!==F.AP&&current.statusCode!==F.IR&&current.statusCode!==F.EP&&d!==null){var e=new gms.Marker(d,{"icon":settings.icons.transport.marker,"title":"Transporter"});map.addOverlay(e);p(e,stations[sl-1].info,sl-2,false)}}if(current.statusCode===F.AP||current.statusCode===F.IR){point=polylines[0];pmarker=new gms.Marker(new gms.Point(point.x+c,point.y),{"icon":settings.icons["ppackage"].marker,"title":"Package"});map.addOverlay(pmarker);p(pmarker,stations[sl-1].info,sl-1,false)}map.addOverlay(new gms.Polyline(polylines,"#4ba602",6,1))}onRenderCompleted(true,"rendering google maps done");addOverlaysRunning=false};var o=function(i){if(current.locationId!==i){current.locationId=i;var a=current.stations,l=a.length,bounds=new gms.LatLngBounds(),changed=false,cZoomlevel=map.getZoom();if(i!==undefined&&(-1<i<l)){var b=a[i].point;if(b){bounds.extend(b);changed=true;var c=(i===0||i<(l-1));while(-1<i<l){i=c?i+1:i-1;if(a[i]&&a[i].point){bounds.extend(a[i].point);break}}var d=map.getBoundsZoomLevel(bounds);var e=0.00065*Math.pow(2,(19-d));var f=new gms.LatLng(b.y-e,b.x+e);var g=new gms.LatLng(b.y+e,b.x-e);bounds.extend(f);bounds.extend(g);var h=map.getBoundsZoomLevel(bounds);cZoomlevel=h>cZoomlevel?h:cZoomlevel}}if(changed){map.setCenter(bounds.getCenter(),cZoomlevel,G_NORMAL_MAP)}}};var p=function(a,b,i,c){gms.Event.addListener(a,"click",function(){if(c){o(i)}q(a,b,true)})};var q=function(a,b,c){var d=a.getLatLng().x+"."+a.getLatLng().y;if(c||current.infoWindowXY!==d){current.infoWindowXY=d;a.openInfoWindowHtml(b,{"maxWidth":(map.getSize().width*0.75)})}};var r=function(b,c){if(current.completed===current.stations.length){m(true);return}if(!b){b=current.stations[current.completed];if(b.geoCode){r(b,b.geoCode)}else if(!T.String.isEmpty(b.address)){geocoder.setBaseCountryCode(b.location.country);geocoder.getLatLng(b.address,function(a){r(b,a)})}else{current.completed++;r()}}else{if(c){b.point=c;if(b.duplicate&&current.statusCode!=F.DL){try{for(var n in b.point){if(n!="x"&&b.point[n]==c.x){b.point.x=c.x+=0.005;b.point[n]=b.point.x}}}catch(ex){}}var d=new gms.Marker(b.point,{"icon":settings.icons[b.icon].marker,"title":b.address});b.marker=d;p(d,b.info,current.completed,true)}else{}current.completed++;r()}};this.rendering=function(b,c){I(function(){map.clearOverlays();map.checkResize();gms.Event.addListener(map,"zoomend",function(){m()});onRenderCompleted=c;current=b;b.completed=0;r()},function(a){c(false,"google map rendering failed!",a)})};this.showMapLocation=function(a){var b=current.stationsMapping[a];if(b>=0){var c=current.stations[b];if(c){var d=c.marker;if(d){o(b);q(d,c.info)}}}};this.updateContainer=function(){map.checkResize();var a=0;if(map.getSize().height<=300){if(!smallMap){a=1}}else{if(smallMap){a=2}}if(a>0){smallMap=!(a===2);map.removeControl(mapZoomControl);mapZoomControl=smallMap?smallMapZoomControl:largeMapZoomControl;map.addControl(mapZoomControl);m(true)}};this.getContainer=function(){return container};this.init=function(){var b=this;I(function(){s=k;settings=b.settings();gms=google.maps;if(typeof gms.Unload==="function"){settings.dispose(gms.Unload)}if(gms.BrowserIsCompatible()){container=settings.getContainer();if(!container){throw"can not load map container.";}map=new gms.Map2(container);map.setCenter(new gms.LatLng(0,0),1,G_NORMAL_MAP);map.enableScrollWheelZoom();geocoder=new gms.ClientGeocoder();largeMapZoomControl=new gms.LargeMapControl();smallMapZoomControl=new gms.SmallMapControl();mapZoomControl=map.getSize().height<300?smallMapZoomControl:largeMapZoomControl;map.addControl(mapZoomControl);map.addControl(new gms.MapTypeControl());map.enableContinuousZoom();var n,i,icon,icons=settings.icons;for(n in icons){i=icons[n];icon=new gms.Icon();icon.image=i.image;icon.iconSize=new gms.Size(i.w,i.h);icon.iconAnchor=new gms.Point(i.t,i.l);icon.infoWindowAnchor=new gms.Point(i.t,i.l);icon.shadow=i.shadow;icon.shadowSize=new gms.Size(i.sw,i.sh);i.marker=icon}}},function(a){settings.callback(false,"google maps initialize failed!",a)})}},u,t);this.GoolgeMapper=v;var w=function(d){if(!d){return}var e={},status=A.Enum.parse(F,d.statusCode),infoLine=function(a,b){return"<div style=\"padding:5px 0 0 5px;text-transform:uppercase;color:#444;font-size:95%;font-weight:bold;\">"+a+"</div><div style=\"color:#666;font-size:88%;padding-left:8px;\">"+b+"</div>"},getGeoAddr=function(a){var b=a.fullLocation;var c=Renative.lib.countryName[a.country]||"";if(!T.String.isEmpty(a.fullLocation)&&!T.String.isEmpty(a.country)&&!T.String.isEmpty(c)){b=b.replace(new RegExp("("+a.country+")$","i"),c)}return b};var f={};e.statusCode=status;var g=d.deliveryDate.display;var h=d.eSTDeliveryDate.display;var j=d.pickupDate.display;var k=d.origin;e.stations=[];e.stationsMapping={};var m=d.packageProgress,l=m.length,i=l,stations=e.stations,station,addr,last;if(l>0){i--;if(k&&!T.String.isEmpty(k.fullLocation)&&!k.hideMap){addr=getGeoAddr(k);last={location:k,geoCode:k.geoCode,address:addr,icon:"origin",rawInfo:[]};stations.push(last);f[last.location.fullLocation]=true}var n=[];for(;i>=0;i--){station=m[i];if(station){addr=getGeoAddr(station.location);if(station.location.hideMap){if(!T.String.isEmpty(addr)){addr=" - ["+addr+"]"}n.push(infoLine(station.description+addr,station.processDate.display))}else{if(last&&((last&&last.address)===addr)){last.rawInfo.push(infoLine(station.description,station.processDate.display))}else if(T.String.isEmpty(addr)){n.push(infoLine(station.description,station.processDate.display))}else{last={location:station.location,geoCode:station.location.geoCode,address:addr,icon:"transitstation",rawInfo:[]};if(n.length>0){last.rawInfo=n;n=[]}last.rawInfo.push(infoLine(station.description,station.processDate.display));if(f[last.location.fullLocation]){last.duplicate=true}else{f[last.location.fullLocation]=true}stations.push(last)}}}}if(e.statusCode===F.DE){last.icon="exception"}}if(d.destination&&!T.String.isEmpty(d.destination.fullLocation)){addr="";var o=true;if(d.destination.hideMap){if(last!=null){addr=last.address;if(e.statusCode===F.DL){last.icon="destination";last.dest=true;o=false}}}else{addr=getGeoAddr(d.destination)}if(o){var p=last&&(last.address===addr);last={location:d.destination,geoCode:d.destination.geoCode,address:addr,icon:"destination",rawInfo:[],dest:true,duplicate:p};stations.push(last)}}if(last!=null){var q=d.processDate.display;if(!T.String.isEmpty(h)&&e.statusCode!==F.DE&&e.statusCode!==F.DL){q="<strong style=\"color:#777;\">Scheduled for: </strong>"+h}last.rawInfo.push(infoLine(d.statusDescription,d.onTimeMessage+"<br />"+q))}i=0;l=stations.length;for(;i<l;i++){stations[i].info="<div style=\"font-weight:bold;color:#333;\">"+stations[i].address+"</div>"+stations[i].rawInfo.reverse().join("");e.stationsMapping[stations[i].location.hash]=i}return e};var x=function(){return(s instanceof u)};this.activated=x;var y=function(c,d){var e=0;d=typeof d==="function"?d:function(){};if(!c){throw"map data invalid!";}var f=function(){var b=false;if(x()||e>=50){I(function(){var a=w(c);s.rendering(a,d);b=true},function(a){if(e>=50){d(false,"render maps retry >= 50",a)}})}if(!b){setTimeout(f,100);e++}};f()};this.rendering=y;this.updateContainer=function(){if(x()){s.updateContainer()}};this.showMapLocation=function(a){if(x()){s.showMapLocation(a)}};this.getContainer=function(){if(x()){return s.getContainer()}}})})();
;(function(){if(!Renative){return}Renative.lib={};Renative.lib.countryName={"AF":"AFGHANISTAN","AX":"ALAND ISLANDS","AL":"ALBANIA","DZ":"ALGERIA","AS":"AMERICAN SAMOA","AD":"ANDORRA","AO":"ANGOLA","AI":"ANGUILLA","AQ":"ANTARCTICA","AG":"ANTIGUA AND BARBUDA","AR":"ARGENTINA","AM":"ARMENIA","AW":"ARUBA","AU":"AUSTRALIA","AT":"AUSTRIA","AZ":"AZERBAIJAN","BS":"BAHAMAS","BH":"BAHRAIN","BD":"BANGLADESH","BB":"BARBADOS","BY":"BELARUS","BE":"BELGIUM","BZ":"BELIZE","BJ":"BENIN","BM":"BERMUDA","BT":"BHUTAN","BO":"BOLIVIA","BA":"BOSNIA AND HERZEGOVINA","BW":"BOTSWANA","BV":"BOUVET ISLAND","BR":"BRAZIL","IO":"BRITISH INDIAN OCEAN TERRITORY","BN":"BRUNEI DARUSSALAM","BG":"BULGARIA","BF":"BURKINA FASO","BI":"BURUNDI","KH":"CAMBODIA","CM":"CAMEROON","CA":"CANADA","CV":"CAPE VERDE","KY":"CAYMAN ISLANDS","CF":"CENTRAL AFRICAN REPUBLIC","TD":"CHAD","CL":"CHILE","CN":"CHINA","CX":"CHRISTMAS ISLAND","CC":"COCOS (KEELING) ISLANDS","CO":"COLOMBIA","KM":"COMOROS","CG":"CONGO","CD":"CONGO, THE DEMOCRATIC REPUBLIC OF THE","CK":"COOK ISLANDS","CR":"COSTA RICA","CI":"CÔTE D'IVOIRE","HR":"CROATIA","CU":"CUBA","CY":"CYPRUS","CZ":"CZECH REPUBLIC","DK":"DENMARK","DJ":"DJIBOUTI","DM":"DOMINICA","DO":"DOMINICAN REPUBLIC","EC":"ECUADOR","EG":"EGYPT","SV":"EL SALVADOR","GQ":"EQUATORIAL GUINEA","ER":"ERITREA","EE":"ESTONIA","ET":"ETHIOPIA","FK":"FALKLAND ISLANDS (MALVINAS)","FO":"FAROE ISLANDS","FJ":"FIJI","FI":"FINLAND","FR":"FRANCE","GF":"FRENCH GUIANA","PF":"FRENCH POLYNESIA","TF":"FRENCH SOUTHERN TERRITORIES","GA":"GABON","GM":"GAMBIA","GE":"GEORGIA","DE":"GERMANY","GH":"GHANA","GI":"GIBRALTAR","GR":"GREECE","GL":"GREENLAND","GD":"GRENADA","GP":"GUADELOUPE","GU":"GUAM","GT":"GUATEMALA","GG":"GUERNSEY","GN":"GUINEA","GW":"GUINEA-BISSAU","GY":"GUYANA","HT":"HAITI","HM":"HEARD ISLAND AND MCDONALD ISLANDS","VA":"HOLY SEE (VATICAN CITY STATE)","HN":"HONDURAS","HK":"HONG KONG","HU":"HUNGARY","IS":"ICELAND","IN":"INDIA","ID":"INDONESIA","IR":"IRAN, ISLAMIC REPUBLIC OF","IQ":"IRAQ","IE":"IRELAND","IM":"ISLE OF MAN","IL":"ISRAEL","IT":"ITALY","JM":"JAMAICA","JP":"JAPAN","JE":"JERSEY","JO":"JORDAN","KZ":"KAZAKHSTAN","KE":"KENYA","KI":"KIRIBATI","KP":"KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF","KR":"KOREA, REPUBLIC OF","KW":"KUWAIT","KG":"KYRGYZSTAN","LA":"LAO PEOPLE'S DEMOCRATIC REPUBLIC","LV":"LATVIA","LB":"LEBANON","LS":"LESOTHO","LR":"LIBERIA","LY":"LIBYAN ARAB JAMAHIRIYA","LI":"LIECHTENSTEIN","LT":"LITHUANIA","LU":"LUXEMBOURG","MO":"MACAO","MK":"MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF","MG":"MADAGASCAR","MW":"MALAWI","MY":"MALAYSIA","MV":"MALDIVES","ML":"MALI","MT":"MALTA","MH":"MARSHALL ISLANDS","MQ":"MARTINIQUE","MR":"MAURITANIA","MU":"MAURITIUS","YT":"MAYOTTE","MX":"MEXICO","FM":"MICRONESIA, FEDERATED STATES OF","MD":"MOLDOVA, REPUBLIC OF","MC":"MONACO","MN":"MONGOLIA","ME":"MONTENEGRO","MS":"MONTSERRAT","MA":"MOROCCO","MZ":"MOZAMBIQUE","MM":"MYANMAR","NA":"NAMIBIA","NR":"NAURU","NP":"NEPAL","NL":"NETHERLANDS","AN":"NETHERLANDS ANTILLES","NC":"NEW CALEDONIA","NZ":"NEW ZEALAND","NI":"NICARAGUA","NE":"NIGER","NG":"NIGERIA","NU":"NIUE","NF":"NORFOLK ISLAND","MP":"NORTHERN MARIANA ISLANDS","NO":"NORWAY","OM":"OMAN","PK":"PAKISTAN","PW":"PALAU","PS":"PALESTINIAN TERRITORY, OCCUPIED","PA":"PANAMA","PG":"PAPUA NEW GUINEA","PY":"PARAGUAY","PE":"PERU","PH":"PHILIPPINES","PN":"PITCAIRN","PL":"POLAND","PT":"PORTUGAL","PR":"PUERTO RICO","QA":"QATAR","RE":"RÉUNION","RO":"ROMANIA","RU":"RUSSIAN FEDERATION","RW":"RWANDA","BL":"SAINT BARTHÉLEMY","SH":"SAINT HELENA","KN":"SAINT KITTS AND NEVIS","LC":"SAINT LUCIA","MF":"SAINT MARTIN","PM":"SAINT PIERRE AND MIQUELON","VC":"SAINT VINCENT AND THE GRENADINES","WS":"SAMOA","SM":"SAN MARINO","ST":"SAO TOME AND PRINCIPE","SA":"SAUDI ARABIA","SN":"SENEGAL","RS":"SERBIA","SC":"SEYCHELLES","SL":"SIERRA LEONE","SG":"SINGAPORE","SK":"SLOVAKIA","SI":"SLOVENIA","SB":"SOLOMON ISLANDS","SO":"SOMALIA","ZA":"SOUTH AFRICA","GS":"SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS","ES":"SPAIN","LK":"SRI LANKA","SD":"SUDAN","SR":"SURINAME","SJ":"SVALBARD AND JAN MAYEN","SZ":"SWAZILAND","SE":"SWEDEN","CH":"SWITZERLAND","SY":"SYRIAN ARAB REPUBLIC","TW":"TAIWAN, PROVINCE OF CHINA","TJ":"TAJIKISTAN","TZ":"TANZANIA, UNITED REPUBLIC OF","TH":"THAILAND","TL":"TIMOR-LESTE","TG":"TOGO","TK":"TOKELAU","TO":"TONGA","TT":"TRINIDAD AND TOBAGO","TN":"TUNISIA","TR":"TURKEY","TM":"TURKMENISTAN","TC":"TURKS AND CAICOS ISLANDS","TV":"TUVALU","UG":"UGANDA","UA":"UKRAINE","AE":"UNITED ARAB EMIRATES","GB":"UNITED KINGDOM","UK":"UNITED KINGDOM","US":"UNITED STATES","UM":"UNITED STATES MINOR OUTLYING ISLANDS","UY":"URUGUAY","UZ":"UZBEKISTAN","VU":"VANUATU","VA":"VATICAN CITY STATE","VE":"VENEZUELA","VN":"VIET NAM","VG":"VIRGIN ISLANDS, BRITISH","VI":"VIRGIN ISLANDS, U.S.","WF":"WALLIS AND FUTUNA","EH":"WESTERN SAHARA","YE":"YEMEN","ZM":"ZAMBIA","ZW":"ZIMBABWE"}})();