
function Point2D(x,y){this.x=x;this.y=y;}
function MapImage(imgSrc,x,y){this.imgSrc=imgSrc;this.x=x;this.y=y;this.img=null;this.imgInit=false;if(x==undefined||y==undefined){this.x=0;this.y=0;}
this.setImage=function(image){this.img=image;this.imgSrc=$(this.img).attr("src");}
this.loadImage=function(){this.img=new Image();$(this.img).attr("src",this.imgSrc);this.imgInit=true;}}
function Office(name,mapImage){this.name=name;this.mapImage=mapImage;if(mapImage==undefined){this.mapImage=null;}
this.getMapImage=function(){return this.mapImage;}
this.toString=function(){return this.name;}}
function Messages(){this.MSG_SELECT_REGION="Please select a region to show our offices...";this.MSG_WORLD_MAP_DEFAULT="Choose Region:  ";this.MSG_WORLD_MAP_SELECTION_PRE="Choose Region:  ";}
function Region(id,name,mapImage){this.id=id;this.name=name;this.mapImage=mapImage;this.url=null;this.fisCode=null;this.getMapImage=function(){return this.mapImage;}
this.setFisCode=function(code){this.fisCode=code;}
this.setUrlLink=function(url){this.url=url;}
this.toString=function(){return this.name;}}
function ControllerWorldMap(){this.worldMapImage=null;this.worldMapRef=null;this.regions=new Array();this.offices=new Array();this.msg=new Messages();this.guiStatusField="div#ofStatusLine";this.guiMapContainer=new GuiMapContainer("div#ofMapContainer");this.guiList=new GuiList("ul#ofNavi");this.guiMapHeader="div#ofMapHeader";this.guiMapHeadSingleText="h2#mapSingleText";this.init=function(worldMapImage,regions){var imgRef=false;if((worldMapImage instanceof MapImage)){this.worldMapImage=worldMapImage;}
else{this.worldMapImageRef=worldMapImage;imgRef=true;}
this.regions=regions;if(this.regions==null||this.regions==undefined){this.regions=new Array();}
this.guiMapContainer.setEventListener(this);this.guiMapContainer.init();if(!imgRef)
this.guiMapContainer.setBaseMap(worldMapImage);else
this.guiMapContainer.setBaseMapRef(worldMapImage);this.guiMapContainer.loadBaseMap();for(i=0;i<this.regions.length;i++){this.guiMapContainer.setFeature(i,this.regions[i]);this.guiMapContainer.enableFeature(i,this.regions[i]);}
this.guiList.setEventListener(this);this.guiList.init();this.guiList.setEntries(this.regions);$(this.guiMapHeadSingleText).text(this.msg.MSG_WORLD_MAP_DEFAULT);$(this.guiMapHeadSingleText).show();}
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.getRegionIndex=function(region){for(i=0;i<this.regions.length;i++){if(this.regions[i]==region){return i;}}
return-1;}
this.evtGuiListEntryHoverIn=function(index,object){this.handleRegionHoverIn(index,this.regions[index]);}
this.evtGuiListEntryHoverOut=function(index,object){this.handleRegionHoverOut(index,this.regions[index]);}
this.evtGuiListHoverIn=function(){}
this.evtGuiListHoverOut=function(){}
this.evtGuiListEntryClick=function(event,index,object){this.handleRegionClick(event,index,this.regions[index]);}
this.evtGuiMapContainerHoverIn=function(index,srcType,object){if(srcType==this.guiMapContainer.C_FEATURE){this.handleRegionHoverIn(index,object);}}
this.evtGuiMapContainerHoverOut=function(index,srcType,object){if(srcType==this.guiMapContainer.C_FEATURE){this.handleRegionHoverOut(index,object);}}
this.evtGuiMapContainerClick=function(event,index,srcType,object){if(srcType==this.guiMapContainer.C_FEATURE){this.handleRegionClick(event,index,object);}
else if(srcType==this.guiMapContainer.C_BASE_MAP){}}
this.setURL=function(strURL){document.location=strURL;}
this.setStatusLineMessage=function(messageText){var txtNode=$(this.guiStatusField).children("p:first");if(txtNode!=null)
$(txtNode).text(messageText);}
this.handleRegionHoverIn=function(index,region){this.guiMapContainer.showFeature(index);this.guiList.highlightEntry(index);$(this.guiMapHeadSingleText).text(this.msg.MSG_WORLD_MAP_SELECTION_PRE+region.name);}
this.handleRegionHoverOut=function(index,region){this.guiMapContainer.hideFeature(index);this.guiList.unhighlightEntry(index);$(this.guiMapHeadSingleText).text(this.msg.MSG_WORLD_MAP_SELECTION_PRE);}
this.handleRegionClick=function(event,index,region){this.setURL(region.url);}}
function GuiMapContainer(htmlID){this.C_BASE_MAP=5;this.C_FEATURE=6;this.GUI_CSS_MAP_SYMBOL_CLASS="grfMapItem";this.id=htmlID;this.rp=new Point2D(0,0);this.eventListener=null;this.baseMap=null;this.features=new Array();this.refBaseMap=null;this.refFeatures=new Array();this.createMapImgItem=function(idName,mapImage){var imgID="img#"+idName;if(mapImage!=null)
$(this.id).append("<img id='"+idName+"' class='"+this.GUI_CSS_MAP_SYMBOL_CLASS+"' src='"+mapImage.img.src+"' GALLERYIMG='no'> </img> ");else
$(this.id).append("<img id='"+idName+"' class='"+this.GUI_CSS_MAP_SYMBOL_CLASS+"' 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.setEventListener=function(listener){this.eventListener=listener;}
this.setBaseMap=function(mapImage){if(mapImage!=null){this.baseMap=mapImage;this.baseMap.loadImage();}
if(this.refBaseMap==null){this.refBaseMap=this.createMapImgItem("baseMap",this.baseMap);}
else
{$(this.refBaseMap).unbind();this.refBaseMap=this.updateMapImgItem(this.refBaseMap,this.baseMap);}
var selfRef=this;$(this.refBaseMap).click(function(event){event.preventDefault();selfRef.eventListener.evtGuiMapContainerClick(event,-1,selfRef.C_BASE_MAP,null);});}
this.setBaseMapRef=function(htmlID){var id=htmlID;if(htmlID==null){id="none";}
if(this.refBaseMap==null){this.refBaseMap=id;}
else
{$(this.refBaseMap).unbind();this.refBaseMap=id;}}
this.addFeature=function(feature){var index=this.features.length;this.setFeature(index,feature);return index;}
this.setFeature=function(index,feature){var i=index;var mapImage=feature.getMapImage();if(mapImage!=null&&!mapImage.imgInit){mapImage.loadImage();}
if(i<this.refFeatures.length){this.features[i]=feature;this.updateMapImgItem(this.refFeatures[i],mapImage);}
else{var itemName="feature"+i;var itemRef=this.createMapImgItem(itemName,mapImage);this.features.push(feature);this.refFeatures.push(itemRef);$(itemRef).css("cursor","hand");var selfRef=this;$(itemRef).hover(function(){selfRef.eventListener.evtGuiMapContainerHoverIn(index,selfRef.C_FEATURE,selfRef.features[i]);},function(){selfRef.eventListener.evtGuiMapContainerHoverOut(index,selfRef.C_FEATURE,selfRef.features[i]);});$(itemRef).click(function(event){event.preventDefault();selfRef.eventListener.evtGuiMapContainerClick(event,i,selfRef.C_FEATURE,selfRef.features[i]);});}}
this.loadBaseMap=function(){$(this.refBaseMap).hide();$(this.refBaseMap).fadeIn(400);}
this.showFeature=function(index){var o=this.refFeatures[index];$(o).css({filter:'alpha(opacity=100)',opacity:'1.0'});$(o).css("cursor","hand");}
this.showTransparentFeature=function(index,alpha){var o=this.refFeatures[index];var ie=alpha*100;$(o).css({filter:"alpha(opacity="+ie+")",opacity:alpha});}
this.hideFeature=function(index){var o=this.refFeatures[index];$(o).css({filter:'alpha(opacity=0)',opacity:'0.0'});$(o).css("cursor","default");}
this.disableFeature=function(index){var o=this.refFeatures[index];$(o).css({filter:'alpha(opacity=0)',opacity:'0.0'});$(o).hide();}
this.enableFeature=function(index){var o=this.refFeatures[index];$(o).css({filter:'alpha(opacity=0)',opacity:'0.0'});$(o).show();}
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=x+this.rp.x;var posY=y+this.rp.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);if(index==0)
$(li).addClass("firstChild");$(li).html(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.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.init=function(rows,cols){this.i=rows;this.j=cols;var body=$(this.id).children("tbody");var head=$(this.id).children("thead");head=$(head).children("tr").get(0);$(head).empty();$(body).empty();var refRows=null;for(j=0;j<cols;j++){$(head).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.setHeader=function(j,entry){var head=$(this.id).children("thead");head=$(head).children("tr").get(0);var cols=$(head).children("th");if(j>=0&&j<cols.length)
$(cols[j]).text(entry);}
this.setHeaders=function(entries){var head=$(this.id).children("thead");head=$(head).children("tr").get(0);var cols=$(head).children("th");for(t=0;t<entries.length;t++){if(t<cols.length)
$(cols[j]).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);}}
