MIRROR="http://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest/linux-i686"

#¡Ojo! LANGUAGE es el nombre del subdirectorio en MIRROR que tiene Firefox traducido.

case $LANG in
    es*)
	LANGUAGE="es-ES"
	TXT1="Parece que firefox no está en el sistema,\n ¿Desea instalarlo?"
	MSG1="# Por favor, espere.\n\n Descargando..."
	MSG2="# Por favor, espere.\n\n Instalando..."
	MSG3="# Por favor, espere.\n\n Lanzando Firefox..."
	MSG4="# Por favor, espere.\n\n Actualizando menús..."
    ;;
    gl*)
	LANGUAGE="gl"
	TXT1="Parece que firefox non está no sistema,\n Desexa instalalo?"
	MSG1="# Por favor, agarde.\n\n Descargando..."
	MSG2="# Por favor, agarde.\n\n Instalando..."
	MSG3="# Por favor, agarde.\n\n Executando Firefox..."
	MSG4="# Por favor, agarde.\n\n Actualizando menús..."
    ;;
    *)
	LANGUAGE="en-GB"
	TXT1="It seems Firefox is not in the system.\n ¿Do you want to install it?"
	MSG1="# Please, wait.\n\n Downloading..."
	MSG2="# Please, wait.\n\n Installing..."
	MSG3="# Please, wait.\n\n Running Firefox..."
	MSG4="# Please, wait.\n\n Menu updating..."
    ;;
esac



#Comprobamos si está firefox en el sistema
#if [ -e "`dirname $0`/firefox/firefox" ] || [ -e "/usr/bin/firefox" ];then
#	`dirname $0`/firefox/firefox
#	/usr/bin/firefox

if [ -e "/opt/firefox/firefox" ];then
	/opt/firefox/firefox
  else
	#Como no está, vamos a descargarlo.
	zenity --question --text="$TXT1"
	if [ $? == "0" ];then
		#(cd `dirname $0`
		(cd /opt
		echo "$MSG1"
		sleep 1
		echo 10
		#wget $MIRROR/$LANGUAGE/$FIREFOX_FILE
		wget -R index.html,index.html?C=D\;O=A,index.html?C=D\;O=D,index.html?C=M\;O=A,index.html?C=M\;O=D,index.html?C=N\;O=A,index.html?C=N\;O=D,index.html?C=S\;O=A,index.html?C=S\;O=D -c -r -nH -np --cut-dirs=7 $1 $MIRROR/$LANGUAGE/
		echo 60
		echo "$MSG2"
		tar xvjf *.bz2
		echo 90
		echo "$MSG4"
		minino_actliza-menu
		rm *.bz2
		rm *.asc
		rm index.html?order*
		rm robots*
		echo 95
		echo "$MSG3"
		sleep 1)|zenity --progress --auto-close
		#`dirname $0`/firefox/firefox
		/opt/firefox/firefox
	else
		exit 0
	fi
fi
