// JavaScript Document

function changeInfoOn(info,titles){
	document.getElementById(titles).style.backgroundColor = '#555555';
	document.getElementById(info).style.display = 'block';
}

function changeInfoOff(info,titles){
	document.getElementById(titles).style.backgroundColor = '#333333';
	document.getElementById(info).style.display = 'none';
}

function changeInfo(targetTable,index){
	var targetRow = document.getElementById(targetTable).rows[index];
	var targetHelpRow = document.getElementById(targetTable).rows[index+1];
	if( targetHelpRow.style.display == '' ){
		targetRow.style.backgroundColor = '#333333';
		targetHelpRow.style.display = 'none';
	}
	else{
		targetRow.style.backgroundColor = '#555555';
		targetHelpRow.style.display = '';
	}
}

function displayHide(targetTable){
	var tables = document.getElementById(targetTable);
	
	for(i=0; i<tables.rows.length; i++){
		if( tables.rows[i].className.indexOf('main_text') >= 0 ){
			tables.rows[i].onclick = (function(i){
				return function(){ changeInfo(targetTable,i); };
			})(i);
		}
		else{
			tables.rows[i].style.display = 'none';
		}
	}
}

function getSkillList(bodyname){
	var skbody = document.getElementById(bodyname);
	
	return skbody;
}

function viewSkill(type){
	
	var skbody = getSkillList('skillbody');
	var i;
	var classname;
	var trtag;
	
	for(i=0; i<skbody.rows.length; i++){
		skbody.rows[i].style.display = 'none';
		skbody.rows[i].style.backgroundColor = '#333333';
		
		classname = skbody.rows[i].className;
		classname = classname.replace('main_text','');
		classname = classname.replace('help_text','');
		
		if(skbody.rows[i].className.indexOf('main_text') >= 0 && (classname.indexOf(type) >= 0 || type == 'all')){
			skbody.rows[i].style.display = '';
		}
	}
}

function viewItem(type){
	
	var skbody = getSkillList('itembody');
	var i;
	var classname;
	var trtag;
	
	for(i=0; i<skbody.rows.length; i++){
		skbody.rows[i].style.display = 'none';
		skbody.rows[i].style.backgroundColor = '#333333';
		
		classname = skbody.rows[i].className;
		classname = classname.replace('main_text','');
		classname = classname.replace('help_text','');
		
		if(skbody.rows[i].className.indexOf('main_text') >= 0 && (classname.indexOf(type) >= 0 || type == 'all')){
			skbody.rows[i].style.display = '';
		}
	}
}

function viewBank(type){
	
	var skbody = getSkillList('bankbody');
	var i;
	var classname;
	var trtag;
	
	for(i=0; i<skbody.rows.length; i++){
		skbody.rows[i].style.display = 'none';
		skbody.rows[i].style.backgroundColor = '#333333';
		
		classname = skbody.rows[i].className;
		classname = classname.replace('main_text','');
		classname = classname.replace('help_text','');
		
		if(skbody.rows[i].className.indexOf('main_text') >= 0 && (classname.indexOf(type) >= 0 || type == 'all')){
			skbody.rows[i].style.display = '';
		}
	}
}

function viewKeyItem(type){
	
	var skbody = getSkillList('keyitembody');
	var i;
	var classname;
	var trtag;
	
	for(i=0; i<skbody.rows.length; i++){
		skbody.rows[i].style.display = 'none';
		skbody.rows[i].style.backgroundColor = '#333333';
		
		classname = skbody.rows[i].className;
		classname = classname.replace('main_text','');
		classname = classname.replace('help_text','');
		
		if(skbody.rows[i].className.indexOf('main_text') >= 0 && (classname.indexOf(type) >= 0 || type == 'all')){
			skbody.rows[i].style.display = '';
		}
	}
}

function viewTec(type){
	var tec_type = new Array(4);
	tec_type[0] = 'battle';
	tec_type[1] = 'magic';
	tec_type[2] = 'field';
	tec_type[3] = 'create';
	
	var i;
	
	for(i=0;i<4;i++){
		if(type != tec_type[i] && type != 'all'){
			document.getElementById(tec_type[i] + '_tec').style.display = 'none';
		}
		else{
			document.getElementById(tec_type[i] + '_tec').style.display = '';
		}
	}
}

function viewhideIn(target){
	if(document.getElementById(target).style.display == 'block' ){
		document.getElementById(target).style.display = 'none';
	}
	else{
		document.getElementById(target).style.display = 'block';
	}
}

