<?
 echo '<script language="JavaScript" src="addons/misc.js"></script>';
 echo '<a href="./?dgo=default.php">Listado de temas</a> -> ';
 echo '<a href="./?dgo=ver_grupo.php&idg='.$idg.'">Informaci&oacute;n del grupo</a> -> ';
 echo 'Disco';
 echo '<br><br><br>';

 $blq1 ="d.idg, e.titulo AS tide, d.FEdicion, d.ids, d.titulo, d.pv, d.comentario";
 $list = true;

 if (isset($idd)) 
 {	
  $res = @mysql_query( "SELECT d.id,$blq1 FROM discos AS d, estilos AS e WHERE d.id=$idd AND e.id=d.ide", $conexion );
  $datos = @mysql_fetch_array( $res );
  
  list( $db_id, $db_idg, $db_ide, $db_FEdicion, $db_ids, $db_titulo, $db_pv, $db_comentario ) = $datos;

  displayForm();
  
  displayFormExtras( $idd );
  
  displayListC( $idd );
 }

function cambiaProporciones()
{
 global $db_Foto_w, $db_Foto_h;
 $W = 100; $H=100; 

 // Las proporciones correctas seran de 100x100
// $db_Foto_w=50;
// $db_Foto_h=50;

 if ( $db_Foto_w > 0 )
 {
  if ( $db_Foto_w > $db_Foto_h )
  {
	  $db_Foto_h = intval(($db_Foto_h/$db_Foto_w)*$W); $db_Foto_w=$W;
  } else {
	  $db_Foto_w = intval(($db_Foto_w/$db_Foto_h)*$H); $db_Foto_h=$H;
  }
 }

}

function displayFormExtras( $idd )
{
 global $conexion, $db_Foto_h, $db_Foto_w;

 echo '<br><br>';
 echo "<a name=\"comentarios\"></a>";
 echo "<table width=100% cellpadding=0 cellspacing=0 class=\"td_lista\"><tr>";
 echo "<td class=menuL>Album de Fotos</td>";
 echo "</tr></table>";

  echo "<table width=100% class=td_lista>";
  $count = 0;
  for( $i=0;$i<6;$i++)
  {
  	if ( ($count%3)==0 ) echo "<tr>";
  	echo "<td>";
  	$res   = @mysql_query( "SELECT file, W, H FROM extrasDiscos WHERE idd=$idd AND tipo='F' AND id_data='$i'", $conexion );
	if ( @mysql_numrows( $res ) > 0 )
	{
          $datos = @mysql_fetch_array( $res );
	  list( $db_file, $db_Foto_w, $db_Foto_h ) = $datos;
	  $imgFile="db/discos/$idd"."_".$i."_"."$db_file";
	  echo "<a href=\"javascript:abreVentana( selectIMG,'$imgFile',$db_Foto_w+20,$db_Foto_h+20)\">"; 
	  cambiaProporciones();
	  echo "<img src='$imgFile' width='$db_Foto_w' height='$db_Foto_h' border=0>";
	  echo '</a>';
	}
	
	echo "</td>";
  	$count++;
  	if ( ($count%3)==0 ) echo "</tr>";
  }
  echo "</table>";
  echo '<script>var selectIMG="selectIMG";</script>';
}

function displayListC( $idd )
{
 global $conexion;

 echo '<br><br>';
 echo "<a name=\"comentarios\"></a>";
 echo "<table width=100% cellpadding=0 cellspacing=0 class=\"td_lista\"><tr>";
 echo "<td class=menuL>Temas incluidos en el disco</td>";
 echo "</tr></table>";

  echo "<table width=100% class=td_lista>";
  echo "<tr><td>Pos.</td><td>Dur.</td><td>Titulo</td><td>&nbsp;</td></tr>";
  $res   = @mysql_query( "SELECT id, posicion, titulo, duracion, autorMusica, autorLetra, f_partitura, f_audio, f_letra, f_midi FROM cancionesDisco WHERE idd=$idd ORDER BY posicion", $conexion );
  while ( $datos=@mysql_fetch_array($res) )
  {
  	list( $dbc_id, $dbc_pos, $dbc_titulo, $dbc_dur, $aut_mus, $aut_let, $fpar, $fsnd, $flet, $fmid ) = $datos;
  	echo "<tr><td>$dbc_pos</td>".
		'<td valign="bottom">'.$dbc_dur.'</td>'.
  		'<td valign="bottom">'.$dbc_titulo.'</td>';
	echo '<td>';

	if (empty($fsnd)) echo '<img src=images/snd.gif>'; 
	else echo '<a href="javascript:popup('.$dbc_id.',\''.$fsnd.'\',\'A\')"><img src=images/snd1.gif border=0></a>';

	if (empty($flet)) echo '<img src=images/let.gif>'; 
	else echo '<a href="javascript:popup('.$dbc_id.',\''.$flet.'\',\'L\')"><img src=images/let1.gif border=0></a>';		

	if (empty($fpar)) echo '<img src=images/par.gif>'; 
	else echo '<a href="javascript:popup('.$dbc_id.',\''.$fpar.'\',\'P\')"><img src=images/par1.gif border=0></a>';

	if (empty($fmid)) echo '<img src=images/mid.gif>'; 
	else echo '<a href="javascript:popup('.$dbc_id.',\''.$fmid.'\',\'P\')"><img src=images/par1.gif border=0></a>';
	echo '</td></tr>';
	echo '<tr><td>&nbsp;</td><td colspan=3><font color="#BBBBBB">Letra:</font> '.$aut_let.'<br><font color="#BBBBBB">Musica:</font> '.$aut_mus.'</td></tr>';
  }
  echo '</table>';
 
  echo '<script>
	var infoMusic="infoMusic";
  	function popup( id, file, ft ){ abreVentana(infoMusic, "db/discos/'.$idd.'_c_"+id+"_"+ft+"_"+file, 400, 400); }
	';
  echo '</script>';
}


function displayForm()
{
 global $db_idg, $db_ide, $db_FEdicion, $db_ids, $db_titulo, $db_pv, $db_comentario;

 echo '<h1>'.$db_titulo.'</h1>';

 echo urldecode($db_comentario);

 echo '<br>Estilo: '.$db_ide;
 echo '<br>Edici&oacute;n: '.$db_FEdicion;
 echo '<br>Estado: '.$db_ids;
 echo '<br>Clase disco: '.$db_pv;

 echo '<br><br>';
 echo "<a name=\"comentarios\"></a>";
 echo "<table width=100% cellpadding=0 cellspacing=0 class=\"td_lista\"><tr>";
 echo "<td class=menuL>Comentarios</td>";
 echo "</tr></table><br>";

 echo urldecode($db_comentario); 
}

?>
