package com.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class AboutAndHelp extends Activity {
	Button help;
	Button about;
	Button back;
	Button last_page;
	Button next_page;
	TextView func_help;
	String FUNC_HELP_DOC[]=
	{
			"Search Events:\n" +
			"	以两种界面提供对事件的搜索：地图界面和列表界面。\n" +
			"	地图界面以本机位置为中心显示周边事件；\n" +
			"	...",
			"Add Events:\n" +
			"...",
			"My Porfile:\n" +
			"...",
			"Interact:\n" +
			"..."
	};
	int page_index=0;
		
	
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.about);
		
		help=(Button)findViewById(R.id.help_in_ha);
		about=(Button)findViewById(R.id.about_in_ha);
		back=(Button)findViewById(R.id.return_in_ha);
		last_page=(Button)findViewById(R.id.last_page);
		next_page=(Button)findViewById(R.id.next_page);
		func_help=(TextView)findViewById(R.id.func_help_doc);
		
		help.setOnClickListener(click_help);
		about.setOnClickListener(click_about);
		back.setOnClickListener(click_return);
		page_index=0;
		
	}
	
	OnClickListener click_about=new OnClickListener()
	{
		public void onClick(View view)
		{
			setContentView(R.layout.about);
			page_index=0;
		}
	};
	
	OnClickListener click_help=new OnClickListener()
	{
		public void onClick(View view)
		{
			Intent i=new Intent(AboutAndHelp.this,HelpPage.class);
			startActivity(i);
		}
	};
	
	OnClickListener click_return=new OnClickListener()
	{
		public void onClick(View view)
		{
			Intent i=new Intent(AboutAndHelp.this,UserMainPage.class);
			startActivity(i);
		}
	};
	
	OnClickListener click_last=new OnClickListener()
	{
		public void onClick(View view)
		{
			if(page_index>0)
				page_index--;
			if(page_index==0)
				last_page.setEnabled(false);
			func_help.setText(FUNC_HELP_DOC[page_index].toCharArray(), 0, FUNC_HELP_DOC[page_index].length());
		}
	};
	
	OnClickListener click_next=new OnClickListener()
	{
		public void onClick(View view)
		{
			page_index++;
			
			if(page_index>=FUNC_HELP_DOC.length)
				{page_index=0;last_page.setEnabled(false);}
			if(page_index==1)
				last_page.setEnabled(true);
			func_help.setText(FUNC_HELP_DOC[page_index].toCharArray(), 0, FUNC_HELP_DOC[page_index].length());
		}
	};

}
