function addEvent(obj, type, fn) {
   if (obj.addEventListener) {
      obj.addEventListener(type, fn, false);
      return true;
   } else if (obj.attachEvent) {
      var r = obj.attachEvent("on"+type, fn);
      return r;
   } else {
      return false;
   }
}  

function addMapPoint(map, latitude, longitude, html) {
   var point = new GMarker(new GLatLng(latitude, longitude));
   if (html) { 
      GEvent.addListener(point, "mouseover", function() { 
         point.openInfoWindowHtml(html); 
      });
   }
   map.addOverlay(point);
}

function addMapAddress(map, address, html) {   
  var geocoder = new GClientGeocoder();
  return geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        //alert(address + " not found");
      } else {
         var marker = new GMarker(point); 
         if (html) {       
            GEvent.addListener(marker, "mouseover", function() { 
               marker.openInfoWindowHtml(html); 
            });
         }
         map.addOverlay(marker);
      }
    }
  );   
}

function setMapAddress(map, address, html) {
   var geocoder = new GClientGeocoder();
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        //alert(address + " not found");
      } else {
        map.setCenter(point, 13);
        var marker = new GMarker(point);
        if (html) {       
           GEvent.addListener(marker, "mouseover", function() { 
              marker.openInfoWindowHtml(html); 
           });
        }
        map.addOverlay(marker);
      }
    }
  );
}

function popImage(imageURL,imageTitle){
   PositionX = 200;
   PositionY = 200;
   defaultWidth  = 100;
   defaultHeight = 100;
   var AutoClose = true;
   if (parseInt(navigator.appVersion.charAt(0))>=4){
   var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
   var isNN=(isIE==0)?1:0;
   var optNN='scrollbars=no,toolbar=0,location=0,statusbar=0,menubar=0,directories=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
   var optIE='scrollbars=no,toolbar=0,location=0,statusbar=0,menubar=0,directories=no,width=150,height=100,left='+PositionX+',top='+PositionY;
   if (isNN){imgWin=window.open('about:blank','',optNN);}
   if (isIE){imgWin=window.open('about:blank','',optIE);}
   with (imgWin.document){
   writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
   writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
   writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
   writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
   writeln('width=300-(document.body.clientWidth-document.images[0].width);');
   writeln('height=300-(document.body.clientHeight-document.images[0].height);');
   writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
   writeln('window.innerWidth=document.images["pop-image"].width;');writeln('window.innerHeight=document.images["pop-image"].height;}}');
   writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
   if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
   else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
   writeln('<img name="pop-image" src="'+imageURL+'" style="display:block"></body></html>');
   close();}
}  
