// News item struc function NewsItem( sNewsText, sNewsID ) { this.NewsText = sNewsText; this.NewsID = sNewsID; } // Array to hold news data var aNewsArray = new Array( new NewsItem( "“Best on the Beat” competition winners announced (03 March 2010)...", 246 ), new NewsItem( "Website shines the spotlight on increasing public confidence results (26 Februar...", 245 ), new NewsItem( "Chat with the Chair (19 February 2010)...", 244 )); // News ticker functions var iCurrentIndex = 0; var iCurrentChar = 0; var sBaseNewsURL = "/NewsDetails.aspx?n="; var sDisplayText = ""; var bGoTicker = true; var iMode = -1; // Load cookie news array if ( getCookie('CurrentNews') != null ) iCurrentIndex = getCookie('CurrentNews'); function GoTicker() { if ( !bGoTicker ) return false; // Display the next part of the news story var sArrayStoryText = aNewsArray[ iCurrentIndex ].NewsText; var iNewsID = aNewsArray[ iCurrentIndex ].NewsID; // If iCurrentChar = 0, then reset display if ( iCurrentChar == 0 ) { sDisplayText = ""; // document.all.TickerArea.innerHTML = ""; document.getElementById("TickerArea").innerHTML = ""; } if ( iCurrentChar >= sArrayStoryText.length ){ // Pause story - Ready next one iMode = 1; // Pause mode // Remember the current news array setCookie( 'CurrentNews', iCurrentIndex, '', '', '', '' ); if ( iCurrentIndex >= ( aNewsArray.length - 1 ) ){ iCurrentIndex = 0; } else { iCurrentIndex++; } iCurrentChar = 0; setTimeout("GoTicker()", 5000); } else { iMode = 2; // Drawing mode // Display var sStoryText = sArrayStoryText.charAt( iCurrentChar ); iCurrentChar++; // Add on the display text sDisplayText += sStoryText; document.getElementById('TickerArea').innerHTML = "Newsfeed: " + sDisplayText + "_"; // Display the text setTimeout("GoTicker()", 100); // TickerLink.href = sBaseNewsURL + iNewsID; } } function GotoNews() { // 3 Feb 2004 - Modified // Fixed issue with clicking on story when finished writing var iClickIndex = iCurrentIndex; if ( iMode == 1 ) // Paused { if ( iClickIndex == 0 ) { // If first, reset to last iClickIndex = aNewsArray.length - 1; } else { // Otherwise, reduce by one iClickIndex--; } } var iNewsID = aNewsArray[ iClickIndex ].NewsID; self.location.href = sBaseNewsURL + iNewsID; return true; } // ################## Cookie code #################### /* name - name of the cookie value - value of the cookie [expires] - expiration date of the cookie (defaults to end of current session) [path] - path for which the cookie is valid (defaults to path of calling document) [domain] - domain for which the cookie is valid (defaults to domain of calling document) [secure] - Boolean value indicating if the cookie transmission requires a secure transmission * an argument defaults when it is assigned null as a placeholder * a null placeholder is not required for trailing omitted arguments */ function setCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; } /* name - name of the desired cookie return string containing value of specified cookie or null if cookie does not exist */ function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } /* name - name of the cookie [path] - path of the cookie (must be same as path used to create cookie) [domain] - domain of the cookie (must be same as domain used to create cookie) path and domain default if assigned null or omitted if no explicit argument proceeds */ function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } // date - any instance of the Date object // * hand all instances of the Date object to this function for "repairs" function fixDate(date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); }