var blkList = new Array('keyword_ja',
						'gene_structure',
						'alternative_splicing_isoforms',
						'non_coding_functional_RNAs',
						'protein_functions',
						'functional_domains',
						'subcellular_localization',
						'metabolic_pathways',
						'protein_3d_structure',
						'genetic_polymorphisms',
						'gene_expression_profiling',
						'relation_with_diseases',
						'molecular_evolutionary_features',
						'ppi',
						'gene_families',
						'others'
						);

var MENU_CNT = 12;
var menuList 	= new Array();
var sectionList = new Array();

var CrossSearch = new function(){};


/**
 * 
 */
CrossSearch.Initialize = function() {
	var list = $('section_area').getElementsByTagName('div');

	for(var i = 0; i < list.length; i++) {
		var obj = list[i];
		if (obj.id.indexOf('_section') != -1) {
			sectionList.push(new Section(obj));
		}
	}
	
	CrossSearch.SetMenuInfomation();	
}

/**
 * 
 */
CrossSearch.SelectAllSearchType = function(){
	for (var i = 0; i < sectionList.length; i++) {
		sectionList[i].setVisible(true);
	}

}

/**
 * 
 */
CrossSearch.ClearSearchType = function(){
	for (var i = 0; i < sectionList.length; i++) {
		sectionList[i].setVisible(false);
	}
	
}

/**
 * 
 */
CrossSearch.ClearSearchData = function(){
	for (var i = 0; i < sectionList.length; i++) {
		sectionList[i].clearSearchArea();
	}
}

/**
 * 
 */
CrossSearch.ChangeState = function() {
	var setList = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
	for (var i = 0; i < menuList.length; i++) {
		var noList = menuList[i].getSectionList();
		
		for(j = 0; j < noList.length; j++) {
			var no = Number(noList[j]);
			if (menuList[i].isSelect() == true) {
				setList[no] = 1;
			} else {
				if (setList[no] == 0) {
					setList[no] = 0;
				} 
			}
		}
	}

	for(var i = 0; i < setList.length; i++) {
		var id = blkList[i];
		if (setList[i] == 1) {
			sectionList[id].setVisible(true);
		} else {
			sectionList[id].setVisible(false);
		}
	}	
}

CrossSearch.GetSectionState = function() {
	var ret = "";
	for(var i = 0; i < sectionList.length; i++) {
		if (sectionList[i].isVisible() == true) {
			if (ret == "") {
				ret = String(i);
			} else {
				ret += "," +String(i);	
			}
		}
	}
	return ret;	
}

CrossSearch.GetSectionWindowState = function() {
	var ret = "";
	for(var i = 0; i < sectionList.length; i++) {
		if (sectionList[i].isWindowState() == false) {
			if (ret == "") {
				ret = String(i);
			} else {
				ret += "," +String(i);	
			}
		}
	}
	return ret;	
}

CrossSearch.SetMenuInfomation = function() {

	var isVisible = false;
	for(var i = 0; i < sectionList.length; i++) {
		if (sectionList[i].isVisible() == true) {
			isVisible = true;
			break;
		}
	}

	if (isVisible == true) {
		$('menu_info').style.display = "none";		
	} else {
		$('menu_info').style.display= "inline";
	}
}


