/*  This is the Prerequisite Skill check Functions.

The only varable that is passed into any of these functions is either true or false.
These functions call the StatMath function.

 This is the section that checks to see if the skill has a Prerequisite

There are 3 types of checks, 1 to 1's, Or's, and And's.

1 to 1's
   One to one's have only one Prerequisite for the skill. 
   Example TestArchaeology.
   If the box is being checked, the function checkes to see if the Prerequisite is also checked.
   If it is checked, the function then runs the StatMath function to determine wether or not 
   the you have enought points to select the skill.
   If the Prerequisite skill is not selected, it pops up an error box stating which skill is 
   required.
   
   If the box is being unchecked, the function calls the StatMath function.

Or's
   Or's have several Prerequisite skills, of which any of them need to be selected. 
   Example TestBiochem.
   If the box is being checked, the function checkes to see if the first Prerequisite is 
   checked.  If it is not it incriments VarHold (set to 0 at the begening of the function) by 1.
   It then procedes to check the rest of the Prerequisite skill in the same way.  At the end of 
   the Prerequisite's is an if (VarHold==#).  The # is the total number of Prerequisite for that 
   skill. If all the Prerequisite are not checked then VarHold will equal the # of Prerequisite. 
   It will not allow the boxed to be checked and a pop up box appears with the Prerequisites 
   needed. 
   
   If the box is being unchecked, the function calls the StatMath function.
   
And's
   And's have serveral Prerequisite Skills that are all required to use this skill.
   The function checks to see if any of the skills are not checked.  If one is not, it kicks 
   out of the function with a pop up box that tells which Prerequisites are needed.
      
   If the box is being unchecked, the function calls the StatMath function.


WARNING!!!!  It has become necessary to include several function lines from primechk.js due to 
the fact that there are some skills that act as both a primary and as a dependant. Please check 
the comments of primechk.js for more info on these lines.

*/

// 1 to 1
function TestArchaeology(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.History.checked==false)
   	{
   		window.alert('Prerequisite - History - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,4);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,4);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


// Or
function TestBiochem(TFValue)
{
   VarHold=0
   if (TFValue==true)
   {
   	if (window.document.PSTPChars.Chemistry.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Biology.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.MilitaryScience.checked==false)
   	{
   		VarHold++;
   	}
   	if (VarHold==3)   	
   	{
   		window.alert('Prerequisite - Chemistry, Biology, or Military Science');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestCloudMind(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Mysticism.checked==false)
   	{
   		window.alert('Prerequisite - Mysticism - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}

function TestCompProg(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Mathematics.checked==false)
   	{
   		window.alert('Prerequisite - Mathematics - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,3);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,3);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestCryptography(TFValue)
{
   VarHold=0
   if (TFValue==true)
   {
   	if (window.document.PSTPChars.Espionage.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Linguistics.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Mathematics.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Edu2.value<15)
   	{
   		VarHold++;
   	}
   	if (VarHold==4)   	
   	{
   		window.alert('Prerequisite - Espionage, Linguistics, Mathematics, or EDU 15+');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestCryptozoology(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Biology.checked==false)
   	{
   		window.alert('Prerequisite - Biology - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestDrugChemist(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Streetwise.checked==false)
   	{
   		window.alert('Prerequisite - Streetwise - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestExoticWeapon(TFValue)
{
   VarHold=0
   if (TFValue==true)
   {
   	if (window.document.PSTPChars.Archery.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Handgun.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.LongGun.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.HeavyMilitaryWeapon.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.MilitaryWeapon.checked==false)
   	{
   		VarHold++;   		
   	}
   	if (window.document.PSTPChars.LargeMelee.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.SmallMeleeWeapon.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.ThrownWeapon.checked==false)
   	{
   		VarHold++;
   	}
   	if (VarHold>7)   	
   	{
   		window.alert('Prerequisite One of the Followling -\n Archery, Handgun, Long Gun, Military Weapon, Heavy Military Weapon,\n Large Melee Weapon, Small Melee Weapon, or Thrown Weapon');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}	

function TestFastDraw(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Dex2.value<10)
   	{
   		window.alert('Prerequisite - Dex 10+ - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestForensics(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Medicine.checked==false)
   	{
   		window.alert('Prerequisite - Medicine - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestForgery(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Dex2.value<12)
   	{
   		window.alert('Prerequisite - Dex 12+ or other - Required\n* See Skill decription for more info');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestHeavyMilitaryWeapon(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.MilitaryWeapon.checked==false)
   	{
   		window.alert('Prerequisite - Long Gun and Military Weapon - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,3);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
	if (window.document.PSTPChars.ExoticWeapon.checked==true)
	{
		TFValue2=ExoticChk();
		if (TFValue2==false)
		{
			TFValue1=StatMath(TFValue,1);
	   		window.document.PSTPChars.ExoticWeapon.checked=TFValue1;
	   	}
	}	
	TFValue1=StatMath(TFValue,3);
	return false;
   }
}


function TestHotWire(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Streetwise.checked==false)
   	{
   		window.alert('Prerequisite - Streetwise - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestMedicine(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Biology.checked==false)
   	{
   		window.alert('Prerequisite - First Aid and Biology - Required');
   		return false;
   	}
   	if (window.document.PSTPChars.FirstAid.checked==false)
   	{
   		window.alert('Prerequisite - First Aid and Biology - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,4);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
	if (window.document.PSTPChars.Forensics.checked==true)
	{
		TFValue1=StatMath(TFValue,2);
   		window.document.PSTPChars.Forensics.checked=TFValue1;
	}	
	if (window.document.PSTPChars.Surgery.checked==true)
	{
		TFValue1=StatMath(TFValue,2);
	   	window.document.PSTPChars.Surgery.checked=TFValue1;
	}	
	if (window.document.PSTPChars.WeirdScience.checked==true)
	{
		TFValue2=WeirdScienceChk();
		if (TFValue2==false)
		{
			TFValue1=StatMath(TFValue,3);
	   		window.document.PSTPChars.WeirdScience.checked=TFValue1;
	   	}
	}
	TFValue1=StatMath(TFValue,4);
	return false;
   }
}


function TestMilitaryWeapon(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.LongGun.checked==false)
   	{
   		window.alert('Prerequisite - Long Gun - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,3);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
	if (window.document.PSTPChars.ExoticWeapon.checked==true)
		{
			TFValue2=ExoticChk();
			if (TFValue2==false)
			{
				TFValue1=StatMath(TFValue,1);
		   		window.document.PSTPChars.ExoticWeapon.checked=TFValue1;
		   	}
		}
   	if (window.document.PSTPChars.HeavyMilitaryWeapon.checked==true)
	{
		TFValue1=StatMath(TFValue,3);
		window.document.PSTPChars.HeavyMilitaryWeapon.checked=TFValue1;
	}
   	TFValue1=StatMath(TFValue,3);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestMysticism(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Occult.checked==false)
   	{
   		window.alert('Prerequisite - Occult - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,8);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
	if (window.document.PSTPChars.CloudMind.checked==true)
	{
		TFValue1=StatMath(TFValue,1);
	   	window.document.PSTPChars.CloudMind.checked=TFValue1;
	}	
	TFValue1=StatMath(TFValue,1);
	return false;
   }
}


//And
function TestParaphysics(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Physics.checked==false)
   	{
   		window.alert('Prerequisite - Mathematics and Physics - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestPhysics(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Mathematics.checked==false)
   	{
   		window.alert('Prerequisite - Mathematics - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,4);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
	if (TFValue==false)
	{		
		if (window.document.PSTPChars.PoliceForensics.checked==true)
		{
			TFValue3=PoliceForensicChk();
			if (TFValue3==false)
			{
				TFValue4=StatMath(TFValue,2);
		   		window.document.PSTPChars.PoliceForensics.checked=TFValue4;
		   	}
		}
		if (window.document.PSTPChars.WeirdScience.checked==true)
		{
			TFValue2=WeirdScienceChk();
			if (TFValue2==false)
			{
				TFValue1=StatMath(TFValue,3);
		   		window.document.PSTPChars.WeirdScience.checked=TFValue1;
		   	}
		}
		if (window.document.PSTPChars.Paraphysics.checked==true)
		{
			TFValue1=StatMath(TFValue,2);
		   	window.document.PSTPChars.Paraphysics.checked=TFValue1;
		}	
		TFValue1=StatMath(TFValue,4);
		return false;
	}

}

//And
function TestPoliceForensics(TFValue)
{
   VarHold=0
   if (TFValue==true)
   {
   	if (window.document.PSTPChars.Chemistry.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Biology.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Physics.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.PoliceScience.checked==false)
   	{
   		VarHold++;
   	}
   	if (VarHold==4)   	
   	{
   		window.alert('Prerequisite - Biology, Chemistry, Physics, or Police Science');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestSniper(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.LongGun.checked==false)
   	{
   		window.alert('Prerequisite - Long Gun - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,1);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}

function TestSurgery(TFValue)
{
   if (TFValue==true)
   {
   	if (window.document.PSTPChars.Medicine.checked==false)
   	{
   		window.alert('Prerequisite - Medicine - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,2);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}


function TestWeirdScience(TFValue)
{
   VarHold=0
   if (TFValue==true)
   {
   	if (window.document.PSTPChars.Astronomy.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Biology.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Chemistry.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Geology.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Mathematics.checked==false)
   	{
   		VarHold++;   		
   	}
   	if (window.document.PSTPChars.Medicine.checked==false)
   	{
   		VarHold++;
   	}
   	if (window.document.PSTPChars.Physics.checked==false)
   	{
   		VarHold++;
   	}
   	if (VarHold>=6)   	
   	{
   		window.alert('Prerequisite Two of the Followling -\n Astronomy, Biology, Chemistry, Geology, Mathematics, Medicine, or Physics');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,3);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,3);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}	

function TestWetwork(TFValue)
{
   if (TFValue==true)
   {   	
   	if (window.document.PSTPChars.Torture.checked==false)
   	{
   		window.alert('Prerequisite - Torture and Power 15+ - Required');
   		return false;
   	}
   	if (window.document.PSTPChars.Power2.value<15)
   	{
   		window.alert('Prerequisite - Torture and Power 15+ - Required');
   		return false;
   	}
   	TFValue1=StatMath(TFValue,3);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
   if (TFValue==false)
   {
   	TFValue1=StatMath(TFValue,3);
   	if (TFValue1==true)
   	{
   		return true;
   	}
   	if (TFValue1==false)
   	{
   		return false;
   	}
   }
}

