function getAbsoluteLeftById(objectId){var o=$(objectId);if(o)
return getAbsoluteLeft(o);
else return null;}

function getAbsoluteTopById(objectId){var o=$(objectId);if(o)
return getAbsoluteTop(o);
else return null;}



function getAbsoluteTop(o){
var oTop=o.offsetTop;
var oParent;
var o;
  while(o.offsetParent!=null){
    oParent=o.offsetParent;
    oTop+=oParent.offsetTop;
    o=oParent;
  }
  return oTop;
}

function getAbsoluteLeft(o){
var oLeft=o.offsetLeft;
var oParent;
var o;
  while(o.offsetParent!=null){
    oParent=o.offsetParent;
    oLeft+=oParent.offsetLeft;
    o=oParent;
  }
  
  return oLeft;
}

var GxMarkerNamespace = function(){
  
var currentSpan=new GBounds();
  
      

        var setCursor = function(container,cursor){
                                    
                try{    container.style.cursor=cursor;
                }  catch(c){
                        if(cursor=="pointer") setCursor("hand");
                }
        };
      
      
    
        var GxMarker = function(a,b,tooltipHtml){
          
                this.inheritFrom=GMarker;
                this.inheritFrom(a,b);
                if(!currentSpan.minX||a.x<currentSpan.minX)currentSpan.minX=a.x;
                if(!currentSpan.maxX||a.x>currentSpan.maxX)currentSpan.maxX=a.x;
                if(!currentSpan.minY||a.y<currentSpan.minY)currentSpan.minY=a.y;
                if(!currentSpan.maxY||a.y>currentSpan.maxY)currentSpan.maxY=a.y;
                if(typeof tooltipHtml!="undefined"){
                                    this.setTooltip(tooltipHtml);
                }
        }
      
      

GxMarker.prototype=new GMarker(new GLatLng(1,1));


      
        GxMarker.prototype.setTooltip=function(string){
                
              this.removeTooltip();
              this.tooltip=new Object();
              this.tooltip.opacity=100;
              this.tooltip.contents=string;
        };


        GxMarker.prototype.initialize=function(a){
  
              try{
                    GMarker.prototype.initialize.call(this,a);
                    GEvent.addListener(this,"mouseover",this.onMouseOver);
                    GEvent.addListener(this,"mouseout",this.onMouseOut);
                    this.map=a;
              } catch(e){
                    console.error(e);
              }
        }
    

        GxMarker.prototype.setCursor=function(cursor){
  
              var c=this.iconImage;
              if(n6&&this.icon.imageMap&&!safari){c=this.imageMap;
              } else if(this.transparentIcon&&typeof this.transparentIcon!="undefined"){c=this.transparentIcon;
              }
        }

        
        GxMarker.prototype.remove=function(a){
              GMarker.prototype.remove.call(this);
              this.removeTooltip();
        }


        GxMarker.prototype.removeTooltip=function(){
              
              if(this.tooltipElement){
                  try{document.body.removeChild(this.tooltipElement);
                  } catch(e){
                  console.error(e);
                  }
                  this.tooltipElement=null;
              }
        }


      
        GxMarker.prototype.onInfoWindowOpen=function(){
            
            this.hideTooltip();
            GMarker.prototype.onInfoWindowOpen.call(this);
        }
      

        GxMarker.prototype.onMouseOver=function(){
        	
            this.showTooltip();
        };


        GxMarker.prototype.onMouseOut=function(){
            
            this.hideTooltip();
        };

        GxMarker.prototype.hideTooltip=function(){
              if(this.tooltipElement){
                    this.tooltipElement.style.display="none";
              }
        }
      

        GxMarker.prototype.showTooltip=function(){
              if(this.tooltip){
                        if(!this.tooltipElement){
                                      var opacity=this.tooltip.opacity/100;
                                      this.tooltipElement=document.createElement("div");
                                      this.tooltipElement.style.display="none";
                                      this.tooltipElement.style.position="absolute";
                                      this.tooltipElement.style.background="#fff";
                                      this.tooltipElement.style.padding="0";
                                      this.tooltipElement.style.margin="8px";
                                      this.tooltipElement.style.MozOpacity=opacity;
                                      this.tooltipElement.style.filter="alpha(opacity="+this.tooltip.opacity+")";
                                      this.tooltipElement.style.opacity=opacity;
                                      this.tooltipElement.style.zIndex=5000;
                                      this.tooltipElement.innerHTML=this.tooltip.contents;
                                      document.body.appendChild(this.tooltipElement);
                        }
        

                        markerPosition=calculateMarkerPosition(this.map,this.getPoint());
      
      
                        try{
                            this.tooltipElement.style.top=markerPosition.top-(this.getIcon().iconAnchor.y-0)+"px";
                            this.tooltipElement.style.left=markerPosition.left+(this.getIcon().iconSize.width-this.getIcon().iconAnchor.x-0)+"px";
                            this.tooltipElement.style.display="block";
                        } catch(e){
                            console.error(e);
                        }
  			
              }
        }


        var calculateMarkerPosition = function(map,markerLatLngPoint){

                            gmapTopLeftLatLng=map.fromContainerPixelToLatLng(new GPoint(0,0));
                            gmapTopLeftPixel=map.fromLatLngToDivPixel(gmapTopLeftLatLng);
                            myMarkerDivPixel=map.fromLatLngToDivPixel(markerLatLngPoint);

                            absoluteTop = getAbsoluteTopById($('vimap'));
                            absoluteLeft = getAbsoluteLeftById($('vimap'));
							
							//alert(screen.width);
							//alert(screen.height);
							
                                if(ie){
                                	if (screen.width == "1280"){
                                	    absoluteTop = absoluteTop - 15;
                                    	absoluteLeft = absoluteLeft - 155;
                                    }
                                    
                                    if (screen.width == "1024"){
                                	    absoluteTop = absoluteTop - 15;
                                    	absoluteLeft = absoluteLeft - 30;
                                    }
                                    
                                    if (screen.width == "1152"){
                                	    absoluteTop = absoluteTop - 15;
                                    	absoluteLeft = absoluteLeft - 90;
                                    }
                                    
                                    if (screen.width == "1400"){
                                	    absoluteTop = absoluteTop - 15;
                                    	absoluteLeft = absoluteLeft - 220;
                                    }
                                    
                                    if (screen.width == "1680"){
                                	    absoluteTop = absoluteTop + 5;
                                    	absoluteLeft = absoluteLeft - 350;
                                    }
                                }

                                if(o6){
                                    
                                    if (screen.width == "1280"){	
                                    	absoluteTop = absoluteTop - 8 + 15;
                                    	absoluteLeft = absoluteLeft + 1;
                                    }
                                    
                                    if (screen.width == "1024"){
                                	    absoluteTop = absoluteTop + 5;
                                    	absoluteLeft = absoluteLeft + 5;
                                    }
                                    
                                    if (screen.width == "1152"){
                                	    absoluteTop = absoluteTop + 5;
                                    	absoluteLeft = absoluteLeft - 5;
                                    }
                                    
                                    if (screen.width == "1400"){
                                	    absoluteTop = absoluteTop + 5;
                                    	absoluteLeft = absoluteLeft;
                                    }
                                    
                                    if (screen.width == "1680"){
                                	    absoluteTop = absoluteTop + 5;
                                    	absoluteLeft = absoluteLeft;
                                    }
                                    
                                }


                            markerTop=absoluteTop-gmapTopLeftPixel.y+myMarkerDivPixel.y;
                            markerLeft=absoluteLeft-gmapTopLeftPixel.x+myMarkerDivPixel.x;

                            return{top:markerTop,left:markerLeft};
        }
        
        	  
			  
        var makeInterface = function(a){
              var b=a||window;
              b.GxMarker=GxMarker;
        }
      
makeInterface();

}

GxMarkerNamespace();

var ViMap={

ObjMap:null

              ,

ObjBounds:null
  
              ,

map:function(){
                if(this.ObjMap==null){

                this.ObjMap=new GMap2($('vimap'));
                }
                return this.ObjMap;
              }
              
              ,

bounds:function(){
                if(this.ObjBounds==null){
                this.ObjBounds=new GLatLngBounds();
                }
                return this.ObjBounds;
              }
            
              ,

init:function(mapControl){
                if(mapControl=='Small'){
                    this.map().addControl(new GSmallMapControl());
                    //this.map().addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10, 10)));
                }
                if (mapControl=='Large'){
                this.map().addControl(new GLargeMapControl());
                //this.map().addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10, 10)));
                              
                }
                var center = new GLatLng(0,0);
                this.map().setCenter(center);
                this.map().getContainer().style.overflow = 'hidden';
              }
            
              ,
            
setZoomAndCenter:function(level){
                var center=this.bounds().getCenter();
                this.map().setCenter(center);
                this.map().setZoom(level);
              }

			  ,
			  
addHere:function(latitude,longitude){

			  //var icon=new GIcon();
              //icon.image="/images/marker_location.gif";
              //icon.shadow="/images/marker_shadow.gif";
              //icon.iconSize=new GSize(18,55);
              //icon.shadowSize=new GSize(38,38);
              //icon.iconAnchor=new GPoint(5,30);
              //icon.infoWindowAnchor=new GPoint(5,30);
              
              var point=new GLatLng(latitude,longitude);
              //var marker = new GMarker(point,null);
			  
				
              //this.map().addOverlay(marker);
              this.bounds().extend(point);
			  }            
			  ,
			  
addPlace:function(html,url,latitude,longitude,pos){
              
              var icon = new GIcon();
              icon.image = "images/markerpurple.png";
              icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
              icon.iconSize = new GSize(20, 34);
              icon.shadowSize = new GSize(37, 34);
              icon.iconAnchor = new GPoint(9, 34);
              icon.infoWindowAnchor = new GPoint(9, 2);

              var point=new GLatLng(latitude,longitude);
              var marker = new GxMarker(point,icon,html);      
              marker.id = pos;
              
              GEvent.addListener(marker, "mouseover", function() {
             	    marker.setImage("images/markerorange.png"); 
               });
               GEvent.addListener(marker, "mouseout", function() {
             	    marker.setImage("images/markerpurple.png"); 
               }); 
    		
    		
              
              if(url) GEvent.addListener(marker,"click",function(){window.location=url;});
  
             
              var hrefmark = $('place'+marker.id);
              
              if (hrefmark != null){
             Event.observe(hrefmark, 'mouseover', function(){  marker.setImage("images/markerorange.png");  });
              Event.observe(hrefmark, 'mouseover', function(){  marker.onMouseOver();  });
              Event.observe(hrefmark, 'mouseout', function(){ marker.setImage("images/markerpurple.png"); });
              Event.observe(hrefmark, 'mouseout', function(){ marker.onMouseOut(); });
              }
              
              this.map().addOverlay(marker);
              this.bounds().extend(point);
              }
              
			  ,

centerAndZoom:function(level){
              var center=this.bounds().getCenter();
              this.map().setCenter(center);
              var zoom=Math.min(this.map().getBoundsZoomLevel(this.bounds()),level);
              this.map().setZoom(zoom);
              }
              
              ,

clear:function(){
              this.map().clearOverlays();
              this.ObjBounds=null;
              }

}