// ----------------------------------------------------------------------
// FUNCIONES PARA EL MANTENIMIENTO DEL MENU
// ----------------------------------------------------------------------

function abre_ventana (url,x,y, scrollact)
{
		window.open (url, 'GrupoPrima', 'width='+x+', height='+y+', toolbar=no, menubar=no, location=no, status=no, resizable=no, titlebar=no, scrollbars=yes');
}
function cierra_todo (el)
{
	var cont = 1;
	while (document.getElementById(el+"-"+cont))
	{		
		cierra_todo (el+"-"+cont);		
		if (document.getElementById(el+"-"+cont))
			document.getElementById(el+"-"+cont).className = "class_resaltado_off";
		if (document.getElementById("sub-"+(el+"-"+cont).substring(2,(el+"-"+cont).length)))
			document.getElementById("sub-"+(el+"-"+cont).substring(2,(el+"-"+cont).length)).style.display = "none"
		cont++;
	}
}
function abre_rama (el)
{
	/* Marco nodo actual */	
	document.getElementById(el).className = "class_resaltado";
	
	/* Muestro su submenu del nodo actual. No se marca ninguno porque es IMPOSIBLE que estando cerrado estuviese marcado algo */	
	el = el.replace ('m','sub');
	if (document.getElementById(el))
		document.getElementById(el).style.display = "";
	
	/* Abro los padres y los resalto */	
	el = el.replace ('sub','m');
	while (el.length > 1)
	{		
		/* Busco el submenu al que pertenece el nodo actual y lo abro */		
		el = el.replace ('m','sub');
		if (document.getElementById(el))
			document.getElementById(el).style.display = "";

		/* Resalto el elemento "padre" del menu que contiene al nodo actual y 
		   elimino el último valor de la cadena para obtener el nombre del padre */		   
		el = el.replace ('sub','m');
		document.getElementById(el).className = "class_resaltado";
		el = el.substring (0, el.lastIndexOf("-",el.length)) 
	}
}
function Accion_menu (el)
{
	cierra_todo ('m');
	abre_rama (el);
}

// ----------------------------------------------------------------------
// FUNCIONES QUERYTRING
// ----------------------------------------------------------------------

function PageQuery(q) {
	if(q.length > 1)
		this.q = q.substring(1, q.length);
	else
		this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() {
		return this.keyValuePairs;
	}
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() {
		return this.keyValuePairs.length;
	}
}

function queryString(key){
	var page = new PageQuery(window.location.search);
	return unescape(page.getValue(key));
}

function isEmpty(s)		
{   			
	if(isNaN(parseFloat(s))) 
	{				
		return ((s == null) || (s.length == 0) )			
	}			
	else 
	{				
		return ((s == null) || (s.length == 0) )			
	}			
}	

function ValidaEntrada(which) 
{			
	if (isEmpty(which.usuario.value)) 
	{				
		alert("Debe introducir el nombre de usuario.");				
		return false;
	}			
	else
		if (isEmpty(which.clave.value))
		{
			alert("Debe introducir la contraseña.");
			return false;
		} 
		else
		{
			which.submit();
		}
}

function AbrirTaller (p,sitio){

  if (sitio === undefined) {
	  sitio = 'grupoprima';
  }

  localidad = new Array ();
  //'nombre', 'teléfono', 'fax', 'web', 'e-mail', 'dirección', 'persona contacto', 'horario', 'disponibilidad', 'imagen';
  //CASTELLÓN
  localidad[0] = new Array ('Talleres Ortgran S.L.', '964.256.719', '', '', 'ortgran@telefonica.net', 'Polígono Pi Gros, nave 2-27', 'Jesús Ortega Granados', '6.00 - 22.00 h', '2 de cortesía', 'TalleresOrtgranSL.jpg');
  localidad[1] = new Array ('Talleres Chulvi S.L.', '964.255.010', '', '', 'chulvi@tallereschulvi.com', 'Pol. Ind. Estadio, Av. Benicasim, 29', 'Luís Chulvi', '8.30-13.30 / 15.30-19.30h', '1 de cortesía', 'TalleresChulviSL.jpg');
  localidad[2] = new Array ('Fravicma S.L.', '964.342.429', '', 'www.fravicma.com', 'info@fravicma.com', 'C/. Bélgica esq. Cuadra de Morteras', 'Silverio Marín', '8.00 - 20.00h', '3 de cortesía', 'FravicmaSL.jpg');
  localidad[3] = new Array ('Xapa-Mobil S.L.', '964.341.904', '', '', 'tallerxapamobil@terra.es', 'Cuadra Lairon, 2-2b (C. Transporte)', 'Antonio', '8-13.30 / 15.30 - 19.30h', '1 de cortesía', 'Xapa-MobilSL.jpg');
  localidad[4] = new Array ('Ferrer Selma S.L.', '964.214.453', '', '', 'info@ferrerselma.es', 'Pol. Ind. "La Basala", nave 5', 'Emilo Ferrer', '8.30-13.30 / 15.30-19.30h', '1 de cortesía', 'FerrerSelmaSL.jpg');
  localidad[5] = new Array ('JJ Jumar S.L.', '964.238.500', '', 'www.jumar.net', 'jumar@jumar.net', 'C/ Els Ports, 7 (junto Nissan-Satra)', 'Marcos Alegre', '8.30-13.30 / 15.30-18.30h', '1 de cortesía', 'JJJumarSL.jpg');
  //ALMAZORA
  localidad[6] = new Array ('Grifo Gimeno S.L.', '964.560.980', '', '', 'administración@grifogimeno.com', 'Pol. Ind. Mijares, C/. Comercio, 5', 'Manuel Grifo', '8.30-13.30 / 15.30-19.30h', '1 de cortesía', 'GrifoGimenoSL.jpg');
  //BECHI
  localidad[7] = new Array ('Automoción F. Alcantara', '964.620.785', '', '', 'anaramos@alavaz.net', 'Joaquin Ferrandis, 70', 'Ana Ramos', '8.30-13.30 / 15.30-19.30h', '1 de cortesía', 'AutomocionFAlcantara.jpg');
  //BENICARLO
  localidad[8] = new Array ('Esteller Import, S.L.', '964.467.240', '', '', 'marta@estellerimport.com', 'Av. Magallanes, 1', 'Marta Esteller', '8.30-13.00 / 15.00-19.00h', '1 de cortesía', 'EstellerImportSL.jpg');
  //BENICASSIM
  localidad[9] = new Array ('Motorcasim S.L.', '964.304.729', '', '', 'motorcasim@telefonica.net', 'Pol. Ind. C/. Isaac Peral, 5', 'Jose Antonio Pintado', '8 - 22h', '2 de cortesía', 'MotorcasimSL.jpg');
  //BURRIANA
  localidad[10] = new Array ('Talleres Fco. Serrano', '964.591.464', '', '', 'fserrano70@hotmail.com', 'Ctra. Burriana-Nules (detrás Renault)', 'Francisco Serrano', '8.30-13.30 / 15.30-18.30h', '', 'TalleresFcoSerrano.jpg');
  //ONDA
  localidad[11] = new Array ('Azulauto S.L.', '964.601.668', '', '', 'azulauto@fordservicios.com', 'Av. Andalucia, 23', 'Andrés López', '8.30-13.30 / 15.30-19.30h', '1 de cortesía', 'AzulautoSL.jpg');
  //SEGORBE
  localidad[12] = new Array ('Talleres Barrachina', '964.71.11.22', '', '', 'b@barrachina.e.telefonica.net', 'Av. Mediterraneo, s/n', 'Natividad Barrachina', '8.30-13.30 / 15.30-19.30h', '1 de cortesía', 'TalleresBarrachina.jpg');
  //VALL D'UXÓ
  localidad[13] = new Array ('Talleres Els Poalets S.L.', '964.663.605', '', '', 'ceraquimia@bsab.com', 'Barrio Carbonaire, calle 12', 'Jesus Mocete', '8.30-13.30 / 15.30-19.30h', '1 de cortesía', 'TalleresElsPoaletsSL.jpg');
  //VILLAFRANCA
  localidad[14] = new Array ('Talleres Porcar S.L.', '964.441.083', '', '', 'repporcar@red.renault.es', 'Av. Del Losar, 175', 'Miguel Porcar', '8.30-13.30 / 15.30-19.30h', '1 de cortesía', 'TalleresPorcarSL.jpg');
  //VILLAREAL
  localidad[15] = new Array ('Talleres Madrigal', '964.523.351', '', '', 'tmadrigal@wanadoo.es', 'Cami Betxi, 4', 'Antonio Adsuara', '8.30-13.30 / 15.30-19.30h', '1 de cortesía', 'TalleresMadrigal.jpg');
  localidad[16] = new Array ('Talleres Fulgor S.L.', '964.520.620', '', 'www.talleresfulgor.com', '', 'Cronista Traver, 29', 'Balma Llop', '8.30-13.30 / 15.30-19.30h', '2 de cortesía', 'TalleresFulgorSL.jpg');
  //VINAROZ
  localidad[17] = new Array ('Auto Esteller S.L.', '964.440.768', '', 'www.autoesteller.seat.com', 'comercial@autoesteller.com', 'Ctra. Nacional 340, km.1051', 'Santiago Esteller', '8.30-13.30 / 15.30-18.30h', '2 de cortesía', 'AutoEstellerSL.jpg');
  //LUNAS
  localidad[101] = new Array ('Carglass', '902.207.010', '', 'www.carglass.es', '', 'Pol. Ind. Pi Gros, nave 9', '- -', '8.30-13.30 / 15.30-18.30h', '', 'Carglass.jpg');
  localidad[102] = new Array ('Guardian Glass Express', '964.520.620', '', 'www.guardianexpress.es', 'mmoreno3@guardian.com', 'Pol. Ind. Los Cipreses, nave 32', 'MariCarmen Moreno', '8.30-13.30 / 15.30-18.30h', '', 'GuardianGlassExpress.jpg');

  var ops = "top=" + ((screen.height - 300) / 2);
  ops += ",left=" + ((screen.width - 650) / 2);
  ops += ",width=" + 650 + ",height=" + 300;

  var contenido = "<html><head><title>Talleres de Confianza</title>\n";
  contenido += "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>\n";
  contenido += "<link href = '../../archivos/"+sitio+"_estilos.css' rel='stylesheet' type='text/css'>\n";
  contenido += "<link href = '../../archivos/"+sitio+"_estilos_TalleresConfianza.css' rel='stylesheet' type='text/css'>\n";
  contenido += "</head><body style='background:#f8f8f8'>\n";
  contenido += "<table height='100%' align='center'><tr><td valign='middle'>\n";
  contenido += "<table border='0' id='TAB_MODREC'><tr><td colspan='3'><img style='float: left' src='../../imagenes/grupoprima/TalleresConfianza/prima.gif' width='140' height='55'><img style='float: right' src='../../imagenes/grupoprima/TalleresConfianza/Vivas.gif' width='140' height=55'></td></tr>\n";
  contenido += "<tr><td colspan='3'><h2 align='left' style='margin: 0; padding: 0'>" + localidad[p][0] + "</h2></td></tr>\n";
  contenido += "<tr><td class='etiqueta'><span class='class_resaltado'>Teléfono</span></td><td class='dato'>" + localidad[p][1] + "</td><td width='200' rowspan='12' align='left' valign='middle'><div align='center'><img src='../../imagenes/grupoprima/TalleresConfianza/" + localidad[p][9] + "' width='200' height='127' class='foto'></div></td></tr>\n";

if(localidad[p][2])
  contenido += "<tr><td class='etiqueta'><span class='class_resaltado'>Fax</span></td><td class='dato'>" + localidad[p][2] + "</td></tr>\n";

if(localidad[p][3])
  contenido += "<tr><td class='etiqueta'><span class='class_resaltado'>Web</span></td><td class='dato'><a href='http://" + localidad[p][3] + "' target='_blank'>" + localidad[p][3] + "</a></td></tr>\n";

if(localidad[p][4])
  contenido += "<tr><td class='etiqueta'><span class='class_resaltado'>E-mail</span></td><td class='dato'><a href='mailto:" + localidad[p][4] + "'>" + localidad[p][4] + "</a></td></tr>\n";

  contenido += "<tr><td class='etiqueta'><span class='class_resaltado'>Direcci&oacute;n</span> <a href='../../imagenes/grupoprima/TalleresConfianza/ubicacion/" + localidad[p][9] + "' target='_blank'> [Ver mapa]</a></td><td class='dato'>" + localidad[p][5] + "</td></tr>\n";
  contenido += "<tr><td class='etiqueta'><span class='class_resaltado'>Contacto</span></td><td class='dato'>" + localidad[p][6] + "</td></tr>\n";
  contenido += "<tr><td class='etiqueta'><span class='class_resaltado'>Horario de atenci&oacute;n </span></td><td class='dato'>" + localidad[p][7] + "</td></tr>\n";

/*if(localidad[p][8])
  contenido += "<tr><td class='etiqueta'><span class='class_resaltado'>Coches</span></td><td class='dato'>" + localidad[p][8] + "</td></tr></table></td></tr></table></body></html>\n";*/
contenido += "</table></body></html>\n";

  var ventana = window.open("", "", ops);
  ventana.document.write(contenido);
  ventana.document.close();
}

/*
function AbrirTaller (p){
  window.open (p,'Talleres_de_Confianza','width=650, height=300, toolbar=no, menubar=no, location=no, status=no, resizable=no, titlebar=no');
}
*/