/***************************************************************************************************************
* File Name		: country_relation_manager.js
* Usage			: 1. Define function to set Country-Category and Country-Card Relation.
*			: 2. Define function to provide a list of country and a list of  
*			:    card which have relation with input country
*			:
* Author		: e-Crusade
* Creation Date		: 2008-12-16
* Amendment History	:
* Date		By		Description
* ---------	------------	--------------------------------------------------------------------------------
***************************************************************************************************************/


var _country_relation_ = new Array();
var _country_have_init_ = new Array();

/***************************************************************************************************************
* Function		: pws_ha_addCountryRelation(country,category,card)
* Description		: Create a Country-Category and Country-Card Relation
*			:
* Parameter Usage	: "country" 	- a country
* 			: "category"	- a list of categroy which have relation to country
*			: "card"	- a list of card which have relation to country
*			:
* Creation Date		: 2008-12-16
* Side effect		: No
* Amendment History	:
* Date		By		Description
* ---------	------------	--------------------------------------------------------------------------------
***************************************************************************************************************/

	function pws_ha_addCountryRelation(country,category,card){
		_country_relation_[country] = new Array(category,card);
		_country_have_init_[country] = true;
	}

/***************************************************************************************************************
* Function		: pws_ha_addCategoryToCountry(country,category,card)
* Description		: Create a Country-Category Relation
*			:
* Parameter Usage	: "country" 	- a country
* 			: "category"	- a category
*			:
* Remarks		: don't call the function pws_ha_addCountryRelation(country,category,card) 
*			: after calling this function if input country are the same.
*			: Data store in this function call will lose otherwise 
*			:
*			:
* Creation Date		: 2008-12-16
* Side effect		: No
* Amendment History	:
* Date		By		Description
* ---------	------------	--------------------------------------------------------------------------------
***************************************************************************************************************/

	function pws_ha_addCategoryToCountry(country,category){
		if(_country_have_init_[country]!=true){
			_country_relation_[country] = new Array(category,new Array());
			_country_have_init_[country] = true;
		}
		else
			_country_relation_[country][0].push(category);
	}


/***************************************************************************************************************
* Function		: pws_ha_addCardToCountry(country,card)
* Description		: Create a Country-Card Relation
*			:
* Parameter Usage	: "country" 	- a country
* 			: "card"	- a card
*			:
* Remarks		: don't call the function pws_ha_addCountryRelation(country,category,card) 
*			: after calling this function if input country are the same.
*			: Data store in this function call will lose otherwise 
*			:
* Creation Date		: 2008-12-16
* Side effect		: No
* Amendment History	:
* Date		By		Description
* ---------	------------	--------------------------------------------------------------------------------
***************************************************************************************************************/
	
	function pws_ha_addCardToCountry(country,card){
		if(_country_have_init_[country]!=true){
			_country_relation_[country] = new Array(new Array(),card);
			_country_have_init_[country] = true;
		}
		else
			_country_relation_[country][1].push(card);
	}

/***************************************************************************************************************
* Function		: pws_ha_queryCountry(country)
* Description		: Provide a list of category and a list of card which have relation with country
*			:
* Parameter Usage	: "country" 	- a country
*			:
* Creation Date		: 2008-12-16
* Side effect		: No
* Amendment History	:
* Date		By		Description
* ---------	------------	--------------------------------------------------------------------------------
***************************************************************************************************************/
		
	function pws_ha_queryCountry(country){
		if(country=="ALL"){
			return new Array(_all_category_list_,_all_card_list_);
		}else if(_country_have_init_[country]!=true){
			return new Array(new Array(),new Array());
		}else{
			return _country_relation_[country];
		}
	}
	