package com.usai.apex;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

public class FunctionSelectActivity extends FragmentActivity implements OnClickListener
{
	String user=null;
	String password=null;
	

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		user=getIntent().getStringExtra("user");
		password= getIntent().getStringExtra("password");
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_function_select);
		
		ImageButton ibtn_booking = (ImageButton)findViewById(R.id.ibtn_booking);
		ibtn_booking.setOnClickListener(this);
		ImageButton ibtn_info = (ImageButton)findViewById(R.id.ibtn_info);
		ibtn_info.setOnClickListener(this);
		ImageButton ibtn_detail = (ImageButton)findViewById(R.id.ibtn_detail);
		ibtn_detail.setOnClickListener(this);
		ImageButton ibtn_cargo = (ImageButton)findViewById(R.id.ibtn_cargo);
		ibtn_cargo.setOnClickListener(this);
		ImageButton ibtn_doc = (ImageButton)findViewById(R.id.ibtn_doc);
		ibtn_doc.setOnClickListener(this);
		ImageButton ibtn_password = (ImageButton)findViewById(R.id.ibtn_password);
		ibtn_password.setOnClickListener(this);
		ImageButton ibtn_exit = (ImageButton)findViewById(R.id.ibtn_exit);
		ibtn_exit.setOnClickListener(this);
	}

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


	@Override
	public void onClick(View v)
	{
		String TAG="onClick@FunctionSelectActivity";
		Log.d(TAG, "ID="+v.getId());
		switch (v.getId())
		{
		case R.id.ibtn_booking:
		{
			Intent intent = new Intent();
			intent.setClass(this, SearchActivity.class);
			intent.putExtra("user", user);
			intent.putExtra("password", password);
			intent.putExtra("function_name", "Ocean Booking");
			startActivity(intent);			
			break;
		}
		case R.id.ibtn_info:
		{
			Intent intent = new Intent();
			intent.setClass(this, SearchActivity.class);
			intent.putExtra("user", user);
			intent.putExtra("password", password);
			intent.putExtra("function_name", "Ocean B/L info.");
			startActivity(intent);			
			break;
		}
		case R.id.ibtn_detail:
		{
			Intent intent = new Intent();
			intent.setClass(this, SearchActivity.class);
			intent.putExtra("user", user);
			intent.putExtra("password", password);
			intent.putExtra("function_name", "Container detail");
			startActivity(intent);			
			break;
		}
		case R.id.ibtn_cargo:
			
			break;
		case R.id.ibtn_doc:
			
			break;
		case R.id.ibtn_password:
			
			break;
		case R.id.ibtn_exit:
		{
			finish();  
            System.exit(0);  
            break;
		}
			
			

		default:
			break;
		}
		// TODO Auto-generated method stub
		
		
	}

}
