using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class MenuUIManager : MonoBehaviour {

	public string GameSceneName = "SceneName";

	public Animator anim_instructionsImg;
	public Image img_instructionsImg;

	public Animator anim_instructionsBtn;
	public Button btn_instructionsBtn;

	public Animator anim_CreditsBtn;
	public Button btn_creditsBtn;

	public Button btn_Start;

	public Button btn_Back;
//	public Text txt_Back;

	public void BeginGame()
	{
		//AutoFade.LoadLevel(GameSceneName, 1f, 1f, Color.black);
        EventManager.TriggerEvent(Constants.ButtonClick);
        Fading.Instance.StartFade(GameSceneName);
	}

	public void ShowInstructions()
	{
		// Show instructions
        EventManager.TriggerEvent(Constants.ButtonClick);
		img_instructionsImg.enabled = true;

		btn_instructionsBtn.interactable = false;
		btn_Start.interactable = false;	
		btn_creditsBtn.interactable = false;

		anim_instructionsBtn.Play("ShowInstructions");
		anim_instructionsImg.Play("ShowInstructions");

			// Disable Start Button
		ShowBackButton(); // Show back button

	}

	public void HideInstructions()
	{
        EventManager.TriggerEvent(Constants.ButtonClick);
		anim_instructionsBtn.Play("HideInstructions");
		anim_instructionsImg.Play("HideInstructions");

		btn_instructionsBtn.interactable = true;
		btn_Start.interactable = true;
		btn_creditsBtn.interactable = true;

		// is animation still playing? if not then disable renderer
		/*if(!anim_instructionsImg.GetCurrentAnimatorStateInfo(0).IsName("HideInstructions"))
			img_instructionsImg.enabled = false;*/

		HideBackButton();
	}

	public void ShowCredits()
	{
        EventManager.TriggerEvent(Constants.ButtonClick);
		btn_instructionsBtn.interactable = false;
		btn_Start.interactable = false;	
		btn_creditsBtn.interactable = false;
		anim_CreditsBtn.Play("ShowCredits");


	}

	public void HideCredits()
	{
        EventManager.TriggerEvent(Constants.ButtonClick);
		btn_instructionsBtn.interactable = true;
		btn_Start.interactable = true;
		btn_creditsBtn.interactable = true;
		anim_CreditsBtn.Play("HideCredits");
	}

	void ShowBackButton()
	{
		btn_Back.interactable = true;
		//txt_Back.enabled = true;
	}

	void HideBackButton()
	{
		btn_Back.interactable = false;
		//txt_Back.enabled = false;
	}
}
