MediaWiki:Kalos Mechanism 4 0 EN.js

From OGC
Revision as of 21:22, 1 October 2022 by Admin (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
function getQueryVariable(variable)
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");

	for (let i=0;i<vars.length;i++) {
		let pair = vars[i].split("=");
		if(pair[0] == variable){return pair[1];}
	}

	return(false);
}

function get_rank_value(rank_value)
{
	rank_value = parseInt(rank_value);
	
	if (isNaN(rank_value))
	{
		rank_value = 0;
	}

	rank_value = Math.max(0, rank_value);
	rank_value = Math.min(10, rank_value);

	return rank_value;
}

function calculate_rank_cost(rank_value)
{
	var rank_cost = 0;
	
	switch (parseInt(rank_value))
	{
		case 0:
			rank_cost = 0;
			break;
		case 1:
			rank_cost = 1;
			break;
		case 2:
			rank_cost = 3;
			break;
		case 3:
			rank_cost = 6;
			break;
		case 4:
			rank_cost = 10;
			break;
		case 5:
			rank_cost = 15;
			break;
		case 6:
			rank_cost = 21;
			break;
		case 7:
			rank_cost = 28;
			break;
		case 8:
			rank_cost = 36;
			break;
		case 9:
			rank_cost = 45;
			break;
		case 10:
			rank_cost = 55;
			break;
		case 11:
			rank_cost = 66;
			break;
		case 12:
			rank_cost = 78;
			break;
		case 13:
			rank_cost = 91;
			break;
		case 14:
			rank_cost = 105;
			break;
		case 15:
			rank_cost = 120;
			break;
		case 16:
			rank_cost = 136;
			break;
		case 17:
			rank_cost = 153;
			break;
		case 18:
			rank_cost = 171;
			break;
		case 19:
			rank_cost = 190;
			break;
		case 20:
			rank_cost = 210;
			break;
		default:
			rank_cost = 210;
			break;
	}
	
	return rank_cost;
}

function format_attribute_cost_output(attribute_cost)
{
	var formatted_attribute_cost_output;
	var derived_attribute_padding = 0;

	attribute_cost['endurance']['value'] = attribute_cost['brawn']['value'] + attribute_cost['presence']['value'] + derived_attribute_padding;
	attribute_cost['health']['value'] = attribute_cost['agility']['value'] + attribute_cost['brawn']['value'] + derived_attribute_padding;

	formatted_attribute_cost_output = "<div class=\"sidebar_title\">Attribute Costs</div>\n";
	formatted_attribute_cost_output += '<div class="sidebar_subtitle">';
	formatted_attribute_cost_output += 'Enter your desired attribute levels to see the total cost.';
	formatted_attribute_cost_output += '<table cellpadding="2" style="margin:auto 0;">';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<th align="left">Attribute</th>';
	formatted_attribute_cost_output += '<th align="center" style="padding-left: 15px; padding-right: 15px;">Level</th>';
	formatted_attribute_cost_output += '<th align="right">Cost</th>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Agility</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="agility_value" type="text" size="2" style="text-align: right" value="' + attribute_cost['agility']['value'] + '" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="agility_cost">' + attribute_cost['agility']['cost'] + '</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Brawn</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="brawn_value" type="text" size="2" style="text-align: right" value="' + attribute_cost['brawn']['value'] + '" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="brawn_cost">' + attribute_cost['brawn']['cost'] + '</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Presence</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="presence_value" type="text" size="2" style="text-align: right" value="' + attribute_cost['presence']['value'] + '" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="presence_cost">' + attribute_cost['presence']['cost'] + '</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Reason</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="reason_value" type="text" size="2" style="text-align: right" value="' + attribute_cost['reason']['value'] + '" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="reason_cost">' + attribute_cost['reason']['cost'] + '</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Power Level</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="power_value" type="text" size="2" style="text-align: right" value="' + attribute_cost['power']['value'] + '" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="power_cost">' + attribute_cost['power']['cost'] + '</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Endurance</td>';
	formatted_attribute_cost_output += '<td align="center">' + attribute_cost['endurance']['value'] + '</td>';
	formatted_attribute_cost_output += '<td align="right"></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Health</td>';
	formatted_attribute_cost_output += '<td align="center">' + attribute_cost['health']['value'] + '</td>';
	formatted_attribute_cost_output += '<td align="right"></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<th align="left">Total</th>';
	formatted_attribute_cost_output += '<th align="center"></th>';
	formatted_attribute_cost_output += '<th align="right"><span id="total_cost">' + attribute_cost['total']['cost'] + '</span></th>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '</table>';
	formatted_attribute_cost_output += '</div>';
		
	return formatted_attribute_cost_output;
}

function set_attribute_cost_output()
{
	var attribute_cost = new Array();
	var raw_value = 0;
	var derived_attribute_padding = 0;

	attribute_cost['agility'] = new Array();
	attribute_cost['brawn'] = new Array();
	attribute_cost['presence'] = new Array();
	attribute_cost['reason'] = new Array();
	attribute_cost['power'] = new Array();
	attribute_cost['endurance'] = new Array();
	attribute_cost['health'] = new Array();
	attribute_cost['total'] = new Array();

	attribute_cost['total']['cost'] = 0;

	attribute_cost['agility']['value'] = get_rank_value(document.getElementById('agility_value').value);
	attribute_cost['agility']['cost'] = calculate_rank_cost(attribute_cost['agility']['value']);
	attribute_cost['total']['cost'] += attribute_cost['agility']['cost'];

	attribute_cost['brawn']['value'] = get_rank_value(document.getElementById('brawn_value').value);
	attribute_cost['brawn']['cost'] = calculate_rank_cost(attribute_cost['brawn']['value']);
	attribute_cost['total']['cost'] += attribute_cost['brawn']['cost'];

	attribute_cost['presence']['value'] = get_rank_value(document.getElementById('presence_value').value);
	attribute_cost['presence']['cost'] = calculate_rank_cost(attribute_cost['presence']['value']);
	attribute_cost['total']['cost'] += attribute_cost['presence']['cost'];

	attribute_cost['reason']['value'] = get_rank_value(document.getElementById('reason_value').value);
	attribute_cost['reason']['cost'] = calculate_rank_cost(attribute_cost['reason']['value']);
	attribute_cost['total']['cost'] += attribute_cost['reason']['cost'];

	attribute_cost['power']['value'] = get_rank_value(document.getElementById('power_value').value);
	attribute_cost['power']['cost'] = calculate_rank_cost(attribute_cost['power']['value']);
	attribute_cost['total']['cost'] += attribute_cost['power']['cost'];

	attribute_cost['endurance']['value'] = attribute_cost['brawn']['value'] + attribute_cost['presence']['value'] + derived_attribute_padding;
	attribute_cost['health']['value'] = attribute_cost['agility']['value'] + attribute_cost['brawn']['value'] + derived_attribute_padding;

	document.getElementById("sidebar_attribute_cost_output_4_0_EN").innerHTML = format_attribute_cost_output(attribute_cost);
}

function initialize_attribute_cost_output()
{
	var formatted_attribute_cost_output;
	var rank_value_default;
	var rank_cost_default;
	var derived_attribute_padding;
	var derived_value_default;
	var total_cost_default;

	rank_value_default = 1;
	rank_cost_default = 1;
	derived_attribute_padding = 0;
	derived_value_default = (2 * rank_value_default) + derived_attribute_padding;
	total_cost_default = 5;

	formatted_attribute_cost_output = "<div class=\"sidebar_title\">Attribute Costs</div>\n";
	formatted_attribute_cost_output += '<div class="sidebar_subtitle">';
	formatted_attribute_cost_output += 'Enter your desired attribute levels to see the total cost.';
	formatted_attribute_cost_output += '<table cellpadding="2" style="margin:auto 0;">';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<th align="left">Attribute</th>';
	formatted_attribute_cost_output += '<th align="center" style="padding-left: 15px; padding-right: 15px;">Level</th>';
	formatted_attribute_cost_output += '<th align="right">Cost</th>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Agility</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="agility_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="agility_cost">' + rank_cost_default + '</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Brawn</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="brawn_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="brawn_cost">' + rank_cost_default + '</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Presence</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="presence_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="presence_cost">' + rank_cost_default + '</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Reason</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="reason_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="reason_cost">' + rank_cost_default + '</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Power Level</td>';
	formatted_attribute_cost_output += '<td align="center"><input id="power_value" type="text" size="2" style="text-align: right;" value="'+ rank_value_default +'" onblur="set_attribute_cost_output()"></td>';
	formatted_attribute_cost_output += '<td align="right"><span id="power_cost">'+ rank_cost_default +'</span></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Endurance</td>';
	formatted_attribute_cost_output += '<td align="center">' + derived_value_default + '</td>';
	formatted_attribute_cost_output += '<td align="right"></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<td align="left">Health</td>';
	formatted_attribute_cost_output += '<td align="center">' + derived_value_default + '</td>';
	formatted_attribute_cost_output += '<td align="right"></td>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '<tr>';
	formatted_attribute_cost_output += '<th align="left">Total</th>';
	formatted_attribute_cost_output += '<th align="center"></th>';
	formatted_attribute_cost_output += '<th align="right"><span id="total_cost">'+ total_cost_default +'</span></th>';
	formatted_attribute_cost_output += '</tr>';
	formatted_attribute_cost_output += '</table>';
	formatted_attribute_cost_output += '</div>';
	
	sidebar_attribute_cost_output_4_0_EN.innerHTML = formatted_attribute_cost_output;
}

function format_skill_cost_output(skill_cost,is_archaic)
{
	var formatted_skill_cost_output;
	var rank_value_default;
	var rank_cost_default;

	rank_value_default = 0;
	rank_cost_default = 0;

	formatted_skill_cost_output = "<div class=\"sidebar_title\">Skill Costs</div>\n";
	formatted_skill_cost_output += '<div class="sidebar_subtitle">';
	formatted_skill_cost_output += 'Enter your desired skill levels to see the total cost.';
	formatted_skill_cost_output += '<table cellpadding="2" style="margin:auto 0;">';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<th align="left">Skill</th>';
	formatted_skill_cost_output += '<th align="center" style="padding-left: 15px; padding-right: 15px;">Level</th>';
	formatted_skill_cost_output += '<th align="right">Cost</th>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Athletics</td>';
	formatted_skill_cost_output += '<td align="center"><input id="athletics_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['athletics']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="athletics_cost">' + skill_cost['athletics']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';

	if (!is_archaic)
	{
		formatted_skill_cost_output += '<tr>';
		formatted_skill_cost_output += '<td align="left">Computing</td>';
		formatted_skill_cost_output += '<td align="center"><input id="computing_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['computing']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
		formatted_skill_cost_output += '<td align="right"><span id="computing_cost">' + skill_cost['computing']['cost'] + '</span></td>';
		formatted_skill_cost_output += '</tr>';
	}

	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Culture</td>';
	formatted_skill_cost_output += '<td align="center"><input id="culture_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['culture']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="culture_cost">' + skill_cost['culture']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Deception</td>';
	formatted_skill_cost_output += '<td align="center"><input id="deception_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['deception']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="deception_cost">' + skill_cost['deception']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Diplomacy</td>';
	formatted_skill_cost_output += '<td align="center"><input id="diplomacy_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['diplomacy']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="diplomacy_cost">' + skill_cost['diplomacy']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Engineering</td>';
	formatted_skill_cost_output += '<td align="center"><input id="engineering_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['engineering']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="engineering_cost">' + skill_cost['engineering']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Finesse</td>';
	formatted_skill_cost_output += '<td align="center"><input id="finesse_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['finesse']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="finesse_cost">' + skill_cost['finesse']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Gambling</td>';
	formatted_skill_cost_output += '<td align="center"><input id="gambling_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['gambling']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="gambling_cost">' + skill_cost['gambling']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Hand-to-hand Combat</td>';
	formatted_skill_cost_output += '<td align="center"><input id="hand-to-hand_combat_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['hand-to-hand_combat']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="hand-to-hand_combat_cost">' + skill_cost['hand-to-hand_combat']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Investigation</td>';
	formatted_skill_cost_output += '<td align="center"><input id="investigation_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['investigation']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="investigation_cost">' + skill_cost['investigation']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Manipulation</td>';
	formatted_skill_cost_output += '<td align="center"><input id="manipulation_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['manipulation']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="manipulation_cost">' + skill_cost['manipulation']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Medicine</td>';
	formatted_skill_cost_output += '<td align="center"><input id="medicine_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['medicine']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="medicine_cost">' + skill_cost['medicine']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Mental Combat</td>';
	formatted_skill_cost_output += '<td align="center"><input id="mental_combat_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['mental_combat']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="mental_combat_cost">' + skill_cost['mental_combat']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Occult</td>';
	formatted_skill_cost_output += '<td align="center"><input id="occult_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['occult']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="occult_cost">' + skill_cost['occult']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Performance</td>';
	formatted_skill_cost_output += '<td align="center"><input id="performance_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['performance']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="performance_cost">' + skill_cost['performance']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Piloting</td>';
	formatted_skill_cost_output += '<td align="center"><input id="piloting_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['piloting']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="piloting_cost">' + skill_cost['piloting']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Ranged Combat</td>';
	formatted_skill_cost_output += '<td align="center"><input id="ranged_combat_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['ranged_combat']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="ranged_combat_cost">' + skill_cost['ranged_combat']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Science</td>';
	formatted_skill_cost_output += '<td align="center"><input id="science_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['science']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="science_cost">' + skill_cost['science']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Stealth</td>';
	formatted_skill_cost_output += '<td align="center"><input id="stealth_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['stealth']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="stealth_cost">' + skill_cost['stealth']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Survival</td>';
	formatted_skill_cost_output += '<td align="center"><input id="survival_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['survival']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="survival_cost">' + skill_cost['survival']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Warfare</td>';
	formatted_skill_cost_output += '<td align="center"><input id="warfare_value" type="text" size="2" style="text-align: right;" value="' + skill_cost['warfare']['value'] + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="warfare_cost">' + skill_cost['warfare']['cost'] + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<th align="left">Total</th>';
	formatted_skill_cost_output += '<th align="center"></th>';
	formatted_skill_cost_output += '<th align="right"><span id="total_cost">' + skill_cost['total']['cost'] + '</span></th>';
	formatted_skill_cost_output += '</tr>';

	if (is_archaic)
	{
		formatted_skill_cost_output += '<tr>';
		formatted_skill_cost_output += '<td></td>';
		formatted_skill_cost_output += '<td><input id="computing_value" type="hidden" value="' + rank_value_default + '"></td>';
		formatted_skill_cost_output += '<td><input id="computing_cost" type="hidden" value="' + rank_cost_default + '"></td>';;
		formatted_skill_cost_output += '</tr>';
	}

	formatted_skill_cost_output += '</table>';
	formatted_skill_cost_output += '</div>';
		
	return formatted_skill_cost_output;
}

function set_skill_cost_output(is_archaic)
{
	var skill_cost = new Array();
	var raw_value = 0;

	skill_cost['athletics'] = new Array();
	skill_cost['computing'] = new Array();
	skill_cost['culture'] = new Array();
	skill_cost['deception'] = new Array();
	skill_cost['diplomacy'] = new Array();
	skill_cost['engineering'] = new Array();
	skill_cost['finesse'] = new Array();
	skill_cost['gambling'] = new Array();
	skill_cost['hand-to-hand_combat'] = new Array();
	skill_cost['investigation'] = new Array();
	skill_cost['manipulation'] = new Array();
	skill_cost['medicine'] = new Array();
	skill_cost['mental_combat'] = new Array();
	skill_cost['occult'] = new Array();
	skill_cost['performance'] = new Array();
	skill_cost['piloting'] = new Array();
	skill_cost['ranged_combat'] = new Array();
	skill_cost['science'] = new Array();
	skill_cost['stealth'] = new Array();
	skill_cost['survival'] = new Array();
	skill_cost['warfare'] = new Array();
	skill_cost['total'] = new Array();

	skill_cost['total']['cost'] = 0;

	skill_cost['athletics']['value'] = get_rank_value(document.getElementById('athletics_value').value);
	skill_cost['athletics']['cost'] = calculate_rank_cost(skill_cost['athletics']['value']);
	skill_cost['computing']['value'] = get_rank_value(document.getElementById('computing_value').value);
	skill_cost['computing']['cost'] = calculate_rank_cost(skill_cost['computing']['value']);
	skill_cost['culture']['value'] = get_rank_value(document.getElementById('culture_value').value);
	skill_cost['culture']['cost'] = calculate_rank_cost(skill_cost['culture']['value']);
	skill_cost['deception']['value'] = get_rank_value(document.getElementById('deception_value').value);
	skill_cost['deception']['cost'] = calculate_rank_cost(skill_cost['deception']['value']);
	skill_cost['diplomacy']['value'] = get_rank_value(document.getElementById('diplomacy_value').value);
	skill_cost['diplomacy']['cost'] = calculate_rank_cost(skill_cost['diplomacy']['value']);
	skill_cost['engineering']['value'] = get_rank_value(document.getElementById('engineering_value').value);
	skill_cost['engineering']['cost'] = calculate_rank_cost(skill_cost['engineering']['value']);
	skill_cost['finesse']['value'] = get_rank_value(document.getElementById('finesse_value').value);
	skill_cost['finesse']['cost'] = calculate_rank_cost(skill_cost['finesse']['value']);
	skill_cost['gambling']['value'] = get_rank_value(document.getElementById('gambling_value').value);
	skill_cost['gambling']['cost'] = calculate_rank_cost(skill_cost['gambling']['value']);
	skill_cost['hand-to-hand_combat']['value'] = get_rank_value(document.getElementById('hand-to-hand_combat_value').value);
	skill_cost['hand-to-hand_combat']['cost'] = calculate_rank_cost(skill_cost['hand-to-hand_combat']['value']);
	skill_cost['investigation']['value'] = get_rank_value(document.getElementById('investigation_value').value);
	skill_cost['investigation']['cost'] = calculate_rank_cost(skill_cost['investigation']['value']);
	skill_cost['manipulation']['value'] = get_rank_value(document.getElementById('manipulation_value').value);
	skill_cost['manipulation']['cost'] = calculate_rank_cost(skill_cost['manipulation']['value']);
	skill_cost['medicine']['value'] = get_rank_value(document.getElementById('medicine_value').value);
	skill_cost['medicine']['cost'] = calculate_rank_cost(skill_cost['medicine']['value']);
	skill_cost['mental_combat']['value'] = get_rank_value(document.getElementById('mental_combat_value').value);
	skill_cost['mental_combat']['cost'] = calculate_rank_cost(skill_cost['mental_combat']['value']);
	skill_cost['occult']['value'] = get_rank_value(document.getElementById('occult_value').value);
	skill_cost['occult']['cost'] = calculate_rank_cost(skill_cost['occult']['value']);
	skill_cost['performance']['value'] = get_rank_value(document.getElementById('performance_value').value);
	skill_cost['performance']['cost'] = calculate_rank_cost(skill_cost['performance']['value']);
	skill_cost['piloting']['value'] = get_rank_value(document.getElementById('piloting_value').value);
	skill_cost['piloting']['cost'] = calculate_rank_cost(skill_cost['piloting']['value']);
	skill_cost['ranged_combat']['value'] = get_rank_value(document.getElementById('ranged_combat_value').value);
	skill_cost['ranged_combat']['cost'] = calculate_rank_cost(skill_cost['ranged_combat']['value']);
	skill_cost['science']['value'] = get_rank_value(document.getElementById('science_value').value);
	skill_cost['science']['cost'] = calculate_rank_cost(skill_cost['science']['value']);
	skill_cost['stealth']['value'] = get_rank_value(document.getElementById('stealth_value').value);
	skill_cost['stealth']['cost'] = calculate_rank_cost(skill_cost['stealth']['value']);
	skill_cost['survival']['value'] = get_rank_value(document.getElementById('survival_value').value);
	skill_cost['survival']['cost'] = calculate_rank_cost(skill_cost['survival']['value']);
	skill_cost['warfare']['value'] = get_rank_value(document.getElementById('warfare_value').value);
	skill_cost['warfare']['cost'] = calculate_rank_cost(skill_cost['warfare']['value']);

	skill_cost['total']['cost'] += skill_cost['athletics']['cost'];
	skill_cost['total']['cost'] += skill_cost['computing']['cost'];
	skill_cost['total']['cost'] += skill_cost['culture']['cost'];
	skill_cost['total']['cost'] += skill_cost['deception']['cost'];
	skill_cost['total']['cost'] += skill_cost['diplomacy']['cost'];
	skill_cost['total']['cost'] += skill_cost['engineering']['cost'];
	skill_cost['total']['cost'] += skill_cost['finesse']['cost'];
	skill_cost['total']['cost'] += skill_cost['gambling']['cost'];
	skill_cost['total']['cost'] += skill_cost['hand-to-hand_combat']['cost'];
	skill_cost['total']['cost'] += skill_cost['investigation']['cost'];
	skill_cost['total']['cost'] += skill_cost['manipulation']['cost'];
	skill_cost['total']['cost'] += skill_cost['medicine']['cost'];
	skill_cost['total']['cost'] += skill_cost['mental_combat']['cost'];
	skill_cost['total']['cost'] += skill_cost['occult']['cost'];
	skill_cost['total']['cost'] += skill_cost['performance']['cost'];
	skill_cost['total']['cost'] += skill_cost['piloting']['cost'];
	skill_cost['total']['cost'] += skill_cost['ranged_combat']['cost'];
	skill_cost['total']['cost'] += skill_cost['science']['cost'];
	skill_cost['total']['cost'] += skill_cost['stealth']['cost'];
	skill_cost['total']['cost'] += skill_cost['survival']['cost'];
	skill_cost['total']['cost'] += skill_cost['warfare']['cost'];

	document.getElementById("sidebar_skill_cost_output_4_0_EN").innerHTML = format_skill_cost_output(skill_cost,is_archaic);
}

function initialize_skill_cost_output(is_archaic)
{
	var formatted_skill_cost_output;
	var rank_value_default;
	var rank_cost_default;
	var total_cost_default;

	rank_value_default = 0;
	rank_cost_default = 0;
	total_cost_default = 0;

	formatted_skill_cost_output = "<div class=\"sidebar_title\">Skill Costs</div>\n";
	formatted_skill_cost_output += '<div class="sidebar_subtitle">';
	formatted_skill_cost_output += 'Enter your desired skill levels to see the total cost.';
	formatted_skill_cost_output += '<table cellpadding="2" style="margin:auto 0;">';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<th align="left">Skill</th>';
	formatted_skill_cost_output += '<th align="center" style="padding-left: 15px; padding-right: 15px;">Level</th>';
	formatted_skill_cost_output += '<th align="right">Cost</th>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Athletics</td>';
	formatted_skill_cost_output += '<td align="center"><input id="athletics_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="athletics_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';

	if (!is_archaic)
	{
		formatted_skill_cost_output += '<tr>';
		formatted_skill_cost_output += '<td align="left">Computing</td>';
		formatted_skill_cost_output += '<td align="center"><input id="computing_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
		formatted_skill_cost_output += '<td align="right"><span id="computing_cost">' + rank_cost_default + '</span></td>';
		formatted_skill_cost_output += '</tr>';
	}

	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Culture</td>';
	formatted_skill_cost_output += '<td align="center"><input id="culture_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="culture_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Deception</td>';
	formatted_skill_cost_output += '<td align="center"><input id="deception_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="deception_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Diplomacy</td>';
	formatted_skill_cost_output += '<td align="center"><input id="diplomacy_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="diplomacy_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Engineering</td>';
	formatted_skill_cost_output += '<td align="center"><input id="engineering_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="engineering_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Finesse</td>';
	formatted_skill_cost_output += '<td align="center"><input id="finesse_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="finesse_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Gambling</td>';
	formatted_skill_cost_output += '<td align="center"><input id="gambling_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="gambling_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Hand-to-hand Combat</td>';
	formatted_skill_cost_output += '<td align="center"><input id="hand-to-hand_combat_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="hand-to-hand_combat_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Investigation</td>';
	formatted_skill_cost_output += '<td align="center"><input id="investigation_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="investigation_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Manipulation</td>';
	formatted_skill_cost_output += '<td align="center"><input id="manipulation_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="manipulation_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Medicine</td>';
	formatted_skill_cost_output += '<td align="center"><input id="medicine_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="medicine_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Mental Combat</td>';
	formatted_skill_cost_output += '<td align="center"><input id="mental_combat_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="mental_combat_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Occult</td>';
	formatted_skill_cost_output += '<td align="center"><input id="occult_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="occult_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Performance</td>';
	formatted_skill_cost_output += '<td align="center"><input id="performance_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="performance_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Piloting</td>';
	formatted_skill_cost_output += '<td align="center"><input id="piloting_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="piloting_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Ranged Combat</td>';
	formatted_skill_cost_output += '<td align="center"><input id="ranged_combat_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="ranged_combat_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Science</td>';
	formatted_skill_cost_output += '<td align="center"><input id="science_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="science_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Stealth</td>';
	formatted_skill_cost_output += '<td align="center"><input id="stealth_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="stealth_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Survival</td>';
	formatted_skill_cost_output += '<td align="center"><input id="survival_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="survival_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<td align="left">Warfare</td>';
	formatted_skill_cost_output += '<td align="center"><input id="warfare_value" type="text" size="2" style="text-align: right;" value="' + rank_value_default + '" onblur="set_skill_cost_output(' + is_archaic + ')"></td>';
	formatted_skill_cost_output += '<td align="right"><span id="warfare_cost">' + rank_cost_default + '</span></td>';
	formatted_skill_cost_output += '</tr>';
	formatted_skill_cost_output += '<tr>';
	formatted_skill_cost_output += '<th align="left">Total</th>';
	formatted_skill_cost_output += '<th align="center"></th>';
	formatted_skill_cost_output += '<th align="right"><span id="total_cost">'+ total_cost_default +'</span></th>';
	formatted_skill_cost_output += '</tr>';

	if (is_archaic)
	{
		formatted_skill_cost_output += '<tr>';
		formatted_skill_cost_output += '<td></td>';
		formatted_skill_cost_output += '<td><input id="computing_value" type="hidden" value="' + rank_value_default + '"></td>';
		formatted_skill_cost_output += '<td><input id="computing_cost" type="hidden" value="' + rank_cost_default + '"></td>';;
		formatted_skill_cost_output += '</tr>';
	}

	formatted_skill_cost_output += '</table>';
	formatted_skill_cost_output += '</div>';
	
	sidebar_skill_cost_output_4_0_EN.innerHTML = formatted_skill_cost_output;
}

//
// Inserts the HTML into the page
//

$(function () {
	var page_title = document.title;
	var is_archaic = page_title.includes("Rough Magic") || page_title.includes("Warlords Of Kruhl");

	var sidebar_attribute_cost_output_div = document.getElementById('sidebar_attribute_cost_output_4_0_EN');
	var sidebar_skill_cost_output_div = document.getElementById('sidebar_skill_cost_output_4_0_EN');

	if (sidebar_attribute_cost_output_div != null)
	{
		initialize_attribute_cost_output();
	}

	if (sidebar_skill_cost_output_div != null)
	{
		initialize_skill_cost_output(is_archaic);
	}
}());