// JavaScript Document

     document.getElementById("BAAFC1").focus()
// *******   ******************  ******************    ******************

function Resetfunc()
	{
   document.getElementById("wbcForm1").reset() ; document.getElementById("BAAFC1").value = "0.00" ; document.getElementById("BAAFC4").value = "0.00"
    document.getElementById("BAAFC22").value = "0.00" ; document.getElementById("BAAFC30").selectedIndex = 2 
   
	}

function valit(obj, lowval, hival) 
  { 
 valmsg = "xxxx" ;  // **** set up variable valmsg
 
 if (obj == document.getElementById("BAAFC3")) 
	(valmsg = "Rent free weeks can't really exceed maximum of 52");

 if ((obj.value < lowval) || (obj.value > hival))
				alert(valmsg)   //***  whatever msg you want !
//   *  Call me with ----- onChange="valit(this, 18, 99)"
   }


function hilite(cellid)   // *******   this function hilites cell with focus on it    ******************
        				 { 
        document.getElementById(cellid).style.backgroundColor="yellow"       // document.all[cellid]
		                  }    
function lolite(cellid)   // *******   this function UN-hilites cell that's lost focus    ******************
                          { 
        document.getElementById(cellid).style.backgroundColor="white"       
		                   }    

// ****** ****** ****** Not for php *****
function DoCB()        {  }

function CAsafenet()        {    
    if (document.getElementById("BAAFC7").selectedIndex == 0 && document.getElementById("BAAFC13").selectedIndex == 1 ) document.getElementById("BAAFC13").selectedIndex = 0 
    if (document.getElementById("BAAFC7").selectedIndex == 0 && document.getElementById("BAAFC13").selectedIndex == 3 ) document.getElementById("BAAFC13").selectedIndex = 0 
    if (document.getElementById("BAAFC7").selectedIndex == 0 && document.getElementById("BAAFC13").selectedIndex == 5 ) document.getElementById("BAAFC13").selectedIndex = 0 
			      }

function chkdskds()        {    
  allkds = (document.getElementById("BAAFC14").value / 1) + (document.getElementById("BAAFC16").value / 1)
  if (document.getElementById("BAAFC17").value > allkds) document.getElementById("BAAFC17").value = allkds 
		}


// ****** this func stops   ***** Back50List   LabelBack50
function chk50()        {    
  if (document.getElementById("BAAFC8").value < 50) { (document.getElementById("BAAFC31").selectedIndex = 0) ; (document.getElementById("LabelBack50").style.color = "lightgrey") }  
	else
		document.getElementById("LabelBack50").style.color = "black"
	}

function knownPClock()        {    
  if (document.getElementById("BAAFC8").value < 60) { (document.getElementById("BAAFC44").value = 0) ; (document.getElementById("LabelknownPC").style.color = "lightgrey") }  
		else
     document.getElementById("LabelknownPC").style.color = "black"
	}


function nojob()        {    
  if (document.getElementById("BAAFC22").value < 9 && document.getElementById("BAAFC23").value < 9 ) document.getElementById("BAAFC30").selectedIndex = 2  
		else
      document.getElementById("BAAFC30").selectedIndex = 0 
				}


// *** combined locker/hider func  ***  
 function DoBFYslotlocker()        {    
  if (document.getElementById("BAAFC8").value < 60 || document.getElementById("BAAFC8").value > 61 )
    { (document.getElementById("BAAFC8sp1").selectedIndex = 0 ) ; (document.getElementById("BAAFC8sp2").selectedIndex = 0 )
         ; (document.getElementById("LabelDoB").style.color = "lightgrey")  
            ; (document.getElementById("LabelFYslot").style.color = "lightgrey")  }
     	else
		 {	(document.getElementById("LabelDoB").style.color = "black") 
            ; (document.getElementById("LabelFYslot").style.color = "black") }
	}

// ****** this func  *****   Kcarebox locker - but once locked, it can't unlock itself ! so get sub16box to run the func !!!
 function kcarelock()        {    
   if (document.getElementById("BAAFC14").value < 1 || document.getElementById("BAAFC30").selectedIndex == 2 )   document.getElementById("BAAFC40").value = 0
		}

function lock30bet()        {    
      allkds = (document.getElementById("BAAFC14").value / 1) + (document.getElementById("BAAFC16").value / 1)
   if (document.getElementById("BAAFC30").selectedIndex == 0 )   document.getElementById("BAAFC45").selectedIndex = 0
   if (allkds  < 1    &&  document.getElementById("BAAFC12").selectedIndex == 0 )   document.getElementById("BAAFC45").selectedIndex = 0
   if (document.getElementById("BAAFC7").selectedIndex == 0 )     document.getElementById("BAAFC45").selectedIndex = 0  //*** single ewitches it off 

   if (document.getElementById("BAAFC30").selectedIndex > 0 && allkds  > 0 && document.getElementById("BAAFC7").selectedIndex == 1 )   document.getElementById("Label30bet").style.color = "black"
	  else
        if (document.getElementById("BAAFC30").selectedIndex > 0 && document.getElementById("BAAFC12").selectedIndex == 1)  document.getElementById("Label30bet").style.color = "black"
      else
           	 { ( document.getElementById("Label30bet").style.color = "lightgrey") }
	    }
 //***  If/Else  needs no  Then or End If

 function lockDSQs()     { 
     if ( document.getElementById("BAAFC9").selectedIndex == 1 ) 
    	 { (document.getElementById("LabeladDLA").style.color = "black" ) ; (document.getElementById("LabeladDSwrk").style.color = "black") ; (document.getElementById("LabelSDP1").style.color = "black") ; (document.getElementById("LabelSDP2").style.color = "black") ; (document.getElementById("LabelDsAAHR").style.color = "black") }
          else
      	 { (document.getElementById("LabeladDLA").style.color = "lightgrey" ) ; (document.getElementById("LabeladDSwrk").style.color = "lightgrey") ; (document.getElementById("LabelSDP1").style.color = "lightgrey") ; (document.getElementById("LabelSDP2").style.color = "lightgrey") ; (document.getElementById("LabelDsAAHR").style.color = "lightgrey")}
	    }

//  ** ** ** If single this func supresses ESA Partner row 
 function singleESA()        {    
     if (document.getElementById("BAAFC7").selectedIndex == 0 )  
  	      { ( document.getElementById("Label_pESA").style.color = "lightgrey" ) ; ( document.getElementById("BAAFC8d").selectedIndex = 0) }
     else
		  ( document.getElementById("Label_pESA").style.color = "black")
 		}

 function Labbabyhider()     {    }

 function Labdskidhider()     { 
  if ( document.getElementById("BAAFC14").value > 0 || document.getElementById("BAAFC16").value > 0 ) 
         	 { (document.getElementById("LabelDSk").style.color = "black") ; (document.getElementById("LabelDSkEN").style.color = "black") }
          else
           	 { (document.getElementById("LabelDSk").style.color = "lightgrey") ; (document.getElementById("LabelDSkEN").style.color = "lightgrey")}
			 }

 function LabSLPhider()     {	
  allkds = (document.getElementById("BAAFC14").value / 1) + (document.getElementById("BAAFC16").value / 1)
       if ( allkds  > 0  &&  document.getElementById("BAAFC7").selectedIndex == 0 ) 
         	 { ( document.getElementById("LabelSLP1").style.color = "black")  }
          else
           	 { (document.getElementById("LabelSLP1").style.color = "lightgrey")   }
			}


 function Labkcarehider()     {	 
     if ( document.getElementById("BAAFC14").value > 0 && document.getElementById("BAAFC30").selectedIndex < 2 ) 
         	 { (document.getElementById("Labelkcare").style.color = "black")  }
          else
           	 { (document.getElementById("Labelkcare").style.color = "lightgrey") }
				}


// ****** this func stops   *****
function chkEnhDPkids()        {    
  if (document.getElementById("BAAFC18").value > document.getElementById("BAAFC17").value) document.getElementById("BAAFC18").value = document.getElementById("BAAFC17").value 
		}

function chklpp()        {    
  allkds = (document.getElementById("BAAFC14").value / 1) + (document.getElementById("BAAFC16").value / 1)

 if (document.getElementById("BAAFC7").selectedIndex ==1  || allkds == 0 )   document.getElementById("BAAFC19").selectedIndex = 0  
		}

function chkdis()        {    
 if (document.getElementById("BAAFC9").selectedIndex == 0 )  
      {( document.getElementById("BAAFC11").selectedIndex = 0) ; ( document.getElementById("BAAFC11a").selectedIndex = 0) ;
 ( document.getElementById("BAAFC10").selectedIndex = 0 ) ; (document.getElementById("BAAFC46").selectedIndex = 0 ) } 

   if (document.getElementById("BAAFC9").selectedIndex == 0 && document.getElementById("BAAFC8a").selectedIndex == 0 && document.getElementById("BAAFC8d").selectedIndex == 0 )  
         ( document.getElementById("BAAFC12").selectedIndex = 0 )
		}

//    function jumpIS()     { 
//     if (document.wbcForm1.incsuplist.selectedIndex ==1)  (document.location.href='#1')   }
// *****  ************************** *************************
//*****************************************************
//   File Name =  valid8.js  ( JavaScript global form validation & checking routines ) * v. 05.08 Aug 2005 ----    KB    

//***** "WillMaster's  currency formatting function - source acknowledged  ****************************
//   Give the function an amount and it will return that amount rounded to the nearest hundredth and with two digits 
//   following a decimal point. Caution .... use for final display only !

  function Formatit(amount)
 	{
 var i = parseFloat(amount);
 if(isNaN(i)) { i = 0.00; }
 var minus = '';
 if(i < 0) { minus = '-'; }
 i = Math.abs(i);
 i = parseInt((i + .005) * 100);
 i = i / 100;
 s = new String(i);
 if(s.indexOf('.') < 0) { s += '.00'; }
 if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
 s = minus + s;
 return s;
	}
// end of function Formatit()


// In future Could do a really neat Final 2 dec place format on numbers but sadly older browsers will give error. 
// Needs JavaScript 1.5, JScript - 5.5, IE 5.5 or Netscape - 6.0 - 'cos toFixed function not supported earlier.
//     For example .............. hb = (hb.toFixed (2))  
//*****************************************************

////////// only inbound funcs are       NoDec  & bounds    ///////////////////////////////////////////////////
//*****   all we really want to do is stop non-numeric values and warn on Negative Values and certain decimals ! 

//*****   KB func to trap decimals where we only want whole numbers - NB Many fields will be ok to have decimals 
function NoDec(nx)  //  NODEC 
{
  var zap = false;
  var f = decapitate(nx.value);
  f = money(f);

 abcint = parseInt (nx.value) ;
   if (abcint < nx.value) 	
       {
     zap = true;
     alert ( "Whole numbers only please");
       }
  if (zap)
  {     reset(nx);     return false;   }
//********* zap blanks the offending field ****************************
}

function money(f) // ********** Need this one ***********************
{      if (f=="") f = 0.0;    return f-0.0;   }

function reset(e)   // ********** Need this one ***********************
{   e.value = "";     e.focus();  }
// **********  Yes isNaN is a JS func to check for a numeric value
function check_number(x)  { return !(isNaN(x));  }

function       // ********** Need this one ***********************
decapitate(s){
  if (s.charAt(0)=="0")
      s = s.slice(1);  	
  return s;   //******     removes leading zeros 
}

// **************  BIGVAL ************************************************
// *** This function checks for NON NUMERIC  +  Negative Values   
function bounds(e)
{
  var zap = false;
  var f = decapitate(e.value);
  f = money(f);
  if(!check_number(f)) //***  Calls isNaN JS func to check for a numeric value
  {
  zap = true;
  alert ( "Inappropriate input, please enter a number");
  }

  if (f<0.0)  //************ LOOKING FOR NEG VAL ******************888   
  {
    zap = true;
    alert("A negative amount is not acceptable here")
  }

  if (zap)
  {
    reset(e);
    return false;
  }
  else
    return true;
} //****************** END of BIGVAL ********************************
