//BEGIN**********************************************************************
function CalculateCharacter(iCharid){
	sFile = "ca_calc.php?var1="+iCharid;
	var winCalc = null;
	winCalc = window.open(sFile,'CalculateCharacter',
		'width=250,height=500,top=5,left=5,location=no, menubar=no, status=yes, toolbar=no, scrollbars=yes, resizable=yes');
	winCalc.focus();
	window.blur();
}//CalculateLifeSigns


//BEGIN**********************************************************************
function CalculateLifeSigns(iCharid){
	sFile = "ca_lifesigns.php?var1="+iCharid;
	var winCalc = null;
	winCalc = window.open(sFile,'LifesignsCharacter',
		'width=500,height=500,top=5,left=5,location=no, menubar=no, status=yes, toolbar=no, scrollbars=yes, resizable=yes');
	winCalc.focus();
	window.blur();
}


//BEGIN**********************************************************************
function CreateCharacterSheet(iCharid,bPlace){
  //bPlace == 0 we are in the create directory. 1 == we are in browse
	if (bPlace == 0){sFile = "../2create_character/ca_sheet.php?var1="+iCharid;}
	if (bPlace == 1){sFile = "../2create_character/ca_sheet.php?var1="+iCharid;}
	var winCalc = null;
	winCalc = window.open(sFile,'LifesignsCharacter',
		'width=600,height=375,top=5,left=5,location=no, menubar=no, status=yes, toolbar=no, scrollbars=yes, resizable=yes');
	winCalc.focus();
}


//SKILL BONUS COST
//*********************************************************************
//find the cost of a skill bonus score
//dropping the iStep divisor increases costs
//parallels with charactercodes.php - function char_SkillBonusCost
//*********************************************************************
function char_SkillBonusCost(sNewBonus,sCost,perfectioncurve){
//bring back to hires
sNewBonus = sNewBonus *5;
if (perfectioncurve == 'a') sCost = 10;
if (perfectioncurve == 'b') sCost = 25;
if (perfectioncurve == 'c') sCost = 50;
if (perfectioncurve == 'd') sCost = 75;
if (perfectioncurve == 'e') sCost = 100;
if (perfectioncurve == 'f') sCost = 125;
if (perfectioncurve == 'g') sCost = 150;
if (perfectioncurve == 'h') sCost = 175;
if (perfectioncurve == 'i') sCost = 200;
if ((!isNaN(sNewBonus)) && (!isNaN(sCost))){
  sNewBonus = parseInt(sNewBonus);
  sCost = parseInt(sCost);
	var iStep = (sNewBonus+sCost)/15;
	var iTotal = Math.round((sNewBonus *iStep));
  return iTotal;
	}
 else{
  return 0;
  }
}
//END



//BEGIN**********************************************************************
function char_TalentScaleCost(iScore, iScale){
return iScore * iScale;
}

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
function super_SuperSizeIt(iScore,iSize,iRound){
iScore = (iScore * iSize);

//always round off to two decimal points
iScore = Math.round(iScore*100)/100;

//find a decimal point and round decimal point off  to the nearest 25
var sScore = iScore.toString();
if (sScore.indexOf(".",0) != 0){
	var s1 = sScore.split(".");
	var d1 = parseInt(s1[0]);
	var d2 = parseInt(s1[1]);
	if ((d2 >= 0)  && (d2 <= 5))  f2 = 00;
	if ((d2 >= 5)  && (d2 <= 15)) f2 = 10;
	if ((d2 >= 15) && (d2 <= 25)) f2 = 20;
	if ((d2 >= 25) && (d2 <= 35)) f2 = 30;
	if ((d2 >= 35) && (d2 <= 45)) f2 = 40;
	if ((d2 >= 45) && (d2 <= 55)) f2 = 50;
	if ((d2 >= 55) && (d2 <= 65)) f2 = 60;
	if ((d2 >= 65) && (d2 <= 75)) f2 = 70;
	if ((d2 >= 75) && (d2 <= 85)) f2 = 80;
	if ((d2 >= 85) && (d2 <= 95)) f2 = 90;
	if (d2 > 95) f1 = d1+1; else f1 = d1;
	var s2 = f1+"."+f2
	iScore = parseFloat(s2);
  //alert(iScore);
  }

//round it off if needed	
if (iRound != 0){
  iScore = Math.round(iScore);
	}
return iScore;
}

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
function super_Defense(iSize){
var i1 = 0;
if (iSize > 1.00){
  i1 = iSize - 1;
	i1 = Math.round(i1 * -8);
	}
 else{
  i1 = 1.00 - iSize;
	i1 = Math.round(i1 * 8);
  }
if (iSize == 1.00){
  i1 = 0;
	}
return i1;
}

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
function super_SuperSizeMidget(iScore,iSize,iRound){
if (iSize < 1.00) {iSize = 1.00;}
iScore = (iScore * iSize);
if (iRound != 0){
  iScore = Math.round(iScore);
	}
return iScore;
}
