CardTabs = {};

CardTabs.CardChoices = null;
CardTabs.SelectedTab = 0;
CardTabs.TabLinks = {
	0 : 'card_det.php',
//	1 : 'trx_lst.php',
	1 : 'stmt_lst.php',
//	3 : 'recurtrx_lst.php'
};

CardTabs.HandleShortcutSelect = function(e) {
	
	Combobox = EventHandler.GetTarget(e);
	if (Combobox.value != '') {
		document.location = Combobox.value;
	}
	
}

CardTabs.ChooseCard = function(e) {
	
//get the li which triggers this event
	Choice = EventHandler.GetTarget(e);
//redirect to appropriate page depending on the li's id
	if (Choice.id == -1) {
		document.location = 'card_lst.php';
	} else {
		document.location = CardTabs.TabLinks[CardTabs.SelectedTab]+'?cat101='+Choice.id;
	}
	
}

CardTabs.ShowHideChoice = function(e) {

	Target = EventHandler.GetTarget(e);
	if (Target.id == 'card_tabs_header') {
		if (CardTabs.CardChoices.style.visibility == 'hidden') {
			CardTabs.CardChoices.style.visibility = 'visible';
		} else {
			CardTabs.CardChoices.style.visibility = 'hidden';
		}
		EventHandler.CancelBubble(e);
	} else {
		CardTabs.CardChoices.style.visibility = 'hidden';
	}
	
}

CardTabs.Initialize = function() {

//get the choice list div	
	CardTabs.CardChoices = document.getElementById('card_tabs_choice');
	if (CardTabs.CardChoices) {
	//assign onlick event on every li that exist under the div
		Choices = CardTabs.CardChoices.getElementsByTagName('li');
		for (i=0; i<Choices.length; i++) {
			EventHandler.AddEvent(Choices[i],'click',CardTabs.ChooseCard);
		}
	//assign onclick event to the header
		EventHandler.AddEvent('card_tabs_header','click',CardTabs.ShowHideChoice);
	//hide card choice if user clicks anywhere 
		EventHandler.AddEvent(document,'click',CardTabs.ShowHideChoice);
	//bug??? force the choice list div to have "hidden" as its visibility
	//dunno, I have set this on the css but initially its value is blank (default)
	//this makes user has to click once anywhere on the screen than click the header to make the choice list div show
		CardTabs.CardChoices.style.visibility = 'hidden';  
	//assign handler for command shortcut selection
		EventHandler.AddEvent('cmd_shortcut','change',CardTabs.HandleShortcutSelect);
	}

}
