// JavaScript Document

		// Define default values
	
		var gender = "Undecided";
		
		var blk = 1;
		var brn = 1;
		var cor = 1;
		var wil = 1;
		
		var health = 0;
		var grip = 0;
		var move = 0;
		
		var vs_points = 8;
		var skill_points = 12;
		
		var detection = 0;
		var faith = 0;
		var gun = 0;
		var hth = 0;
		var medical = 0;
		var melee = 0;
		var science = 0;
		var sneak = 0;
		var sweet_talk = 0;
		var technical = 0;
		var thief = 0;
		var watchfulness = 0;
		
		var have_point = true;
		var point = 1;
		var health_bonus = 0;
		var grip_bonus = 0;
		var note = "";

		//Contains data passed to char sheet popup window
    var popup_features = "scrollbars=yes, resizable=yes menubar=yes, status=no, toolbar=yes, width=800, height=600";
		
		//Set gender, based on radio button click
		function Sex_Change(num)
		{
		    if ( num == 1 ) 
				{ 
				   gender = "M"; 
				}
				
				else 
				{ 
				   gender = "F"; 
				}
		}
		
		// Decrease a Vital Stat by 1
    function Stat_Down(num)
    {
       var changed = false;
 
       switch (num)
       {
         case 1:
                 if (blk > 1)
                 {
                   blk--;
                   document.main.blk.value = blk;
                   changed = true;
                 }
                 break;

         case 2:
                 if (brn > 1)
                 {
                   brn--;
                   document.main.brn.value = brn;
                   changed = true;
                 }
                 break;

         case 3:
                 if (cor > 1)
                 {
                   cor--;
                   document.main.cor.value = cor;
                   changed = true;
                 }
                 break;

         case 4:
                 if (wil > 1)
                 {
                   wil--;
                   document.main.wil.value = wil;
                   changed = true;
                 }
                 break;

       }     // end of switch

       if (changed)
       {
         vs_points++;
         document.main.vs_points.value = vs_points;
				 Calc_Signs();
       }
    }

		// Increase a Vital Stat by 1
    function Stat_Up(num)
    {
       var changed = false;

       // Check to make sure there are points left
       if (vs_points <= 0)
          return;

       switch (num)
       {
         case 1: 
				 			if (blk < 5 )
							{
							 blk++;
							 document.main.blk.value = blk;
							 changed = true;
							}
							break;

         case 2: 			 				
			 				if (brn < 5 )
							{
							 brn++;
							 document.main.brn.value = brn;
							 changed = true;
							}
							break;

         case 3: 
			 				if (cor < 5 )
							{
							 cor++;
							 document.main.cor.value = cor;
							 changed = true;
							}
							break;

         case 4: 
			 				if (wil < 5 )
							{
							 wil++;
							 document.main.wil.value = wil;
							 changed = true;
							}
							break;

       }     // end of switch
			
      if (changed)
       {
         vs_points--;
         document.main.vs_points.value = vs_points;
				 Calc_Signs();				 														
       }
 
    }

		//Calculate Vital Signs
		function Calc_Signs()
		{
		   health = 3 * blk + health_bonus;
			 grip = 3* wil + grip_bonus;
			 move = blk + cor;
			 
			 document.main.health.value = health;
			 document.main.grip.value = grip;
			 document.main.move.value = move;
		}
		
		// Decrease a Skill by 1
    function Skill_Down(num)
    {
       var changed = false;
 
       switch (num)
       {
         case 1:
                 if (detection > 0)
                 {
                   detection--;
                   document.main.detection.value = detection;
                   changed = true;
                 }
                 break;

         case 2:
                 if (faith > 0)
                 {
                   faith--;
                   document.main.faith.value = faith;
                   changed = true;
                 }
                 break;

         case 3:
                 if (gun > 0)
                 {
                   gun--;
                   document.main.gun.value = gun;
                   changed = true;
                 }
                 break;

         case 4:
                 if (hth > 0)
                 {
                   hth--;
                   document.main.hth.value = hth;
                   changed = true;
                 }
                 break;

				case 5:
						 	 	 if (medical > 0)
								 {
								 		medical--;
										document.main.medical.value = medical;
										changed = true;
								 }
								 break;
			
			  case 6:
						 	 if (melee > 0)
							 {
							 		melee--;
									document.main.melee.value = melee;
									changed = true;
								}
								break;
								
				case 7:
						 	 if (science > 0)
							 {
							 		science--;
									document.main.science.value = science;
									changed = true;
							 }
							 break;
				
				case 8:
						 	 if (sneak > 0)
							 {
							 		sneak--;
									document.main.sneak.value = sneak;
									changed = true;
								}
								break;
				
				case 9:
						 	 if (sweet_talk > 0)
							 {
							 		sweet_talk--;
									document.main.sweet_talk.value = sweet_talk;
									changed = true;
								}
								break;
				
				case 10:
						 	 if (technical > 0)
							 {
							 		technical--;
									document.main.technical.value = technical;
									changed = true;
								}
								break;
				
				case 11:
						 	 if (thief > 0)
							 {
							 		thief--;
									document.main.thief.value = thief;
									changed = true;
								}
								break;
			
			 case 12:
			 				 if (watchfulness > 0)
							 {
							 		watchfulness--;
									document.main.watchfulness.value = watchfulness;
									changed = true;
							 }
							 break;

       }     // end of switch

       if (changed)
       {
         skill_points++;
         document.main.skill_points.value = skill_points;
       }
    }

		// Increase a Skill by 1
    function Skill_Up(num)
    {
       var changed = false;

       // Check to make sure there are points left
       if (skill_points <= 0)
          return;

       switch (num)
       {
         case 1:
				 			if (detection < 4 )
							{
							 detection++;
							 document.main.detection.value = detection;
							 changed = true;
							}
							break;

         case 2: 			 				
			 				if (faith < 4 )
							{
							 faith++;
							 document.main.faith.value = faith;
							 changed = true;
							}
							break;

         case 3: 
			 				if (gun < 4 )
							{
							 gun++;
							 document.main.gun.value = gun;
							 changed = true;
							}
							break;

         case 4: 
			 				if (hth < 4 )
							{
							 hth++;
							 document.main.hth.value = hth;
							 changed = true;
							}
							break;

				case 5:
						 	 	 if (medical < 4)
								 {
								 		medical++;
										document.main.medical.value = medical;
										changed = true;
								 }
								 break;
			
			  case 6:
						 	 if (melee < 4)
							 {
							 		melee++;
									document.main.melee.value = melee;
									changed = true;
								}
								break;
								
				case 7:
						 	 if (science < 4)
							 {
							 		science++;
									document.main.science.value = science;
									changed = true;
							 }
							 break;
				
				case 8:
						 	 if (sneak < 4)
							 {
							 		sneak++;
									document.main.sneak.value = sneak;
									changed = true;
								}
								break;
				
				case 9:
						 	 if (sweet_talk < 4)
							 {
							 		sweet_talk++;
									document.main.sweet_talk.value = sweet_talk;
									changed = true;
								}
								break;
				
				case 10:
						 	 if (technical < 4)
							 {
							 		technical++;
									document.main.technical.value = technical;
									changed = true;
								}
								break;
				
				case 11:
						 	 if (thief < 4)
							 {
							 		thief++;
									document.main.thief.value = thief;
									changed = true;
								}
								break;
			
			 case 12:
			 				 if (watchfulness < 4)
							 {
							 		watchfulness++;
									document.main.watchfulness.value = watchfulness;
									changed = true;
							 }
							 break;

       }     // end of switch
 
      if (changed)
       {
         skill_points--;
         document.main.skill_points.value = skill_points;
       }
 
    }
		
		//Sets the variable for The Point when a radio button is clicked
		function Set_Point(num)
		{
		 		 if (have_point) 
				 {
		 		 	   point = num;
				 }			     
				 
	    	 else
			   {
			  	  alert('Hey! You already spent your Point. Remember?!');
			   }
	
		}
		
		//Locks in the choice selected for The Point
		function Spend_Point()
		{
		 		 if (have_point)
				 {
				 
				 	switch(point)
				 	{
				 		 case 1:
						 			vs_points++;
									document.main.vs_points.value = vs_points;
						      break;

				 		 case 2:
						 			skill_points = skill_points +2;
									document.main.skill_points.value = skill_points;
						      break;						

				 		 case 3:
						 			health_bonus = 2;
									grip_bonus = 2;
									Calc_Signs();
						      break;						

				 		 case 4:
						 			note = "Extra Luck Point";
						      break;						

				 		 case 5:  
						 			note = "Extra 2nd Thought Point";
						      break;						

				 		 case 6:  
						 			note = "Special Trait: " + document.main.trait.value;
						      break;

					 }		//end of switch					
     
			 have_point=false;
			 document.main.spend_point.value = "Point Spent";

       }
			 
			 else
			 {
			 	  alert('Hey! You already spent your Point. Remember?!');
			 }
		}
		
		//Display all information in character sheet format
		function View_Sheet()
		{
			 //displaywin.document.writeln(''); blank line to copy

       displaywin = window.open('','Language',popup_features);

       displaywin.document.writeln('<FORM NAME=sheet>');
			 displaywin.document.writeln('<CENTER>');
			 displaywin.document.writeln('<TABLE>')
			 displaywin.document.writeln('<TR>')
			 displaywin.document.writeln('  <TD align=left><IMG SRC="images/hrlogo_bw.jpg" height=50> </TD>')
			 displaywin.document.writeln('  <TD align=center><FONT face=arial size=+1><B>Horror Rules Character Sheet</B></FONT></TD>');
			 displaywin.document.writeln('  <TD align=center></TD>')
	     displaywin.document.writeln('</TR>');
	     displaywin.document.writeln('</TABLE><P>');
	     displaywin.document.writeln('<TABLE BORDER=0 CELLSPACING=10 CELLPADDING=0>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD WIDTH=200><B>Name: </B> ' + document.main.name.value + '</TD>');
       displaywin.document.writeln('  <TD WIDTH=125><B>Sex: </B> ' + gender + '</TD>');
       displaywin.document.writeln('  <TD WIDTH=200><B>Type: </B> ' + document.main.type.value + '</TD>');
	     displaywin.document.writeln('</TR>');
	     displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD WIDTH=200><B>Occupation: </B> ' + document.main.occupation.value + '</TD>');
       displaywin.document.writeln('  <TD WIDTH=75><B>Age: </B> ' + document.main.age.value + '</TD>');
       displaywin.document.writeln('  <TD WIDTH=150><B>Morality: </B> ' + document.main.morality.value + '</TD>');
	     displaywin.document.writeln('</TR>');
	     displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD colspan=3><B>Description: </B> ' + document.main.description.value + '</TD>');
	     displaywin.document.writeln('</TR>');
	     displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD colspan=3><B>Brief: </B> ' + document.main.brief.value + '</TD>');
	     displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR></TR>');
       displaywin.document.writeln('<TR>');
			 displaywin.document.writeln('<TD><B><U>VITAL STATS</U></B></TD>');       
			 displaywin.document.writeln('<TD></TD>');       
			 displaywin.document.writeln('<TD><B><U>VITAL SIGNS</U></B></TD>');       
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
			 displaywin.document.writeln('  <TD><B>Bulk: </B>' + blk + '</TD>');
       displaywin.document.writeln('  <TD></TD>');
       displaywin.document.writeln('  <TD><B>Health: </B>' + health + '</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD><B>Brains: </B>' + brn + '</TD>');
       displaywin.document.writeln('  <TD></TD>');
       displaywin.document.writeln('  <TD><B>Grip: </B>' + grip + '</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD><B>Coordination: </B>' + cor + '</TD>');
       displaywin.document.writeln('  <TD></TD>');
       displaywin.document.writeln('  <TD><B>Movement: </B>' + move + '</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD><B>Will: </B>' + wil + '</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
			 displaywin.document.writeln('<TD align=center colspan=3><B><U>SKILLS</U></B>');       
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD><B>Detection (brn): </B>' + detection + '</TD>');
       displaywin.document.writeln('  <TD><B>Faith (wil): </B>' + faith + '</TD>');
       displaywin.document.writeln('  <TD><B>Gun (cor): </B>' + gun + '</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD><B>HtH (cor/blk): </B>' + hth + '</TD>');
       displaywin.document.writeln('  <TD><B>Medical (brn): </B>' + medical + '</TD>');
       displaywin.document.writeln('  <TD><B>Melee (cor/blk): </B>' + melee + '</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD><B>Science (brn): </B>' + science + '</TD>');
       displaywin.document.writeln('  <TD><B>Sneak (cor): </B>' + sneak + '</TD>');
       displaywin.document.writeln('  <TD><B>Sweet Talk (brn): </B>' + sweet_talk + '</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD><B>Technical (brn): </B>' + technical + '</TD>');
       displaywin.document.writeln('  <TD><B>Thief (cor): </B>' + thief + '</TD>');
       displaywin.document.writeln('  <TD><B>Watchfulness (wil): </B>' + watchfulness + '</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('</TABLE><P>');

       displaywin.document.writeln('<TABLE CELLSPACING=10>');
       displaywin.document.writeln('<TR>');
			 displaywin.document.writeln('  <TD align=center><B><U>WEAPONS</U></B></TD>');
			 displaywin.document.writeln('  <TD align=center><B><U>DAMAGE</U></B></TD>');
			 displaywin.document.writeln('  <TD align=center><B><U>SPEED</U></B></TD>');
			 displaywin.document.writeln('  <TD align=center><B><U>RANGE</U></B></TD>');
			 displaywin.document.writeln('  <TD align=center><B><U>AMMO</U></B></TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
			 displaywin.document.writeln('  <TD align=center>' + document.main.weapon1.value + '</TD>');
			 displaywin.document.writeln('  <TD>___________</TD>');
			 displaywin.document.writeln('  <TD>___________</TD>');
			 displaywin.document.writeln('  <TD>___________</TD>');
			 displaywin.document.writeln('  <TD>_______</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
			 displaywin.document.writeln('  <TD align=center>' + document.main.weapon2.value + '</TD>');
			 displaywin.document.writeln('  <TD>___________</TD>');
			 displaywin.document.writeln('  <TD>___________</TD>');
			 displaywin.document.writeln('  <TD>___________</TD>');
			 displaywin.document.writeln('  <TD>_______</TD>');
       displaywin.document.writeln('</TR>');
       displaywin.document.writeln('<TR>');
			 displaywin.document.writeln('  <TD align=center>' + document.main.weapon3.value + '</TD>');
			 displaywin.document.writeln('  <TD>___________</TD>');
			 displaywin.document.writeln('  <TD>___________</TD>');
			 displaywin.document.writeln('  <TD>___________</TD>');
			 displaywin.document.writeln('  <TD>_______</TD>');
       displaywin.document.writeln('</TR>');
			 displaywin.document.writeln('</TABLE><P>');

			 displaywin.document.writeln('<TABLE BORDER=0>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD width=200 align=center><INPUT type="checkbox" name="luck"><B>Luck Point</B></TD>');
       displaywin.document.writeln('  <TD width=200 align=center><INPUT type="checkbox" name="2ndthought"><B>Second Thought Point</B></TD>');
       displaywin.document.writeln('</TR>');
			 displaywin.document.writeln('</TABLE><P>');
			 displaywin.document.writeln('<TABLE BORDER=1>');
       displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD width=250 valign=top align=center><B>Equipment</B></TD>');
       displaywin.document.writeln('  <TD width=250 valign=top align=center><B>Notes</B></TD>');
			 displaywin.document.writeln('</TR>');
			 displaywin.document.writeln('<TR>');
       displaywin.document.writeln('  <TD valign=top align=center>' + document.main.equipment.value + '<BR><BR><BR><BR><BR><BR></TD>');
       displaywin.document.writeln('  <TD valign=top align=center>' + note + '</TD>');
       displaywin.document.writeln('</TR></TABLE><P>');

			 displaywin.document.writeln('<FONT size=-1>copyright 2004 &copy Crucifiction Games</FONT></CENTER>');
       displaywin.document.writeln('</CENTER></FORM>');

       displaywin.document.close();
       displaywin.focus();
			 
			 displaywin.document.sheet.name.value=document.main.name.value;

		}
		
		//Resets all variables to intitial values, resets/clears display
		function Reset_Form()
		{

			gender = "Undecided";
			
			blk = 1;
			brn = 1;
			cor = 1;
			wil = 1;
		  health = 3;
			grip = 3;
			move = 2;
		  vs_points = 8;
			skill_points = 12;
			detection = 0;
			faith = 0;
			gun = 0;
			hth = 0;
			medical = 0;
			melee = 0;
			science = 0;
			sneak = 0;
			sweet_talk = 0;
			technical = 0;
			thief = 0;
			watchfulness = 0;
			
			have_point = true;
			point = 1;
			health_bonus = 0;
			grip_bonus = 0;
		  note = "";
			
			document.main.name.value="";
			document.main.type.value="";
			document.main.age.value="";
			document.main.morality.value="";
			document.main.brief.value="";
			document.main.description.value="";
			document.main.occupation.value="";
	
			document.main.blk.value = blk;
			document.main.brn.value = brn;
			document.main.cor.value = cor;
			document.main.wil.value = wil;
			
			document.main.health.value = health;
			document.main.grip.value = grip;
			document.main.move.value = move;
			
			document.main.vs_points.value = vs_points;
			document.main.skill_points.value = skill_points;
			
			document.main.detection.value = detection;
			document.main.faith.value = faith;
			document.main.gun.value = gun;
			document.main.hth.value = hth;
			document.main.medical.value = medical;
			document.main.melee.value = melee;
			document.main.science.value = science;
			document.main.sneak.value = sneak;
			document.main.sweet_talk.value = sweet_talk;
			document.main.technical.value = technical;
			document.main.thief.value = thief;
			document.main.watchfulness.value = watchfulness;
			
			document.main.weapon1.value="";
			document.main.weapon2.value="";
			document.main.weapon3.value="";
			document.main.equipment.value="";
			
			document.main.spend_point.value = "Spend Point";
			
			}

