<?php
session_start();
include('db.php');
include("_incl/shoopBanners.php");

ini_set("display_errors", true);

$main_id = '';

$tipoArticulo = $_REQUEST['t'];
switch($tipoArticulo){
	case 2:
		$titulo = 'titLearning';
		break;
	case 3:
		$titulo = 'titInstalaciones';
		break;
	case 4:
		$titulo = 'titCuriosidades';
		break;
	case 1:
	default:
		$tipoArticulo = 1;	// novedades
		$titulo = 'titNovedades';
		break;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>clave audio</title>
<link href="_incl/ca.css" rel="stylesheet" type="text/css" />
<link href="_incl/banners.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="_incl/code.js"></script>
</head>
<body>
<?php  include("top.htm"); ?>
<table width="708" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td colspan="7"><img src="_bann/instalaciones.jpg"></td></tr>
	<tr>
		<td><img src="_imgs/d.gif" width="168" height="12"></td>
		<td><img src="_imgs/d.gif" width="12" height="12"></td>
		<td><img src="_imgs/d.gif" width="168" height="12"></td>
		<td><img src="_imgs/d.gif" width="12" height="12"></td>
		<td><img src="_imgs/d.gif" width="168" height="12"></td>
		<td><img src="_imgs/d.gif" width="12" height="12"></td>
		<td><img src="_imgs/d.gif" width="168" height="12"></td></tr>
	<tr>
		<td width="168" valign="top" class="pie">
			<div style="margin-left:10px;">
<?php
// MENU
	$conn = db_connect();
	if($conn) {
		$query = 'SELECT articulo_id, articulo_titular FROM edito_articulos WHERE articulo_tipo=' . $tipoArticulo . ' ORDER BY articulo_orden, articulo_id DESC';
		$result = mysql_query($query, $conn);
		if($result){
			$num_results = mysql_num_rows($result);
			for ($i=0; $i <$num_results; $i++) {
				$row = mysql_fetch_array($result);
				if($i == 0) {
					$main_id = $row['articulo_id'];
				}
?>
			<a href="articulos.php?t=<?php echo $tipoArticulo;?>&id=<?php echo $row['articulo_id']; ?>" class="menu1"><?php echo $row['articulo_titular']; ?></a><br>
			<img src="_imgs/d.gif" width="100" height="6"><br />

<?php
			}	// for
		} else {	// if result
			// no hay resultados
		}	 
	}
?></div>
<br><?php if($tipoArticulo == 4) include("curio.htm"); ?>
	  </td>
		<td background="_imgs/ptos.gif"></td>
		<td colspan="3" valign="top" width="348">
			<img src="_imgs/<?php echo $titulo; ?>.gif" width="214" height="20"><br><img src="_imgs/g.gif" width="348" height="1">
			<p>
<?php
// CONTENIDO
	if($conn) {
		if(isset($_REQUEST['id'])){
			$main_id = $_REQUEST['id'];
		}
		$query = 'SELECT articulo_tipo, articulo_titular, articulo_entradilla, articulo_texto, articulo_views FROM edito_articulos WHERE articulo_id=' . $main_id;
		$result = mysql_query($query, $conn);
		if($result && mysql_num_rows($result)){
			$row = mysql_fetch_array($result);
			
// sumo uno al numero de veces que se ha visto este articulo
			$numViews = $row['articulo_views'] + 1;
			$query = 'UPDATE edito_articulos SET articulo_views=' . $numViews . ' WHERE articulo_id=' . $main_id;
			$result = mysql_query($query, $conn);
?>
	<span class="tit trece azul"><?php echo $row['articulo_titular']; ?></span><br>
<?php if(strlen($row['articulo_entradilla'])) { ?> <span class="data"><b><?php echo str_replace("\r", "<p>", stripslashes($row['articulo_entradilla'])); ?></b><br><br><?php } ?>
	<span class="data"><?php echo 	str_replace("[N]", "<b>", 
        				str_replace("[/N]", "</b>", 
        				str_replace("[I]", "<i>", 
        				str_replace("[/I]", "</i>", 
        				str_replace("\r", "<br>", 
        					stripslashes($row['articulo_texto'])
        				))))); ?></span>
<br><br>
<?php
	// aqui van la foto y los thumbnails si hay mas de una foto.
	$query = 'SELECT galeria_imagen_name FROM edito_galeria_imagenes WHERE galeria_articulo_id = ' . $main_id . ' ORDER BY galeria_imagen_name';
	$result = mysql_query($query, $conn);
	if($result && mysql_num_rows($result)){
		$cuantas_imagenes = mysql_num_rows($result);
		$row_img = mysql_fetch_array($result);
			// la primera la quiero seguro
?>
	<img src="_pics/<?php echo $row_img['galeria_imagen_name']; ?>_348.jpg" width="348" id="art_imagen" name="art_imagen"><br><br>
<?php
		if($cuantas_imagenes > 1) {
			$preload = '';
			mysql_data_seek($result, 0);			
		// dibujo los thumbnails
			for($cur_img = 0, $j = 1; $cur_img < $cuantas_imagenes; $cur_img++, $j++) {
				$row_img = mysql_fetch_array($result);
				$path_348 = '_pics/' . $row_img['galeria_imagen_name'] . '_348.jpg';
				$path_108 = '_pics/' . $row_img['galeria_imagen_name'] . '_108.jpg';
				if($cur_img > 0 && file_exists($path_348)) {
					$preload = $preload . '\'$path_348\', ';
?>
<a href="javascript:;" onMouseOver="MM_swapImage('art_imagen','','<?php echo $path_348; ?>',1)" onMouseOut="MM_swapImgRestore()"><img src="<?php echo $path_108; ?>" width="108" border="0"></a><?php echo ($j == 3 ? '<br><br>' : '<img src="/_imgs/d.gif" width="12">'); ?>
<?php			} else {	?>
<img src="<?php echo $path_108; ?>" width="108" border="0"><?php echo ($j == 3 ? '<br><br>' : '<img src="/_imgs/d.gif" width="12">'); ?>
<?php	
				}
				if($j == 3) {
					$j = 0;
				}
			}	// for
?>
<script language="JavaScript" type="text/JavaScript">
<!--
	MM_preloadImages(<?php echo substr($preload, 0, strlen($preload) - 2); ?>);
//-->
</script>
<?php
		}		// if($cuantas_imagenes > 1) 
	}		// hay afotos
	}   // hay un articulo
	}
?>
			</p></td>
	    <td></td>
		<td valign="top">
<?php
		// el parametro que paso es el numero de baners de tipo 2 que quiero 
	$miBanner = new shoopBanners(1, 168);
	if($miBanner->getNum()){
		echo $miBanner->getNextBanner();
	}
?>
		</td></tr>
	<tr>
		<td colspan="7"><img src="_imgs/d.gif" width="708" height="12"></td></tr>
	<tr>
    	<td colspan="7"><?php include("pie.htm"); ?></td></tr>
	<tr>
		<td colspan="7"><img src="_imgs/d.gif" width="708" height="12"></td></tr>
</table>
</body>
</html>