
function Point2D(x,y){this.x=x;this.y=y;}
function MapImage(imgSrc,x,y){this.imgSrc=imgSrc;this.x=x;this.y=y;if(x==undefined||y==undefined){this.x=0;this.y=0;}
this.img=null;this.imgInit=false;this.loadImage=function(fadeIn,imgRef){this.img=new Image();if(fadeIn!=null&&fadeIn!=undefined&&imgRef!=null&&imgRef!=undefined){$(this.img).load(function(){$(this).hide();$(imgRef).fadeIn(fadeIn);});}
$(this.img).attr("src",this.imgSrc);this.imgInit=true;}}
function Route(srcRegionPorts,trgRegionPorts,transitTable,mapImage){this.srcRegionPorts=srcRegionPorts;this.trgRegionPorts=trgRegionPorts;this.arrivalDays=null;this.transitTable=null;this.mapImage=mapImage;this.addSourcePort=function(portName){if(this.srcRegionPorts==null){this.srcRegionPorts=new Array();}
this.srcRegionPorts.push(port);}
this.addTargetPort=function(portName){if(this.trgRegionPorts==null){this.trgRegionPorts=new Array();}
this.trgRegionPorts.push(port);}
this.setArrivalDays=function(strDays){if(this.trgRegionPorts!=null&&(this.trgRegionPorts.length==strDays.length)){this.arrivalDays=strDays;}}
this.setTransitTimeEntry=function(i,j,time){if(this.transitTable!=null){if(i>=0&&i<this.transitTable.length){var row=this.transitTable[i];if(j>=0&&j<row.length){row[j]=time;}}}}
this.initTransitTimeMatrix=function(){if(this.srcRegionPorts!=null&&this.trgRegionPorts!=null){this.transitTable=new Array(this.srcRegionPorts.length);for(i=0;i<this.transitTable.length;i++){var array=new Array(this.trgRegionPorts.length);for(j=0;j<array.length;j++)
array[j]="";this.transitTable[i]=array;}}}
this.setTransitTimeMatrix=function(matrix){var row=null;for(i=0;i<matrix.length;i++){row=matrix[i];for(j=0;j<row.length;j++)
this.setTransitTimeEntry(i,j,row[j]);}}
if(this.srcRegionPorts==null)
this.srcRegionPorts=new Array();if(this.trgRegionPorts==null)
this.trgRegionPorts=new Array();this.initTransitTimeMatrix();if(transitTable!=null){this.setTransitTimeMatrix(transitTable);}}
function Service(name,westboundRoute,eastboundRoute){this.name=name;this.fisCode=null;this.reverseDirectionCode=false;this.eastRoute=eastboundRoute;this.westRoute=westboundRoute;this.setFisCode=function(code,isReverseDirection){this.fisCode=code;if(isReverseDirection==true)
this.reverseDirectionCode=isReverseDirection;}
this.toString=function(){return this.name;}}
function ServiceMap(mapImage,regionFrom,regionTo,services){this.mapImage=mapImage;this.regionFrom=regionFrom;this.regionTo=regionTo;this.services=services;this.url=null;this.westbound=true;if(services==null||services==undefined){this.services=new Array();}
this.addService=function(service){if(this.services==null){this.services=new Array();}
this.services.push(service);}
this.setURL=function(url){this.url=url;}}
function WorldMap(mapImage,regions,serviceMaps){this.mapImage=mapImage;this.regions=regions;this.serviceMaps=serviceMaps;this.addServiceMap=function(serviceMap){if(this.serviceMaps==null){this.serviceMaps=new Array();}
this.serviceMaps.push(serviceMap);}}
function Messages(){this.MSG_SRC_REGION="1. Please select a source region...";this.MSG_TRG_REGION="2. Please select a target region...";this.MSG_WORLD_MAP_DEFAULT="Choose Regions:  ";this.MSG_WORLD_MAP_SELECTION_PRE="Choose Regions:  ";this.MSG_WORLD_MAP_NO_SELECTION_MIDDLE="  to  ";this.MSG_WORLD_MAP_TARGET_DEFAULT="...";this.MSG_WORLD_MAP_BTN_RESET_SELECTION="Reset Selection";this.MSG_SERVICE_MAP_BTN_DIRECTION_WEST="Switch Direction";this.MSG_SERVICE_MAP_BTN_DIRECTION_EAST="Switch Direction";this.MSG_SERVICE_MAP_BTN_SCHEDULE_SERVICE="Show Schedule by Service";this.MSG_SERVICE_MAP_BTN_SCHEDULE_REGION="Show Schedule by Region";this.MSG_SERVICE_MAP_BTN_RESET_SELECTION="Reset Selection";this.MSG_SERVICE_MAP_NO_SELECTION="Please select a service...";this.MSG_SERVICE_MAP_SERVICE_SELECTION="Please select a service...";this.MSG_SERVICE_MAP_HEADER_MAP_PRE="Chosen Regions:  ";this.MSG_SERVICE_MAP_HEADER_MAP_MIDDLE="  to  ";this.MSG_SERVICE_MAP_TABLE_FROM_TO="From/To";this.MSG_SERVICE_MAP_SCHEDULE_SELECTION_REGION="Go to interactive schedule with your selected regions or service";this.MSG_SERVICE_MAP_SCHEDULE_SELECTION_SERVICE="Go to interactive schedule with your selected service or service";this.MSG_SERVICE_MAP_NO_SCHEDULE_LINK="This service is not available in the interactive schedule";}
function Region(id,name,mapImage){this.id=id;this.name=name;this.mapImage=mapImage;if(mapImage==undefined){this.mapImage=null;}
this.fisCode=null;this.setFisCode=function(code){this.fisCode=code;}
this.toString=function(){return this.name;}}
function ControllerWorldMap(){this.C_APP_PROD=0;this.C_APP_SMART_EDIT=1;this.C_NONE=0;this.C_SRC=1;this.C_TRG=2;this.C_FINISHED=3;this.C_WEST=0;this.C_EAST=1;this.C_PARAM_DIRECTION="dir";this.C_TARGET_REGION_ALPHA=0.1;this.worldMap=null;this.serviceMaps=null;this.regions=null;this.selectedSrcRegion=null;this.selectedTrgRegion=null;this.targets=new Array();this.msg=new Messages();this.appMode=this.C_APP_PROD;this.selectMode=this.C_SRC;this.ajaxLoader=null;this.guiStatusField="div#grfStatusLine";this.guiMapContainer=new GuiMapContainer("div#grfMapContainer",this.worldMap);this.guiList=new GuiList("ul#grfNavi");this.guiBtnResetSelection="input#btnResetSelection";this.guiMapHeadSingleText="h2#mapSingleText";this.init=function(worldMap){this.worldMap=worldMap;this.serviceMaps=worldMap.serviceMaps;this.regions=worldMap.regions;this.guiMapContainer.setEventListener(this);this.guiMapContainer.init();this.guiMapContainer.setWorldMap(worldMap);this.guiMapContainer.loadWorldMap();this.guiList.setEventListener(this);this.guiList.init();this.guiList.setEntries(this.regions);this.setStatusLineText(this.msg.MSG_SRC_REGION);this.setMapHeaderText(this.msg.MSG_WORLD_MAP_DEFAULT);$(this.guiBtnResetSelection).attr("value",this.msg.MSG_WORLD_MAP_BTN_RESET_SELECTION);$(this.guiBtnResetSelection).hide();}
this.evtGuiBtnResetSelectionClick=function(){this.deselectAllRegions();}
this.evtGuiListHoverIn=function(){}
this.evtGuiListHoverOut=function(){}
this.evtGuiListEntryHoverIn=function(index,object){if(this.selectMode!=this.C_FINISHED){this.handleRegionHoverIn(index,this.regions[index]);}}
this.evtGuiListEntryHoverOut=function(index,object){if(this.selectMode!=this.C_FINISHED){this.handleRegionHoverOut(index,this.regions[index]);}}
this.evtGuiListEntryClick=function(event,index,object){if(this.selectMode!=this.C_FINISHED){this.handleRegionClick(event,index,this.regions[index]);}}
this.evtGuiMapContainerHoverIn=function(index,srcType,object){if(srcType==this.guiMapContainer.C_REGION){if(this.selectMode!=this.C_FINISHED){this.handleRegionHoverIn(index,object);}}}
this.evtGuiMapContainerHoverOut=function(index,srcType,object){if(srcType==this.guiMapContainer.C_REGION){if(this.selectMode!=this.C_FINISHED){this.handleRegionHoverOut(index,object);}}}
this.evtGuiMapContainerClick=function(event,index,srcType,object){if(this.selectMode!=this.C_FINISHED){if(srcType==this.guiMapContainer.C_REGION){this.handleRegionClick(event,index,object);}
else if(srcType==this.guiMapContainer.C_BASE_MAP){this.deselectAllRegions();}}}
this.handleRegionHoverIn=function(index,region){if(this.selectMode==this.C_SRC){this.guiMapContainer.showRegion(index);this.guiList.highlightEntry(index);}
else if(this.selectMode==this.C_TRG){var contained=false;for(i=0;i<this.targets.length;i++){if(this.targets[i]==region)
contained=true;}
if(contained){this.guiMapContainer.showRegion(index);this.guiList.highlightEntry(index);this.setMapHeaderText(this.msg.MSG_WORLD_MAP_SELECTION_PRE+this.selectedSrcRegion.name+
this.msg.MSG_WORLD_MAP_NO_SELECTION_MIDDLE+region.name);}}}
this.handleRegionHoverOut=function(index,region){if(this.selectMode!=this.C_TRG){this.guiMapContainer.hideRegion(index);this.guiList.unhighlightEntry(index);}
else if(this.selectMode==this.C_TRG){var contained=false;for(i=0;i<this.targets.length;i++){if(this.targets[i]==region)
contained=true;}
if(contained&&this.selectedSrcRegion!=region){this.guiMapContainer.showTransparentRegion(index,this.C_TARGET_REGION_ALPHA);this.guiList.unhighlightEntry(index);}
this.setMapHeaderText(this.msg.MSG_WORLD_MAP_SELECTION_PRE+this.selectedSrcRegion.name+
this.msg.MSG_WORLD_MAP_NO_SELECTION_MIDDLE+
this.msg.MSG_WORLD_MAP_TARGET_DEFAULT);}}
this.handleRegionClick=function(event,index,region){if(this.selectMode==this.C_SRC){this.selectMode=this.C_TRG;this.selectedSrcRegion=region;this.setStatusLineText(this.msg.MSG_TRG_REGION);this.guiList.selectEntry(index);$(this.guiBtnResetSelection).show();this.setMapHeaderText(this.msg.MSG_WORLD_MAP_SELECTION_PRE+region.name+
this.msg.MSG_WORLD_MAP_NO_SELECTION_MIDDLE+
this.msg.MSG_WORLD_MAP_TARGET_DEFAULT);this.guiMapContainer.showRegion(index);var reg=null;for(i=0;i<this.targets.length;i++){this.targets[i]=null;}
for(i=0;i<this.serviceMaps.length;i++){if(this.serviceMaps[i].regionFrom==this.selectedSrcRegion){this.targets.push(this.serviceMaps[i].regionTo);}
else if(this.serviceMaps[i].regionTo==this.selectedSrcRegion){this.targets.push(this.serviceMaps[i].regionFrom);}}
for(i=0;i<this.regions.length;i++){reg=this.regions[i];if(index!=i){this.guiList.disableEntry(i);}}
var intraRegion=false;for(t=0;t<this.targets.length;t++){var tindex=this.getRegionIndex(this.targets[t]);if(this.selectedSrcRegion!=this.targets[t]){this.guiMapContainer.showTransparentRegion(tindex,this.C_TARGET_REGION_ALPHA);this.guiList.enableEntry(tindex);}
else if(this.selectedSrcRegion==this.targets[t])
intraRegion=true;}
if(intraRegion){this.setMapHeaderText(this.msg.MSG_WORLD_MAP_SELECTION_PRE+this.selectedSrcRegion.name+
this.msg.MSG_WORLD_MAP_NO_SELECTION_MIDDLE+this.selectedSrcRegion.name);}}
else if(this.selectMode==this.C_TRG){var contained=false;for(x=0;x<this.targets.length;x++){if(this.targets[x]==region)
contained=true;}
if(!(this.selectedSrcRegion==region)||contained){this.selectMode=this.C_SRC;this.selectedTrgRegion=region;for(t=0;t<this.targets.length;t++){if(this.targets[t]!=this.selectedTrgRegion){var tindex=this.getRegionIndex(this.targets[t]);this.guiMapContainer.hideRegion(tindex);}}
var sMap=null;for(i=0;i<this.serviceMaps.length;i++){if((this.serviceMaps[i].regionFrom==this.selectedSrcRegion&&this.serviceMaps[i].regionTo==this.selectedTrgRegion)||(this.serviceMaps[i].regionTo==this.selectedSrcRegion&&this.serviceMaps[i].regionFrom==this.selectedTrgRegion)){sMap=this.serviceMaps[i];}}
if(sMap!=null){this.selectMode=this.C_FINISHED;this.guiMapContainer.showRegion(index);this.guiMapContainer.showRegion(this.getRegionIndex(this.selectedSrcRegion));if(this.selectedSrcRegion==sMap.regionFrom){this.dispatchServiceMap(sMap,this.C_EAST);}
else{this.dispatchServiceMap(sMap,this.C_WEST);}}
else{this.selectMode=this.C_TRG;this.selectedTrgRegion=null;this.deselectAllRegions();}}}}
this.getRegionIndex=function(region){for(i=0;i<this.regions.length;i++){if(this.regions[i]==region){return i;}}
return-1;}
this.setStatusLineText=function(messageText){}
this.setMapHeaderText=function(messageText){$(this.guiMapHeadSingleText).text(messageText);}
this.deselectAllRegions=function(){for(i=0;i<this.regions.length;i++){this.guiList.unselectEntry(i);this.guiMapContainer.hideRegion(i);this.guiList.enableEntry(i);}
this.selectMode=this.C_SRC;this.selectedSrcRegion=null;this.selectedTrgRegion=null;this.setStatusLineText(this.msg.MSG_SRC_REGION);this.setMapHeaderText(this.msg.MSG_WORLD_MAP_DEFAULT);$(this.guiBtnResetSelection).hide();}
this.dispatchServiceMap=function(serviceMap,direction){var dir="";var service="none";if(direction==this.C_WEST){dir+="west";}
else{dir+="east";}
document.location=serviceMap.url+'#'+service+'_'+dir;}
this.setMessages=function(msgObject){this.msg=msgObject;}}
function ControllerServiceMap(){this.C_APP_PROD=0;this.C_APP_SMART_EDIT=1;this.C_WEST=0;this.C_EAST=1;this.C_PARAM_DIRECTION="dir";this.C_PARAM_SERVICE="service";this.C_PARAM_VAL_DIRECTION_EAST="east";this.C_PARAM_VAL_DIRECTION_WEST="west";this.C_SMART_EDIT_PARAM_DIRECTION="dir";this.C_SMART_EDIT_PARAM_SERVICE="service";this.C_ANIM_SERVICE_CLICK_FADE_OUT_IN=300;this.C_ANIM_SERVICE_DIRECTION_CHANGE=600;this.currentServiceMap=null;this.services=null;this.selectedService=null;this.lastSelectedServiceIndex=0;this.direction=this.C_WEST;this.disabledServices=new Array();this.urlWorldMap=null;this.urlSchedule="http://fisworkweb.ad.hl.lan/en/schedules/interactive.html?view=V7060";this.msg=new Messages();this.appMode=this.C_APP_PROD;this.guiStatusField="div#grfStatusLine";this.guiMapContainer=new GuiMapContainer("div#grfMapContainer",null);this.guiList=new GuiList("ul#grfNavi");this.guiBtnDirection="input#btnDirection";this.guiBtnResetSelection="input#btnResetSelection";this.guiBtnSchedule="input#btnSchedule";this.guiScheduleBox="div#schedule";this.guiMapHeader="div#grfMapHeader";this.guiMapHeadSingleText="h2#mapSingleText";this.guiTransitTableContainer="div#grfTransitTables";this.guiTableHeader="div#grfTableHeader";this.guiTable=new GuiTable("table#transit");this.guiTableHeadArrowWest="div#tableArrowWest";this.guiTableHeadArrowEast="div#tableArrowEast";this.guiTableHeadRegionFrom="div#tableRegionFrom";this.guiTableHeadRegionTo="div#tableRegionTo";this.guiTableInfo="div#tableInfo";this.guiTableInfoComment="div#tableInfoComment";this.guiTableInfoUpdate="div#tableInfoUpdate";this.guiServiceInfo="div#serviceInfo";this.init=function(serviceMap,direction,smartEdit,htmlBaseMap){this.enableSmartEditMode(smartEdit);if(direction==this.C_WEST||direction==this.C_EAST){this.direction=direction;}
var paramDirection=null;var paramService=this.getURLParam(this.C_PARAM_SERVICE);paramDirection=this.getURLParam(this.C_PARAM_DIRECTION);var hashVal=this.getURLHash();if(hashVal!=null){var params=hashVal.substring(1).split("_");paramService=params[0];paramDirection=params[1];}
if(this.appMode==this.C_APP_SMART_EDIT){paramService=this.readCookie(this.C_SMART_EDIT_PARAM_SERVICE);paramDirection=this.readCookie(this.C_SMART_EDIT_PARAM_DIRECTION);}
this.currentServiceMap=serviceMap;this.services=serviceMap.services;if(this.services==null){this.services=new Array();}
this.disabledServices=new Array(this.services.length);this.selectedService=null;this.guiMapContainer.setEventListener(this);this.guiMapContainer.init();if(paramDirection==this.C_PARAM_VAL_DIRECTION_EAST){this.direction=this.C_EAST;this.guiMapContainer.setServiceMap(serviceMap,this.guiMapContainer.C_EASTBOUND,htmlBaseMap);}
else if(paramDirection==this.C_PARAM_VAL_DIRECTION_WEST){this.direction=this.C_WEST;this.guiMapContainer.setServiceMap(serviceMap,this.guiMapContainer.C_WESTBOUND,htmlBaseMap);}
else{if(this.direction==this.C_WEST)
this.guiMapContainer.setServiceMap(serviceMap,this.guiMapContainer.C_WESTBOUND,htmlBaseMap);else
this.guiMapContainer.setServiceMap(serviceMap,this.guiMapContainer.C_EASTBOUND,htmlBaseMap);}
var index=-1;if(paramService!=null){if(this.appMode==this.C_APP_SMART_EDIT){if(paramService>=0&&paramService<this.services.length){this.selectedService=this.services[paramService];index=paramService;}}
else{for(i=0;i<this.services.length;i++){if(paramService.toString().toLowerCase()==this.services[i].fisCode.toString().toLowerCase()){this.selectedService=this.services[i];index=i;}}}}
this.guiList.setEventListener(this);this.guiList.setEntries(this.services);this.setStatusLineMessage(this.msg.MSG_SERVICE_MAP_NO_SELECTION);this.setScheduleBoxMessage(this.msg.MSG_SERVICE_MAP_SCHEDULE_SELECTION_REGION);$(this.guiBtnSchedule).attr("value",this.msg.MSG_SERVICE_MAP_BTN_SCHEDULE_REGION);$(this.guiTransitTableContainer).hide();this.guiTable.init(0,0);$(this.guiBtnResetSelection).css("visibility","hidden");$(this.guiBtnResetSelection).attr("value",this.msg.MSG_SERVICE_MAP_BTN_RESET_SELECTION);this.guiMapContainer.showServiceMap();this.guiList.show();this.showDirectionStatus(this.direction,serviceMap);if(this.selectedService!=null){if(!this.disabledServices[index]){this.setScheduleBoxMessage(this.msg.MSG_SERVICE_MAP_SCHEDULE_SELECTION_SERVICE);$(this.guiBtnSchedule).attr("value",this.msg.MSG_SERVICE_MAP_BTN_SCHEDULE_SERVICE);this.guiList.selectEntry(index);this.guiMapContainer.showService(index);this.setTransitTable(index);$(this.guiBtnResetSelection).css("visibility","visible");$(this.guiTransitTableContainer).fadeIn(80);if(this.appMode==this.C_APP_SMART_EDIT){var elem="div#smartedit_"+index;$(elem).show();}}
else{if(this.appMode==this.C_APP_SMART_EDIT){this.setScheduleBoxMessage(this.msg.MSG_SERVICE_MAP_SCHEDULE_SELECTION_SERVICE);$(this.guiBtnSchedule).attr("value",this.msg.MSG_SERVICE_MAP_BTN_SCHEDULE_SERVICE);this.guiList.selectEntry(index);this.handleDirectionChangeClick();$(this.guiBtnResetSelection).css("visibility","visible");$(this.guiTransitTableContainer).fadeIn(80);var elem="div#smartedit_"+index;$(elem).show();}
else{this.selectedService=null;}}}}
this.setSmartEditParam=function(serviceCookieName){this.C_SMART_EDIT_PARAM_SERVICE=serviceCookieName;}
this.getURLParam=function(strParamName){var strReturn="";var strHref=window.location.href;var bFound=false;var cmpstring=strParamName+"=";var cmplen=cmpstring.length;if(strHref.indexOf("?")>-1){var strQueryString=strHref.substr(strHref.indexOf("?")+1);var aQueryString=strQueryString.split("&");for(var iParam=0;iParam<aQueryString.length;iParam++){if(aQueryString[iParam].substr(0,cmplen)==cmpstring){var aParam=aQueryString[iParam].split("=");strReturn=aParam[1];bFound=true;break;}}}
if(bFound==false)
return null;return strReturn;}
this.getURLHash=function(){var hash=document.location.hash;if(hash!=null&&hash!=undefined&&hash!="")
return hash;else
return null;}
this.showDirectionStatus=function(direction,serviceMap){if(direction==this.C_WEST){if(serviceMap.regionFrom!=null&&serviceMap.regionTo!=null){$(this.guiMapHeadSingleText).text(this.msg.MSG_SERVICE_MAP_HEADER_MAP_PRE+
serviceMap.regionTo.name+
this.msg.MSG_SERVICE_MAP_HEADER_MAP_MIDDLE+
serviceMap.regionFrom.name);}
$(this.guiTableHeadRegionFrom).text(serviceMap.regionFrom.name);$(this.guiTableHeadRegionTo).text(serviceMap.regionTo.name);$(this.guiTableHeadArrowWest).show();$(this.guiTableHeadArrowEast).hide();$(this.guiBtnDirection).attr("value",this.msg.MSG_SERVICE_MAP_BTN_DIRECTION_WEST);for(i=0;i<this.services.length;i++){this.disabledServices[i]=false;if(this.services[i].westRoute==null){this.disabledServices[i]=true;this.guiList.disableEntry(i);}
else{this.guiList.enableEntry(i);}}}
else if(direction==this.C_EAST){var text=serviceMap.regionFrom.name+" to "+serviceMap.regionTo.name;if(serviceMap.regionFrom!=null&&serviceMap.regionTo!=null){$(this.guiMapHeadSingleText).text(this.msg.MSG_SERVICE_MAP_HEADER_MAP_PRE+
serviceMap.regionFrom.name+
this.msg.MSG_SERVICE_MAP_HEADER_MAP_MIDDLE+
serviceMap.regionTo.name);}
$(this.guiTableHeadRegionFrom).text(serviceMap.regionFrom.name);$(this.guiTableHeadRegionTo).text(serviceMap.regionTo.name);$(this.guiTableHeadArrowWest).hide();$(this.guiTableHeadArrowEast).show();$(this.guiBtnDirection).attr("value",this.msg.MSG_SERVICE_MAP_BTN_DIRECTION_EAST);for(i=0;i<this.services.length;i++){this.disabledServices[i]=false;if(this.services[i].eastRoute==null){this.disabledServices[i]=true;this.guiList.disableEntry(i);}
else{this.guiList.enableEntry(i);}}}}
this.getServiceIndex=function(service){for(i=0;i<this.services.length;i++){if(this.services[i]==service){return i;}}
return-1;}
this.evtGuiListEntryHoverIn=function(index,object){this.handleServiceHoverIn(index,this.services[index]);}
this.evtGuiListEntryHoverOut=function(index,object){this.handleServiceHoverOut(index,this.services[index]);}
this.evtGuiListEntryClick=function(event,index,object){this.handleServiceClick(event,index,this.services[index]);}
this.evtGuiListHoverIn=function(){}
this.evtGuiListHoverOut=function(){if(this.selectedService==null){this.guiList.unhighlightEntry(this.lastSelectedServiceIndex);this.guiMapContainer.hideService(this.lastSelectedServiceIndex);$(this.guiTransitTableContainer).hide();$(this.guiServiceInfo).hide();}
else if(this.selectedService!=null){var index=this.getServiceIndex(this.selectedService);if(index!=this.lastSelectedServiceIndex){this.guiList.unhighlightEntry(this.lastSelectedServiceIndex);this.guiMapContainer.hideService(this.lastSelectedServiceIndex);this.guiMapContainer.showService(index);this.setTransitTable(index);}
this.lastSelectedServiceIndex=index;}}
this.evtGuiBtnResetSelectionClick=function(){this.deselectAllServices();}
this.evtGuiBtnBackToWorldmapClick=function(){if(this.urlWorldMap!=null){this.setURL(this.urlWorldMap);}}
this.evtGuiBtnDirectionChangeClick=function(){this.handleDirectionChangeClick();}
this.evtGuiMapContainerHoverIn=function(index,srcType,object){if(srcType==this.guiMapContainer.C_SERVICE){}}
this.evtGuiMapContainerHoverOut=function(index,srcType,object){if(srcType==this.guiMapContainer.C_SERVICE){}}
this.evtGuiMapContainerClick=function(event,index,srcType,object){if(srcType==this.guiMapContainer.C_SERVICE||srcType==this.guiMapContainer.C_BASE_MAP){}}
this.handleOnlineScheduleClick=function(){var url=null;if(this.selectedService==null&&this.currentServiceMap.regionFrom!=null&&this.currentServiceMap.regionTo!=null){var urlFilter="&filter=limitPortsByRegion";var urlLoadRegion="&loadRegion=";var urlDischargeRegion="&dischargeRegion=";if(this.guiMapContainer.serviceMode==this.guiMapContainer.C_WESTBOUND){url=this.urlSchedule+urlFilter+urlLoadRegion+
this.currentServiceMap.regionTo.fisCode+urlDischargeRegion+
this.currentServiceMap.regionFrom.fisCode;}
else{url=this.urlSchedule+urlFilter+urlLoadRegion+
this.currentServiceMap.regionFrom.fisCode+urlDischargeRegion+
this.currentServiceMap.regionTo.fisCode;}
this.setURL(url);}
else{if(this.selectedService.fisCode!=null){var urlFilter="&filter=limitPortsByService";var urlService="&service=";var urlDirection="&direction=";var west="w";var east="e";if(this.selectedService.reverseDirectionCode){west="e";east="w";}
if(this.guiMapContainer.serviceMode==this.guiMapContainer.C_WESTBOUND){url=this.urlSchedule+urlFilter+urlService+this.selectedService.fisCode
+urlDirection+west;}
else{url=this.urlSchedule+urlFilter+urlService+this.selectedService.fisCode
+urlDirection+east;}
this.setURLHashParams();this.setURL(url);}
else{alert(this.msg.MSG_SERVICE_MAP_NO_SCHEDULE_LINK);}}}
this.setURL=function(strURL){document.location=strURL;}
this.replaceURL=function(strURL){location.replace(strURL);}
this.setCookie=function(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
this.setURLHashParams=function(){var fisCode="none";if(this.selectedService!=null){if(this.selectedService.fisCode!=null&&this.selectedService.fisCode!=""){fisCode=this.selectedService.fisCode;}}
var hashVal="#"+fisCode+"_";if(this.direction==this.C_WEST)
hashVal+=this.C_PARAM_VAL_DIRECTION_WEST;else
hashVal+=this.C_PARAM_VAL_DIRECTION_EAST;this.replaceURL(hashVal);}
this.readCookie=function(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')
c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)
return c.substring(nameEQ.length,c.length);}
return null;}
this.enableSmartEditMode=function(enabled){if(enabled==true){this.appMode=this.C_APP_SMART_EDIT;}
else if(enabled==false){this.appMode=this.C_APP_PROD;this.setCookie(this.C_PARAM_SERVICE,null,-1);}}
this.setWorldMapURL=function(urlWorldMap){this.urlWorldMap=urlWorldMap;}
this.setScheduleURL=function(scheduleURL){this.urlSchedule=scheduleURL;}
this.setMessages=function(msgObject){this.msg=msgObject;}
this.setStatusLineMessage=function(messageText){}
this.setMapHeaderMessage=function(messageText){$(this.guiMapHeadSingleText).text(messageText);}
this.setScheduleBoxMessage=function(messageText){var txtNode=$(this.guiScheduleBox).children("p:first");if(txtNode!=null)
$(txtNode).text(messageText);}
this.setTransitTable=function(index){var route=null;if(this.direction==this.C_WEST){route=this.services[index].westRoute;}
else{route=this.services[index].eastRoute;}
if(route!=null&&route.srcRegionPorts!=null&&route.trgRegionPorts!=null&&route.transitTable!=null){this.guiTable.fillCrossTable(this.msg.MSG_SERVICE_MAP_TABLE_FROM_TO,route.srcRegionPorts,route.trgRegionPorts,route.transitTable);}
else{this.guiTable.reset(0,1);this.guiTable.setHeader(0,0,this.msg.MSG_SERVICE_MAP_TABLE_FROM_TO);}
this.setTableInfo(index,this.direction);this.setServiceInfo(index);}
this.setTableInfo=function(index,direction){var data=$(this.createTableInfoID(index,direction)).children("div");var textComment=$(data[0]).children("p:eq(0)").text();var textUpdate=$(data[1]).children(":eq(1)").children("p:eq(0)").text();var fields=$(this.guiTableInfo).children("div");$(fields[0]).children("p:eq(0)").text(textComment);$(fields[1]).children(":eq(1)").children("p:eq(0)").text(textUpdate);}
this.setServiceInfo=function(index){var text=$(this.createServiceInfoID(index)).children("p:eq(0)").text();$(this.guiServiceInfo).children("p:eq(0)").text(text);}
this.createTableInfoID=function(index,direction){var tableInfo="div#tableInfo_"+index+"_";if(direction==this.C_WEST)
tableInfo=tableInfo+"west";else
tableInfo=tableInfo+"east";return tableInfo;}
this.createServiceInfoID=function(index){var serviceInfo="div#serviceInfo_"+index;return serviceInfo;}
this.handleDirectionChangeClick=function(){if(this.guiMapContainer.serviceMode==this.guiMapContainer.C_WESTBOUND){this.guiMapContainer.setDirection(this.guiMapContainer.C_EASTBOUND);this.direction=this.C_EAST;var index=this.getServiceIndex(this.selectedService);if(index>-1){if(this.selectedService.eastRoute!=null){this.guiMapContainer.fadeInService(i,this.C_ANIM_SERVICE_DIRECTION_CHANGE);this.setTransitTable(index);}
else{this.guiMapContainer.hideService(index);this.selectedService=null;this.guiTable.init(0,0);}}
else{}
this.showDirectionStatus(this.C_EAST,this.guiMapContainer.serviceMap);if(this.appMode==this.C_APP_SMART_EDIT){this.setCookie(this.C_SMART_EDIT_PARAM_DIRECTION,this.C_PARAM_VAL_DIRECTION_EAST,0);}}
else{this.guiMapContainer.setDirection(this.guiMapContainer.C_WESTBOUND);this.direction=this.C_WEST;var index=this.getServiceIndex(this.selectedService);if(index>-1){if(this.selectedService.westRoute!=null){this.guiMapContainer.fadeInService(i,this.C_ANIM_SERVICE_DIRECTION_CHANGE);this.setTransitTable(index);}
else{this.guiMapContainer.hideService(index);this.selectedService=null;this.guiTable.init(0,0);}}
else{}
this.showDirectionStatus(this.C_WEST,this.guiMapContainer.serviceMap);if(this.appMode==this.C_APP_SMART_EDIT){this.setCookie(this.C_SMART_EDIT_PARAM_DIRECTION,this.C_PARAM_VAL_DIRECTION_WEST,0);}}}
this.handleServiceHoverIn=function(index,service){if(this.selectedService==null){this.guiList.unhighlightEntry(this.lastSelectedServiceIndex);this.guiMapContainer.hideService(this.lastSelectedServiceIndex);if(!this.disabledServices[index]){$(this.guiTransitTableContainer).show();$(this.guiServiceInfo).show();this.guiList.highlightEntry(index);this.guiMapContainer.showService(index);this.setTransitTable(index);}
else{$(this.guiTransitTableContainer).hide();$(this.guiServiceInfo).hide();}
this.lastSelectedServiceIndex=index;}
else{if(index!=this.lastSelectedServiceIndex){this.guiList.unhighlightEntry(this.lastSelectedServiceIndex);}
if(!this.disabledServices[index]){if(index!=this.lastSelectedServiceIndex){this.guiMapContainer.hideService(this.lastSelectedServiceIndex);}
if(this.selectedService!=service){this.guiList.highlightEntry(index);}
this.guiMapContainer.showService(index);this.lastSelectedServiceIndex=index;this.setTransitTable(index);}
else if(this.disabledServices[index]){var selectedServiceIndex=this.getServiceIndex(this.selectedService);if(index!=this.lastSelectedServiceIndex&&this.lastSelectedServiceIndex!=selectedServiceIndex){this.guiMapContainer.hideService(this.lastSelectedServiceIndex);this.guiMapContainer.showService(selectedServiceIndex);}
this.lastSelectedServiceIndex=selectedServiceIndex;this.setTransitTable(selectedServiceIndex);}}}
this.handleServiceHoverOut=function(index,service){}
this.handleServiceClick=function(event,index,service){if(!this.disabledServices[index]){if(this.selectedService==service){}
else{this.selectedService=service;for(t=0;t<this.services.length;t++){if(t!=index&&!this.disabledServices[t]){this.guiList.unselectEntry(t);this.guiMapContainer.hideService(t);if(this.appMode==this.C_APP_SMART_EDIT){var elem="div#smartedit_"+t;$(elem).hide();}}}
if((this.direction==this.C_WEST&&service.eastRoute==null)||(this.direction==this.C_EAST&&service.westRoute==null)){$(this.guiBtnDirection).css("visibility","hidden");}
else{$(this.guiBtnDirection).css("visibility","visible");}
this.guiList.selectEntry(index);this.setScheduleBoxMessage(this.msg.MSG_SERVICE_MAP_SCHEDULE_SELECTION_SERVICE);$(this.guiBtnSchedule).attr("value",this.MSG_SERVICE_MAP_BTN_SCHEDULE_SERVICE);this.guiMapContainer.fadeOutService(index,this.C_ANIM_SERVICE_CLICK_FADE_OUT_IN);this.guiMapContainer.fadeInService(index,this.C_ANIM_SERVICE_CLICK_FADE_OUT_IN);$(this.guiBtnSchedule).attr("value",this.msg.MSG_SERVICE_MAP_BTN_SCHEDULE_SERVICE);this.setTransitTable(index);$(this.guiBtnResetSelection).css("visibility","visible");this.setStatusLineMessage(this.msg.MSG_SERVICE_MAP_SERVICE_SELECTION);if(this.appMode==this.C_APP_SMART_EDIT){this.setCookie(this.C_SMART_EDIT_PARAM_SERVICE,index,0);var elem="div#smartedit_"+index;$(elem).show();}
this.setURLHashParams();}}}
this.selectFirstService=function(){index=0;service=this.services[index];if(!this.disabledServices[index]){if(this.selectedService==service){}
else{this.selectedService=service;for(t=0;t<this.services.length;t++){if(t!=index&&!this.disabledServices[t]){this.guiList.unselectEntry(t);this.guiMapContainer.hideService(t);if(this.appMode==this.C_APP_SMART_EDIT){var elem="div#smartedit_"+t;$(elem).hide();}}}
if((this.direction==this.C_WEST&&service.eastRoute==null)||(this.direction==this.C_EAST&&service.westRoute==null)){$(this.guiBtnDirection).css("visibility","hidden");}
else{$(this.guiBtnDirection).css("visibility","visible");}
this.guiList.selectEntry(index);this.setScheduleBoxMessage(this.msg.MSG_SERVICE_MAP_SCHEDULE_SELECTION_SERVICE);$(this.guiBtnSchedule).attr("value",this.MSG_SERVICE_MAP_BTN_SCHEDULE_SERVICE);this.guiMapContainer.fadeOutService(index,this.C_ANIM_SERVICE_CLICK_FADE_OUT_IN);this.guiMapContainer.fadeInService(index,this.C_ANIM_SERVICE_CLICK_FADE_OUT_IN);$(this.guiBtnSchedule).attr("value",this.msg.MSG_SERVICE_MAP_BTN_SCHEDULE_SERVICE);this.setTransitTable(index);$(this.guiTransitTableContainer).show();$(this.guiBtnResetSelection).css("visibility","visible");this.setStatusLineMessage(this.msg.MSG_SERVICE_MAP_SERVICE_SELECTION);if(this.appMode==this.C_APP_SMART_EDIT){this.setCookie(this.C_SMART_EDIT_PARAM_SERVICE,index,0);var elem="div#smartedit_"+index;$(elem).show();}}}}
this.unselectService=function(){this.selectedService=null;this.setStatusLineMessage(this.msg.MSG_SERVICE_MAP_NO_SELECTION);for(t=0;t<this.services.length;t++){if(!this.disabledServices[t])
this.guiList.unselectEntry(t);else
this.guiList.disableEntry(t);this.guiMapContainer.hideService(t);}
$(this.guiBtnResetSelection).css("visibility","hidden");this.setScheduleBoxMessage(this.msg.MSG_SERVICE_MAP_SCHEDULE_SELECTION_REGION);$(this.guiBtnSchedule).attr("value",this.msg.MSG_SERVICE_MAP_BTN_SCHEDULE_REGION);$(this.guiBtnDirection).css("visibility","visible");}
this.deselectAllServices=function(){this.unselectService();$(this.guiServiceInfo).hide();$(this.guiTransitTableContainer).hide();this.guiTable.init(0,0);var dir="west";if(this.direction==this.C_WEST){dir="west";}
else if(this.direction==this.C_EAST){dir="east";}
this.replaceURL("#none"+'_'+dir);}}
function GuiMapContainer(htmlID,worldmap){this.C_REGION=0;this.C_SERVICE=1;this.C_BASE_MAP=5;this.C_WORLD_MAP=0;this.C_SERVICE_MAP=1;this.C_WESTBOUND=0;this.C_EASTBOUND=1;this.id=htmlID;this.rp=new Point2D(0,0);this.eventListener=null;this.width=0;this.height=0;this.worldmap=null;this.regions=null;this.services=new Array();this.serviceMap=null;this.ajaxLoader=null;this.viewMode=this.C_WORLD_MAP;this.serviceMode=this.C_WESTBOUND;this.refWorldMap=null;this.refServiceMap=null;this.refRegions=new Array();this.refServices=new Array();this.refAjaxLoader=null;this.createMapImgItem=function(idName,mapImage){var imgID="img#"+idName;if(mapImage!=null){$(this.id).append("<img id='"+idName+"' class='grfMapItem' src='"+mapImage.img.src+"' GALLERYIMG='no'> </img> ");}
else
$(this.id).append("<img id='"+idName+"' class='grfMapItem' src='' GALLERYIMG='no'> </img> ");$(imgID).hide();if(mapImage!=null)
this.placeFeature(imgID,mapImage.x,mapImage.y);else
this.placeFeature(imgID,0,0);return imgID;}
this.updateMapImgItem=function(itemID,mapImage){if(mapImage!=null){$(itemID).attr("src",$(mapImage.img).attr('src'));}
else
$(itemID).attr("src","");$(itemID).hide();if(mapImage!=null)
this.placeFeature(itemID,mapImage.x,mapImage.y);}
this.init=function(){this.calcMapRefPoint();this.calcMapSize();}
this.calcMapSize=function(){this.width=$(this.id).width();this.height=$(this.id).height();}
this.setAjaxLoader=function(mapImage){this.ajaxLoader=mapImage;if(this.refAjaxLoader==null){mapImage.loadImage();this.refAjaxLoader=this.createMapImgItem("ajaxLoader",mapImage);}
else{this.refAjaxLoader=this.updateMapImgItem("ajaxLoader",mapImage);}}
this.setServiceMap=function(serviceMap,direction,htmlBaseMap){this.serviceMap=serviceMap;this.services=serviceMap.services;if(this.services==null){this.services=new Array();}
this.viewMode=this.C_SERVICE_MAP;this.serviceMap.mapImage.loadImage(400,"img#serviceMap");for(i=0;i<this.services.length;i++){if(this.services[i].westRoute!=null&&this.services[i].westRoute.mapImage!=null)
this.services[i].westRoute.mapImage.loadImage();if(this.services[i].eastRoute!=null&&this.services[i].eastRoute.mapImage!=null)
this.services[i].eastRoute.mapImage.loadImage();}
if(!htmlBaseMap||htmlBaseMap==undefined)
this.refServiceMap=this.createMapImgItem("serviceMap",this.serviceMap.mapImage);else{this.refServiceMap=htmlBaseMap;}
var selfRef=this;$(this.refServiceMap).click(function(event){event.preventDefault();selfRef.eventListener.evtGuiMapContainerClick(event,-1,selfRef.C_BASE_MAP,null);});this.serviceMode=direction;for(i=0;i<this.services.length;i++){this.setService(i);}}
this.showServiceMap=function(){$(this.refServiceMap).fadeIn(400);}
this.setRegion=function(index){if(this.regions==null){this.regions=this.worldmap.regions;}
var i=index;if(i<this.refRegions.length){this.updateMapImgItem(this.refRegions[i],this.regions[i].mapImage);}
else{var itemName="reg"+i;var itemRef=this.createMapImgItem(itemName,this.regions[i].mapImage);$(itemRef).css("cursor","hand");this.refRegions.push(itemRef);var selfRef=this;$(itemRef).hover(function(){selfRef.eventListener.evtGuiMapContainerHoverIn(index,selfRef.C_REGION,selfRef.regions[i]);},function(){selfRef.eventListener.evtGuiMapContainerHoverOut(index,selfRef.C_REGION,selfRef.regions[i]);});$(itemRef).click(function(event){event.preventDefault();selfRef.eventListener.evtGuiMapContainerClick(event,i,selfRef.C_REGION,selfRef.regions[i]);});}}
this.setService=function(index){if(this.services==null){this.services=this.serviceMap.services;}
var i=index;var img=null;if(this.serviceMode==this.C_WESTBOUND){if(this.services[i].westRoute!=null&&this.services[i].westRoute.mapImage!=null)
img=this.services[i].westRoute.mapImage;}
else if(this.serviceMode==this.C_EASTBOUND){if(this.services[i].eastRoute!=null&&this.services[i].eastRoute.mapImage!=null)
img=this.services[i].eastRoute.mapImage;}
if(i<this.refServices.length){this.updateMapImgItem(this.refServices[i],img);}
else{var itemName="svc"+i;var itemRef=this.createMapImgItem(itemName,img);this.refServices.push(itemRef);var selfRef=this;$(itemRef).hover(function(){selfRef.eventListener.evtGuiMapContainerHoverIn(index,selfRef.C_SERVICE,selfRef.services[i]);},function(){selfRef.eventListener.evtGuiMapContainerHoverOut(index,selfRef.C_SERVICE,selfRef.services[i]);});$(itemRef).click(function(event){event.preventDefault();selfRef.eventListener.evtGuiMapContainerClick(event,i,selfRef.C_SERVICE,selfRef.services[i]);});}}
this.setWorldMap=function(worldMap){this.worldmap=worldMap;this.worldmap.mapImage.loadImage(400,"img#worldMap");for(i=0;i<this.worldmap.regions.length;i++){if(this.worldmap.regions[i].mapImage!=null){this.worldmap.regions[i].mapImage.loadImage();}}
for(i=0;i<this.worldmap.serviceMaps.length;i++){if(this.worldmap.serviceMaps[i].mapImage!=null)
this.worldmap.serviceMaps[i].mapImage.loadImage();}
this.refWorldMap=this.createMapImgItem("worldMap",this.worldmap.mapImage);var selfRef=this;$(this.refWorldMap).click(function(event){event.preventDefault();selfRef.eventListener.evtGuiMapContainerClick(event,-1,selfRef.C_BASE_MAP,null);});this.regions=this.worldmap.regions;for(i=0;i<regions.length;i++){this.setRegion(i);}}
this.setDirection=function(direction){this.serviceMode=direction;if(this.services!=null){for(i=0;i<this.services.length;i++){this.setService(i);}
for(i=0;i<this.services.length;i++){this.hideService(i);}}}
this.showAjaxLoader=function(){if(this.refAjaxLoader!=null)
$(this.refAjaxLoader).show();}
this.hideAjaxLoader=function(){if(this.refAjaxLoader!=null)
$(this.refAjaxLoader).hide();}
this.showService=function(index){var o=this.refServices[index];$(o).fadeIn(80);}
this.hideService=function(index){var o=this.refServices[index];$(o).hide();}
this.fadeInService=function(index,time){var o=this.refServices[index];$(o).fadeIn(time);}
this.fadeOutService=function(index,time){var o=this.refServices[index];$(o).fadeOut(time);}
this.showRegion=function(index){var o=this.refRegions[index];$(o).css({filter:'alpha(opacity=100)',opacity:'1.0'});$(o).css("cursor","hand");}
this.showTransparentRegion=function(index,alpha){var o=this.refRegions[index];var ie=alpha*100;$(o).css({filter:"alpha(opacity="+ie+")",opacity:alpha});}
this.hideRegion=function(index){var o=this.refRegions[index];$(o).css({filter:'alpha(opacity=0)',opacity:'0.0'});$(o).css("cursor","default");}
this.disableRegion=function(index){var o=this.refRegions[index];$(o).css({filter:'alpha(opacity=0)',opacity:'0.0'});$(o).hide();}
this.enableRegion=function(index){var o=this.refRegions[index];$(o).css({filter:'alpha(opacity=0)',opacity:'0.0'});$(o).show();}
this.setEventListener=function(listener){this.eventListener=listener;}
this.loadWorldMap=function(){for(i=0;i<this.services.length;i++){$(this.refServices[i]).hide();}
$(this.refWorldMap).hide();$(this.refWorldMap).fadeIn(400);for(i=0;i<this.regions.length;i++){this.enableRegion(i);}}
this.loadServiceMap=function(serviceMap){for(i=0;i<this.regions.length;i++){this.disableRegion(i);}
this.serviceMap=serviceMap;if(this.serviceMap.mapImage!=null){if(this.refServiceMap!=null){this.updateMapImgItem(this.refServiceMap,this.serviceMap.mapImage);}
else{this.refServiceMap=this.createMapImgItem("serviceMap",this.serviceMap.mapImage);}}
this.services=serviceMap.services;if(this.services!=null){for(i=0;i<this.services.length;i++){if(this.services[i].westRoute!=null){if(this.services[i].westRoute.mapImage!=null&&!this.services[i].westRoute.mapImage.imgInit){this.services[i].westRoute.mapImage.loadImage();}}
if(this.services[i].eastRoute!=null){if(this.services[i].eastRoute.mapImage!=null&&!this.services[i].eastRoute.mapImage.imgInit){this.services[i].eastRoute.mapImage.loadImage();}}}
for(i=0;i<this.services.length;i++){this.setService(i);}}
$(this.refWorldMap).fadeOut(400);$(this.refServiceMap).fadeIn(400);this.viewMode=this.C_SERVICE_MAP;}
this.animationWorldMap=function(){$(this.refWorldMap).fadeIn(400);}
this.calcMapRefPoint=function(){var p=$(this.id).offset();this.rp.x=0;this.rp.y=0;}
this.placeFeature=function(objectID,x,y){var posX=this.rp.x+x;var posY=this.rp.y+y;$(objectID).css({left:posX,top:posY});}}
function GuiList(htmlID){this.id=htmlID;this.eventListener=null;this.setEventListener=function(listener){this.eventListener=listener;var selfRef=this;$(this.id).hover(function(){selfRef.eventListener.evtGuiListHoverIn();},function(){selfRef.eventListener.evtGuiListHoverOut();});}
this.clearAll=function(){var c=$(this.id).children("li").get();var o=null;for(i=0;i<c.length;i++){o=$(c).get(i);$(o).text("");$(o).removeClass("selected");$(o).removeClass("disabled");$(o).unbind();}}
this.clear=function(index){var c=$(this.id).children("li").get(index);$(c).text("");}
this.init=function(){var c=$(this.id).children("li").get();for(i=0;i<c.length;i++){$(c[i]).unbind();}
$(this.id).empty();}
this.setEntries=function(objects){for(i=0;i<objects.length;i++){this.setEntry(i,objects[i].toString());}}
this.setSize=function(size){var c=$(this.id).children("li").get();if(c!=null&&size<c.length){var diff=c.length-size;for(t=0;t<diff;t++){$(this.id).children("li:last").remove();}}
else if(c!=null&&size>c.length){var diff=size-c.length;for(t=0;t<diff;t++){$(this.id).append("<li></li>");}}}
this.setEntry=function(index,text){var c=$(this.id).children("li").get();var li=null;if(index<c.length){li=c[index];}
else{$(this.id).append("<li></li>");li=$(this.id).children("li").get(index);}
this.resetStyle(li);$(li).text(text);var selfRef=this;$(li).unbind();$(li).hover(function(){selfRef.eventListener.evtGuiListEntryHoverIn(index,null);},function(){selfRef.eventListener.evtGuiListEntryHoverOut(index,null);});$(li).click(function(event){event.preventDefault();selfRef.eventListener.evtGuiListEntryClick(event,index,null);});}
this.hide=function(){$(this.id).hide();}
this.show=function(){$(this.id).show();}
this.fadeIn=function(){$(this.id).fadeIn();}
this.highlightEntry=function(index){var c=$(this.id).children("li").get(index);$(c).addClass("highlighted");}
this.unhighlightEntry=function(index){var c=$(this.id).children("li").get(index);$(c).removeClass("highlighted");}
this.selectEntry=function(index){var c=$(this.id).children("li").get(index);this.resetStyle(c);$(c).addClass("selected");}
this.unselectEntry=function(index){var c=$(this.id).children("li").get(index);this.resetStyle(c);$(c).removeClass("selected");}
this.disableEntry=function(index){var c=$(this.id).children("li").get(index);this.resetStyle(c);$(c).addClass("disabled");}
this.enableEntry=function(index){var c=$(this.id).children("li").get(index);$(c).removeClass("disabled");}
this.resetStyle=function(object){$(object).removeClass("disabled");$(object).removeClass("selected");$(object).removeClass("highlighted");}}
function GuiTable(htmlID){this.id=htmlID;this.num=0;this.i=0;this.j=0;this.refRows=new Array();this.refCols=new Array();this.head=null;this.body=null;this.show=function(){$(this.id).show();}
this.fadeIn=function(){$(this.id).fadeIn();}
this.fadeOut=function(){$(this.id).fadeOut(200);}
this.hide=function(){$(this.id).hide();}
this.preInit=function(){this.body=$(this.id).children("tbody");this.head=$(this.id).children("thead");}
this.init=function(rows,cols){this.i=rows;this.j=cols;var body=$(this.id).children("tbody");var head=$(this.id).children("thead");var head1=$(head).children("tr").get(0);$(head1).empty();$(body).empty();var refRows=null;for(j=0;j<cols;j++){$(head1).append("<th></th>");}
for(i=0;i<rows;i++){$(this.id).append("<tr></tr>");refRows=$(body).children("tr");for(j=0;j<cols;j++){if(j==0){$(refRows[i]).append("<td class='strong'></td>");}
else{$(refRows[i]).append("<td></td>");}}}
$(body).children("tr:odd").addClass("even");$(body).children("tr:even").addClass("odd");}
this.reset=function(rows,cols){this.i=rows;this.j=cols;var body=$(this.id).children("tbody");var head=$(this.id).children("thead");var head1=$(head).children("tr").get(0);$(head1).empty();$(body).empty();var refRows=null;for(j=0;j<cols;j++){$(head1).append("<th></th>");}
var row="<tr><td class='strong'></td>";for(j=0;j<(cols-1);j++){row+="<td></td>";}
row+="</tr>";for(i=0;i<rows;i++){$(this.id).append(row);}
$(body).children("tr:odd").addClass("even");$(body).children("tr:even").addClass("odd");}
this.fillCrossTable=function(topLeftCorner,rowHeader,colHeader,values){var rows=values.length;var cols=0;if(rows>0){cols=values[0].length;}
var body=$(this.id).children("tbody");var head=$(this.id).children("thead");var head1=$(head).children("tr").get(0);$(head1).empty();$(body).empty();$(head1).append("<th>"+topLeftCorner+"</th>");for(j=0;j<cols;j++){$(head1).append("<th>"+colHeader[j]+"</th>");}
for(i=0;i<rows;i++){var row="<tr><td class='strong'>"+rowHeader[i]+"</td>";var rowValues=values[i];for(j=0;j<cols;j++){row+="<td>"+rowValues[j]+"</td>";}
row+="</tr>";$(this.id).append(row);}
$(body).children("tr:odd").addClass("even");$(body).children("tr:even").addClass("odd");}
this.setHeader=function(i,j,entry){var head=$(this.id).children("thead");head=$(head).children("tr").get(i);var cols=$(head).children("th");if(j>=0&&j<cols.length)
$(cols[j]).text(entry);}
this.setHeaderRow=function(i,o,entries){var head=$(this.id).children("thead");head=$(head).children("tr").get(i);var cols=$(head).children("th");for(t=0;t<entries.length;t++){if(t<cols.length)
$(cols[t+o]).text(entries[t]);}}
this.setEntry=function(i,j,entry){var body=$(this.id).children("tbody");var rows=$(body).children("tr");var cols=$(rows[i]).children("td");var cell=$(cols[j]);$(cols[j]).text(entry);}
this.setBodyRow=function(i,o,entries){if(this.body!=null){var rows=this.body.children("tr");var cols=$(rows[i]).children("td");var cell=null;for(x=0;x<entries.length;x++){cell=$(cols[x+o]);cell.text(entries[x]);}}}}
