<!-- Hide script from older browsers 
// setTimeout("changePage();", 3000);

// don't allow it to be framed
function changePage() {
	// NOTE: this function fails if the browser itself places content into frames.
	if (self.parent.frames.length > 1) self.parent.location=document.location;
}

// spellcalculator script
  
var lngSelectedSpell	= -1;
var lngInvokeType	= -1;
var lngDuration		= 0;
var lngBaseTime		= 0;
var lngTrainings    	= 0;
var lngTrainingTime	= 0;
var lngAddedTime	= 0;

var spellDuration = [
// minor spirit spells
[1200, 60],	// 101 Spirit Warding I
[1800, 60],	// 102 Spirit Barrier
[1800, 90],	// 103 Spirit Defense
[1200, 60],	// 104 Disease Resist
[1200, 60],	// 105 Poison Resist
[1200, 60],	// 107 Spirit Warding II
[1200, 60],	// 112 Water Walking
[1200, 60],	// 120 Lesser Shroud
[60, 0],	// 150 Wall of Force
// major spirit spells
[1200, 60],	// 202 Spirit Shield
[1200, 60],	// 204 Unpresence
[1200, 60],	// 207 Purify Air
[1200, 60],	// 211 Bravery
[1200, 60],	// 215 Heroism
[1200, 60],	// 219 Spell Shield
// cleric spells
[900, 20],	// 303 Prayer of Protection
[900, 20],	// 307 Benediction
[900, 20],	// 310 Sphere of Warding
[900, 20],	// 313 Prayer
[420, 5],	// 317 Zealot
// minor elemental spells
[1200, 60],	// 401 Elemental Defense I
[0, 2],		// 402 Presence
[30, 1],	// 403 Pick Enhancement
[30, 1],	// 404 Disarm Enhancement
[1200, 60],	// 406 Elemental Defense II
[1200, 60],	// 414 Elemental Defense III
[0, 60],	// 418 Mana Focus
[1200, 60],	// 419 Mass Elemental Defense
[900, 30],	// 425 Elemental Targeting
[900, 30],	// 430 Elemental Barrier
// major elemental spells
[1200, 60],	// 503 Personal Blurs
[600, 15],	// 507 Elemental Deflection
[600, 30],	// 508 Elemental Bias
[600, 30],	// 509 Strength
[600, 30],	// 513 Elemental Focus
[600, 30],	// 520 Stone Skin
// ranger spells
[600, 20],	// 601 Natural Colors
[1200, 60],	// 602 Resist Elements
[900, 30],	// 606 Phoen's Strength
[900, 30],	// 611 Mass Natural Colors
[1200, 60],	// 613 Self Control
[300, 20],	// 617 Sneaking
[900, 30],	// 618 Mobility
[300, 10],	// 625 Nature's Touch
// sorcerer spells
[1200, 60],	// 712 Cloak of Shadows
// wizard spells
[600, 15],	// 905 Elemental Refraction
[900, 30],	// 911 Mass Blurs
[1200, 60],	// 913 Melgorehn's Aura
[0, 10],	// 915 Weapon Fire
[1200, 30],	// 916 Invisibility
[60, 0],	// 919 Wizard Shield
// empath spells
[360, 20],	// 1106 Empathic Focus
[360, 10],	// 1109 Rage
[600, 10],	// 1119 Strength of Will
[600, 10]   // 1130 Intensity
];     

function fClearForm(form) {
	form.txtBTMinutes.value = "";
	form.txtATMinutes.value = "";
	form.txtBTSeconds.value = "";
	form.txtATSeconds.value = "";
	form.txtSCTBase.value = "";
	form.txtSCTAdded.value = "";
	form.txtPerCastTime.value = "";
	form.txtPerInvokeTime.value = "";
	return;
}

function fSpellSelected(form) {
	var strTemp = "Blah!";
	// var coll = document.all.tags("SELECT");
	
	fClearForm(form);
	lngSelectedSpell = parseInt(form.cmbSelectSpell.selectedIndex);
	// strTemp = coll(0).options[lngSelectedSpell].text;		// this works!
	// strTemp = form.cmbSelectSpell[lngSelectedSpell].value;	// NOT
	strTemp = document.SpellCalculator.cmbSelectSpell.options[lngSelectedSpell].text;
	form.txtSelectedSpell.value = strTemp;
	
	fUpdateSCTFields(form);
	Calculate(form);
	return;
}

function fUpdateSCTFields(form) {
	form.txtSCTBase.value = parseInt(spellDuration[lngSelectedSpell][0]);
	form.txtSCTAdded.value = parseInt(spellDuration[lngSelectedSpell][1]);
	return;
}

function frmtNum(tmpNumber) {
	var xNumber = tmpNumber;
	
	xNumber = xNumber * 1000;
	xNumber = Math.round(xNumber);
	xNumber = xNumber / 1000;
	
	return(xNumber);
}

function Calculate(form) {
	var strTemp = "Blah!";
	var lngDura = 0;
	// var coll = document.all.tags("SELECT");
	
	lngSelectedSpell = parseInt(form.cmbSelectSpell.selectedIndex);
	lngInvokeType = parseInt(form.cmbInvokeType.selectedIndex);
	lngTrainings = parseInt(form.txtTraining.value);
	lngBaseTime = parseInt(spellDuration[lngSelectedSpell][0]);
	lngAddedTime = parseInt(spellDuration[lngSelectedSpell][1]);
	
	fUpdateSCTFields(form);
	
	if (lngInvokeType == 0) {	// spell cast
		lngTrainingTime = lngAddedTime * lngTrainings;
		lngDuration = (lngBaseTime + lngTrainingTime)/60;
		lngDura = frmtNum(lngDuration);
		
		form.txtPerCastTime.value = lngDura;			// Total Time if known spell (minutes)
		form.txtPerInvokeTime.value = 0;			// Total Time (minutes) for magic items
		form.txtBTMinutes.value = frmtNum(lngBaseTime/60);	// Base Time (minutes)
		form.txtATMinutes.value = frmtNum(lngTrainingTime/60);	// Added Time (minutes)
		form.txtBTSeconds.value = lngBaseTime;			// Base Time (seconds)
		form.txtATSeconds.value = lngTrainingTime;		// Added Time (seconds)
		form.txtCastsForFour.value = parseInt(240/lngDuration);
		form.txtTimeForCastsForFour.value = form.txtCastsForFour.value * lngDura;
	}
	
	if (lngInvokeType == 1) {		// magic item or scroll
		lngAddedTime = lngAddedTime/2;
		lngTrainingTime = lngAddedTime*lngTrainings;
		lngDuration = (lngBaseTime + lngTrainingTime)/60;
		lngDura = frmtNum(lngDuration);
		
		form.txtPerCastTime.value = 0;			// Total Time if known spell (minutes)
		form.txtPerInvokeTime.value = lngDura;		// Total Time (minutes)
		form.txtBTSeconds.value = lngBaseTime;		// Base Time (seconds)
		form.txtATSeconds.value = lngTrainingTime;		// Added Time (seconds)
		form.txtBTMinutes.value = frmtNum(lngBaseTime/60);		// Base Time (minutes)
		form.txtATMinutes.value = frmtNum(lngTrainingTime/60);	// Added Time (minutes)
		form.txtCastsForFour.value = parseInt(240/lngDuration);
		form.txtTimeForCastsForFour.value = form.txtCastsForFour.value * lngDura;
	}
	
	if (lngInvokeType == 2) {				// edible or drink
		lngTrainingTime = 0;
		lngDuration = lngBaseTime/60;
		lngDura = frmtNum(lngDuration);
		
		form.txtPerCastTime.value = 0;			// Total Time if known spell (minutes)
		form.txtPerInvokeTime.value = lngDura;		// Total Time (minutes)
		form.txtBTMinutes.value = lngDura;			// Base Time (minutes)
		form.txtATMinutes.value = 0;			// Added Time (minutes)
		form.txtBTSeconds.value = lngBaseTime;		// Base Time (seconds)
		form.txtATSeconds.value = lngAddedTime;		// Added Time (seconds)
		form.txtCastsForFour.value = parseInt(240/lngDuration);
		form.txtTimeForCastsForFour.value = form.txtCastsForFour.value * lngDura;
	}
	// strTemp = coll(0).options(lngSelectedSpell).value;		// NOT
	// strTemp = coll(0).options.length;				// NOT
	// strTemp = coll(0).options[lngSelectedSpell].text;		// this works! but not on NetScape Systems
	// strTemp = form.cmbSelectSpell.text;				// NOT
	// strTemp = form.cmbSelectSpell[lngSelectedSpell].value;	// NOT
	strTemp = document.SpellCalculator.cmbSelectSpell.options[lngSelectedSpell].text;
	form.txtSelectedSpell.value = strTemp;
	
	return;
}
// end hiding contents -->
