function valida_login(){
	if (document.form_login.usuario.value == ''){
		alert ("Por favor, Rellene el campo login.");
	} else {
		if (document.form_login.contrasenia.value == ''){
			alert ("Por favor, Rellene el campo password.");
		} else {
			document.form_login.submit();
			document.form_login.usuario.value = '';
			document.form_login.contrasenia.value = '';
		}
	}
}

var myConn_carga_destacados = new XHConn();
var fin_carga_destacados = function (oXML) { document.getElementById('div_destacados').innerHTML = oXML.responseText;};
function carga_destacados(){
	cargando_destacados = '<table width="794" height="240" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
	cargando_destacados += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
	document.getElementById('div_destacados').innerHTML = cargando_destacados;
	window.setTimeout("myConn_carga_destacados.connect('dinamic/destacados.php', 'GET', 'ididioma=', fin_carga_destacados)", 1000);

}

var myConn_carga_buscador = new XHConn();
var fin_carga_buscador = function (oXML) { document.getElementById('div_buscador').innerHTML = oXML.responseText;};
function carga_buscador(){
	cargando_buscador = '<table width="204" height="242" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
	cargando_buscador += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
	document.getElementById('div_buscador').innerHTML = cargando_buscador;
	window.setTimeout("myConn_carga_buscador.connect('catalogo/buscador.php', 'GET', 'idtipo_g="+idtipo_global+"&idsubtipo_g="+idsubtipo_global+"&estado_g="+estado_global+"', fin_carga_buscador)", 1000);

}

var myConn_selec_tipo_producto = new XHConn();
var fin_selec_tipo_producto = function (oXML) { document.getElementById('div_selec_subtipo').innerHTML = oXML.responseText;};
function selec_tipo_producto(idtipo){
	if (idtipo == 0){
		if (subtipo_activo != 0){
			desaciva_subtipo();
		}
		if (estado_activo != 0){
			desaciva_estado();
		}
	} else {
		if (estado_activo != 0){
			desaciva_estado();
		}
		document.getElementById('div_selec_subtipo').innerHTML = '<img src="img/preload-campos.gif" width="56" height="21">';
		window.setTimeout("myConn_selec_tipo_producto.connect('catalogo/selec_subtipo.php', 'GET', 'idtipo="+idtipo+"&estado_activo="+estado_activo+"&subtipo_activo="+subtipo_activo+"', fin_selec_tipo_producto)", 1000);
		boton_buscar();
	}
}

var myConn_selec_subtipo_producto = new XHConn();
var fin_selec_subtipo_producto = function (oXML) { document.getElementById('div_selec_estado').innerHTML = oXML.responseText;};
function selec_subtipo_producto(idsubtipo,idtipo){
	if (idsubtipo == 0){
		if (estado_activo != 0){
			desaciva_estado();
		}
	} else {
		boton_buscar();
		document.getElementById('div_selec_estado').innerHTML = '<img src="img/preload-campos.gif" width="56" height="21">';
		window.setTimeout("myConn_selec_subtipo_producto.connect('catalogo/selec_estado.php', 'GET', 'idtipo="+idtipo+"&idsubtipo="+idsubtipo+"', fin_selec_subtipo_producto)", 1000);
	}
}

function desaciva_subtipo(){
	desplegable_desactivado = '<select name="subtipo" class="list_catalogo" id="subtipo" disabled="disabled">';
	desplegable_desactivado += '<option value="0" selected="selected">Cualquier</option>';
	desplegable_desactivado += '</select>';
	document.getElementById('div_selec_subtipo').innerHTML = desplegable_desactivado;
}

function desaciva_estado(){
	desplegable_desactivado = '<select name="estado" class="list_catalogo" id="estado" disabled="disabled">';
	desplegable_desactivado += '<option value="0" selected="selected">Cualquier</option>';
	desplegable_desactivado += '</select>';
	document.getElementById('div_selec_estado').innerHTML = desplegable_desactivado;
}

var myConn_boton_buscar = new XHConn();
var fin_boton_buscar = function (oXML) { document.getElementById('div_boton_buscar').innerHTML = oXML.responseText;};
function boton_buscar(){
	document.getElementById('div_boton_buscar').innerHTML = '<img src="img/preload-campos.gif" width="56" height="21">';
	window.setTimeout("myConn_boton_buscar.connect('catalogo/boton_buscar.php', 'GET', 'idtipo=', fin_boton_buscar)", 1000);
}

function activar_boton_buscar(){
	buscar_descativado = '<a href="javascript:buscar();" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'buscar\',\'\',\'img/boto_buscar02.jpg\',1)"><img src="img/boto_buscar01.jpg" name="buscar" width="60" height="19" border="0" id="buscar" /></a>';
	document.getElementById('div_boton_buscar').innerHTML = buscar_descativado;
}

function buscar(){
	idtipo_global = document.getElementById('tipo').value;
	if (subtipo_activo != 0){
		idsubtipo_global = document.getElementById('subtipo').value;
	} else {
		idsubtipo_global = 0;
	}
	if (estado_activo != 0){
		estado_global = document.getElementById('estado').value;
	} else {
		estado_global = 0;
	}
	listado_productos();
}

var myConn_listado_productos = new XHConn();
var fin_listado_productos = function (oXML) { document.getElementById('div_listado_productos').innerHTML = oXML.responseText;};
function listado_productos(pagina,num_pags){
		cargando_lista = '<table width="587" height="246" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
		cargando_lista += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
		document.getElementById('div_listado_productos').innerHTML = cargando_lista;
		window.setTimeout("myConn_listado_productos.connect('catalogo/listado.php', 'GET', 'idtipo="+idtipo_global+"&idsubtipo="+idsubtipo_global+"&estado="+estado_global+"&pagina="+pagina+"&num_pags="+num_pags+"', fin_listado_productos)", 1000);
}

var myConn_carga_ficha = new XHConn();
var fin_carga_ficha = function (oXML) { document.getElementById('div_ficha_producto').innerHTML = oXML.responseText;};
function carga_ficha(idproducto,pagina,productos_x_pag){
		cargando_ficha = '<table width="587" height="246" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
		cargando_ficha += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
		document.getElementById('div_ficha_producto').innerHTML = cargando_ficha;
		window.setTimeout("myConn_carga_ficha.connect('catalogo/ficha.php', 'GET', 'idproducto="+idproducto+"&pagina="+pagina+"&prod_x_pag="+productos_x_pag+"', fin_carga_ficha)", 1000);
}

var myConn_carga_imagen = new XHConn();
var fin_carga_imagen = function (oXML) { document.getElementById('div_foto_principal').innerHTML = oXML.responseText;};
function carga_imagen(foto){
		cargando_imagen = '<table width="253" height="247" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
		cargando_imagen += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
		document.getElementById('div_foto_principal').innerHTML = cargando_imagen;
		window.setTimeout("myConn_carga_imagen.connect('catalogo/ver_foto.php', 'GET', 'foto="+foto+"', fin_carga_imagen)", 1000);
}

var myConn_carga_noticias_portada = new XHConn();
var fin_carga_noticias_portada = function (oXML) { document.getElementById('div_noticias_portada').innerHTML = oXML.responseText;};
function carga_noticias_portada(){
		cargando_noticias = '<table width="810" height="215" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
		cargando_noticias += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
		document.getElementById('div_noticias_portada').innerHTML = cargando_noticias;
		window.setTimeout("myConn_carga_noticias_portada.connect('dinamic/noticias_portada.php', 'GET', '', fin_carga_noticias_portada)", 1000);
}

var myConn_carga_listado_noticias = new XHConn();
var fin_carga_listado_noticias = function (oXML) { document.getElementById('div_lista_noticias').innerHTML = oXML.responseText;};
function carga_listado_noticias(pagina){
		cargando_noticias = '<table width="205" height="242" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
		cargando_noticias += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
		document.getElementById('div_lista_noticias').innerHTML = cargando_noticias;
		window.setTimeout("myConn_carga_listado_noticias.connect('dinamic/listado_noticias.php', 'GET', 'pagina="+pagina+"', fin_carga_listado_noticias)", 1000);
}

var myConn_carga_noticia = new XHConn();
var fin_carga_noticia = function (oXML) { document.getElementById('div_carga_noticia').innerHTML = oXML.responseText;};
function carga_noticia(idnoticia){
		cargando_noticia = '<table width="205" height="242" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
		cargando_noticia += '<td><div align="center"><img src="img/preload-grande.gif" width="32" height="32"></div></td></tr></table>';
		document.getElementById('div_carga_noticia').innerHTML = cargando_noticia;
		window.setTimeout("myConn_carga_noticia.connect('dinamic/carga_noticia.php', 'GET', 'idnoticia="+idnoticia+"', fin_carga_noticia)", 1000);
}

function carga_ficha_destacado(idproducto,idtipo,idsubtipo,idestado){
	location.href = "./catalogo.php?idtipo="+idtipo+"&idsubtipo="+idsubtipo+"&idestado="+idestado+"&idproducto="+idproducto+"";
}


function valida_contacto(pagina){
	if (document.getElementById("acepto").checked == false){
	alert ("Por favor, acepta las condiciones del aviso legal");
	} else {
		if (document.getElementById("nombre").value == ''){
			alert ("Por favor, Rellene el campo nombre.");
		} else {
			if (document.getElementById("poblacion").value == ''){
				alert ("Por favor, Rellene el campo poblacion.");
			} else {
				if (document.getElementById("telf").value == ''){
					alert ("Por favor, especifica tu número de teléfono para que podamos contactar contigo");
				} else {
					pageTracker._trackPageview('/formularios/'+pagina+'.php');	
					document.getElementById("contacto").submit();
				}
			}
		}
	}
}

function borra_formulario(){
	document.contacto.nombre.value = '';
	document.contacto.poblacion.value = ''
	document.contacto.telf.value = '';
	document.contacto.mail.value = '';
	document.contacto.coments.value = '';
	document.contacto.conocio.value = '';
	document.contacto.acepto.checked = false
}



//---------------MAPA SITUACIÓN---------------------------------------------------

var map_tienda; //hacemos global la variable para poder interactuar con otras funciones
function mapa_tienda() {

			latitud_centro = "41.540241";
			longitud_centro = "2.213088";
			inicia_mapa_tienda(longitud_centro,latitud_centro);
	
function inicia_mapa_tienda(longitud_centro,latitud_centro){

	document.getElementById('div_mapa_tienda').style.width = '566px';
	document.getElementById('div_mapa_tienda').style.height = '218px';

	var icon = new GIcon();
icon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
//icon.shadow = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png"; 
	icon.iconSize = new GSize(22, 23);
	//icon.shadowSize = new GSize(37, 34);
	icon.iconAnchor = new GPoint(6, 20);
	icon.infoWindowAnchor = new GPoint(5, 1);

	map_tienda = new GMap2(document.getElementById("div_mapa_tienda"));
	map_tienda.addControl(new GSmallMapControl());
	map_tienda.setCenter(new GLatLng(latitud_centro, longitud_centro), 15);
	map_tienda.setMapType(G_NORMAL_MAP);
	
	//function createInfoMarker(point, address) {
	//var marker = new GMarker(point, icon);
	//return marker;
	//}
	
	var point = new GPoint(longitud_centro, latitud_centro);
	//var address = 'prueba';
	//var marker = createInfoMarker(point, address);
	var marker = new GMarker(point, icon);
	map_tienda.addOverlay(marker);
	
} // fin funcion inicia mapa

} // fin carga_mapa


//---------------MAPA SITUACIÓN 2---------------------------------------------------

var map_tienda; //hacemos global la variable para poder interactuar con otras funciones
function mapa_tienda2() {

			latitud_centro = "41.91229";
			longitud_centro = "3.167900";
			inicia_mapa_tienda(longitud_centro,latitud_centro);
	
function inicia_mapa_tienda(longitud_centro,latitud_centro){

	document.getElementById('div_mapa_tienda2').style.width = '566px';
	document.getElementById('div_mapa_tienda2').style.height = '218px';

	var icon = new GIcon();
icon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
//icon.shadow = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png"; 
	icon.iconSize = new GSize(22, 23);
	//icon.shadowSize = new GSize(37, 34);
	icon.iconAnchor = new GPoint(6, 20);
	icon.infoWindowAnchor = new GPoint(5, 1);

	map_tienda = new GMap2(document.getElementById("div_mapa_tienda2"));
	map_tienda.addControl(new GSmallMapControl());
	map_tienda.setCenter(new GLatLng(latitud_centro, longitud_centro), 15);
	map_tienda.setMapType(G_NORMAL_MAP);
	
	//function createInfoMarker(point, address) {
	//var marker = new GMarker(point, icon);
	//return marker;
	//}
	
	var point = new GPoint(longitud_centro, latitud_centro);
	//var address = 'prueba';
	//var marker = createInfoMarker(point, address);
	var marker = new GMarker(point, icon);
	map_tienda.addOverlay(marker);
	
} // fin funcion inicia mapa

} // fin carga_mapa


//Funciones para efectos del menú
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->


//-------------------------funciones de carga del formulario de contacto en las fichas------------------//

function carga_formulario()
{
	var con_cargar_formulario = new XHConn();
	document.getElementById('div_formulario').innerHTML = "Cargando formulario...";
	var fin_cargar_formulario = function (oXML) { document.getElementById('div_formulario').innerHTML = oXML.responseText; };
	con_cargar_formulario.connect("dinamic/formulario_ficha.php", "POST", "", fin_cargar_formulario);
}