function modtext(){ if(document.getElementById('textmod')){ var mywords=new Array(); var mylink=new Array(); var myalt=new Array(); mywords[0] = "iasbet.com"; mylink[0] = "/linkout.php?ad=46"; myalt[0] = "bet with iasbet.com and get a $100 free bet"; mywords[1] = "betfair"; mylink[1] = "/linkout.php?ad=50"; myalt[1] = "get 20% better odds at betfair"; mywords[2] = "sportsbet"; mylink[2] = "/linkout.php?ad=60"; myalt[2] = "Get up to $200 in free bets"; mywords[3] = "Sportsbet"; mylink[3] = "/linkout.php?ad=59"; myalt[3] = "Get up to $200 in free bets"; mywords[4] = "centrebet"; mylink[4] = "/linkout.php?ad=57"; myalt[4] = "Get the best racing odds online"; mywords[5] = "Centrebet"; mylink[5] = "/linkout.php?ad=58"; myalt[5] = "get the best odds online"; mywords[6] = "iasbet"; mylink[6] = "/linkout.php?ad=45"; myalt[6] = "Bet with iasbet and get a $100 free bet"; mywords[7] = "Betfair"; mylink[7] = "/linkout.php?ad=51"; myalt[7] = "get 20% better odds at Betfair"; mywords[8] = "Sportingbet"; mylink[8] = "/linkout.php?ad=62"; myalt[8] = "Australia\'s biggest online bookie"; mywords[9] = "IASbet"; mylink[9] = "/linkout.php?ad=47"; myalt[9] = "bet with IASbet and get a $100 free bet"; mywords[10] = "www.iasbet.com"; mylink[10] = "/linkout.php?ad=48"; myalt[10] = "bet with iasbet.com and get a $100 free bet"; mywords[11] = "www.IASbet.com"; mylink[11] = "/linkout.php?ad=49"; myalt[11] = "bet with www.IASbet.com and get a $100 free bet"; mywords[12] = "SportsBet"; mylink[12] = "/linkout.php?ad=87"; myalt[12] = "Get up to $200 in free bets"; mywords[13] = "Bet365.com"; mylink[13] = "/linkout.php?ad=97"; myalt[13] = "200%1st deposit bonus"; mywords[14] = "free bet comparison table"; mylink[14] = "http://www.bet-au.com/freebets.php"; myalt[14] = "free bets"; for (var k=0;k < mywords.length;k++){ var str = document.getElementById('textmod').innerHTML; var txt = mywords[k]; //old broken line of code var txt=new RegExp(mywords[k],'k');//g = global / i = case insensitive //var txt=new RegExp(mywords[k],'i');//g = global / i = case insensitive // document.getElementById('textmod').innerHTML = str.replace(txt,' '+mywords[k]+' '); var fnd=new RegExp('('+txt+')(?![^<]*>|[^<]*<\/a>)','gi'); var pos = mylink[k].indexOf("bet-au.com"); if (pos>=0){ var ns = str.replace(fnd,' '+mywords[k]+' '); }else{ var ns = str.replace(fnd,' '+mywords[k]+' '); } document.getElementById('textmod').innerHTML = ns; } } } //////// val function validate(theform){ var errors = 0; if(document.validateme.fname){ if(!notempty(document.validateme.fname.value)){ errors++; document.validateme.fname.style.border = '1px solid red'; }else{ document.validateme.fname.style.border = '1px solid green'; } } if(document.validateme.fsurname){ if(!notempty(document.validateme.fsurname.value)){ errors++; document.validateme.fsurname.style.border = '1px solid red'; }else{ document.validateme.fsurname.style.border = '1px solid green'; } } if(document.validateme.email){ if(checkMail(document.validateme.email.value)){ errors++; document.validateme.email.style.border = '1px solid red'; }else{ document.validateme.email.style.border = '1px solid green'; } } if(document.validateme.dayofyear){ if(document.validateme.dayofyear.value == 'DD' ){ errors++; document.validateme.dayofyear.style.border = '1px solid red'; }else{ document.validateme.dayofyear.style.border = '1px solid green'; } } if(document.validateme.month){ if(document.validateme.month.value == 'MM'){ errors++; document.validateme.month.style.border = '1px solid red'; }else{ document.validateme.month.style.border = '1px solid green'; } } if(document.validateme.year){ if(document.validateme.year.value == 'YYYY'){ errors++; document.validateme.year.style.border = '1px solid red'; }else{ document.validateme.year.style.border = '1px solid green'; } } if(document.validateme.telephone){ if(checkNum(document.validateme.telephone.value)){ errors++; document.validateme.telephone.style.border = '1px solid red'; }else{ document.validateme.telephone.style.border = '1px solid green'; } } if(document.validateme.telephone2){ if(checkNum(document.validateme.telephone2.value)){ errors++; document.validateme.telephone2.style.border = '1px solid red'; }else{ document.validateme.telephone2.style.border = '1px solid green'; } } if(document.validateme.comment){ if(!notempty(document.validateme.comment.value)){ errors++; document.validateme.comment.style.border = '1px solid red'; }else{ document.validateme.comment.style.border = '1px solid green'; } } if(errors == 0){ document.validateme.submit(); }else{ alert('Please check data'); } } function notempty(val){ if(val == ''){ return false; }else{ return true; } } function checkNum(fieldval){ var NumberToTest = fieldval.split(' ').join(''); var IsFound = /^-?\d+$/.test(NumberToTest); if((IsFound) && (NumberToTest.length >= 7) && (NumberToTest.length < 12)){ return false; }else{ return true; } } function checkMail(value) { var x = value; var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (filter.test(x)) return false; else return true; }