// Pagination script resultsPerPage=12; pageLinksInPagination=7; mediaResultsPerPage=15; function checkQueryString(){ var qrStr = window.location.search; var spQrStr = qrStr.substring(1); var arrQrStr = new Array(); // splits each of pair var arr = spQrStr.split('&'); for (var i=0;i=pageNo*resultsPerPage ) liItem[i].style.display='none'; else liItem[i].style.display='block'; } if(liItem.length!=0) pagination(pageNo); } function dispPage1(pageNo){ checkQueryString(); liItem = document.getElementsByClassName('list'); for(var i=0; i=pageNo*resultsPerPage ) liItem[i].style.display='none'; else liItem[i].style.display='block'; } if(liItem.length!=0) pagination1(pageNo); } function pagination(currentPageNo){ var liItem = document.getElementsByName('list'); var maxNoOfPages = Math.ceil(liItem.length/resultsPerPage); var pageNosToDisplay=""; if(currentPageNo%pageLinksInPagination==0) fromPage=currentPageNo-(pageLinksInPagination-1); else fromPage = currentPageNo-currentPageNo%pageLinksInPagination + 1; if((maxNoOfPages-fromPage+1)>=pageLinksInPagination) toPage = pageLinksInPagination; else toPage = maxNoOfPages-fromPage+1; for(i=fromPage;i<(fromPage+toPage);i++){ if(i==fromPage){ //alert("inside i=fromPage, i= "+i); if(i==currentPageNo) pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; else pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; } else if(i==(fromPage+toPage-1)){ if(i==currentPageNo) pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; else pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; } else if(i==currentPageNo) pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; //pageNosToDisplay = pageNosToDisplay + "" + i + " "; else pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; } if(isPreviousNextLinksRequired(maxNoOfPages)){ pageNosToDisplay = previous(pageNosToDisplay,currentPageNo); pageNosToDisplay = first(pageNosToDisplay); pageNosToDisplay = next(pageNosToDisplay,maxNoOfPages,currentPageNo); pageNosToDisplay = last(pageNosToDisplay,maxNoOfPages); } document.getElementById('leftPagingTextTop').innerHTML = "

    Displaying Page "+currentPageNo+" of "+maxNoOfPages+"

    Show all"; document.getElementById('pagingTop').innerHTML = pageNosToDisplay; document.getElementById('leftPagingTextBottom').innerHTML = "

    Displaying Page "+currentPageNo+" of "+maxNoOfPages+"

    Show all"; document.getElementById('pagingBottom').innerHTML = pageNosToDisplay; } function pagination1(currentPageNo){ var liItem = document.getElementsByClassName('list'); var maxNoOfPages = Math.ceil(liItem.length/resultsPerPage); var pageNosToDisplay=""; if(currentPageNo%pageLinksInpagination1==0) fromPage=currentPageNo-(pageLinksInpagination1-1); else fromPage = currentPageNo-currentPageNo%pageLinksInpagination1 + 1; if((maxNoOfPages-fromPage+1)>=pageLinksInpagination1) toPage = pageLinksInpagination1; else toPage = maxNoOfPages-fromPage+1; for(i=fromPage;i<(fromPage+toPage);i++){ if(i==fromPage){ //alert("inside i=fromPage, i= "+i); if(i==currentPageNo) pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; else pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; } else if(i==(fromPage+toPage-1)){ if(i==currentPageNo) pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; else pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; } else if(i==currentPageNo) pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; //pageNosToDisplay = pageNosToDisplay + "" + i + " "; else pageNosToDisplay = pageNosToDisplay + "
  • "+i+"
  • "; } if(isPreviousNextLinksRequired(maxNoOfPages)){ pageNosToDisplay = previous(pageNosToDisplay,currentPageNo); pageNosToDisplay = first(pageNosToDisplay); pageNosToDisplay = next(pageNosToDisplay,maxNoOfPages,currentPageNo); pageNosToDisplay = last(pageNosToDisplay,maxNoOfPages); } document.getElementById('leftPagingTextTop').innerHTML = "

    Displaying Page "+currentPageNo+" of "+maxNoOfPages+"

    Show all"; document.getElementById('pagingTop').innerHTML = pageNosToDisplay; document.getElementById('leftPagingTextBottom').innerHTML = "

    Displaying Page "+currentPageNo+" of "+maxNoOfPages+"

    Show all"; document.getElementById('pagingBottom').innerHTML = pageNosToDisplay; } function isPreviousNextLinksRequired(maxNoOfPages){ if(maxNoOfPages > pageLinksInPagination){ return true; } return false; } function previous(pageNosToDisplay,currentPageNo){ if(currentPageNo==1) dispParameter=1; else dispParameter=currentPageNo-1; //pageNosToDisplay = "\<    " + pageNosToDisplay; pageNosToDisplay = "
  • Previous page
  • " + pageNosToDisplay; return pageNosToDisplay; } function first(pageNosToDisplay){ //pageNosToDisplay = "\<\<   " + pageNosToDisplay; pageNosToDisplay = "
  • First page
  • " + pageNosToDisplay; return pageNosToDisplay; } function next(pageNosToDisplay,maxNoOfPages,currentPageNo){ if(currentPageNo==maxNoOfPages) dispParameter=maxNoOfPages; else dispParameter=currentPageNo+1; //pageNosToDisplay = pageNosToDisplay + "   \>"; pageNosToDisplay = pageNosToDisplay + "
  • Next page
  • "; return pageNosToDisplay; } function last(pageNosToDisplay,maxNoOfPages){ //pageNosToDisplay = pageNosToDisplay + "   \>\>" pageNosToDisplay = pageNosToDisplay + "
  • Last page
  • "; return pageNosToDisplay; } function showAll(){ liItem = document.getElementsByName('list'); for(var i=0; i 6 ) sz = 6; startSz = sz; if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ]; cEl.style.fontSize = szs[ sz ]; for ( i = 0 ; i < tgs.length ; i++ ) { cTags = cEl.getElementsByTagName( tgs[ i ] ); for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ]; } } /* This method opens outlook mail window with predefined body text */ function sendPage() { mail_str = "mailto:?subject=Thames Water website: " + document.title; mail_str += "&body=You have been sent a link from the Thames Water website. %0D%0A%0D%0A"; mail_str += "The page can be viewed by following this link: " + location.href; location.href = mail_str; } /*function sendPage() { mail_str = "mailto:?subject=View this page on the Thames Water website" + document.title; mail_str += "&body=You have been sent a link from Thames Water official website %0D%0A%0D%0A" + document.title; mail_str += ". You can view it at, " + location.href; location.href = mail_str; }*/ /* This method changes style sheet to textonly and vice versa */ function switchstyle() { var hrefValue; var i, link_tag ; for (i = 0, link_tag = document.getElementsByTagName("link") ;i < link_tag.length ; i++ ){ if ((link_tag[i].rel.indexOf( "stylesheet" ) != -1) && link_tag[i].title) { if(link_tag[i].title == "main") { //alert("if block"); hrefValue = link_tag[i].href; //alert(hrefValue); //alert("/cps/rde/xchg/corp/hs.xsl/main.css"); //alert(hrefValue.indexOf("/cps/rde/xchg/corp/hs.xsl/main.css")); if( hrefValue.indexOf("/cps/rde/xchg/corp/hs.xsl/main.css") >= 0) { link_tag[i].href = "/cps/rde/xchg/corp/hs.xsl/textonly.css"; } else { //alert("else block"); link_tag[i].href = "/cps/rde/xchg/corp/hs.xsl/main.css"; } } } } } // functions related to search form submit - added by Jagadish. //function trim(s){ //var l=0;var r=s.length - 1; //while(ll && s[r] == '') //{r-=1;} //return s.substring(l,r+1); //} function submitsearch(){ var searchTerm = document.getElementById("fSearchTerms").value; //alert(searchTerm); document.testform.wholesite.value='TWwebsite'; //document.testform.sterm.value=searchTerm; if (searchTerm.length == 0) return false; if (searchTerm.length > 0) document.testform.submit(); } function submitsearchagain(){ //alert("in search again"); var searchTerm = document.searchagainform.fSearchTerms.value; //alert("*"); //alert(searchTerm); document.searchagainform.wholesite.value='TWwebsite'; if (searchTerm.length > 0) document.searchagainform.submit(); } function submitadvsearch(){ var check = 0; //alert("in adv search"); var searchTerm = document.advsearchform.fSearchTerms.value; //alert(searchTerm); if (document.advsearchform.TWwebsite.checked){ document.advsearchform.wholesite.value='TWwebsite'; check++; //alert(document.advsearchform.wholesite.value); } if (document.advsearchform.Yourhome.checked){ document.advsearchform.fYourhome.value='home_services'; check++; //alert(document.advsearchform.fYourhome.value); } if (document.advsearchform.Yourbusiness.checked){ document.advsearchform.fYourbusiness.value='business_services'; check++; //alert(document.advsearchform.fYourbusiness.value); } if (document.advsearchform.Community.checked){ document.advsearchform.fCommunity.value='community'; check++; //alert(document.advsearchform.fCommunity.value); } if (document.advsearchform.Environment.checked){ document.advsearchform.fEnvironment.value='environment'; check++; //alert(document.advsearchform.fEnvironment.value); } if (document.advsearchform.Careers.checked){ document.advsearchform.fCareers.value='careers'; check++; //alert(document.advsearchform.fCareers.value); } if (document.advsearchform.Aboutus.checked){ document.advsearchform.fAboutus.value='about_us'; check++; //alert(document.advsearchform.fAboutus.value); } if (document.advsearchform.Media.checked){ document.advsearchform.fMedia.value='media_centre'; check++; //alert(document.advsearchform.fMedia.value); } if (document.advsearchform.Contactus.checked){ document.advsearchform.fContactus.value='contact_us'; check++; //alert(document.advsearchform.fContactus.value); } if (searchTerm.length > 0 && check > 0) return true;//document.advsearchform.submit(); if (searchTerm.length > 0 && check == 0) { document.advsearchform.wholesite.value='TWwebsite'; return true; //document.advsearchform.submit(); } return false; } function submitadvarticlesearch(){ var searchTerm = document.advarticlesearchform.fSearchTerms.value; if (searchTerm.length > 0) return true;//document.advarticlesearchform.submit(); return false; } // Advance search inline javascript function enablecontrols() { if (document.getElementById("TWwebsite").checked) { //alert("checked"); document.getElementById("Yourhome").disabled=true; document.getElementById("Yourbusiness").disabled=true; document.getElementById("Community").disabled=true; document.getElementById("Environment").disabled=true; document.getElementById("Media").disabled=true; document.getElementById("Aboutus").disabled=true; document.getElementById("Careers").disabled=true; document.getElementById("Contactus").disabled=true; } else { //alert("unchecked"); document.getElementById("Yourhome").disabled=false; document.getElementById("Yourbusiness").disabled=false; document.getElementById("Community").disabled=false; document.getElementById("Environment").disabled=false; document.getElementById("Media").disabled=false; document.getElementById("Aboutus").disabled=false; document.getElementById("Careers").disabled=false; document.getElementById("Contactus").disabled=false; } if (!(document.getElementById("Yourhome").checked) && !(document.getElementById("Yourbusiness").checked) && !(document.getElementById("Community").checked) && !(document.getElementById("Environment").checked) && !(document.getElementById("Media").checked) && !(document.getElementById("Aboutus").checked) && !(document.getElementById("Careers").checked)&& !(document.getElementById("Contactus").checked)) { //alert("nothing checked"); document.getElementById("TWwebsite").disabled=false; } else { //alert("something checked"); document.getElementById("TWwebsite").disabled=true; } }//END OF INLINE SCRIPT // Article search submit //function articlesearchsubmit(){ //var searchTerm = document.articlesearchform.fSearchTerms.value; //if (searchTerm.length > 0) return true;//document.articlesearchform.submit(); //return false; //} // Article search submit function articlesearchsubmit(){ var searchTerm = document.articlesearchform.fSearchTerms.value; var monthvalue = document.articlesearchform.month.value; var yearvalue = document.articlesearchform.year.value; if ((searchTerm.length > 0) && (monthvalue != "" && yearvalue != "")) return true; if ((searchTerm.length == 0) && (monthvalue != "" && yearvalue != "")) return true; if ((searchTerm.length > 0) && (monthvalue == "" && yearvalue == "")) return true; if ((searchTerm.length == 0) && (monthvalue == "" && yearvalue == "")) return false; //if (searchTerm.length > 0) return true;//document.articlesearchform.submit(); return false; } // Function being called when user press enter for search. function checkEnter(e,from){ e = e || window.event; var characterCode = e.keyCode || e.which; if (characterCode == 13){ //alert(from); if (from == 'utility'){ //alert("utility got it"); document.testform.search-submit.click(); } if (from == 'searchagain'){ //alert("search agian got it"); document.searchagainform.searchagainid.click(); } if (from == 'advsearch'){ //alert("adv search got it"); document.advsearchform.advsearchid.click(); } if (from == 'articlesearch'){ //alert("got it"); document.articlesearchform.articlesearchid.click(); } if (from == 'advarticlesearch'){ //alert("advarticlesearch got it"); document.advarticlesearchform.advarticlesearchid.click(); } } } // Utility functions for Building Water Supplies function calcQuote() { var VAT = ""; var TotalPayable = ""; var TotalFee = ""; //CHECK IF IT HAS COMMAS IN IT, IF IT DOES ALERT THAT NUMBERS ARE NOT ALLOWED var str = String(document.BuildingWaterSupplies.ContractValue.value); if(document.BuildingWaterSupplies.ContractValue.value != "") { ContractValue = WholeNumber(document.BuildingWaterSupplies.ContractValue.value); if(ContractValue != 0) { if(ContractValue < 10000) { TotalFee = 0; VAT = 0; TotalPayable = 0; } else if(ContractValue < 38500) { TotalFee = 65; VAT = RoundUp(65 * 0.175); TotalPayable = 65 + VAT; } else { ContractValue = ContractValue * 0.0017; TotalFee = RoundUp(ContractValue); VAT = RoundUp(TotalFee * 0.175); TotalPayable = RoundUp(ContractValue + VAT); } } else { if(str.indexOf(",") >= 0){ alert("Do not enter commas in the contract value"); } } } if(str.indexOf(",") >= 0) { document.BuildingWaterSupplies.TotalFee.value = ""; document.BuildingWaterSupplies.VAT.value = ""; document.BuildingWaterSupplies.TotalPayable.value = ""; } else { document.BuildingWaterSupplies.TotalFee.value = moneyCheck(TotalFee); document.BuildingWaterSupplies.VAT.value = moneyCheck(VAT); document.BuildingWaterSupplies.TotalPayable.value = moneyCheck(TotalPayable); } } //------------------------------------------------------ //function to ensure numbers follow correct money format //------------------------------------------------------ function moneyCheck(x) { var answer; var number = x.toString(); //alert("number: "+number); var point = number.indexOf("."); //alert("pointplace: " +point); if(point>=1) { var firstpart = number.substring(0,point); var secondpart = number.substring(point+1,number.length); //alert("secondpart: "+secondpart); var checkpart = secondpart.substring(0,2); //alert("checkpart: "+checkpart); if(checkpart.length == 1) { secondpart=secondpart+"0"; //alert("add zero secondpart: "+secondpart); } answer = firstpart+"."+secondpart; //alert("answer: "+firstpart+"."+secondpart); } else { answer = number +".00"; //alert("answer: "+answer); } return answer; } //------------------------------------------------ // round up to 2 dec. pl. //------------------------------------------------ function RoundUp(x){ //return (Math.round(x * 100)) / 100; return (Math.round(x * 100)) / 100; } function WholeNumber(x){ if(isNaN(x)){ // alert("Not a number!"); return 0; } else{ var rem = x % Math.floor(x); //alert("Rem: " + rem); if(rem != 0){ x = Math.round(x); //alert("Rounded to " + x); // PUT THE NEW VALUE INTO THE CONTRACT VALUE FIELD //document.BuildingWaterSupplies.ContractValue.value = x; } return x; } } // Used for PR09 Project foundation function applyshades(){ var liItem = document.getElementsByName("countylist"); for (var i=0,j=1;i