
var servicios_1 = new Array("Seleccione una zona","Zona A","Zona B","Zona C");
var servicios_2 = new Array("Seleccione una zona","Zona A","Zona B");
var servicios_3 = new Array("Seleccione una zona","Zona A","Zona B","Zona C");
var servicios_4 = new Array("Seleccione una zona","Zona A","Zona B"); 

/*var precios_Hora = new Array(0,  8.75,  8.75,  8.75,  8.50,   8.50,  8.50,  8.25,  8.10);
var precios_ZAS1 = new Array(0,    35,  52.5,    70,  76.5,    102, 127.5,   165,   324);
var precios_ZBS1 = new Array(0, 36.68, 55.86, 73.36, 81.54, 107.04, 135.9, 173.4, 332.4); 
var precios_ZCS1 = new Array(0, 36.90, 56.30, 73.80, 82.20, 107.70,   137, 174.5, 333.5); 

var precios_Servicio2 = new Array(0, 11, 11, 11, 11, 11, 11, 11, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 11, 11, 11); */


var precios_Hora = new Array(0,  8.90,  8.90,  8.90,  8.65,   8.65,   8.65,   8.39,   8.24);
var precios_ZAS1 = new Array(0, 35.60, 53.40, 71.20, 77.85, 103.80, 129.75, 167.80, 329.60);
var precios_ZBS1 = new Array(0, 37.32, 56.84, 74.64, 83.01, 110.68, 138.35, 176.40, 338.20); 
var precios_ZCS1 = new Array(0, 37.64, 57.28, 75.08, 83.67, 111.56, 139.45, 177.50, 339.30); 

var precios_ZAS2 = new Array(0, 11.19, 11.19, 11.19, 11.19, 11.19, 11.19, 11.19, 9.67, 9.67, 9.67, 9.67, 9.67, 9.67, 9.67, 9.67, 9.67, 9.67, 9.67, 9.67, 9.67, 9.67, 11.19, 11.19, 11.19); 
var precios_ZBS2 = new Array(0, 12.91, 12.91, 12.91, 12.91, 12.91, 12.91, 12.91, 11.39, 11.39, 11.39, 11.39, 11.39, 11.39, 11.39, 11.39, 11.39, 11.39, 11.39, 11.39, 11.39, 11.39, 12.91, 12.91, 12.91); 





Main.InitMenus = function  (aURL)
{
	if (aURL.length == 1 && aURL [0] == '') Main.InitMenus (Array ('home'));
	else
	{	if (aURL.length >= 1) 
		{	$ ('idMen_' + aURL [0], 'src', '/imagenes/menu/' + aURL [0] + '_on.gif');
			$ ('idMen_' + aURL [0]).onmouseout = null;
			$ ('idMen_' + aURL [0]).onmouseover = null;
		}
		if (aURL.length > 1)
		{	$ ('idMen_' + aURL [1], 'src', '/imagenes/menu/' + aURL [0] + '/' + aURL [1] + '_on.gif');
			$ ('idMen_' + aURL [1]).onmouseout = null;
			$ ('idMen_' + aURL [1]).onmouseover = null;
		}
	}
}


function Main () {}


//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////

Main.AvisoLegal = function ()
{
	var Ventana = new TVentanas ();

	Ventana.Tipo           = 2;
	Ventana.Ancho          = 550;
	Ventana.Alto           = 550;
	Ventana.BarraScroll    = true;
	Ventana.Vars.Plantilla = 'plantillas/tpls/avisolegal.tpl';
	Ventana.CerrarOnVelo   = true;
	Ventana.Cargar ();
}

Main.Lopd = function ()
{
	var Ventana = new TVentanas ();

	Ventana.Tipo           = 2;
	Ventana.Ancho          = 550;
	Ventana.Alto           = 300;
	Ventana.Vars.Plantilla = 'plantillas/tpls/lopd.tpl';
	Ventana.CerrarOnVelo   = true;
	Ventana.Cargar ();
}

Main.VerMapa = function ()
{
  var Ventana = new TVentanas ();
  	
  Ventana.Tipo           = 2;
  Ventana.Ancho          = 640;
  Ventana.Alto           = 640;
  Ventana.Vars.Plantilla = 'plantillas/tpls/mapa.tpl';
  Ventana.Cargar ();
}


Main.EnviarAmigo = function Ventana ()
{
  var Ventana = new TVentanas ();
  	
  Ventana.Tipo           = 2;
  Ventana.Ancho          = 600;
  Ventana.Alto           = 400;
  Ventana.Vars.Plantilla = 'plantillas/tpls/enviaramigo.tpl';
  Ventana.Cargar ();
}


Main.RollOut = function (oImg) 
{
	oImg.src = oImg.src.substr (0, oImg.src.length - 7) + '.gif';
}


Main.RollOver = function (oImg) 
{ 
	oImg.src = oImg.src.substr (0, oImg.src.length - 4) + '_on.gif';
}

Main.RollOutHome = function (oImg) 
{
	oImg.src = oImg.src.substr (0, oImg.src.length - 7) + '.jpg';
}

Main.RollOverHome = function (oImg) 
{ 
	oImg.src = oImg.src.substr (0, oImg.src.length - 4) + '_on.jpg';
}




Main.CambiarServicio = function ()
{
    var servicio = document.Datos.Servicios[document.Datos.Servicios.selectedIndex].value;
    
    if (servicio != 0) 
   	{
       mis_zonas = eval("servicios_" + servicio);
       num_zonas = mis_zonas.length;
       document.Datos.Zonas.length = num_zonas;
       for (i=0; i<num_zonas; i++)
       {
          document.Datos.Zonas.options[i].value	= mis_zonas[i];
          document.Datos.Zonas.options[i].text	= mis_zonas[i];
       }
    } else
    {
       document.Datos.Zonas.length = 1
       document.Datos.Zonas.options[0].value = "0";
       document.Datos.Zonas.options[0].text  = "Seleccione una zona";
    }
    document.Datos.Zonas.options[0].selected = true;
    Main.MostrarTarifas ();
}


Main.MostrarTarifas = function ()
{
	$ ('Zona A', 'style.display', 'none');
	$ ('Zona B', 'style.display', 'none');
	$ ('Zona C', 'style.display', 'none');
	
	var Zona  = document.Datos.Zonas[document.Datos.Zonas.selectedIndex].value;
	if (document.Datos.Zonas.selectedIndex != 0) 
	{
		 for(i=1;i<5;i++) $ (Zona+'_Servicio'+i, 'style.display', 'none');
     $ (Zona, 'style.display', 'block');
		 var Servicio = document.Datos.Servicios[document.Datos.Servicios.selectedIndex].value;
		 $ (Zona+'_Servicio'+Servicio, 'style.display', 'block');
		 
		 if (Servicio == 1)
		 { $ ('idTR_TotalZAS1', 'style.display', 'none');
		 	 $ ('idTR_TotalZBS1', 'style.display', 'none');
		 	 $ ('idTR_TotalZCS1', 'style.display', 'none');
		 	 document.Datos.selZAS1.options[0].selected = true;
		 	 document.Datos.selZBS1.options[0].selected = true;
		 	 document.Datos.selZCS1.options[0].selected = true;		 	 
		 }
		 
		 if (Servicio == 2)
		 { $ ('idTR_TotalZAS2', 'style.display', 'none');
		 	 $ ('idTR_TotalZBS2', 'style.display', 'none');
		 	 document.Datos.selZAS2_Inicio.options[0].selected = true;
		 	 document.Datos.selZAS2_Fin.options[0].selected = true;
			 document.Datos.selZBS2_Inicio.options[0].selected = true;
		 	 document.Datos.selZBS2_Fin.options[0].selected = true;		 	 
		 }
		 
	} 
}


Main.TotalZA_Servicio1 = function ()
{
	$ ('id_TotalZAS1_H', 'style.display', document.Datos.selZAS1.selectedIndex != 0 ? 'block' : 'none');
	$ ('id_TotalZAS1_S', 'style.display', document.Datos.selZAS1.selectedIndex != 0 ? 'block' : 'none');
	$ ('TotalZAS1_S', 'innerHTML', FlotanteACadena (precios_ZAS1 [document.Datos.selZAS1.selectedIndex], 2));	
	$ ('TotalZAS1_H', 'innerHTML', FlotanteACadena (precios_Hora [document.Datos.selZAS1.selectedIndex], 2));	
}

Main.TotalZB_Servicio1 = function ()
{
	$ ('id_TotalZBS1_H', 'style.display', document.Datos.selZBS1.selectedIndex != 0 ? 'block' : 'none');
	$ ('id_TotalZBS1_S', 'style.display', document.Datos.selZBS1.selectedIndex != 0 ? 'block' : 'none');
	$ ('TotalZBS1_H', 'innerHTML', FlotanteACadena (precios_Hora [document.Datos.selZBS1.selectedIndex], 2));
	$ ('TotalZBS1_S', 'innerHTML', FlotanteACadena (precios_ZBS1 [document.Datos.selZBS1.selectedIndex], 2));
	
}

Main.TotalZC_Servicio1 = function ()
{
	$ ('id_TotalZCS1_H', 'style.display', document.Datos.selZCS1.selectedIndex != 0 ? 'block' : 'none');
	$ ('id_TotalZCS1_S', 'style.display', document.Datos.selZCS1.selectedIndex != 0 ? 'block' : 'none');
	$ ('TotalZCS1_H', 'innerHTML', FlotanteACadena (precios_Hora [document.Datos.selZCS1.selectedIndex], 2));
	$ ('TotalZCS1_S', 'innerHTML', FlotanteACadena (precios_ZCS1 [document.Datos.selZCS1.selectedIndex], 2));
	
}


Main.TotalZA_Servicio2 = function ()
{
	var iInicio = document.Datos.selZAS2_Inicio[document.Datos.selZAS2_Inicio.selectedIndex].value.asInteger ();
	var iFin    = document.Datos.selZAS2_Fin[document.Datos.selZAS2_Fin.selectedIndex].value.asInteger ();
	var TotalI	= 0;
	var TotalF	= 0;
		
	$ ('idTR_TotalZAS2', 'style.display', (iInicio != 0 && iFin != 0 && iInicio != iFin) ? 'block' : 'none');
	
	if (iInicio != 0 && iFin != 0 && iInicio != iFin)
	{	
		if ((iFin > iInicio) && (iFin <= 24)) for (i=iInicio; i<=iFin-1; i++) TotalI += precios_ZAS2 [i]; 
		else 
			if (iFin < iInicio)	
			{ for (i=iInicio; i<=24; i++) TotalI += precios_ZAS2 [i];
				for (i=1; i<=iFin-1; i++)   TotalF += precios_ZAS2 [i];				
			}
	
		$ ('TotalZAS2', 'innerHTML', FlotanteACadena (TotalI+TotalF, 2));
	}
}


Main.TotalZB_Servicio2 = function ()
{
	var iInicio = document.Datos.selZBS2_Inicio[document.Datos.selZBS2_Inicio.selectedIndex].value.asInteger ();
	var iFin    = document.Datos.selZBS2_Fin[document.Datos.selZBS2_Fin.selectedIndex].value.asInteger ();
	var TotalI	= 0;
	var TotalF	= 0;
		
	$ ('idTR_TotalZBS2', 'style.display', (iInicio != 0 && iFin != 0 && iInicio != iFin) ? 'block' : 'none');
	
	if (iInicio != 0 && iFin != 0 && iInicio != iFin)
	{	
		if ((iFin > iInicio) && (iFin <= 24)) for (i=iInicio; i<=iFin-1; i++) TotalI += precios_ZBS2 [i]; 
		else 
			if (iFin < iInicio)	
			{ for (i=iInicio; i<=24; i++) TotalI += precios_ZBS2 [i];
				for (i=1; i<=iFin-1; i++)   TotalF += precios_ZBS2 [i];				
			}
		
		$ ('TotalZBS2', 'innerHTML', FlotanteACadena (TotalI+TotalF, 2));
	}
}



Main.EnviarMailAmigo = function (oFormulario)
{
  var Ajax = new TAjax ();
	
	if (Formulario.Validar (oFormulario))
	{	if (! oFormulario.Lopd.checked) alert ('Tiene que aceptar nuestra politica de privacidad y confidencialidad.');
		else
		{	Ajax.onCargar = function (oPeticion)
											{
												var Aux = oPeticion.asText ();
												
												if (Aux.substr (0, 4) == 'MSG:') alert (Aux.substr (4));
												else if (Aux == 'OK') 	{ alert('Su mensaje ha sido enviado correctamente.'); TVentanas.Cerrar (); }
												else alert ("No se ha podido enviar el formulario.\nPor favor vuelva a intentarlo.");
											}
			Ajax.Formulario (oFormulario)
			Ajax.Cargar ('/fuentes/enviaramigo.php');
		}
	}
}
