function pinchar(){
	var capa = $('vineta'); 
	capa.style.display='none';
}
	
	// la funcion sumar y restar, tiene dos maneras distintas en la web, al aņadir un producto y al modificar en la cesta la cantidad de cada productos,
	// es por ello por lo ke le pasamos la variable "valor", si valor tiene contenido, significa k se llama a la funcion desde la cesta para poder ponerle 
	// los "input" el nombre del id+valor, un tema del sebas valla.
	
/*function sumar(valor,id){
	if((valor=='' || valor==-1) && (id=='' || id==-1)){				 
		var a = $('canti');  // funcion de prototype para sustituir document.getElementById('cantidad');
		if(a.value > 0)
			 a.value = Number(a.value) + 1;	
		else
			 a.value = 1;		
	}else{
		var a = $('cantidad'+valor);  // funcion de prototype para sustituir document.getElementById('cantidad');
		if(a.value > 0){		
			 a.value = Number(a.value) + 1;	
		}else
			 a.value = 1;	
			 
		document.getElementById('form_cesta').idp.value = id;
		document.getElementById('form_cesta').submit();
	}		
}*/
	
	
function sumar(valor){
	ruta = eval('document.formcesta_'+valor);
	cantidad = ruta.cantidad.value;
	if(cantidad > 0)		
		ruta.cantidad.value = Number(cantidad) + 1;	
	else
		ruta.cantidad.value = 1;	
	ruta.submit();	
}
function restar(valor){	
	ruta = eval('document.formcesta_'+valor);
	cantidad = ruta.cantidad.value;
	if(cantidad > 1)		
		ruta.cantidad.value = Number(cantidad) - 1;	
	else
		ruta.cantidad.value = 1;	
	ruta.submit();	 
}

function sumar_ficha(){
	ruta = document.form_meter;
	cantidad = ruta.cantidad.value;
	if(cantidad > 0)		
		ruta.cantidad.value = Number(cantidad) + 1;	
	else
		ruta.cantidad.value = 1;	
}

function restar_ficha(){
	ruta = document.form_meter;
	cantidad = ruta.cantidad.value;
	if(cantidad > 1)		
		ruta.cantidad.value = Number(cantidad) - 1;	
	else
		ruta.cantidad.value = 1;	
}

function popup_avisos (pagina, altura) {
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=450, height="+altura+", top=250, left=300";
	window.open(pagina,"",opciones);
}
	
function validacantidad(stock,activo,url){   // le tengo ke pasar la seccion url para ke me coja el archivo del popup

	var a = $('cantidad');	
	var reg=/^\d{1,8}$/;   // expresion regular para solo numeros
	if(activo){ //control de stock activo
		if(a.value <= stock){
			if(reg.test(a.value)){
				document.getElementById('form_meter').submit();
			}else{
				var capa = $('vineta');
				capa.style.display='block';
			}
		}else{
			popup_avisos(''+url+'avisar_stock.php', 300);
		}
	}else{
		if(reg.test(a.value)){
			document.getElementById('form_meter').submit();
		}else{
			var capa = $('vineta');
			capa.style.display='block';
		}
	}
}

function enviar_pedido(){		
	form=document.getElementById("comprar_paypal");
	form.submit();		
}
		
function enviar(num){
	document.getElementById('form'+num).submit();			
}
function enviar_favoritos(num){
	document.getElementById('favorito'+num).submit();			
}
function enviar2(){		
	document.getElementById('comprar').submit();			
}


function comprobar_busqueda(){
	 form=document.getElementById("formu");
	 error = 0;
	 if(form.id_provincia.value=='null')
	 {
		error = 1;
		document.getElementById('error1').style.display = 'block';
	 }
	 if(form.id_provincia.value!='null')
	 {
		document.getElementById('error1').style.display = 'none';
	 }
	  if(form.id_cine.value=='null')
	 {
		error = 1;
		document.getElementById('error2').style.display = 'block';
	 }
	 if(form.id_cine.value!='null')
	 {
		document.getElementById('error2').style.display = 'none';
	 }
	
	if(error==1){
	   	document.getElementById('mensaje').style.display = 'block';
		document.getElementById('id_provincia').style.display = 'none';
		document.getElementById('id_cine').style.display = 'none';
		document.getElementById('peli').style.display = 'none';
	}
	if(error==0){
	   	form.submit();	
	}
	   
	
}

function comprobar_busqueda2(){
	 form=document.getElementById("form_buscar");
	 error = 0;
	/* if(form.id_provincia.value=='null')
	 {
		error = 1;
		document.getElementById('error1').style.display = 'block';
	 }
	 if(form.id_provincia.value!='null')
	 {
		document.getElementById('error1').style.display = 'none';
	 }*/
	  if(form.id_cine.value=='null')
	 {
		error = 1;
		document.getElementById('id_cine').style.backgroundColor ="#fb8686";
		document.getElementById('id_cine').style.color = "#191919";	
	 }	
	
	
	if(error==0){
	 	form.submit();	
	}
	   
	
}


function cerrar()
{  
	document.getElementById('mensaje').style.display = 'none';
}