package gov.nasa.jpl.issm;

import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.content.DialogInterface;
import android.content.Intent;

/////////////////////////////////////////////////////////////////////////// 
public class MenuPage extends BaseActivity {
	// ISSM issm = new ISSM();
	// GalleryImage gallery = new GalleryImage();
	private static String issmFolder;

	// ------------------------------------------------------------------------
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.menupage);
		transition();
		Bundle map = getIntent().getExtras();
		{
			if (map != null) {
				issmFolder = map.getString("pathToFile");
			}
		}

		// start the core implementation of ISSM
		// Button start = (Button) findViewById(R.id.play_tab);
		// start.setOnClickListener(new View.OnClickListener() {
		// public void onClick(View v) {
		// Intent i = new Intent(MenuPage.this, ISSM.class);
		// i.putExtra("pathToFile", issmFolder);
		// startActivity(i);
		// }
		// });
		// // navigate to youtube video
		// Button video = (Button) findViewById(R.id.video_tab);
		// video.setOnClickListener(new View.OnClickListener() {
		// public void onClick(View v) {
		// // String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
		// // Intent i = new Intent(Intent.ACTION_VIEW);
		// // i.setData(Uri.parse(url));
		// Intent i = new Intent(MenuPage.this, VideoActivity.class);
		// startActivity(i);
		// }
		// });
		// // pop up a text box that contains information about ISSM
		// final Button intro = (Button) findViewById(R.id.about_tab);
		// intro.setOnClickListener(new View.OnClickListener() {
		// public void onClick(View v) {
		// // LayoutInflater layoutInflater =
		// //
		// //
		// (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
		// // View popupView = layoutInflater.inflate(R.layout.popuptext,
		// // null);
		// // final PopupWindow popupWindow = new PopupWindow( popupView,
		// // 400,600, true);
		// // popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
		// // Button dismiss =
		// // (Button)popupView.findViewById(R.id.dismiss);
		// // dismiss.setOnClickListener(new Button.OnClickListener()
		// // {
		// // public void onClick(View v)
		// // {
		// // popupWindow.dismiss();
		// // }
		// // });
		// Intent i = new Intent(MenuPage.this, AboutActivity.class);
		// startActivity(i);
		// }
		// });
		// // Show Team Website
		// Button visitus = (Button) findViewById(R.id.team_tab);
		// visitus.setOnClickListener(new View.OnClickListener() {
		// public void onClick(View v) {
		// // String url = "http://issm.jpl.nasa.gov/";
		// // Intent i = new Intent(Intent.ACTION_VIEW);
		// // i.setData(Uri.parse(url));
		// // startActivity(i);
		//
		// Intent i = new Intent(MenuPage.this, TeamActivity.class);
		// startActivity(i);
		// }
		// });
		// // start gallery image
		// Button galleryImage = (Button) findViewById(R.id.gallery_tab);
		// galleryImage.setOnClickListener(new View.OnClickListener() {
		// public void onClick(View v) {
		// Intent i = new Intent(MenuPage.this, GalleryImage.class);
		// startActivity(i);
		// }
		// });

		Button start = (Button) findViewById(R.id.start);
		start.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(MenuPage.this, ISSM.class);
				i.putExtra("pathToFile", issmFolder);
				startActivity(i);
				finish();
			}
		});

		Button galleryTab = (Button) findViewById(R.id.gallery_tab);
		galleryTab.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(MenuPage.this, GalleryImage.class);
				startActivity(i);
				finish();
			}
		});
		Button videoTab = (Button) findViewById(R.id.video_tab);
		videoTab.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// String url = "http://www.youtube.com/watch?v=KlDO0C8r_ws";
				// Intent i = new Intent(Intent.ACTION_VIEW);
				// i.setData(Uri.parse(url));
				Intent i = new Intent(MenuPage.this, VideoActivity.class);
				startActivity(i);
				finish();
			}
		});
		Button aboutTab = (Button) findViewById(R.id.about_tab);
		aboutTab.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(MenuPage.this, AboutActivity.class);
				startActivity(i);
				finish();
			}
		});
		Button teamTab = (Button) findViewById(R.id.team_tab);
		teamTab.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// String url = "http://issm.jpl.nasa.gov/";
				// Intent i = new Intent(Intent.ACTION_VIEW);
				// i.setData(Uri.parse(url));
				// startActivity(i);

				Intent i = new Intent(MenuPage.this, TeamActivity.class);
				startActivity(i);
				finish();
			}
		});
	}

	// -------------------------------------------------------------------------------------

	@Override
	public void onBackPressed() {
		new AlertDialog.Builder(this)
				.setMessage("Are you sure you want to exit?")
				.setCancelable(false)
				.setPositiveButton("Yes",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog, int id) {
								MenuPage.this.finish();
							}
						}).setNegativeButton("No", null).show();
	}

	// ----------------------------------------------------------------------------------------
	public static String getISSMPath() {
		return issmFolder;
	}
}
// /////////////////////////////////////////////////////////////////////////////////////// 