package example.com.velezguiatour;


import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.GridView;
import android.widget.ImageButton;

public class MainActivity extends Activity {
	ImageButton telefono, hotel;
	ImageButton ocio;
	ImageButton monumento;
	ImageButton acercade;
	ImageButton museo;
	ImageButton admin;
	ImageButton restaurant;
	ImageButton shooping;
	ImageButton clima;

	GridView gridView;
	public static MediaPlayer mp = null;
	public static MediaPlayer mam;

	private void hotel() {
		Intent i = new Intent(this, Hotels.class);
		startActivity(i);
	}
	private void museo() {
		Intent i = new Intent(this, Museo.class);
		startActivity(i);
	}

	private void shooping() {
		Intent i = new Intent(this, Shopping.class);
		startActivity(i);
	}
	private void restaurant() {
		Intent i = new Intent(this, Restaurant.class);
		startActivity(i);

	}
	public void pulsarAcercaDe(View vista) {
		Intent intencion = new Intent(this, AcercaDe.class);
		startActivity(intencion);
	}

	private void telefono() {
		Intent i = new Intent(this, Telefono.class);
		startActivity(i);
	}
	private void ocio() {
		Intent i = new Intent(this, Ocio.class);
		startActivity(i);
	}
	private void monumento() {
		Intent i = new Intent(this, Visita.class);
		startActivity(i);
	}





	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		ocio = (ImageButton) findViewById(R.id.btnocio);
		shooping = (ImageButton) findViewById(R.id.btnshopping);
		restaurant = (ImageButton) findViewById(R.id.btnrestaurants);
		monumento = (ImageButton) findViewById(R.id.btnmonumento);
		hotel = (ImageButton) findViewById(R.id.btnhotel);
		telefono = (ImageButton) findViewById(R.id.btntelefono);
		museo = (ImageButton) findViewById(R.id.btnmuseo);
		admin = (ImageButton) findViewById(R.id.btnadmin);
		clima = (ImageButton)findViewById(R.id.btnclima);

	
		
		ocio.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				ocio();
				if (mam != null) {
					mam.stop();
					mam.release();
				}
				mam = MediaPlayer
						.create(getApplicationContext(), R.raw.ocio);
				mam.start();

			}
		});


		restaurant.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				restaurant();
				if (mam != null) {
					mam.stop();
					mam.release();
				}
				mam = MediaPlayer.create(getApplicationContext(),
						R.raw.dondecomer);
				mam.start();

			}
		});
		clima.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				Uri uriUrl = Uri.parse("http://www.tiempo.com/velez-malaga.htm");
				//Especificamos la accion a realizar con el ACTION_VIEW
				//para que elija lo mas razonable
				Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
				startActivity(intent);

			}
		});
		telefono.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				telefono();
				if (mam != null) {
					mam.stop();
					mam.release();
				}
				mam = MediaPlayer.create(getApplicationContext(), R.raw.telefonos);
				mam.start();

			}
		});


	monumento.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				monumento();
				if (mam != null) {
					mam.stop();
					mam.release();
				}
				mam = MediaPlayer.create(getApplicationContext(), R.raw.monumentos);
				mam.start();

			}
		});
		museo.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				museo();
				if (mam != null) {
					mam.stop();
					mam.release();
				}
				mam = MediaPlayer.create(getApplicationContext(), R.raw.museos);
				mam.start();

			}
		});
		shooping.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				shooping();
				if (mam != null) {
					mam.stop();
					mam.release();
				}
				mam = MediaPlayer
						.create(getApplicationContext(), R.raw.comprar);
				mam.start();

			}
		});

		admin.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				Intent i = new Intent(MainActivity.this, Login.class);
				startActivity(i);
			}
		});
		
		

		hotel.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				hotel();
				if (mam != null) {
					mam.stop();
					mam.release();
				}
				mam = MediaPlayer.create(getApplicationContext(), R.raw.hoteles);
				mam.start();

			}
		});

	}
		
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu_main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
	
}
