// TPhoto() GMaps API extension copyright 2005-2006 Tom Mangan
// http://gmaps.tommangan.us/tphoto.html
// free for non-commercial use
function TPhoto(){}
TPhoto.prototype.initialize=function(a){
 this.parentMap=a;
 var b=document.createElement('img');
 b.style.display='none';
 b.setAttribute('id',this.id);
 b.setAttribute('src',this.src);
 b.style.position='absolute';
 b.style.zIndex=1;
 this.mapTray=a.getPane(G_MAP_MAP_PANE);
 this.mapTray.appendChild(b);
 this.setPosition(a);
 b.style.display='block';
 if(this.percentOpacity){this.setOpacity(this.percentOpacity);}
 GEvent.bind(a,"zoomend",this,function(){this.setPosition(a)});
 GEvent.bind(a,"moveend",this,function(){this.setPosition(a)});
}
TPhoto.prototype.setPosition=function(a){
 var d=this.parentMap.fromLatLngToDivPixel(this.anchorTopLeft);
 var e=this.parentMap.fromLatLngToDivPixel(this.anchorBottomRight);
 var x=document.getElementById(this.id);
 x.style.top=d.y+'px';
 x.style.left=d.x+'px';
 x.style.width=e.x-d.x+'px';
 x.style.height=e.y-d.y+'px';
}
TPhoto.prototype.setOpacity=function(b){
 if(b<0){b=0;}  if(b>=100){b=100;}
 var c=b/100;
 var d=document.getElementById(this.id);
 if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
 if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
 if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
 if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
}
GMap2.prototype.addTPhoto=function(a){
 a.initialize(this);
}
GMap2.prototype.removeTPhoto=function(a){
 var b=document.getElementById(a.id);
 this.getPane(G_MAP_MAP_PANE).removeChild(b);
 delete(b);
}
    
function site(url) {
     window.open(url,'mywindow','width=1024,height=780,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes')
}


function rzCC(s){
   // thanks http://www.ruzee.com/blog/2006/07/\
   // retrieving-css-styles-via-javascript/
   for(var exp=/-([a-z])/; 
       exp.test(s); 
       s=s.replace(exp,RegExp.$1.toUpperCase()));
   return s;
 }

 function _setStyle(element, declaration) {
   if (declaration.charAt(declaration.length-1)==';')
     declaration = declaration.slice(0, -1);
   var k, v;
   var splitted = declaration.split(';');
   for (var i=0, len=splitted.length; i<len; i++) {
      k = rzCC(splitted[i].split(':')[0]);
      v = splitted[i].split(':')[1];
      eval("element.style."+k+"='"+v+"'");

   }
 }




function popImg2(ref,id,posx,posy,position) {  

 if ( ! position ) position = 'absolute';
 var console = document.getElementById(id);
 
 var popImg = document.getElementById('popImg');
 if (  popImg ) {
   console.removeChild(popImg);  
 } 

 var img = '<a href="javascript:delpopImg2(\'' + id + '\')"><img  class="popimg" border="0" src="' + ref + '"/></a><br><a href="javascript:delpopImg2(\'' + id + '\')">Close Window</a>';
 var pop  = document.createElement('DIV');
 var popimg = 'margin:0 0 0 0; position:' + position + ';width:900px;height:900px;  background:white;';
 popimg +=    'border:0px solid black;display:block;padding:0;'; 
 popimg +=    'text-align:center;font:12px verdana, arial, sans-serif;'; 
 popimg +=    'left      :' + posx + 'px;';
 popimg +=    'top       :' + posy + 'px;';
 pop.id   = 'popImg';
 console.appendChild(pop);     
//popImg.setAttribute("style",popimg); 
 _setStyle(document.getElementById('popImg') , popimg);
 pop.innerHTML = img;   
}

function delpopImg2(id) {
  var console = document.getElementById(id);
  var popImg  = document.getElementById('popImg');
  var removed = console.removeChild(popImg);   
} 
