
var datafaxwin;
var showPointsCost = true;
window.onscroll = refreshPointsBox;

function init()
{
  data = document.designform;
  refreshPoints();
}

function applyGargantuan()
{
  if(data.gargantuan.checked)
  {
    if(data.mass.selectedIndex == 0)
    {
       window.alert("Gargantuan creatures must be given at least one mass point.");
       data.mass.selectedIndex = 1;
    }

    //DCC 16/9/08 - logic was wrong here, max T is determined by Mass, not Mass by T
    switch(data.mass.selectedIndex)
    {
	case 0: //m0
    case 1: //m1
		if(data.toughness.selectedIndex > 2)
		{
		   window.alert("Maximum toughness of 7 for 1 mass point.");
		   data.toughness.selectedIndex = 2;
		   return applyGargantuan();
		}
		break;


	case 2: //m2
	case 3: //m3
		if(data.toughness.selectedIndex > 3)
		{
		   window.alert("Maximum toughness of 8 for 2-3 mass points.");
		   data.toughness.selectedIndex = 3;
		   return applyGargantuan();
		}
		break;
	case 4: //m4
    case 5: //m5
    case 6: //m6
		if(data.toughness.selectedIndex > 4)
		{
		   window.alert("Maximum toughness of 9 for 4-6 mass points.");
		   data.toughness.selectedIndex = 4;
		   return applyGargantuan();
		}
		break;
    }
    
    if(!data.terror.checked)
    {
      window.alert("Gargantuan creatures must take 'The Terror' hive mind power.");
      data.terror.checked = true;
    }
  }
  else
  {
     if(data.mass.selectedIndex != 0) window.alert("Only gargantuan creatures may have mass points.");
     data.mass.selectedIndex = 0;

     if(data.toughness.selectedIndex > 2)
     {
		   window.alert("Maximum toughness of 7 if not gargantuan.");
		   data.toughness.selectedIndex = 2;
		   return applyGargantuan();
     }
  }

  applyWeapon1();
  applyWeapon2();
  applyWeapon3();
  applyWeapon4();
  applyTransport();
}




function applyTransport()
{
   if( isNaN(parseInt(data.transport.value)) )
   {
      window.alert("A numeric value must be entered in the transport field.");
      data.transport.value = "0";
   }
   else
   {
      capacity = (data.mass.selectedIndex * 5) + 11;
      if(parseInt(data.transport.value) > capacity)
      {
          window.alert("The transport capacity for this creature is " + capacity);
          data.transport.value = capacity;
      }
      else if(parseInt(data.transport.value) < 0)
      {
         data.transport.value = 0;
      }
   }
   refreshPoints();
}



function applyWeapon1(arg)
{
   
   status = 0;

   if(data.gargantuan.checked) status += GARGANTUAN;
     else status += NORMAL;
   if(data.wpn1cluster.checked) status += CLUSTER;
   if(data.wpn1ranged.checked) status += RANGED;
   if(data.wpn1spasm.checked) status += SPASM;
   if(data.wpn1massive.checked) status += MASSIVE;
   if(data.wpn1.selectedIndex == SHARED_WEAPON) status += WPN1_SHARED;
   if(data.wpn2.selectedIndex == SHARED_WEAPON) status += WPN2_SHARED;

   if((data.wpn1.selectedIndex <= ACID_SPRAY) || (data.wpn1.selectedIndex >= SPORE_MINES_1))
   {  status += NO_UPGRADE; }



   if( check(NO_UPGRADE) && checkAny(UPGRADES) )
   {
      window.alert("Upgrades are not allowed for this weapon.");
      wipeCheckboxes("wpn1");
      return applyWeapon1();
   }


   if( check(NORMAL) && checkAny(CLUSTER+SPASM) )
   {
      window.alert("The Cluster and Spasm upgrades may only be taken by gargantuan creatures.");
      data.wpn1cluster.checked = false;
      data.wpn1spasm.checked = false;
      return applyWeapon1();
   }


   if( !checkCCWeapons() )
   {
       data.wpn1.selectedIndex = LASH_WHIP;
   }


   if( ( check(LARGE_GARG_WPN)  || check(LARGE_WPN) ) )
   {
      if( !check(WPN2_SHARED) )
      {  
         window.alert("This weapon takes up both weapon slots.");
         data.wpn2.selectedIndex = SHARED_WEAPON;
         wipeCheckboxes("wpn2");
      }
   }
   else
   {
      if( check(WPN2_SHARED) )
      {
         window.alert("The shared weapon option is only available for large weapons.");
         data.wpn2.selectedIndex = VENOM_CANNON;
         return applyWeapon1();
      }
   }
}




function applyWeapon2()
{
   
   status = 0;

   if(data.gargantuan.checked) status += GARGANTUAN;
     else status += NORMAL;
   if(data.wpn2cluster.checked) status += CLUSTER;
   if(data.wpn2ranged.checked) status += RANGED;
   if(data.wpn2spasm.checked) status += SPASM;
   if(data.wpn2massive.checked) status += MASSIVE;
   if(data.wpn1.selectedIndex == SHARED_WEAPON) status += WPN1_SHARED;
   if(data.wpn2.selectedIndex == SHARED_WEAPON) status += WPN2_SHARED;

   if((data.wpn2.selectedIndex <= ACID_SPRAY) || (data.wpn2.selectedIndex >= SPORE_MINES_1))
   {  status += NO_UPGRADE; }



   if( check(NO_UPGRADE) && checkAny(UPGRADES) )
   {
      window.alert("Upgrades are not allowed for this weapon.");
      wipeCheckboxes("wpn2");
      return applyWeapon2();
   }


   if( check(NORMAL) && checkAny(CLUSTER+SPASM) )
   {
      window.alert("The Cluster and Spasm upgrades may only be taken by gargantuan creatures.");
      data.wpn2cluster.checked = false;
      data.wpn2spasm.checked = false;
      return applyWeapon2();
   }


   if( !checkCCWeapons() )
   {
       data.wpn2.selectedIndex = LASH_WHIP;
   }


   if( ( check(LARGE_GARG_WPN)  || check(LARGE_WPN) ) )
   {
      if( !check(WPN1_SHARED) )
      {  
         window.alert("This weapon takes up both weapon slots.");
         data.wpn1.selectedIndex = SHARED_WEAPON;
         wipeCheckboxes("wpn1");
      }
   }
   else
   {
      if( check(WPN1_SHARED) )
      {
         window.alert("The shared weapon option is only available for large weapons.");
         data.wpn1.selectedIndex = VENOM_CANNON;
         return applyWeapon2();
      }
   }
}




function applyWeapon3()
{
   
   status = 0;

   if(data.gargantuan.checked) status += GARGANTUAN;
     else status += NORMAL;
   if(data.wpn3cluster.checked) status += CLUSTER;
   if(data.wpn3ranged.checked) status += RANGED;
   if(data.wpn3spasm.checked) status += SPASM;
   if(data.wpn3massive.checked) status += MASSIVE;
   if(data.wpn3.selectedIndex == SHARED_WEAPON) status += WPN1_SHARED;
   if(data.wpn4.selectedIndex == SHARED_WEAPON) status += WPN2_SHARED;

   if((data.wpn3.selectedIndex <= ACID_SPRAY) || (data.wpn3.selectedIndex >= SPORE_MINES_1))
   {  status += NO_UPGRADE; }


   if( check(NORMAL) && (data.wpn3.selectedIndex != NONE) ) 
   {
      window.alert("Non-gargantuan creatures may not have more than two weapons.");
      data.wpn3.selectedIndex = NONE;
      return applyWeapon3();
   }


   if( check(NO_UPGRADE) && checkAny(UPGRADES) )
   {
      window.alert("Upgrades are not allowed for this weapon.");
      wipeCheckboxes("wpn3");
      return applyWeapon3();
   }


   if( check(NORMAL) && checkAny(CLUSTER+SPASM) )
   {
      window.alert("The Cluster and Spasm upgrades may only be taken by gargantuan creatures.");
      data.wpn3cluster.checked = false;
      data.wpn3spasm.checked = false;
      return applyWeapon3();
   }


   if( !checkCCWeapons() )
   {
       data.wpn3.selectedIndex = LASH_WHIP;
   }


   if( ( check(LARGE_GARG_WPN)  || check(LARGE_WPN) ) )
   {
      if( !check(WPN2_SHARED) )
      {  
         window.alert("This weapon takes up both weapon slots.");
         data.wpn4.selectedIndex = SHARED_WEAPON;
         wipeCheckboxes("wpn4");
      }
   }
   else
   {
      if( check(WPN2_SHARED) )
      {
         window.alert("The shared weapon option is only available for large weapons.");
         data.wpn4.selectedIndex = VENOM_CANNON;
         return applyWeapon3();
      }
   }
}




function applyWeapon4()
{
   
   status = 0;

   if(data.gargantuan.checked) status += GARGANTUAN;
     else status += NORMAL;
   if(data.wpn4cluster.checked) status += CLUSTER;
   if(data.wpn4ranged.checked) status += RANGED;
   if(data.wpn4spasm.checked) status += SPASM;
   if(data.wpn4massive.checked) status += MASSIVE;
   if(data.wpn4.selectedIndex == SHARED_WEAPON) status += WPN1_SHARED;
   if(data.wpn3.selectedIndex == SHARED_WEAPON) status += WPN2_SHARED;

   if((data.wpn4.selectedIndex <= ACID_SPRAY) || (data.wpn4.selectedIndex >= SPORE_MINES_1) )
   {  status += NO_UPGRADE; }

   if( check(NORMAL) && (data.wpn4.selectedIndex != NONE) ) 
   {
      window.alert("Non-gargantuan creatures may not have more than two weapons.");
      data.wpn4.selectedIndex = NONE;
      return applyWeapon4();
   }

   if( check(NO_UPGRADE) && checkAny(UPGRADES) )
   {
      window.alert("Upgrades are not allowed for this weapon.");
      wipeCheckboxes("wpn4");
      return applyWeapon4();
   }


   if( check(NORMAL) && checkAny(CLUSTER+SPASM) )
   {
      window.alert("The Cluster and Spasm upgrades may only be taken by gargantuan creatures.");
      data.wpn4cluster.checked = false;
      data.wpn4spasm.checked = false;
      return applyWeapon1();
   }


   if( !checkCCWeapons() )
   {
       data.wpn4.selectedIndex = LASH_WHIP;
   }


   if( ( check(LARGE_GARG_WPN)  || check(LARGE_WPN) ) )
   {
      if( !check(WPN2_SHARED) )
      {  
         window.alert("This weapon takes up both weapon slots.");
         data.wpn3.selectedIndex = SHARED_WEAPON;
         wipeCheckboxes("wpn3");
      }
   }
   else
   {
      if( check(WPN2_SHARED) )
      {
         window.alert("The shared weapon option is only available for large weapons.");
         data.wpn3.selectedIndex = VENOM_CANNON;
         return applyWeapon4();
      }
   }
}




function check(code)
{
   if( (status & code) ^ code ) return false;
     else return true;
}



function checkAny(code)
{
   if(status & code) return true;
      else return false;
}


function wipeCheckboxes(wpn)
{
   eval("data." + wpn + "cluster.checked = false;");
   eval("data." + wpn + "ranged.checked = false;");
   eval("data." + wpn + "spasm.checked = false;");
   eval("data." + wpn + "massive.checked = false;");
}



function checkCCWeapons()
{
   var c = 0
   if(data.wpn1.selectedIndex == SCYTHING_TALONS) c++;
   if(data.wpn2.selectedIndex == SCYTHING_TALONS) c++;
   if(data.wpn3.selectedIndex == SCYTHING_TALONS) c++;
   if(data.wpn4.selectedIndex == SCYTHING_TALONS) c++;
   if(c > 2)
   { 
      window.alert("You may not select Scything Talons more than twice.");
      return false;
   }

   c = 0;
   if(data.wpn1.selectedIndex == RENDING_CLAWS) c++;
   if(data.wpn2.selectedIndex == RENDING_CLAWS) c++;
   if(data.wpn3.selectedIndex == RENDING_CLAWS) c++;
   if(data.wpn4.selectedIndex == RENDING_CLAWS) c++;
   if(c > 1)
   { 
      window.alert("You may not select Rending Claws more than once.");
      return false;
   }

   c = 0;
   if(data.wpn1.selectedIndex == RAZOR_CLAWS) c++;
   if(data.wpn2.selectedIndex == RAZOR_CLAWS) c++;
   if(data.wpn3.selectedIndex == RAZOR_CLAWS) c++;
   if(data.wpn4.selectedIndex == RAZOR_CLAWS) c++;
   if( (c > 0) && !data.gargantuan.checked )
   {
      window.alert("Only gargantuan creatures may select Razor Claws.");
      return false;
   }
   if(c > 1)
   { 
      window.alert("You may not select Razor Claws more than once.");
      return false;
   }

   return true;

}




function calculate(arg)
{

var cost = 0;

cost += data.mass.selectedIndex * 50;
cost += (data.wounds.selectedIndex + 3) * 10;
cost *= (1 + BASE_COSTS[data.save.selectedIndex][data.toughness.selectedIndex] + MOVEMENT_COSTS[data.movement.selectedIndex])

if(data.terror.checked) cost += 5;
if(data.warpblast.checked)   cost += (data.gargantuan.checked) ? 75 : 30 ;
if(data.synapse.checked)   cost += (data.gargantuan.checked) ? 15 : 10 ;
if(data.catalyst.checked)   cost += (data.gargantuan.checked) ? 15 : 10 ;
if(data.warpshield.checked)   cost += (data.gargantuan.checked) ? 30 : 20 ;

var attacks = data.attacks.selectedIndex + 1;
var cc_attacks = data.attacks.selectedIndex + 1;
var claws_mplr = 1;
var cc_mplr = 1 + INIT_MODIFIERS[data.initiative.selectedIndex] + (data.ws.selectedIndex * 0.50);
if(data.ws.selectedIndex == 0) cc_mplr += 0.25;
var wpncost = 0;
var wpnmplr = 1;



wpnmplr = 1;
switch(data.wpn1.selectedIndex)
{
  case SCYTHING_TALONS:
	cc_attacks++;
	break;
  case RENDING_CLAWS:
	claws_mplr = 1.5;
	break;
  case RAZOR_CLAWS:
	claws_mplr = 3;
	break;
  case FLESHBORER:
  case DEVOURER:
  case SPINEFIST:
  case VENOM_CANNON:
	wpnmplr += (data.attacks.selectedIndex * 0.5);
  case DEATHSPITTER:
  case BARBED_STRANGLER:
	wpnmplr += (data.bs.selectedIndex * 0.25);
	if(data.wpn1cluster.checked) wpnmplr += 0.5;
        if(data.wpn1ranged.checked) wpnmplr += 0.5;
        if(data.wpn1spasm.checked) wpnmplr += 1.0;
        if(data.wpn1massive.checked) wpnmplr += 1.0;
	break;
}

wpncost = WEAPON_COSTS[data.wpn1.selectedIndex][data.strength.selectedIndex];
wpncost *= wpnmplr;
cost += wpncost;



wpnmplr = 1;
switch(data.wpn2.selectedIndex)
{
  case SCYTHING_TALONS:
	cc_attacks++;
	break;
  case RENDING_CLAWS:
	claws_mplr = 1.5;
	break;
  case RAZOR_CLAWS:
	claws_mplr = 3;
	break;
  case FLESHBORER:
  case DEVOURER:
  case SPINEFIST:
  case VENOM_CANNON:
	wpnmplr += (data.attacks.selectedIndex * 0.5);
  case DEATHSPITTER:
  case BARBED_STRANGLER:
	wpnmplr += (data.bs.selectedIndex * 0.25);
	if(data.wpn2cluster.checked) wpnmplr += 0.5;
        if(data.wpn2ranged.checked) wpnmplr += 0.5;
        if(data.wpn2spasm.checked) wpnmplr += 1.0;
        if(data.wpn2massive.checked) wpnmplr += 1.0;
	break;
}

wpncost = WEAPON_COSTS[data.wpn2.selectedIndex][data.strength.selectedIndex];
wpncost *= wpnmplr;
cost += wpncost;


wpnmplr = 1;
switch(data.wpn3.selectedIndex)
{
  case SCYTHING_TALONS:
	cc_attacks++;
	break;
  case RENDING_CLAWS:
	claws_mplr = 1.5;
	break;
  case RAZOR_CLAWS:
	claws_mplr = 3;
	break;
  case FLESHBORER:
  case DEVOURER:
  case SPINEFIST:
  case VENOM_CANNON:
	wpnmplr += (data.attacks.selectedIndex * 0.5);
  case DEATHSPITTER:
  case BARBED_STRANGLER:
	wpnmplr += (data.bs.selectedIndex * 0.25);
	if(data.wpn3cluster.checked) wpnmplr += 0.5;
        if(data.wpn3ranged.checked) wpnmplr += 0.5;
        if(data.wpn3spasm.checked) wpnmplr += 1.0;
        if(data.wpn3massive.checked) wpnmplr += 1.0;
	break;
}

wpncost = WEAPON_COSTS[data.wpn3.selectedIndex][data.strength.selectedIndex];
wpncost *= wpnmplr;
cost += wpncost;



wpnmplr = 1;
switch(data.wpn4.selectedIndex)
{
  case SCYTHING_TALONS:
	cc_attacks++;
	break;
  case RENDING_CLAWS:
	claws_mplr = 1.5;
	break;
  case RAZOR_CLAWS:
	claws_mplr = 3;
	break;
  case FLESHBORER:
  case DEVOURER:
  case SPINEFIST:
  case VENOM_CANNON:
	wpnmplr += (data.attacks.selectedIndex * 0.5);
  case DEATHSPITTER:
  case BARBED_STRANGLER:
	wpnmplr += (data.bs.selectedIndex * 0.25);
	if(data.wpn4cluster.checked) wpnmplr += 0.5;
        if(data.wpn4ranged.checked) wpnmplr += 0.5;
        if(data.wpn4spasm.checked) wpnmplr += 1.0;
        if(data.wpn4massive.checked) wpnmplr += 1.0;
	break;
}

wpncost = WEAPON_COSTS[data.wpn4.selectedIndex][data.strength.selectedIndex];
wpncost *= wpnmplr;
cost += wpncost;


cost += (cc_attacks * (data.strength.selectedIndex + 5) * claws_mplr * cc_mplr);


if(data.amphibious.checked) cost += 10;
if(data.wrecker.checked) cost += 25;
if(data.implant.checked) cost += data.strength.selectedIndex + 5;
if(data.claws.checked) cost += cc_attacks;
cost += parseInt(data.transport.value) * 5;

if(data.bioplasma.checked)
{
   if(data.gargantuan.checked)
   {
      cost += ( (data.strength.selectedIndex+5) * 4 * data.mass.selectedIndex );
   }
   else cost += (data.strength.selectedIndex+5) * 2;
}

if(data.tunneller.checked) cost *= 1.25;

cost = Math.ceil(cost);

var temp = "";

if(data.terror.checked) temp += "Terror<br />";
if(data.warpblast.checked) temp += "Warp Blast<br />";
if(data.synapse.checked)  temp += "Synapse<br />";
if(data.catalyst.checked)  temp += "Catalyst<br />";
if(data.warpshield.checked)  temp += "Warp Shield<br />";

if(temp != "")
{
    temp = temp.substring(0, temp.length-6);
}
var powers = temp;

var myWpns = "";

if(data.wpn1.selectedIndex < SHARED_WEAPON)
{
   temp = "";
   if(data.wpn1massive.checked) temp += "Massive ";
   if(data.wpn1ranged.checked)  temp += "Ranged ";
   if(data.wpn1cluster.checked) temp += "Cluster ";
   if(data.wpn1spasm.checked)   temp += "Spasm ";
   temp += data.wpn1.options[data.wpn1.selectedIndex].text;
   myWpns += temp + "<br />";
}

if(data.wpn2.selectedIndex < SHARED_WEAPON)
{
   temp = "";
   if(data.wpn2massive.checked) temp += "Massive ";
   if(data.wpn2ranged.checked) temp += "Ranged ";
   if(data.wpn2cluster.checked) temp += "Cluster ";
   if(data.wpn2spasm.checked) temp += "Spasm ";
   temp += data.wpn2.options[data.wpn2.selectedIndex].text;
   myWpns += temp + "<br />";
}

if(data.wpn3.selectedIndex < SHARED_WEAPON)
{
   temp = "";
   if(data.wpn3massive.checked) temp += "Massive ";
   if(data.wpn3ranged.checked) temp += "Ranged ";
   if(data.wpn3cluster.checked) temp += "Cluster ";
   if(data.wpn3spasm.checked) temp += "Spasm ";
   temp += data.wpn3.options[data.wpn3.selectedIndex].text;
   myWpns += temp + "<br />";
}

if(data.wpn4.selectedIndex < SHARED_WEAPON)
{
   temp = "";
   if(data.wpn4massive.checked) temp += "Massive ";
   if(data.wpn4ranged.checked) temp += "Ranged ";
   if(data.wpn4cluster.checked) temp += "Cluster ";
   if(data.wpn4spasm.checked) temp += "Spasm ";
   temp += data.wpn4.options[data.wpn4.selectedIndex].text;
   myWpns += temp + "<br />";
}

if(myWpns != "") myWpns = myWpns.substring(0, myWpns.length-6);

var myOpts = "";
if(data.amphibious.checked) {myOpts +="Amphibious<br />";}
if(data.wrecker.checked)    {myOpts +="Wrecker<br />";}
if(data.implant.checked)    {myOpts +="Implant attack<br />";}
if(data.claws.checked)      {myOpts +="Claws & hooks<br />";}
if(data.tunneller.checked)  {myOpts +="Tunneller<br />";}
if(data.bioplasma.checked)  {myOpts +="Bio-plasma<br />";}

if(data.transport.value != "0")
{
   myOpts  += "Transport " + data.transport.value + "<br />";
}

if(myOpts != "") myOpts = myOpts.substring(0, myOpts.length-6);

if(!arg)
{
  datafaxwin = window.open('datafax.html', "datafaxwin","width=675,height=350,left=50,top=15,location=no,directories=no,toolbar=yes,status=no,menubar=yes,scrollbars=yes");
}

save = document.saveForm;
if(data.cname.value != '')  save.name.value = data.cname.value;
  else save.name.value = '-';
save.points.value = cost;
save.movetype.value = data.movement.options[data.movement.selectedIndex].text;
save.ws.value = data.ws.selectedIndex + 4;
save.bs.value = data.bs.selectedIndex + 2;
save.s.value = data.strength.selectedIndex + 5;
save.t.value = data.toughness.selectedIndex + 5;
save.i.value = data.initiative.selectedIndex + 2;
save.w.value = data.wounds.selectedIndex + 3;
save.a.value = (attacks == cc_attacks) ? attacks : attacks + "(" + cc_attacks + ")" ;
save.save.value = (4 - data.save.selectedIndex) + "+";
save.mass.value = data.mass.selectedIndex;
save.weapons.value = myWpns;
save.options.value = myOpts;
save.powers.value = powers;

return true;

}


function togglePoints()
{
    if(showPointsCost)
    {
    	showPointsCost = false;
    	document.getElementById('pointsbox').style.display = 'none';
    	document.forms['designform'].showpointsbtn.value = 'Show Points Cost';
    	document.getElementById('showpointsbtn2').value = 'Show Points Cost';
    }
    else
    {
    	showPointsCost = true;
    	showPoints();
    	document.forms['designform'].showpointsbtn.value = 'Hide Points Cost';
    	document.getElementById('showpointsbtn2').value = 'Hide Points Cost';
    }
}


function showPoints()
{
    if(calculate('nodisplay'))
    {
       document.getElementById('pointsbox').style.top = document.documentElement.scrollTop+250;
       document.getElementById('pointsbox').innerHTML = save.points.value;
       document.getElementById('pointsbox').style.display = 'block';
    }
    else
    {
       document.getElementById('pointsbox').style.display = 'none';
       showPointsCost = false;
    }
}

function refreshPoints()
{
   if(showPointsCost) showPoints()
}

function refreshPointsBox()
{	
   document.getElementById('pointsbox').style.top = document.documentElement.scrollTop+250;
}


function dfCallback()
{
   save = document.forms['saveForm'];
   with(datafaxwin.document)
   {
      title =  save.name.value;
      getElementById('name').innerHTML = save.name.value;
      getElementById('points').innerHTML = save.points.value;
      getElementById('movetype').innerHTML = save.movetype.value;
      if(save.mass.value == 0)
      {
         getElementById('size').innerHTML = 'Normal';
         getElementById('mass').innerHTML =  '-';
      }
      else
      {
      	 getElementById('size').innerHTML = 'Gargantuan';
         getElementById('mass').innerHTML =  save.mass.value;
      }
      getElementById('ws').innerHTML = save.ws.value;
      getElementById('bs').innerHTML = save.bs.value;
      getElementById('s').innerHTML = save.s.value;
      getElementById('t').innerHTML = save.t.value;
      getElementById('w').innerHTML = save.w.value;
      getElementById('i').innerHTML = save.i.value;
      getElementById('a').innerHTML = save.a.value;
      getElementById('save').innerHTML = save.save.value;
      getElementById('powers').innerHTML = save.powers.value;
      getElementById('weapons').innerHTML = save.weapons.value;
      getElementById('options').innerHTML = save.options.value;
   }
}







function doSubmit()
{
   if(data.cname.value == "")
   {
     window.alert("You must enter the creature name before submitting");
     return false;
   }
   if(calculate('nodisplay')) return true;
     else return false;
}

