function add_sub_frac3_check() { if(document.forms[0].elements[0].value == "3/4") { self.parent.top.location="add_sub_frac4.html"; } else { if(document.forms[0].elements[0].value == "9/12") { alert("Yes, that is correct, but It would like a simplified, mixed number, if you please."); } else { alert("No, that's not the correct answer."); } } return false; } function add_sub_frac4_check(str) { if(str.length > 0) { if( str.indexOf("hours") == -1 ) { if(str == "1/2") { self.parent.top.location="add_sub_frac5.html"; } else { if(str == ".5" || str == "0.5") { alert("Yes, that's correct, but Elmiro's deals strictly in fractions."); } else { if(IsAFraction(str)) { if( ParseFraction(str) == 0.5 ) { alert("Yes, that may be correct, but I think it can be simplified."); } else { alert("Nope, that's not right."); } } else { alert("Nope, that's not right."); } } } } else { return add_sub_frac4_check(str.substr(0, str.indexOf("hours")-1)); } } else { alert("Nope, that's not right."); } return false; } function add_sub_frac5_check() { if(document.forms[0].elements[0].value == "3") { self.parent.top.location="add_sub_frac6.html"; } else { alert("No, that's not quite right."); } return false; } //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; }