// formatos.js copyright Poggi Sebastian  May/Jun 2009
//--------------------------------------------------------------------------------------------------------------
var desplazamiento = 0;
var idDesp;							// intervalo de desplazamiento
var herramientasVisible = false;
var mapa_cargado = 'no';
var map;							// mapa de google


var geocoder;
var rutaParcial; // GDirections Object
//--------------------------------------------------------------------------------------------------------------
function myWidth() 
{
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------

function myHeight() 
{
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
window.onload = function() { 
misVentanas(); 
} 
window.onresize = function() { 
misVentanas(); 
} 
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
function misVentanas() 
{
	var alto_logo = 100;
	var ancho_logo = 550;
	var alto_barramenu = 25;
	var ancho_publi2 = 170;
	var mi_alto = myHeight();
	var mi_ancho = myWidth();
	
	document.getElementById('publicidad1').style.width = (mi_ancho-ancho_logo)+'px';
	
	document.getElementById('encuadrePublicidad1').style.width = (mi_ancho-ancho_logo-70)+'px';

	document.getElementById('publicidad2').style.height = (mi_alto-alto_barramenu-alto_logo)+'px';
	
	document.getElementById('barraMenu').style.width = (mi_ancho)+'px';
	
	document.getElementById('herramientas').style.height = (mi_alto-alto_barramenu-alto_logo)+'px';
	
	document.getElementById('menuEmergente').style.height = (mi_alto-alto_logo)+'px';

	if(herramientasVisible == true)
	{	
		var mi_ancho = myWidth();
		document.getElementById('mapa').style.width = (mi_ancho-desplazamiento)+'px';
	}
	else
	{
		document.getElementById('mapa').style.width = (mi_ancho-ancho_publi2)+'px';
	}
	document.getElementById('mapa').style.height = (mi_alto-alto_barramenu-alto_logo)+'px';
		
	if(mapa_cargado=='no')
	{
		cargarHtmlAsincrono('urbanos/herramientas/menu.php', 'barraMenu');
		//var ruta1 = 'urbanos/publicidades/propias/ubicador1.php?espacio=' + (mi_ancho-ancho_logo-70);
		//cargarHtmlAsincrono(ruta1, 'encuadrePublicidad1');
		var ruta2 = 'urbanos/publicidades/propias/preUbicador2.php?alto=' + (mi_alto-alto_logo-alto_barramenu);
		cargarHtmlAsincrono(ruta2, 'publicidad2');
		document.getElementById('cuerpo').style.visibility = 'visible';//una vez que esta todo acomodado muestra
		if(GBrowserIsCompatible()) 
		{
			// Make sure that SVG is on.
			if(document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#SVG","1.1"))
			{ 
				_mSvgEnabled = true;
				_mSvgForced  = true;
			}
			map = new GMap2(document.getElementById("mapa"));
			map.addControl(new GSmallMapControl());
			map.setCenter(new GLatLng(-31.416706, -64.183846),12);
			map.enableScrollWheelZoom();
		}
		mapa_cargado = 'si';
		cargarHtmlAsincrono('urbanos/herramientas/buscadores/paginaInicial.php', 'herramientas');
	}
}
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
function iniciarDesp() 
{
	if(desplazamiento == 492 || desplazamiento == 0)//antirebote
	{
		idDesp = setInterval("despHerramientas()",10);
	}
}
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
function despHerramientas()
{
	var ancho = 492;	
	if(herramientasVisible == false)
	{
			document.getElementById('publicidad2').style.visibility = 'hidden';
			desplazamiento = desplazamiento + 30;
			if(desplazamiento >= ancho)
			{	
				clearInterval(idDesp);
				desplazamiento = ancho;
				herramientasVisible = true;
				document.getElementById('expandirMenu').style.visibility = 'hidden';
				document.getElementById('expandirMenuMouse').style.visibility = 'hidden';
			}
			var variable = desplazamiento + 'px';
			document.getElementById('menuEmergente').style.width = variable;
			if(desplazamiento >= 170)
			{	
				var mi_ancho = myWidth();
				document.getElementById('mapa').style.width = (mi_ancho-desplazamiento)+'px';
			}
			return;
	}
	if(herramientasVisible == true)
	{
			if(desplazamiento == ancho)
			{	
				
			}
			desplazamiento = desplazamiento - 30;
			if(desplazamiento <= 0)
			{	
				clearInterval(idDesp);
				desplazamiento = 0;
				herramientasVisible = false;
				document.getElementById('publicidad2').style.visibility = 'visible';
				document.getElementById('expandirMenu').style.visibility = 'visible';
				document.getElementById('expandirMenuMouse').style.visibility = 'visible';
			}
			var variable = desplazamiento + 'px';
			document.getElementById('menuEmergente').style.width = variable;
			if(desplazamiento >= 170)
			{	
				var mi_ancho = myWidth();
				document.getElementById('mapa').style.width = (mi_ancho-desplazamiento)+'px';
			}
			else
			{
				var mi_ancho = myWidth();
				document.getElementById('mapa').style.width = (mi_ancho-170)+'px';
			}
			return;
	}
}
//--------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------
inicioUp = new Image()
inicioUp.src = "urbanos/imagenes/botones/inicioUp.gif"
inicioSelect = new Image()
inicioSelect.src = "urbanos/imagenes/botones/inicioUp.gif"
inicioOver = new Image()
inicioOver.src = "urbanos/imagenes/botones/inicioOver.gif" 
callesUp = new Image()
callesUp.src = "urbanos/imagenes/botones/callesUp.gif"
callesSelect = new Image()
callesSelect.src = "urbanos/imagenes/botones/callesUp.gif"
callesOver = new Image()
callesOver.src = "urbanos/imagenes/botones/callesOver.gif" 
barriosUp = new Image()
barriosUp.src = "urbanos/imagenes/botones/barriosUp.gif"
barriosSelect = new Image()
barriosSelect.src = "urbanos/imagenes/botones/barriosUp.gif"
barriosOver = new Image()
barriosOver.src = "urbanos/imagenes/botones/barriosOver.gif" 
colectivosUp = new Image()
colectivosUp.src = "urbanos/imagenes/botones/colectivosUp.gif"
colectivosSelect = new Image()
colectivosSelect.src = "urbanos/imagenes/botones/colectivosUp.gif"
colectivosOver = new Image()
colectivosOver.src = "urbanos/imagenes/botones/colectivosOver.gif"
traspasoUp = new Image()
traspasoUp.src = "urbanos/imagenes/botones/traspasoUp.gif"
traspasoSelect = new Image()
traspasoSelect.src = "urbanos/imagenes/botones/traspasoUp.gif"
traspasoOver = new Image()
traspasoOver.src = "urbanos/imagenes/botones/traspasoOver.gif" 
datosUp = new Image()
datosUp.src = "urbanos/imagenes/botones/datosUp.gif"
datosSelect = new Image()
datosSelect.src = "urbanos/imagenes/botones/datosUp.gif"
datosOver = new Image()
datosOver.src = "urbanos/imagenes/botones/datosOver.gif" 
//--------------------------------------------------------------------------------------------------------------
