<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */

# Biblioteca de funcions
# Public domain. 2006. No warranties. http://structio.sourceforge.net/sigue

/**
 * Shows a select with the items of the associative array using the
 * key as the value and the value as the text of the option
 * @param string $arreglo String array
 * @param string $name name of the select
 */
function showselect($arreglo,$name, $selected="", $reverse=false){
  print "<select name=\"$name\">";
  $i=0;
  foreach($arreglo as $key => $value) {
	if ($selected==$key) {
		$s="selected=\"1\"";
	}
	else {
		$s="";
	}
    	$n="<option value=\"$key\" $s>$value</option>\n";
	if ($reverse) {
		$op[sizeof($arreglo)-1-$i]=$n;
	}
	else {
		$op[$i]=$n;
	}
	$i++;
  }
  for ($i=0;$i<sizeof($arreglo);$i++) {
	print $op[$i];
  }
  print "</select>";
}

function hierarchy($level) {
  if (strstr($level,"a")||strstr($level,"b")) {
    return "media/".$level;
  }
  if ($level < 6) {
    return "bprimaria/".$level;
  }
  return "bsecundaria/".$level;
}


?>
