<?
	include('../includes/Conexion.inc.php');
	$Id=$_GET['Id'];
	
	$link=Conectar();  
	$Id_cajon = $_GET['Id_cajon'];
	
	if (!isset($Id_cajon)){
		$sql = "select Archivo from Imagenes where Id = '$Id'";
		$rs = mysql_query($sql);
		list($url) = mysql_fetch_row($rs);	
		unlink("../imagenes/grandes/$url");
		unlink("../imagenes/miniaturas/$url");	
		
		$sql = "Delete from Imagenes "; 
		$sql.= "WHERE Id ='$Id'";
		mysql_query($sql);	
		
		
	}
	else{
		$sql = "select Archivo from imagenes_cajon where Id = '$Id'";
		$rs = mysql_query($sql);
		list($url) = mysql_fetch_row($rs);	
		unlink("../imagenes/grandes/$url");
		unlink("../imagenes/miniaturas/$url");	
		
		$sql = "Delete from imagenes_cajon "; 
		$sql.= "WHERE Id ='$Id'";
		mysql_query($sql);	
	}
	Desconectar();
	header("Location:".$_SERVER['HTTP_REFERER']);
?>