// JavaScript Document
var comercial= new Array();
comercial[0] = new Array('galicia', 'Galicia','C/ Betanzos, 5', '', '15004 A Coruña', '981 210 462', 'galicia@conexionempresas.com');
comercial[1] = new Array('cantabria', 'Cantabria','Pol. Ind. Mies de Molladar, 7', '', '39311 Cartes', '942 82 31 92', 'cantabria@conexionempresas.com');
comercial[2] = new Array('pais_vasco', 'Euskadi','C/ General Concha, 32', '', '48012 Bilbao', '944 420 483', 'euskadi@conexionempresas.com');
comercial[3] = new Array('madrid', 'Madrid','Edificio Torre Garena', 'Avda. Juan Carlos I, 13 - of. 5ºB', 'Avda. Juan Carlos I, 13 - of. 5ºB', '28806 Alcalá de Henares', 'madrid@conexionempresas.com');
comercial[4] = new Array('catalunya', 'Catalu&ntilde;a','Pº Maragall, 66', '', '08041 Barcelona', '934 365 004', 'catalunya@conexionempresas.com');
comercial[6] = new Array('malaga', 'Malaga','Paseo de Reding, 43 - 1º Izq.', '', '29016 Málaga', '952 211 901', 'malaga@conexionempresas.com');
comercial[7] = new Array('central', 'TIENDAS CONEXIÓN, SL','', '', '', '', '');
comercial[8] = new Array('sevilla','Sevilla','C/ Asunción, 37', '', '41011 Sevilla','902 013 279', 'sevilla@conexionempresas.com' );

function isset(variable_name) {
try {
	 if (typeof(eval(variable_name)) != 'undefined')
	 if (eval(variable_name) != null)
	 return true;
 } catch(e) { }
return false;
}

function getcomercial(cual)
{
document.getElementById('mapregion').innerHTML=comercial[cual][1];
document.getElementById('mapdireccion1').innerHTML=comercial[cual][2];
//document.getElementById('mapdireccion2').innerHTML=comercial[cual][3]; 
document.getElementById('codpostal').innerHTML=comercial[cual][4];
document.getElementById('telefono').innerHTML=comercial[cual][5];
document.getElementById('email').innerHTML=comercial[cual][6];

if(isset(document.getElementById('noticia')))
	{
	getnoticia(comercial[cual][0])
	}
}

function limpiar(cual)
{
document.getElementById('mapregion').innerHTML="";
document.getElementById('mapdireccion1').innerHTML="";
document.getElementById('codpostal').innerHTML="";
document.getElementById('telefono').innerHTML="";
document.getElementById('email').innerHTML="";

}
function limpiar_Info(cual)
{
document.getElementById('comunidadConoce').innerHTML="";
document.getElementById('direccionConoce').innerHTML="";
document.getElementById('codpostalConoce').innerHTML="";
document.getElementById('telefonoConoce').innerHTML="";
document.getElementById('emailConoce').innerHTML="";

}

function limpiar_Info_c(cual)
{
document.getElementById('comunidadContacto').innerHTML="";
document.getElementById('direccionContacto').innerHTML="";
document.getElementById('codpostalContacto').innerHTML="";
document.getElementById('telefonoContacto').innerHTML="";
document.getElementById('emailContacto').innerHTML="";

}

function envia_email(form)
{
	if(megavalidacion(form))
	{
		if($("#colectivo").html()!='')
		{
			respuesta = document.getElementById('resp_visita');
			envia('visita/mail.php','nombre='+document.frmVisita.nombre.value+
				  '&telefono='+document.frmVisita.telefono.value+
				  '&email='+document.frmVisita.email.value+
				  '&para='+document.frmVisita.para.value+
				  '&consulta='+document.frmVisita.consulta.value+
				  '&colectivo='+document.frmVisita.colectivo.value);
		}
		else
		{
			respuesta = document.getElementById('resp_visita');
			envia('visita/mail.php','nombre='+document.frmVisita.nombre.value+
				  '&telefono='+document.frmVisita.telefono.value+
				  '&email='+document.frmVisita.email.value+
				  '&para='+document.frmVisita.para.value+
				  '&consulta='+document.frmVisita.consulta.value);		
		}
	}
	//else
	//	alert("hola");
	//alert("hola");
}

function envia_email_c(form)
{
	var nombre = document.frmContacto.nombre.value;
	var telefono = document.frmContacto.telefono.value;
	var email = document.frmContacto.email.value;
	var para = document.frmContacto.para.value;
	var consulta = document.frmContacto.consulta.value;
	
	if(megavalidacion(form))
					  {
	$('#respcontacto').load('contacto/mail.php', { 'nombre': nombre , 'telefono': telefono, 'email': email , 'para': para, 'consulta': consulta});
					  }
}

function verInfo_tienda(cual)
{
document.getElementById('comunidadConoce').innerHTML=comercial[cual][1];
document.getElementById('direccionConoce').innerHTML=comercial[cual][2];
document.getElementById('codpostalConoce').innerHTML=comercial[cual][4];
document.getElementById('telefonoConoce').innerHTML=comercial[cual][5];
document.getElementById('emailConoce').innerHTML=comercial[cual][6];

if(isset(document.getElementById('noticia')))
	{
	getnoticia(comercial[cual][0])
	}
}

function verInfo_tienda_c(cual)
{
document.getElementById('comunidadContacto').innerHTML=comercial[cual][1];
document.getElementById('direccionContacto').innerHTML=comercial[cual][2];
document.getElementById('codpostalContacto').innerHTML=comercial[cual][4];
document.getElementById('telefonoContacto').innerHTML=comercial[cual][5];
document.getElementById('emailContacto').innerHTML=comercial[cual][6];

if(isset(document.getElementById('noticia')))
	{
	getnoticia(comercial[cual][0])
	}
}

function cambiarmarca()
{
	respuesta = document.getElementById('divmodelo');
	envia('catalogo/ajax/selectModelo.php','marca='+document.avanzado.marca.value);
}
function cambiarservicio()
{
	respuesta = document.getElementById('divmarca');
	envia('catalogo/ajax/selectServicio.php','servicio='+document.avanzado.servicio.value);
}


function buscar()
{
document.forms['avanzado'].submit();
}
function buscador_avanzado()
{
	var caracteristicas = new Array('TresG','VL','CA','BT','MP','MS','IR','RA','MM','VJ','TB','CB','GP','ML','TM');
	
	var carac=0;
	for(x=0;x<caracteristicas.length;x++)
	{
		if(document.getElementById(caracteristicas[x]).checked)
			carac = carac+"-"+document.getElementById(caracteristicas[x]).id;
	}
	
	respuesta = document.getElementById('resultado');
	envia('catalogo/ajax/resultados.php','marca='+document.avanzado.marca.value+
		  '&modelo='+document.avanzado.modelo.value+
		  '&servicio='+document.avanzado.servicio.value+
		  '&caracteristicas='+carac);
}
function paginador(servicio,marca,modelo,caracteristicas,pagina)
{
	respuesta=document.getElementById('resultado');
	envia('catalogo/ajax/resultados.php','marca='+marca+
		  '&modelo='+modelo+
		  '&caracteristicas='+caracteristicas+
		  '&servicio='+servicio+
		  '&pagina='+pagina);
}

function abre_popup(pagina)
{
	var alto = $(document).height();
	var ancho = $(window).width();
	
	$("#popup").css({"width":ancho,"height":alto});
	$('#popup').fadeTo("slow",0.6);    
	$("#todopopup").fadeTo("slow",1);
	//$("#todopopup").css("display","block");
	
	$(".imgpopup").load("tarifas/popups.php",{"pagina":pagina});
}
