function card1_check() { var str=document.forms[0].elements[0].value; if( str == "4 2/3" ) { self.parent.top.location="card1x.html"; return false; } else { return CardErrorCheck( str, eval(4+2/3) ); } } function card2_check() { var str=document.forms[0].elements[0].value; if(str == "25 1/2") { self.parent.top.location="card2x.html"; return false; } else { return CardErrorCheck( str, 25.5 ); } } function card3_check() { var str=document.forms[0].elements[0].value; if(str == "24") { self.parent.top.location="card3x.html"; return false; } else { return CardErrorCheck( str, 24); } } function card4_check() { var str=document.forms[0].elements[0].value; if(str == "4 1/2") { self.parent.top.location="card4x.html"; return false; } else { return CardErrorCheck( str, 4.5 ); } } function blq_frac3_check() { var str=document.forms[0].elements[0].value; if(str == "12852") { self.parent.top.location="continued1.html"; return false; } else { return CardErrorCheck( str, 12852); } } function CardErrorCheck( str, decimalAnswer ) { if(IsAFraction(str)) { if(ParseFraction(str) == decimalAnswer) { alert("You must enter your answer as a simplified mixed number."); } else { alert("That isn't quite right."); } } else { alert("You must enter your answer in fractional notation."); } return false; } //Again, the fraction functions. function IsAFraction( str ) { var isFraction=true; if( str.length == 0 ) return false; for( var i = 0; i < str.length; i ++ ) { if( !IsValidChar(str[i]) ) { isFraction = false; } } return isFraction; } function IsValidChar( ch ) { return ( ch == 0 || ch == 1 || ch == 2 || ch == 3 || ch ==4 || ch ==5 || ch ==6 || ch ==7 || ch ==8 || ch ==9 || ch ==" " || ch =="/" ); } function ParseFraction( frac ) { var toReturn; var i; for( i=0; i < frac.length && frac[i] != " "; i++ ); toReturn = eval (frac.substr(0, i)); if(i < frac.length - 1) toReturn += eval (frac.substr(i+1, frac.length)); return toReturn; }