	function agregarCategoria(){
		
	var categoria;

		if(categoria=prompt("Introduce el nombre de la categoria que quieres agregar")){

			
			document.getElementById("formulario_categorias").getElementsByTagName("input")[0].value=categoria;
			
			document.getElementById("formulario_categorias").submit();
		}

	}

		function agregarSubCategoria(formulario,IdCategoria){
		
	var subcategoria;

		if(subcategoria=prompt("Introduce el nombre de la subcategoria que quieres agregar")){

			
			document.getElementById(formulario).getElementsByTagName("input")[0].value=subcategoria;
			
			document.getElementById(formulario).submit();

			
		}
		else{
		return false;
		}

	}



	function agregarSubNivel(tipo){
		
	var categoria;

	

		if(subnivel=prompt("Introduce el nombre nombre para el nuevo tipo dentro de " +tipo)){

			document.getElementById("agregar_subnivel").getElementsByTagName("input")[0].value=subnivel;
			
			document.getElementById("agregar_subnivel").submit();
		}

	}
	function eliminarSubNivel(tipo){

		if(confirm("Estas seguro de que deseas eliminar el tipo\n"+tipo)){
		return true;

		}
		else{
		return false;
		}
	}
		function editarSubNivel(tipo,numSubSubCategoria,pagina,numCategoria,numSubCategoria,subsubcategoria_r,id){


		
		if(nuevotipo=prompt("Escribe el nuevo nombre para este tipo",tipo)){
			//alert(subsubcategoria_r);
			//alert("editar_subnivel.php?SubNivel="+numSubSubCategoria+"&p="+pagina+"&Cat="+numCategoria+"&SubCatProd="+numSubCategoria+"&tipo="+nuevotipo+"&subsubcategoria_r="+subsubcategoria_r);
			
		//alert("editar_subnivel.php?SubNivel="+numSubSubCategoria+"&p="+pagina+"&Cat="+numCategoria+"&SubCatProd="+numSubCategoria+"&tipo="+nuevotipo)
		location.href="editar_subnivel.php?SubNivel="+numSubSubCategoria+"&p="+pagina+"&Cat="+numCategoria+"&SubCatProd="+numSubCategoria+"&tipo="+nuevotipo+"&subsubcategoria_r="+subsubcategoria_r+"&id="+id;		
		return false;
		
		}
		else{

		return false;
	}
		}
			function eliminarSubCategoria(subcategoria,numCategoria,numSubCategoria,p){

		if(confirm("Estas seguro de que deseas eliminar la subcategoria\n"+subcategoria)){
		
		location.href="eliminar_subcategoria.php?Cat="+numCategoria+"& SubCatProd="+numSubCategoria+"&p="+p;
			

		}
		else{
		return false;
		}
	}

				function eliminarProducto(numCategoria,numSubCategoria,numSubNivel,numProducto,p){
				
		if(confirm("Estas seguro de que deseas eliminar este producto ?")){
		
		location.href="eliminar_producto.php?Cat="+numCategoria+"&SubCatProd="+numSubCategoria+"&SubNivel="+numSubNivel+"&producto="+numProducto+"&p="+p;
			

		}
		else{
		return false;
		}
	}

			function editarSubCategoria(SubCategoria_anterior,numSubSubCategoria,pagina,numCategoria,numSubCategoria){
				//alert("SubCategoria_anterior: "+SubCategoria_anterior+"\nnumSubSubCategoria: "+numSubSubCategoria+"\pagina: "+pagina+"\nnumCategoria: "+numCategoria+"\nnumSubCategoria: "+numSubCategoria);

	
		
		if(nuevasubcategoria=prompt("Escribe el nuevo nombre para esta subcategoria",SubCategoria_anterior)){
		
		location.href="editar_subcategoria.php?SubNivel="+numSubSubCategoria+"&p="+pagina+"&Cat="+numCategoria+"&SubCatProd="+numSubCategoria+"&subcategoria="+nuevasubcategoria;
		}
		else{

		return false;
	}
		}

	function reordenar(formulario){
	document.getElementById(formulario).submit();
			}

function reordenar_subsubcategorias(formulario){

document.getElementById(formulario).submit()

}

function f_buscador(){

document.getElementById("buscador").submit();
}

	function inserta_anuncio(){
a=(screen.height-470)/2;
d=(screen.width-550)/2;

var ventana=window.open("formulario_anuncios.php","formularioanuncios","width=570,height=470,left="+d+",top="+a);
ventana.focus();
}


	function edita_anuncio(id){
a=(screen.height-570)/2;
d=(screen.width-550)/2;

var ventana=window.open("formulario_anuncios.php?accion=editar&id="+id,"formularioanuncios","width=570,height=570,left="+d+",top="+a);
ventana.focus();
}



function ordproductos(Seccion,Categoria,SubCategoria,SubNivel){

var criterio_ordenacion=document.getElementById("ordproduc").options[document.getElementById("ordproduc").selectedIndex].value;

if(criterio_ordenacion!=0){
var pagina=Seccion;
var categoria=Categoria;
var subcategoria=SubCategoria;
var subsubcategoria=SubNivel;

location.href=pagina+"?Cod="+categoria+","+subcategoria+","+subsubcategoria+"&ord="+criterio_ordenacion;
}
}


	function validaFormConsulta(){
	formulario=document.getElementById("form_contacto");
	error=false;
	enfoca=false;
	formatoemail="-";

	
	for(i=0;i<(formulario.elements.length-2);i++){
		
		if(formulario.elements[i].value=="" && formulario.elements[i].name!="direccion"){
			if(enfoca==false){
			enfoca=formulario.elements[i];
			}
		 formulario.elements[i].style.backgroundColor="#FFE0E0";
		 
		error=true;
		
		}
		else{

					if(formulario.elements[i].name=="email"){
					regx = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;

							if(regx.test(formulario.elements[i].value)==true){	
							formulario.elements[i].style.backgroundColor="#FFFFFF";
							
							formatoemail=true;
							}
							else{
							formulario.elements[i].style.backgroundColor="#FFE0E0";
							
							formatoemail=false;
							}

							

					}
					else{
						
		 formulario.elements[i].style.backgroundColor="#FFFFFF";
					}
		}
	
	}

	
	if(error==true || formatoemail==false){

			if(formatoemail==false){

				alert("El formato del email no es correcto");
				
				formulario.elements["email"].focus();
				return false;
			}
			
			else{
				alert("Por favor rellena todos los campos obligatorios");

			enfoca.focus();
			return false;
		}
	}
	else{

	return true;
	}
	}


	function valida(){
		//FUNCION PARA VALIDAR CARRITO
	cuadros_error=false;
var cuadros_seleccion=document.getElementById("comprar").getElementsByTagName("select");

for(i=0;i<cuadros_seleccion.length;i++){

if(cuadros_seleccion[i].options[cuadros_seleccion[i].selectedIndex].value==0){
cuadros_error=true;
}
}
if(cuadros_error==true){
alert("debes seleccionar las tallas y colores de los productos");
}
else{

location.href="carrito2.php";
}
}


/*INICIO FUNCIONES PARA EL CARRITO*/
function elimina_producto_cesta(sid,id,idc){
	
	if(confirm("Estas seguro de que deseas eliminar esta fila de la cesta ?")){
		//alert("c_eliminar_producto.php?sid="+sid+"&id="+id+"&idc="+idc)
		location.href="c_eliminar_producto.php?sid="+sid+"&id="+id+"&idc="+idc;
	}
	
	else{
	return false;
	}
}


function actualiza_cesta_tallas(ide,sesion,idc){
id_producto_id_talla=document.getElementById(ide).options[document.getElementById(ide).selectedIndex].value;
id_producto_id_talla=id_producto_id_talla.split("-");
location.href="c_actualizar_producto.php?sid="+sesion+"&idc="+idc+"&id="+id_producto_id_talla[0]+"&t="+id_producto_id_talla[1];
}


function actualiza_cesta_colores(ide,sesion,idc){

id_producto_id_color=document.getElementById(ide).options[document.getElementById(ide).selectedIndex].value;
id_producto_id_color=id_producto_id_color.split("-");
location.href="c_actualizar_producto.php?sid="+sesion+"&idc="+idc+"&id="+id_producto_id_color[0]+"&t=&c="+id_producto_id_color[1];
}
/*FIN FUNCIONES PARA EL CARRITO*/




function alta_lista_correo(){

	//alert("La lista de correo no esta activada aun");
	//return false;
	var email=document.getElementById("email_boletin").value;

	if(email!=""){
		
    regx = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;

		if(regx.test(email)==true){
		document.getElementById("form_alta_lista_correo").submit();
		}
		else{

		alert("El formato del email no es correcto");
		return false;
		}

	}
	else{

		alert("El campo email esta vacio");
		document.getElementById("email_boletin").focus();
		return false;
	}
    
}


/*FUNCION PARA ENCUADRAR PRODUCTOS*/
var activado;
activado=false
	function recuadra(producto){
		if(!activado){
document.getElementById(producto).style.border="1px solid #C9C9C9";
activado=true;
		}
		else{
document.getElementById(producto).style.border="1px solid #FFFFFF";
activado=false;
		}

	}