var sImageName = "myimage";
var oImageInfo     = { x : -1, y : -1, w : -1, h : -1 };
var oSelectInfo    = { x1 : -1, y1 : -1, x2 : -1, y2 : -1 };
var oRulerInfo    = { x1 : -1, y1 : -1, x2 : -1, y2 : -1 };
var bDown          = false;
var bMustSetValues = false;
var currentTool = 0;
var dirLine;
var oldDirLine;
var points = new Array();
var brow;
var browVer;

var polyX=0;
var polyY=0;

var iniX,iniY;

var xs = new Array();
var ys = new Array();


var mfd = null;
var mfo = null;


var sLayer;
var mapa;
var circ;

var mapW;
var mapH;

var diag1;
var diag2;

var sTooltipX = 0, stTooltipY = 0;

if( navigator.appVersion.indexOf('MSIE') > - 1 ) {
	brow = 'ie';
}
else if( navigator.appName == "Netscape" && parseInt( navigator.appVersion  ) >= 5 ) {
	brow = 'gk';
}
else if( navigator.appName == "Netscape"  ) {
	brow = 'ns';
}
else if( navigator.appVersion.indexOf('compatible') ) {
	brow = 'ot';
}


function initLocal( ) {
}



function init( ) {

	sLayer = mfd.getElementById("selectLayer");
	mapa = mfd.getElementById(sImageName);

	if( document.all ) 
		circ = mfd.all['circle'];
	else 
		circ = mfd.getElementById('circle');

	with( mfd ) {

		mapW = parseInt(  status.mw.value );
		mapH = parseInt(  status.mh.value );

		mapWb2 = mapW/2;
		mapHb2 = mapH/2;
	
	}

	diag1 = new Image();
	diag1.src = "mapimages/diag1.gif";
	
	diag2 = new Image();
	diag2.src = "mapimages/diag2.gif";

	//window.status =  document.statusdata.mapas.value ;

	if ( document.statusdata ) {
		document.statusdata.mapas.value = crossGetFrame('map').status.mapas.value;
		document.statusdata.rmapas.value = crossGetFrame('map').status.rmapas.value;
	}
}

function nada() {
	return false;
}

function findObjectPosition(oTmp){
	var oPosition = { x : 0, y : 0 };
        while (oTmp.offsetParent){
		oPosition.x += oTmp.offsetLeft;	oPosition.y += oTmp.offsetTop; oTmp = oTmp.offsetParent;
	}
	return oPosition;
}

function getMouse(e){
	if(document.all){
		mouseY = mfo.event.clientY + mfd.body.scrollTop; mouseX = mfo.event.clientX + mfd.body.scrollLeft;
	} else {
		mouseY = e.pageY; mouseX = e.pageX;
	}
}

function showSelect() {
  mfd.getElementById("selectLayer").style.visibility="visible";
}

function hideSelect() {
  mfd.getElementById("selectLayer").style.visibility="hidden";
}




function redrawSelect() {

	with( mfd ) {

		sLayer.style.top = (oSelectInfo.y1 < oSelectInfo.y2 ? oSelectInfo.y1:oSelectInfo.y2) - (document.all ? 0:1);
		sLayer.style.left = (oSelectInfo.x1 < oSelectInfo.x2 ? oSelectInfo.x1:oSelectInfo.x2) - (document.all ? 0:1);
		sLayer.style.width  = Math.abs(oSelectInfo.x2 - oSelectInfo.x1);
		sLayer.style.height = Math.abs(oSelectInfo.y2 - oSelectInfo.y1);

		if( defClickAction == 2 || defClickAction == 5 ) {
			status.ix.value = (oSelectInfo.x1 < oSelectInfo.x2 ? oSelectInfo.x1 : oSelectInfo.x2) - oImageInfo.x;
			status.iy.value = (oSelectInfo.y1 < oSelectInfo.y2 ? oSelectInfo.y1 : oSelectInfo.y2) - oImageInfo.y;
			status.iw.value = Math.abs(oSelectInfo.x2 - oSelectInfo.x1);
			status.ih.value = Math.abs(oSelectInfo.y2 - oSelectInfo.y1);
		}
		else if ( defClickAction == 1 ) {

			mapa.style.top =   ( mouseY - iniY );
			mapa.style.left =  ( mouseX - iniX );

			status.ix.value = ( iniX - mouseX ) + mapWb2;
  		 	status.iy.value = ( iniY - mouseY ) + mapHb2;

			status.iw.value = 2;

			//mfd.images['myimage'].style.cursor = 'url(mapimages/hmove.cur)';
		}
		else if ( defClickAction == 6 ) {

	
			circleW = parseInt( sLayer.style.width ); 
			circleH = parseInt( sLayer.style.height ); 

			var radio = Math.sqrt( Math.pow( circleW , 2 ) + Math.pow( circleH , 2 ) );
	
			if( radio <  60 ) 
				circ.src = 'mapimages/circulo6.gif';
			else 
				circ.src = 'mapimages/circulo5.gif';

	
			if( oSelectInfo.y1 < oSelectInfo.y2 ) {
				sLayer.style.top = parseInt( sLayer.style.top ) - ( radio  );
			}
			else {
				sLayer.style.top = parseInt( sLayer.style.top  ) - ( radio - circleH );
			}

			if( oSelectInfo.x1 < oSelectInfo.x2 ) {
				sLayer.style.left = parseInt( sLayer.style.left ) - ( radio  ) ;
			}
			else {
				sLayer.style.left = parseInt( sLayer.style.left ) - ( radio - circleW  ) ;
			}

			circ.style.height = radio * 2;
			circ.style.width = radio * 2;

			status.ix.value = (oSelectInfo.x1 < oSelectInfo.x2 ? oSelectInfo.x1 : oSelectInfo.x2) - oImageInfo.x;
			status.iy.value = (oSelectInfo.y1 < oSelectInfo.y2 ? oSelectInfo.y1 : oSelectInfo.y2) - oImageInfo.y;

			status.iw.value = radio;
			status.ih.value = radio;


			window.status = 'Radio -> ' + ( ( parseInt( parseFloat( status.z.value ) * radio ) / mapW ) * 100 ) / 100  + ' Kilometros';

		}
		else if ( defClickAction == 7 ) {


			if( polyX == 0 && polyY == 0 || Math.sqrt( Math.pow( mouseX - polyX , 2 ) + Math.pow( mouseY - polyY , 2)  ) >= 10  ) {

				points[ points.length ] = mfd.createElement( '<img src="mapimages/punto.gif" height="3" width="3"  border="0" id="img' + points.length + '" style="position:absolute;" />' );
	
				mfd.body.insertBefore( points[ points.length - 1 ]  );
	

				points[ points.length - 1 ].style.top = mouseY;
				points[ points.length - 1 ].style.left = mouseX;



				polyX = mouseX;
				polyY = mouseY;
	
				xs[ xs.length ] = polyX;
				ys[ ys.length ] = polyY;
 		

				status.iw.value = mouseX;
				status.ih.value = mouseY;
			}

		}




	}
}

function cleanTools( ) {
		//ocultar bordes de cuadro de seleccion
		sLayer.style.borderWidth = 0;
		sLayer.style.height = 0;
		sLayer.style.width = 0;

		// eliminar puntos
		for( k = points.length - 1; k >= 0; k-- ) {		

			mfd.body.removeChild( points[k] );
		}
		points = new Array();



		// ocultar circulo 
		if( brow == 'ie' ) {
			mfd.all['circle'].style.visibility = 'hidden';
			mfd.all['circle'].style.height = 0;
			mfd.all['circle'].style.width = 0;
		} 
		else if(  brow == 'gk' ) {
			mfd.getElementById( 'circle' ).style.visibility = 'hidden';
			mfd.getElementById( 'circle' ).style.height = 0;
			mfd.getElementById( 'circle' ).style.width = 0;
		}
		else {
			mfd.all['circle'].style.visibility = 'hidden';
			mfd.all['circle'].style.height = 0;
			mfd.all['circle'].style.width = 0;
		} 




}


function down(e){

	with( mfd ) {

		defClickAction = Math.abs( status.daction.value );
		if((document.layers && e.which!=1) || (document.all && mfo.event.button!=1)) return true;

		bDown = true;
		bMustSetValues = true;
		getMouse(e);

		cleanTools();

		if ( defClickAction == 1 ) {
			iniX = mouseX;
			iniY = mouseY;
			changeCursor( 11 , crossGetFrame('map').images['myimage']  );

			if( document.all ) 
				mfd.all['virtualLayer'].style.visibility = 'hidden';
			else 
				mfd.getElementById('virtualLayer').style.visibility = 'hidden';

		}

		if ( defClickAction == 6 ) {
			if( brow == 'ie' || brow == 'gk' ) {
				mfd.getElementById( 'circle' ).src = 'mapimages/circulo6.gif';
				mfd.getElementById( 'circle' ).style.visibility = 'visible';
			}
			else  {
				mfd.images['circle'].src = 'mapimages/circulo3.gif';
				mfd.all['circle'].style.visibility = 'visible';
			}
		}
		else if( defClickAction == 2 || defClickAction == 5  ){
			sLayer.style.borderWidth = 2;		
		}


		if ( defClickAction == 1 || defClickAction == 2  || defClickAction == 5 || defClickAction == 6 || defClickAction == 7 ) {
			if (mouseX < oImageInfo.x) mouseX = oImageInfo.x;
			if (mouseX > (oImageInfo.x + oImageInfo.w)) mouseX = (oImageInfo.x + oImageInfo.w);
			if (mouseY < oImageInfo.y) mouseY = oImageInfo.y;
			if (mouseY > (oImageInfo.y + oImageInfo.h)) mouseY = (oImageInfo.y + oImageInfo.h);
		}
		else if ( defClickAction == 4 ) {
//- - - - - 
			oTmp = mfd.getElementById("rulerLayer");
			lin = mfd.getElementById("line");
			ver = mfd.getElementById("vertical");
			hor = mfd.getElementById("horizontal");
			dis = mfd.getElementById("distancia");

			lin.style.display = 'block';
			lin.style.visibility = 'visible';

			ver.style.display = 'block';
			hor.style.display = 'block';
			dis.style.display = 'block';

			ver.style.visibility = 'visible';
			hor.style.visibility = 'visible';
			dis.style.visibility = 'visible';
		
			oTmp.style.display = 'block';
			oTmp.style.visibility = 'visible';

		
			lin.style.height = 0;
			lin.style.width = 0;

			oTmp.style.visibility = "visible";

			oTmp.style.left =  mouseX ;
			oTmp.style.right =  mouseY ;

			oRulerInfo.x1 = mouseX;
			oRulerInfo.y1 = mouseY;

			oTmp.style.top = mouseY;
			oTmp.style.left = mouseX;

			oTmp.style.width = 1;
			oTmp.style.height = 1;


//- - - - -



		
		}
		else {
			bDown = false;
		}
	}

	return false;
}

function move(e){




	with( mfd ) {

		defClickAction = status.daction.value;

		if( defClickAction == 1 ||  defClickAction == 2 || defClickAction == 5 || defClickAction == 6 || defClickAction == 7 ) {
			if (bDown) {


				if (bMustSetValues) {
			 		oSelectInfo.x1 = mouseX;
					oSelectInfo.y1 = mouseY;
					bMustSetValues = false;
				}
				getMouse(e);

				if (mouseX < oImageInfo.x) mouseX = oImageInfo.x;
				if (mouseX > (oImageInfo.x + oImageInfo.w)) mouseX = (oImageInfo.x + oImageInfo.w);
				if (mouseY < oImageInfo.y) mouseY = oImageInfo.y;
				if (mouseY > (oImageInfo.y + oImageInfo.h)) mouseY = (oImageInfo.y + oImageInfo.h);
				oSelectInfo.x2 = mouseX;
			 	oSelectInfo.y2 = mouseY;
			 	redrawSelect();
			 	showSelect();

			}
			else if( defClickAction == 1 && parent.toolTipOn && parseInt( status.z.value ) <= 4 ) {

				getMouse(e);
				mouseX = parseInt( mouseX / 5 ) * 5;
				mouseY = parseInt( mouseY / 5 ) * 5;
	 
				locTooltip =  'street_tooltip.asp?ix=' + mouseX + '&iy=' + mouseY ;
				locTooltip += '&sx=' + status.x.value + '&sy=' + status.y.value;
				locTooltip += '&z=' + status.z.value;		
	
				if ( parent.sTooltipX != mouseX || parent.sTooltipY != mouseY )  {

					if( parent.calles[ mouseX + '-' + mouseY ] != null  ) {
						parent.showStreetTip( parent.calles[ mouseX + '-' + mouseY ]  );
					}
					else if ( parent.nocalles[ mouseX + '-' + mouseY ] == null ){
						if ( document.all ) {
							parent.document.frames['ttfeed'].location = locTooltip;
						}
						else {
							parent.document.getElementById( 'ttfeed' ).src = locTooltip;
						}
					}

				}
				parent.sTooltipX = mouseX;
				parent.sTooltipY = mouseY;			
	
			}
		


			if(document.all) return false;
		}
		else if ( defClickAction == 4 ) {


//-------
			if ( bDown ) {

				if (bMustSetValues) {
			 		oSelectInfo.x1 = mouseX;
					oSelectInfo.y1 = mouseY;
					bMustSetValues = false;
				}
				getMouse(e);
/*
				var oTmp = mfd.getElementById("rulerLayer");
				var ver = mfd.getElementById("vertical");
				var hor = mfd.getElementById("horizontal");
				var dis = mfd.getElementById("distancia");
				var lin = mfd.getElementById("line");
*/

				if( mouseX -  oRulerInfo.x1 > 0 ) {
					oTmp.style.borderColor = "red";
					oTmp.style.borderRightStyle = "dotted";
					oTmp.style.borderRightWidth = 1;
					oTmp.style.borderLeftStyle = "none";
					hor.style.left = oRulerInfo.x1 +  parseFloat( oTmp.style.width )/2;
					hor.style.top = oRulerInfo.y1;
					dis.style.left = oRulerInfo.x1 +  parseFloat( oTmp.style.width )/2 - 10;
				}
				else {
        		                oTmp.style.borderColor = "red";
					oTmp.style.borderLeftStyle = "dotted";
					oTmp.style.borderLeftWidth = 1;
					oTmp.style.borderRightStyle = "none";
					oTmp.style.left = oRulerInfo.x1 - Math.abs( mouseX -  oRulerInfo.x1  );
					hor.style.left = oRulerInfo.x1 - parseFloat( oTmp.style.width )/2;
					hor.style.top = oRulerInfo.y1;
					dis.style.left = oRulerInfo.x1 - parseFloat( oTmp.style.width )/2 - 25;
				}
		
				if(  mouseY -  oRulerInfo.y1 >  0 ) {
        		                oTmp.style.borderColor = "red";
					oTmp.style.borderTopStyle = "dotted";
					oTmp.style.borderTopWidth = 1;
					oTmp.style.borderBottomStyle = "none";	
	
					ver.style.top = oRulerInfo.y1 +  parseFloat( oTmp.style.height )/2;
					ver.style.left = mouseX;
					dis.style.top = oRulerInfo.y1 +  parseFloat( oTmp.style.height )/2 + 12;
				}
				else {
                		        oTmp.style.borderColor = "red";
					oTmp.style.borderBottomStyle = "dotted";
					oTmp.style.borderBottomWidth = 1;
					oTmp.style.borderTopStyle = "none";
					oTmp.style.top = oRulerInfo.y1 - Math.abs( mouseY -  oRulerInfo.y1  );
	
					ver.style.top = oRulerInfo.y1 -  parseFloat( oTmp.style.height )/2;
					ver.style.left = mouseX;
					dis.style.top = oRulerInfo.y1 -  parseFloat( oTmp.style.height )/2 + 12;

				}	


				if ( ( mouseX - oRulerInfo.x1 >= 0 && mouseY - oRulerInfo.y1  < 0 )  || ( mouseX - oRulerInfo.x1 < 0 && mouseY - oRulerInfo.y1  >= 0 )   ) {
                		        if( lin.src != diag2.src )
					      lin.src = diag2.src
				}
				else {
                		        if( lin.src != diag1.src )
					      lin.src = diag1.src
				} 

				if( mouseX < oImageInfo.w && mouseY < oImageInfo.h  ) {
					oTmp.style.width =  Math.abs( mouseX -  oRulerInfo.x1  );
					oTmp.style.height = Math.abs( mouseY -  oRulerInfo.y1 );
					lin.style.width =  Math.abs( mouseX -  oRulerInfo.x1  );
					lin.style.height = Math.abs( mouseY -  oRulerInfo.y1 );

				}

/*
				if ( parseInt( oTmp.style.width ) < 10 || parseInt( oTmp.style.height ) < 10  ) {
				    if( dis.style.visibility != "hidden" ) {
					    dis.style.visibility = "hidden";
					    lin.style.visibility = "hidden";
			            }
				}

				else {
				    if( dis.style.visibility != "visible" ) {                      
	    				    dis.style.visibility = "visible";
	    				    lin.style.visibility = "visible";
				    }
				}	
*/

				if( parseInt(oTmp.style.width) < 10 ) {

				//    if ( hor.style.visibility != "hidden" )   
				//	    hor.style.visibility = "hidden";


				    if (oTmp.style.borderLeftStyle != "solid"  ) {
					    oTmp.style.borderLeftStyle = "solid";
					    oTmp.style.borderLeftWidth = 2;
	        	   		    oTmp.style.borderRightStyle = "none";
					    oTmp.style.borderColor = "black";
				    }	    
				}
				else {

				  //  if( hor.style.visibility != "visible" ) {
			    	  //	    hor.style.visibility = "visible";
				  //  }
	
				}

				if( parseInt( oTmp.style.height ) < 10 ) {
	
		                    //if ( ver.style.visibility != "hidden" )  
				    //	    ver.style.visibility = "hidden";

	                	    if ( oTmp.style.borderTopStyle != "solid" ) {
					    oTmp.style.borderTopStyle = "solid";
					    oTmp.style.borderTopWidth = 2;
					    oTmp.style.borderBottomStyle = "none";
					    oTmp.style.borderColor = "black";
				    }
                    

				}
				else {


				}

	                	    if( ver.style.visibility != "visible" )
 				    	    ver.style.visibility = "visible";



				var ancho = parseInt(  ( ( Math.abs(mouseX -  oRulerInfo.x1) * iZoom  ) / iMWidth  )  * 1000 );
				ancho = parseFloat( ancho/1000 ) + 'Km';

				var alto = parseInt( ( ( Math.abs(mouseY -  oRulerInfo.y1) *  iZoom ) /  iMWidth  ) * 1000 );
				alto = parseFloat( alto/1000 ) + 'Km';

				var diagonal = Math.sqrt(  Math.pow( parseFloat(ancho), 2 ) + Math.pow( parseFloat(alto), 2 )   );
				diagonal = parseInt( diagonal * 1000 );
				diagonal = parseFloat( diagonal / 1000 ) +  'Km';




				if( document.all ) {
					ver.innerText = alto;
					hor.innerText = ancho;
					dis.innerText = diagonal;
				}
				else {
					if(  ver.hasChildNodes() ) {
						ver.replaceChild( document.createTextNode( alto ) , ver.lastChild  );
						hor.replaceChild( document.createTextNode( ancho ) , hor.lastChild  );
						dis.replaceChild( document.createTextNode( diagonal ) , dis.lastChild  );
					}
					else {
						ver.appendChild( document.createTextNode( alto )  );
						hor.appendChild( document.createTextNode( ancho )  );
						dis.appendChild( document.createTextNode( diagonal ) );
					}
				}
	
			}
			if(document.all) return false;
//--------





		}
	}
}

function up(e){
	with( mfd ) {

		if((document.layers && e.which!=1) || (document.all && mfo.event.button!=1)) return true;

		defClickAction = Math.abs( status.daction.value ) ;
		var oTmp = { x : mouseX, y : mouseY};

		bDown = false;

		getMouse(e);

		if (mouseX == oTmp.x && mouseY == oTmp.y) hideSelect;

		if( status.iw.value > 1  ) {
	
			if ( defClickAction == 1 ) {
				center( mfd.forms['status'] );
			}
			else if ( defClickAction == 2 ) {
				zoomArea( mfd.forms['status'] );
			}
			else if ( defClickAction == 5 ) {
				parent.localShowInfo( 'info.asp?x=' + mouseX + '&y=' + mouseY + '&sx=' + iLong + '&sy=' + iLat + '&z=' + iZoom  + '&mw=' + status.mw.value + '&mh=' + status.mh.value + '&iw=' + status.iw.value + '&ih=' + status.ih.value + '&ix=' + status.ix.value + '&iy=' + status.iy.value , 580 , 200  );

				status.iw.value = 0;
				status.ih.value = 0;
			}	
			else if ( defClickAction == 6 ) {
				parent.localShowInfo( 'info.asp?x=' + mouseX + '&y=' + mouseY + '&sx=' + iLong + '&sy=' + iLat + '&z=' + iZoom  + '&mw=' + status.mw.value + '&mh=' + status.mh.value + '&iw=' + status.iw.value + '&ih=' + status.ih.value + '&ix=' + status.ix.value + '&iy=' + status.iy.value + '&r=1' , 580 , 200  );
				status.iw.value = 0;
				status.ih.value = 0;
			}
			else if( defClickAction == 7 ) {
				status.xs.value = xs.join('-');
				status.ys.value = ys.join('-');

				parent.localShowInfo( 'info.asp?x=' + mouseX + '&y=' + mouseY + '&sx=' + iLong + '&sy=' + iLat + '&z=' + iZoom  + '&mw=' + status.mw.value + '&mh=' + status.mh.value + '&iw=' + status.iw.value + '&ih=' + status.ih.value + '&ix=' + status.ix.value + '&iy=' + status.iy.value + '&xs=' + xs.join('-') + '&ys=' + ys.join('-') , 580 , 200  );


				xs = new Array();
				ys = new Array();

			}
		}
		else {
			status.ix.value = mouseX;
			status.iy.value = mouseY;

			switch ( defClickAction ) {

				case 1:
				center( status );
				changeCursor( 1 , crossGetFrame('map').images['myimage']  );
				break;

				case 2:
				zoomInAndCenter( status );
				break;

				case 3:
				zoomOutAndCenter( status );
				break;

				case 5:
				status.iw.value = 0;
				status.ih.value = 0;
				hideSelect();
				parent.localShowInfo( 'info.asp?x=' + mouseX + '&y=' + mouseY + '&sx=' + iLong + '&sy=' + iLat + '&z=' + iZoom  + '&mw=' + status.mw.value + '&mh=' + status.mh.value  , 580 , 200  );
				break;

				case 7:
				break;

				case 9:
				status.iw.value = 0;
				status.ih.value = 0;
				hideSelect();
				parent.localShowInfo( 'regionid.asp?x=' + mouseX + '&y=' + mouseY + '&sx=' + iLong + '&sy=' + iLat + '&z=' + iZoom  + '&mw=' + status.mw.value + '&mh=' + status.mh.value  , 380 , 400  );
				break;


				case 10:
				status.iw.value = 0;
				status.ih.value = 0;
				hideSelect();
				parent.alterOpenPopUp( 'add_anotation.asp?x=' + mouseX + '&y=' + mouseY + '&sx=' +  status.x.value + '&sy=' +  status.y.value + '&z=' + iZoom  + '&mw=' + status.mw.value + '&mh=' + status.mh.value + '&pio=' + status.pio.value , 400, 80, 'addpoi' );

				break;



			}
		}
	}
	return true;
}


function showStatus( ) {


	if ( browser == 'moz'  ) {
		window.frames['map'].showStatus();		
	}
	else if( browser == 'ie' ) {
		mfo.showStatus();
	}
	else {
		mfo.showStatus();
	}
	
	if ( document.statusdata ) {
		document.statusdata.mapas.value = crossGetFrame('map').status.mapas.value;
	}


}


function center( forma ) {
forma.op.value="6";
showStatus();
forma.submit();	
}
function zoomOutAndCenter( forma ) {
forma.op.value="9";
showStatus();
forma.submit();	
}
function zoomInAndCenter( forma ) {
forma.op.value="8";
showStatus();
forma.submit();	
}
function zoomArea( forma ) {
forma.op.value="4";
showStatus();
forma.submit();	
}
function testCom(){
alert('Hola desde este frame');
}
function hideLayer( layer ) {
if( mapOn ) {
with( mfd ) {
if( document.all ) {
 mfd.all[ layer ].style.visibility="hidden";
 mfd.all[ 'don' ].style.visibility="hidden";
}
else {
 mfd.getElementById( layer ).style.visibility="hidden";
 mfd.getElementById('don').style.visibility="hidden";
}
}
}
}


function showLayer( t, d, w ) {
	var mylayer, mypoi, tlayer, nlayer, onlayer, mytop, myleft, myheight, mywidth;
if( mapOn ) {
	with( mfd ) {
	
 		if( document.all ) {
			mylayer = mfd.all['poilabel'];
			tlayer = mfd.all['poitype'];
			nlayer = mfd.all['poiname'];
			onlayer = mfd.all['don'];
			mypoi = mfd.all[ w ];
		}
		else {
			mylayer = mfd.getElementById('poilabel');
			tlayer = mfd.getElementById('poitype');
			nlayer = mfd.getElementById('poiname');
			onlayer = mfd.getElementById('don');
			mypoi = mfd.getElementById( w );
		}

	mylayer.style.visibility= "visible";

	mytop = parseFloat( mypoi.style.top );
	myleft = parseFloat( mypoi.style.left );


	if( document.all ) {
		tlayer.innerText = t;
		nlayer.innerText = d;
		myheight = parseFloat(  mylayer.clientHeight );
	}
	else {
		if( tlayer.hasChildNodes() ) {
			tlayer.replaceChild( document.createTextNode( t ) , tlayer.lastChild  );
			nlayer.replaceChild( document.createTextNode( d ), nlayer.lastChild  );
		}
		else {
			tlayer.appendChild( document.createTextNode( t )  );
			nlayer.appendChild( document.createTextNode( d )  );
		}
		myheight = parseFloat(  mylayer.style.height );
	}

	onlayer.style.visibility = "visible";
	onlayer.style.top = mypoi.style.top;
	onlayer.style.left = mypoi.style.left;

	if( mytop < ( iMHeight - 50 ) ) {
		mylayer.style.top = ( mytop  );
	}
	else {
		mylayer.style.top = ( mytop - myheight + 12 );
	}

	if( myleft < ( iMWidth - 150 ) ) {
		mylayer.style.left = ( myleft + 16 );
	}
	else {
		mylayer.style.left = ( myleft - 150);
	}

	}
}
}


function hideStreetTip() {
	if ( mapOn ) {
		with( mfd ) {
	
 			if( document.all ) {
				mfd.all['stooltip'].style.visibility = 'hidden';
			}
			else {
				mfd.getElementById('stooltip').style.visibility = 'hidden';
			}
		}
	}
}

function showStreetTip( calle ) {
	var mylayer;
if( mapOn ) {
	with( mfd ) {
	
 		if( document.all ) {
			myLayer = mfd.all['stooltip'];
		}
		else {
			myLayer = mfd.getElementById('stooltip');
		}

	myLayer.style.visibility= "visible";

	iMWidth = mfd.status.mw.value;
	iMHeight = mfd.status.mh.value;

	myleft = parent.sTooltipX;	
	mytop = parent.sTooltipY;


	if( document.all ) {
		myLayer.innerText = calle;
		myheight = parseFloat(  myLayer.clientHeight );
		mywidth = parseFloat(  myLayer.clientWidth );
	}
	else {
		if( myLayer.hasChildNodes() ) {
			myLayer.replaceChild( document.createTextNode( calle ) , myLayer.lastChild  );

		}
		else {
			myLayer.appendChild( document.createTextNode( calle )  );

		}
		myheight = parseFloat(  myLayer.style.height );
		mywidth = parseFloat(  myLayer.style.width );

	}

	if( mytop < ( iMHeight  ) ) {
		myLayer.style.top = ( mytop - 14 );
	}
	else {
		myLayer.style.top = ( mytop - myheight - 14 );
	}

	if( myleft < ( iMWidth - mywidth ) ) {
		myLayer.style.left = ( myleft  );
	}
	else {
		myLayer.style.left = ( myleft - mywidth);
	}

	}

}
}



