/* ABC News common scripts Created by: Andrew Kesper, October 2006 Modified by: Andrew Kesper, April 2008 */ news = true; // News livery if (!getQueryStringVariable('site').match(/^(news)?$/)) news = false; // one-story-many-views /************* NEW FUNCTIONS ***************/ // Add new string functions String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }; String.prototype.toTitleCase = function() { var ls = this.toLowerCase(); var la = ls.split(' '); for (var i=0; i 0) return output; // If no elements were found, try this alternative method instead... // Works in Firefox 2, Safari, Opera: output = new Array(); var temp = xmlelement.getElementsByTagName(localname); for (var i=0; i elements; abort var itemsIndex; if (guid != null) { // guid specified; use with matching for (var i=0; i var url = ''; var content = getElementsByTagNameScope(items[itemsIndex], 'media', 'content'); var format = preferenceGet('video'); var connection = preferenceGet('connection'); if (connection == 'lo') var bestbitrate = 999999999; else var bestbitrate = 0; for (var j=0; j bestbitrate)) { bestbitrate = content[j].getAttribute('bitrate'); url = content[j].getAttribute('url'); } } } var link = items[itemsIndex].getElementsByTagName('link'); if (link.length > 0) if (typeof insertafter.href != 'undefined') if (insertafter.href.indexOf('.htm') != -1) if (link[0].firstChild.nodeValue != insertafter.href) var transcript = link[0].firstChild.nodeValue; if (url != '') { if (format == 'inpage') showVideo_play(url, insertafter, width, autoplay, transcript); else location = url; } else { // preferred format not available if (typeof insertafter.href != 'undefined') location = insertafter.href; } } else location = insertafter.href; // Media RSS file not available } } function showVideo_play (url, insertafter, width, autoplay, transcript) { classAdd(insertafter, 'active'); if (width.indexOf('%') != -1) var height = Math.round((parseInt(width, 10)/100)*insertafter.parentNode.scrollWidth/16*9); // width is a percentage else var height = Math.round(parseInt(width, 10)/16*9); // assume width is in pixels var div = document.createElement('DIV'); div.id = inpageplayer; div.className = 'videoplayer'; insertafter.parentNode.insertBefore(div, insertafter.nextSibling); window.onresize = function () { resize16x9(inpageplayer+'Object'); }; swfurl = 'http://www.abc.net.au/news/swf/flvplayer.swf'; var so = new SWFObject(swfurl, inpageplayer+'Object', width, height, '8', '#000000', true); so.addParam('allowFullScreen', 'true'); so.addVariable('mediaURL', url); so.addVariable('autoPlay', autoplay); so.write(inpageplayer); resize16x9(inpageplayer+'Object'); if (transcript) { if (!transcript.match(/news(_dev)?\/(audio|video)\//)) { var p = document.createElement('P'); p.innerHTML = 'View Transcript'; div.insertBefore(p, null); } } } function showAudio (mediaUrl, insertafter, width, autoplay, guid) { if (!mediaUrl) return true; if (!insertafter) return true; if (typeof insertafter == 'string') insertafter = document.getElementById(insertafter); if (!width) var width = '100%'; if (!autoplay) var autoplay = 'true'; if (!guid) var guid = null; if (temp = document.getElementById(inpageplayer)) { if (temp.previousSibling != null) classRemove(temp.previousSibling, 'active'); temp.parentNode.removeChild(temp); delete temp; } if (typeof nowPlaying != 'undefined' && nowPlaying == mediaUrl+'?'+guid) { // was already playing this item - don't want to play it again delete nowPlaying; } else { nowPlaying = mediaUrl+'?'+guid; if (mediaUrl.indexOf('.mp3') != -1) { // already know the MP3 file showAudio_play(mediaUrl, insertafter, width, autoplay); } else if (mediaUrl.indexOf('.xml') != -1 || mediaUrl.indexOf('.rss') != -1) { // need to read Media RSS file to determine MP3 file mediaUrl += (mediaUrl.indexOf('?') == -1 ? '?' : '&') + Math.floor(new Date().getTime()/(1000*60*2)); var ajaxobj = new XMLHttpRequest(); ajaxobj.onreadystatechange = function() {showAudio_ajax(ajaxobj, insertafter, width, autoplay, guid);}; ajaxobj.open('GET', mediaUrl, true); ajaxobj.send(''); } else { // assume we are directly linking to another type of media file (e.g. asx, ram) delete nowPlaying; location = mediaUrl; } } if (insertafter.blur) insertafter.blur(); // removes dotted outline from link in Mozilla browsers return false; } function showAudio_ajax (ajaxobj, insertafter, width, autoplay, guid) { if (ajaxobj.readyState == 4) { // only if "loaded" if (ajaxobj.status == 200 || ajaxobj.status == 304) { // only if "OK" var mediarss = ajaxobj.responseXML; // this is a document node var items = mediarss.getElementsByTagName('item'); if (items.length < 1) return true; // No elements; abort var itemsIndex; if (guid != null) { // guid specified; use with matching for (var i=0; i var url = ''; var content = getElementsByTagNameScope(items[itemsIndex], 'media', 'content'); var format = preferenceGet('audio'); for (var j=0; j 0) if (typeof insertafter.href != 'undefined') if (insertafter.href.indexOf('.htm') != -1) if (link[0].firstChild.nodeValue != insertafter.href) var transcript = link[0].firstChild.nodeValue; if (url != '') { if (format == 'inpage') showAudio_play(url, insertafter, width, autoplay, transcript); else location = url; } else { // preferred format not available if (typeof insertafter.href != 'undefined') location = insertafter.href; } } else location = insertafter.href; // Media RSS file not available } } function showAudio_play (url, insertafter, width, autoplay, transcript) { classAdd(insertafter, 'active'); if (width.indexOf('%') != -1) width = Math.round((parseInt(width, 10)/100)*insertafter.parentNode.scrollWidth); // Standard size of audio player is 285x40 pixels. Should be no bigger than this if (width > 285) width = 285; var height = Math.round(width/285*40); var div = document.createElement('DIV'); div.id = inpageplayer; div.className = 'audioplayer'; insertafter.parentNode.insertBefore(div, insertafter.nextSibling); window.onresize = function () {}; var swfurl = 'http://www.abc.net.au/news/swf/mp3player.swf'; var so = new SWFObject(swfurl, inpageplayer+'Object', width, height, '8', '#FFFFFF', true); so.addParam('allowFullScreen', 'true'); so.addVariable('mediaURL', url); so.addVariable('autoPlay', autoplay); so.write(inpageplayer); if (transcript) { if (!transcript.match(/news(_dev)?\/(audio|video)\//)) { var p = document.createElement('P'); p.innerHTML = 'View Transcript'; div.insertBefore(p, null); } } } function showPhotos (mediaUrl) { if (!mediaUrl) return true; if (mediaUrl.indexOf('.xml') != -1 || mediaUrl.indexOf('.rss') != -1) { // assume mediaUrl is a Media RSS file var ajaxobj = new XMLHttpRequest(); ajaxobj.onreadystatechange = function() {showPhotos_ajax(ajaxobj);}; ajaxobj.open('GET', mediaUrl, true); ajaxobj.send(''); } else { // can't do anything with mediaUrl return true; } return false; } function showPhotos_ajax (ajaxobj) { if (ajaxobj.readyState == 4) { // only if "loaded" if (ajaxobj.status == 200 || ajaxobj.status == 304) { // only if "OK" slideshow = new Array(); slideshowIndex = 0; // Load existing image into slideshow var img; if (img = document.getElementById('storyPhotosImg')) { slideshow[slideshow.length] = new StoryPhoto(img.src, img.width, img.height, (document.getElementById('storyPhotosCaption') ? document.getElementById('storyPhotosCaption').innerHTML : img.alt)); } delete img; // Load rest of items into slideshow var mediarss = ajaxobj.responseXML; // this is a document node var items = mediarss.getElementsByTagName('item'); for (var i=0; i parseInt(content[tallest].getAttribute('height'), 10)) tallest = m; versions[versions.length] = new StoryPhotoVersion(content[m].getAttribute('url'), parseInt(content[m].getAttribute('width'), 10), parseInt(content[m].getAttribute('height'), 10)); } for (var k=0; k 0 ? ' ('+source[0].firstChild.nodeValue+')' : ''), versions); addToSlideshow = false; } } } } slideshowInit(); } } } function slideshowInit () { if (typeof slideshow == 'undefined') return; if (slideshow.length < 1) return; if (typeof slideshowIndex == 'undefined') slideshowIndex = 0; if (slideshow.length > 1) { var sp; if (sp = document.getElementById('storyPhotos')) { var p = document.createElement('P'); p.id = 'storyPhotosNav'; p.innerHTML = ' '; sp.insertBefore(p, sp.firstChild); } } slideshowUpdate(); } function slideshowNext () { if (typeof slideshow == 'undefined') return; if (slideshow.length <= 1) return; if (typeof slideshowIndex == 'undefined') slideshowIndex = 0; if (slideshowIndex < slideshow.length-1) slideshowIndex++; else slideshowIndex = 0; if (slideshowIndex < slideshow.length-2) { var preload = new Image(); preload.src = slideshow[slideshowIndex+1].src; } slideshowUpdate(); } function slideshowPrev () { if (typeof slideshow == 'undefined') return; if (slideshow.length <= 1) return; if (typeof slideshowIndex == 'undefined') slideshowIndex = 0; if (slideshowIndex > 0) slideshowIndex--; else slideshowIndex = slideshow.length-1; slideshowUpdate(); } function slideshowUpdate () { if (typeof slideshow == 'undefined') return; if (slideshow.length < 1) return; if (typeof slideshowIndex == 'undefined') slideshowIndex = 0; var img, caption, link, navtext; if (img = document.getElementById('storyPhotosImg')) { if (img.src != slideshow[slideshowIndex].src) { currentFade = new Date().getTime(); opacitySet(img, 0, currentFade); img.style.visibility = 'hidden'; doFade = function () { img.src = slideshow[slideshowIndex].src; img.width = slideshow[slideshowIndex].width; img.height = slideshow[slideshowIndex].height; img.title = slideshow[slideshowIndex].caption; img.alt = img.title; img.onload = function () { img.style.visibility = 'visible'; setTimeout("opacityFade('storyPhotosImg', 0, 100, 150, "+currentFade+")", 100); }; } setTimeout("doFade()", 100); } } if (caption = document.getElementById('storyPhotosCaption')) { caption.innerHTML = slideshow[slideshowIndex].caption; } if (link = document.getElementById('storyPhotosLink')) { link.href = slideshow[slideshowIndex].versions[slideshow[slideshowIndex].biggest].src; link.onclick = function () { var img = slideshow[slideshowIndex].versions[slideshow[slideshowIndex].best]; imgWindow(img.src, null, img.width, img.height, slideshow[slideshowIndex].caption); return false; }; } if (navtext = document.getElementById('storyPhotosNavText')) { navtext.innerHTML = 'Slideshow: Photo '+(slideshowIndex+1)+' of '+slideshow.length; } } // StoryPhoto object function StoryPhoto (src, width, height, caption, versions) { this.src = src; this.width = width; this.height = height; this.caption = caption; if (versions) { this.versions = versions; // array of StoryPhotoVersion objects this.biggest = 0; // index of biggest version, compared by width*height this.best = 0; // index of version most suitable for this screen resolution for (var i=0; i'); w.document.writeln('' + title + ''); w.document.writeln(''); w.document.writeln('
'+title+'
'); w.document.writeln('
'); w.document.writeln('

'+caption+'

'); w.document.writeln('

Close Image

'); w.document.writeln(''); w.document.close(); if (window.focus) w.focus(); return false; } function resize16x9 (element) { if (typeof element == 'undefined') return; if (typeof element == 'string') { if (element = document.getElementById(element)); else return; } width = element.clientWidth; height = Math.round((width/16)*9); element.style.height = height+'px'; } /************* SLIDESHOWPRO PHOTO GALLERY *************/ function showGallery (mediaUrl, insertafter, openFirstAlbum) { if (typeof insertafter == 'undefined') return true; if (typeof insertafter == 'string') insertafter = document.getElementById(insertafter); if (typeof openFirstAlbum == 'undefined') var openFirstAlbum = false; var div = document.createElement('DIV'); div.id = inpageplayer; div.className = 'galleryplayer'; insertafter.parentNode.insertBefore(div, insertafter.nextSibling); mediaUrl += encodeURIComponent((mediaUrl.indexOf('?') == -1 ? '?' : '&') + Math.floor(new Date().getTime()/(1000*60*2))); // ensures fresh request every 2 minutes var so = new SWFObject('/news/swf/slideshow.swf', 'slideshowpro', '100%', 460, '8', '#000000', true); so.addParam('allowFullScreen', 'true'); if (typeof mediaUrl != 'undefined') so.addVariable('xmlFilePath', mediaUrl); if (openFirstAlbum) so.addVariable('startMode', 'album'); so.write(inpageplayer); } /************* MAPPING ***************/ function showMap (insertafter, width, latitude, longitude, caption) { if (!insertafter) return true; if (!width) var width = '100%'; if (!latitude) return true; if (!longitude) return true; if (!caption) var caption = ''; if (insertafter.nextSibling != null && classExists(insertafter.nextSibling, 'map')) { // collapse video player if already open if (insertafter != null) classRemove(insertafter, 'active'); insertafter.nextSibling.parentNode.removeChild(insertafter.nextSibling); } else { classAdd(insertafter, 'active'); var div = document.createElement('DIV'); div.className = 'map'; div.style.width = width; div.style.height = '1px'; insertafter.parentNode.insertBefore(div, insertafter.nextSibling); resize16x9(div); div.innerHTML = (''); } if (insertafter.blur) insertafter.blur(); // removes dotted outline from link in Mozilla browsers return false; } /************* COOKIES ***************/ function setCookie(name, value, expires, path, domain, secure) { document.cookie= name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } 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)); } 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"; } /************* OPACITY ***************/ // (adapted from: http://www.brainerror.net/scripts_js_blendtrans.php) // Fade from one opacity setting to another function opacityFade (object, opacStart, opacEnd, millisec, thisFade) { if (!thisFade) var thisFade = new Date().getTime(); currentFade = thisFade; //speed for each frame var skip = 10; var speed = Math.round((millisec / 100) * skip); var timer = 0; //determine the direction for the blending, if start and end are the same nothing happens if (opacStart > opacEnd) { for (var i=opacStart; i>=opacEnd; i-=skip) { setTimeout("opacitySet('" + object + "', " + i + ", "+thisFade+")",(timer * speed)); timer++; } } else if (opacStart < opacEnd) { for (var i=opacStart; i<=opacEnd; i+=skip) { setTimeout("opacitySet('" + object + "', " + i + ", "+thisFade+")",(timer * speed)); timer++; } } } // Change the opacity for different browsers function opacitySet (object, opacity, thisFade) { if (thisFade && typeof currentFade != 'undefined') { if (thisFade != currentFade) { return; } } if (typeof object == 'string') object = document.getElementById(object); object = object.style; object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); object.filter = (opacity < 100 ? "alpha(opacity=" + opacity + ")" : "none"); } /************* ENABLE WATCHLIST AND CLIPPINGS ***************/ if (news) addLoadEvent(enableMyStuff); function enableMyStuff () { var x; // items will be inserted after this element if (document.body.id == 'newshome') x = document.getElementById('tools').lastChild; else x = document.getElementById('search'); if (x) { // My Stories if (!document.getElementById('clippings')) { var cDiv = document.createElement('DIV'); cDiv.className = 'section'; cDiv.innerHTML = 'Help

My Stories

'; x.parentNode.insertBefore(cDiv, x.nextSibling); } // My Tags if (!document.getElementById('watchlist')) { var wDiv = document.createElement('DIV'); wDiv.className = 'section'; wDiv.innerHTML = 'Help

My Tags

'; x.parentNode.insertBefore(wDiv, x.nextSibling); } } } /************* WATCHLIST FUNCTIONALITY ***************/ if (news) addLoadEvent(populateWatchlist); // Cookie format: tag1;tag2;tag3 etc. var watchlistCookie = 'newsMyTags'; function watchlistAdd (title) { lbHide_do(); if (watchlistExists(title)) return false; // If we have reached this point, we need to set the cookie var exp = new Date().getTime(); exp += 1000*60*60*24*31; // expire 1 month from now exp = new Date(exp); var cookieData = getCookie(watchlistCookie); setCookie(watchlistCookie, (cookieData==null || cookieData.trim()=='' ? '' : cookieData+';')+title, exp, '/', '.abc.net.au'); if (!watchlistExists(title)) { var cookieData = getCookie(watchlistCookie); if (cookieData == null || cookieData == '') alert('Sorry, this tag could not be added.\n\nPlease ensure that cookies are enabled in your web browser.'); else alert('Sorry, this tag could not be added.\n\nYou may have too many items in My Tags.'); } else populateWatchlist(title); return false; } function watchlistRemove (title) { lbHide_do(); var cookieData = getCookie(watchlistCookie); if (cookieData == null) { return false; } var removed = false; var watchlist = cookieData.split(';'); for (var i=0; i'+watchlist[i].replace(/-/g, '-')+''; } if (html!='') html = '
    '+html+'
'; } if (html=='' || cookieData==defaultWatchlist) html += '

Add Tag Page links here to follow news categories important to you.

'; html += '

View all tags | Tag cloud

'; w.innerHTML = html; tagPageMyTags(); } processLinks(); } function tagPageMyTags () { if (document.URL.match(/\/tag\/[^\.]+\//)) { // if currently on a tag page tagname = document.URL; tagname = tagname.replace(/^.*\/tag\//, ''); tagname = tagname.replace(/\/.*$/, ''); var wla; var tl; if (wla = document.getElementById('watchlistAdd')) { if (watchlistExists(tagname)) { wla.onclick = function () { return watchlistRemove(tagname) }; wla.innerHTML = 'Remove from My Tags'; } else { wla.onclick = function () { return watchlistAdd(tagname) }; wla.innerHTML = 'Add to My Tags'; } } if (tl = document.getElementById('tl')) { var tp; if (tp = document.getElementById('tp')) tp.innerHTML = ''; else { tp = document.createElement('P'); tl.parentNode.insertBefore(tp, tl); } if (watchlistExists(tagname)) tp.innerHTML = 'Remove \''+tagname.replace(/-/g, '-')+'\' from My Tags'; else tp.innerHTML = 'Add \''+tagname.replace(/-/g, '-')+'\' to My Tags'; } } } /************* CLIPPINGS FUNCTIONALITY ***************/ if (news) addLoadEvent(populateClippings); // Cookie format: url1~title1;url2~title2;url3~title3 etc. var clippingsCookie = 'newsMyStories'; function clippingAdd (url, title) { lbHide_do(); url = url.replace(/^[a-z]+:\/\/[^\/]+/, ''); // discard the domain name, we only need the path to the web page title = title.replace(/(<[^>]+>|Related Story:)/ig, '').trim(); // discard HTML tags and "Related Story:" in title if (clippingExists(url)) return false; // If we have reached this point, we need to set the cookie var exp = new Date().getTime(); exp += 1000*60*60*12; // expire 12 hours from now exp = new Date(exp); var cookieData = getCookie(clippingsCookie); setCookie(clippingsCookie, (cookieData==null || cookieData.trim()=='' ? '' : cookieData+';')+url+'~'+title, exp, '/', '.abc.net.au'); if (!clippingExists(url)) { var cookieData = getCookie(clippingsCookie); if (cookieData == null || cookieData == '') alert('Sorry, this story could not be added.\n\nPlease ensure that cookies are enabled in your web browser.'); else alert('Sorry, this story could not be added.\n\nYou may have too many items in My Stories.'); } else populateClippings(url); storytools(); return false; } function clippingRemove (url) { lbHide_do(); var cookieData = getCookie(clippingsCookie); if (cookieData == null) { return false; } var removed = false; var clippings = cookieData.split(';'); for (var i=0; i'+x[1]+''; } c.innerHTML = '
    '+html+'
'; } } processLinks(); } function lbHide () { lbTimeout = window.setTimeout('lbHide_do();', 1500); } function lbHide_do () { var lb; if (lb = document.getElementById('linkButton')) lb.parentNode.removeChild(lb); } function lbHide_abort () { if (window.lbTimeout) window.clearTimeout(lbTimeout); } function processLinks () { var links = document.getElementsByTagName('A'); var storyPageRegex = /(news|news_dev)\/(items|newsitems|stories|video|audio|photos)\/[0-9]{4}.*/; var tagPageRegex = /(news|news_dev)\/tag\/[-'A-Za-z0-9]+\/?$/; for (var i=0; i]+>)/ig, '').trim() != '' && !classExists(links[i], 'more')) myStoriesLink(links[i]); else if (tagPageRegex.test(links[i].href) && links[i].innerHTML.replace(/(<[^>]+>)/ig, '').trim() != '' && !classExists(links[i], 'more')) myTagsLink(links[i]); } } function myStoriesLink (link) { link.onmouseout = function (e) { if (typeof lbHide == 'function') lbHide(); }; link.onmouseover = function (e) { if (typeof lbHide_abort == 'function') lbHide_abort(); if (typeof lbHide_do == 'function') lbHide_do(); var side = 'right'; if (link.parentNode.nodeName.match(/^(li|h[1-6])$/i)) { var parentText = link.parentNode.innerHTML.replace(/<[^>]+>/g, '').trim(); var linkText = link.innerHTML.replace(/<[^>]+>/g, '').trim(); if (parentText.indexOf(linkText) == 0) side = 'left'; } if (link.parentNode.scrollWidth == link.scrollWidth) { side = 'left'; } var lb = document.createElement('A'); lb.id = 'linkButton'; lb.appendChild(document.createTextNode(' ')); lb.onmouseover = function (f) { if (typeof lbHide_abort == 'function') lbHide_abort(); }; lb.onmouseout = function (f) { if (typeof lbHide == 'function') lbHide(); }; if (typeof clippingExists == 'function' && clippingExists(this.href)) { lb.className = 'lb_'+side+'_remove_blue'; lb.title = 'Remove from My Stories'; lb.alt = lb.title; lb.href = 'javascript:clippingRemove("'+this.href.replace(/"/g, '\"')+'");'; } else { lb.className = 'lb_'+side+'_add_blue'; lb.title = 'Add to My Stories'; lb.alt = lb.title; lb.href = 'javascript:clippingAdd("'+this.href.replace(/"/g, '\"')+'", "'+this.innerHTML.replace(/(<[^>]+>|Related Story:)/ig, '').trim().replace(/"/g, '\"')+'");'; } lb.onclick = function (f) { eval(this.href.replace(/^javascript:/, '')); return false; }; this.parentNode.insertBefore(lb, (side=='left' ? this : this.nextSibling)); } } function myTagsLink (link) { link.onmouseout = function (e) { if (typeof lbHide == 'function') lbHide(); }; link.onmouseover = function (e) { if (typeof lbHide_abort == 'function') lbHide_abort(); if (typeof lbHide_do == 'function') lbHide_do(); var side = 'right'; if (link.parentNode.nodeName.match(/^(li|h[1-6])$/i)) { var parentText = link.parentNode.innerHTML.replace(/<[^>]+>/g, '').trim(); var linkText = link.innerHTML.replace(/<[^>]+>/g, '').trim(); if (parentText.indexOf(linkText) == 0) side = 'left'; } if (link.parentNode.scrollWidth == link.scrollWidth) { side = 'left'; } var tagname = this.href; tagname = tagname.replace(/^.*\/tag\//, ''); tagname = tagname.replace(/\/.*$/, ''); var lb = document.createElement('A'); lb.id = 'linkButton'; lb.appendChild(document.createTextNode(' ')); lb.onmouseover = function (f) { if (typeof lbHide_abort == 'function') lbHide_abort(); }; lb.onmouseout = function (f) { if (typeof lbHide == 'function') lbHide(); }; if (typeof watchlistExists == 'function' && watchlistExists(tagname)) { lb.className = 'lb_'+side+'_remove_green'; lb.title = "Remove '"+tagname+"' from My Tags"; lb.alt = lb.title; lb.href = 'javascript:watchlistRemove("'+tagname.replace(/"/g, '\"')+'");'; } else { lb.className = 'lb_'+side+'_add_green'; lb.title = "Add '"+tagname+"' to My Tags"; lb.alt = lb.title; lb.href = 'javascript:watchlistAdd("'+tagname.replace(/"/g, '\"')+'");'; } lb.onclick = function (f) { eval(this.href.replace(/^javascript:/, '')); return false; }; this.parentNode.insertBefore(lb, (side=='left' ? this : this.nextSibling)); } } function storytools () { var st; if (st = document.getElementById('storytools')) { var html = ''; html += 'Print Email'; if (document.URL.match(/(news|news_dev)\/(items|newsitems|stories|video|audio|photos)\/[0-9]{4}.*/)) { if (clippingExists(document.URL)) html += ' Remove from My Stories'; else html += ' Add to My Stories'; } var com; if (com = document.getElementById('comments')) { html += ' '+com.getElementsByTagName('H2')[0].innerHTML+''; } st.innerHTML = html; } } if (news) addLoadEvent(storytools); function printStory () { printStoryClose(); var sp, sc, o; sp = document.getElementById('storyPhotos'); sc = document.getElementById('comments'); o = new Array(); if (sp) { o[o.length] = ' '; } if (sc) { o[o.length] = ' '; } if (o.length > 0) { var html = '

Print Options

'+o.join('
')+'

'; var ps = document.createElement('DIV'); ps.id = 'printStoryDialog'; ps.className = 'dialog noprint'; ps.innerHTML = html; var st = document.getElementById('storytools'); st.parentNode.insertBefore(ps, st.nextSibling); } else { window.print(); } } function printStoryClose() { var psd; if (psd = document.getElementById('printStoryDialog')) psd.parentNode.removeChild(psd); } /************* IMAGE TOOLTIPS ****************/ // For each image, if title attribute is empty, set it to equal the alt attribute function processImages() { var images = document.getElementsByTagName('IMG'); for (var i=0; i'; } processLinks(); processImages(); classRemove(target, 'ajaxLoading'); } }; req.open('GET', url, true); req.send(''); } } // Load content into target container when tab is clicked function tabLoad (tabLink, target, url, onsuccess) { if (typeof target == 'string') target = document.getElementById(target); setClassUnsetSiblings(tabLink.parentNode, 'active'); simpleAjax(url, target, onsuccess); if (tabLink.blur) tabLink.blur(); // removes dotted outline from link in Mozilla browsers return false; } function stateTabLoad (state) { // for state headlines on news home page tabLoad(document.getElementById('t-'+state), 'stateContent', '/news/indexes/idx-'+state+'/top3.inc', copyFitStateHeadlines); preferenceSet('state', state); return false; } function copyFitStateHeadlines () { copyfit('topstory', 'topstories', document.getElementById('stateContent').getElementsByTagName('UL')[0], 3); } // copyfit: Get heights of 'columnA' and 'columnB' as close as possible by removing items from 'list' (however 'list' will always have at least 'stopAt' number of items) function copyfit (columnA, columnB, list, stopAt) { if (typeof columnA == 'string') columnA = document.getElementById(columnA); if (typeof columnB == 'string') columnB = document.getElementById(columnB); if (typeof list == 'string') list = document.getElementById(list); if (typeof list == 'undefined') var list = columnA.parentNode.getElementsByTagName('UL')[0]; if (typeof stopAt == 'undefined') var stopAt = 3; if (columnA && columnB && list) { if (contains(columnA, list)) { var listColumn = columnA; var otherColumn = columnB; } else if (contains(columnB, list)) { var listColumn = columnB; var otherColumn = columnA; } else return; // list sits outside both columns - abort var items = new Array(); for (var i=0; i0; i--) items[numVisible-1].style.display = 'block'; } } // Finds out if 'a' is an ancestor of 'b' function contains (a, b) { // climb through 'b' parents till we find 'a' while (b && (a != b) && (b != null)) b = b.parentNode; return a == b; } /************ MISCELLANEOUS FUNCTIONS **************/ // Give focus to the first text/textarea form element in the document function formFocus () { var inputs = document.getElementsByTagName('INPUT'); for (var i=0; i 0) inputs[0].focus(); } function thumnbailScrollerGenerate (containerid) { var container; var colnames = new Array('column5a','column5b','column5c','column5d','column5e'); if (container = document.getElementById(containerid)) { if (!window.highlightScroller) highlightScroller = new Object(); var controls = document.createElement('DIV'); controls.id = containerid+'_controls'; controls.className = 'highlightscrollercontrols'; var temp = container.childNodes; var divs = new Array(); for (var i=0; i 5) controls.appendChild(aprev); for (var i=0; i 5) controls.appendChild(a); } var anext = document.createElement('A'); anext.id = containerid+'_show_next'; anext.className = 'next'; anext.href = 'javascript:highlightScrollerMoveBy("'+containerid+'", 1);'; anext.onclick = function (f) { eval(this.href.replace(/^javascript:/, '')); return false; }; var anextimg = document.createElement('IMG'); anextimg.src = '/news/img/2007/blank.gif'; anextimg.width = 26; anextimg.height = 16; anext.appendChild(anextimg); if (divs.length > 5) controls.appendChild(anext); container.parentNode.insertBefore(controls, container.nextSibling); highlightScrollerMoveTo(containerid, 0); } } // Generate a scrollable feature thingy function highlightScrollerGenerate (containerid) { var container; if (container = document.getElementById(containerid)) { if (classExists(container, 'thumbnailscroller')) { thumnbailScrollerGenerate(containerid); return; } if (!window.highlightScroller) highlightScroller = new Object(); var controls = document.createElement('DIV'); controls.id = containerid+'_controls'; controls.className = 'highlightscrollercontrols'; var temp = container.childNodes; var divs = new Array(); for (var i=0; i 2) controls.appendChild(aprev); for (var i=0; i 2) controls.appendChild(a); } var anext = document.createElement('A'); anext.id = containerid+'_show_next'; anext.className = 'next'; anext.href = 'javascript:highlightScrollerMoveBy("'+containerid+'", 1);'; anext.onclick = function (f) { eval(this.href.replace(/^javascript:/, '')); return false; }; var anextimg = document.createElement('IMG'); anextimg.src = '/news/img/2007/blank.gif'; anextimg.width = 26; anextimg.height = 16; anext.appendChild(anextimg); if (divs.length > 2) controls.appendChild(anext); container.parentNode.insertBefore(controls, container.nextSibling); highlightScrollerMoveTo(containerid, 0); } } function highlightScrollerMoveTo (containerid, num) { highlightScroller[containerid+'_current'] = num; displayThisHideSiblings(containerid+'_'+highlightScroller[containerid+'_current']); setClassUnsetSiblings(containerid+'_show_'+highlightScroller[containerid+'_current'], 'active'); } function highlightScrollerMoveBy (containerid, num) { highlightScroller[containerid+'_current'] += num; if (highlightScroller[containerid+'_current'] >= highlightScroller[containerid+'_length']) highlightScroller[containerid+'_current'] -= highlightScroller[containerid+'_length']; else if (highlightScroller[containerid+'_current'] < 0) highlightScroller[containerid+'_current'] += highlightScroller[containerid+'_length']; displayThisHideSiblings(containerid+'_'+highlightScroller[containerid+'_current']); setClassUnsetSiblings(containerid+'_show_'+highlightScroller[containerid+'_current'], 'active'); } function displayThisHideSiblings (element) { // 'element' can be a DOM element or a string representing the ID of a DOM element if (typeof element == 'undefined') return; if (typeof element == 'string') element = document.getElementById(element); var x = element.previousSibling; while (x != null) { if (x.nodeType == 1) x.style.display = 'none'; x = x.previousSibling; } x = element.nextSibling; while (x != null) { if (x.nodeType == 1) x.style.display = 'none'; x = x.nextSibling; } element.style.display = 'block'; } function setClassUnsetSiblings (element, theclass) { // 'element' can be a DOM element or a string representing the ID of a DOM element if (element == null) return; if (typeof element == 'undefined') return; if (typeof element == 'string') { if (document.getElementById(element)) element = document.getElementById(element); else return; } var x = element.previousSibling; while (x != null) { classRemove(x, theclass); x = x.previousSibling; } x = element.nextSibling; while (x != null) { classRemove(x, theclass); x = x.nextSibling; } classAdd(element, theclass); } // Open link in a popup window function popup (url, width, height, windowname) { if (!width) var width = 600; if (!height) var height = 400; if (!windowname) var windowname = 'abcnewspopup'+new Date().getTime(); if (url.indexOf('?') != -1) url += '&layout=popup'; else url += '?layout=popup'; var left = screen.width/2 - width/2; var top = screen.height/2 - height/2; window.open(url, windowname, 'width='+width+',height='+height+',toolbar=0,resizable=1,scrollbars=1,left='+left+',top='+top); return false; } /************ NEWSRADIO WIDGET FUNCTIONS **************/ function nrInit () { if (nr = document.getElementById('newsradio-widget-nowplaying')) { nrText = nr.innerHTML.replace(/<[^>]+>/g, '').trim(); // original text, HTML tags removed nr.innerHTML = nrText; if (nr.scrollWidth > nr.clientWidth) { // if the text is longer than the space allocated for it nrOn = false; // ticker enabled? nrRev = false; // reverse direction? nrSubstr = 0; // character position to display text from nr.onmouseover = function () { if (!nrOn) { nrOn = true; nrGo(); } }; nr.onmouseout = function () { nrStop(); }; } } } function nrGo() { var nrChange = false; // change direction? if (nrRev) { if (nrSubstr == 0) nrChange = true; // if start of text is visible else nrSubstr--; } else { if (nr.scrollWidth <= nr.clientWidth) nrChange = true; // if end of text is visible else nrSubstr++; } if (nrChange) { nrRev = !nrRev; nrTimeout = setTimeout('nrGo();', 2000); } else { //nr.innerHTML = nrText.substr(nrSubstr).replace(/ +/, ' '); nr.style.textIndent = '-'+(nrSubstr)+'px'; nrTimeout = setTimeout('nrGo();', 30); } } function nrStop() { clearTimeout(nrTimeout); //nr.innerHTML = nrText; nr.style.textIndent = '0'; nrOn = false; nrRev = false; nrSubstr = 0; } if (news) addLoadEvent(nrInit); /************ COUNTER FUNCTIONS **************/ function setCountersSourceHit() { if (document.getElementById('imgCounter')) { var blnEnabled = true; // enable/disable the hit counter var blnValidDomain = (document.URL.indexOf('http://www2b.abc.net.au/') != 0); var blnValidURL = (document.URL.indexOf('start_rank') == -1); if (blnEnabled && blnValidDomain && blnValidURL) { // set the image source to the counter URL + query string containing document URL document.getElementById('imgCounter').src = 'http://www2b.abc.net.au/Counters/Client/Hit.aspx?' + encodeURIComponent(document.URL); } } } addLoadEvent(setCountersSourceHit); /** * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/ * * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License: * http://www.opensource.org/licenses/mit-license.php * */ if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="";_19+="";var _1d=this.getParams();for(var key in _1d){_19+="";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="";}_19+="";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.majorfv.major){return true;}if(this.minorfv.minor){return true;}if(this.rev=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject; /************ DATE FUNCTIONS **************/ // Return true if dateObj falls within Australian Eastern Daylight Time (Sydney) function daylightSavings (dateObj) { var aedt = new Array( /*'October 29, 1995','March 31, 1996', 'October 27, 1996','March 30, 1997', 'October 26, 1997','March 29, 1998', 'October 25, 1998','March 28, 1999', 'October 31, 1999','March 26, 2000', 'August 27, 2000','March 25, 2001',*/ 'October 28, 2001','March 31, 2002', 'October 27, 2002','March 30, 2003', 'October 26, 2003','March 28, 2004', 'October 31, 2004','March 27, 2005', 'October 30, 2005','April 2, 2006', 'October 29, 2006','March 25, 2007', 'October 28, 2007','April 6, 2008', 'October 26, 2008','April 5, 2009', 'October 25, 2009','March 28, 2010', 'October 31, 2010','March 27, 2011', 'October 30, 2011','March 25, 2012', 'October 28, 2012','March 31, 2013', 'October 27, 2013','March 30, 2014', 'October 26, 2014','March 29, 2015', 'October 25, 2015','March 27, 2016', 'October 30, 2016','March 26, 2017'); var dateInt = dateObj.getTime(); var ds; for (var i=0; i12 ? spans[i].ts.getHours()-12 : (spans[i].ts.getHours()==0 ? 12 : spans[i].ts.getHours()))+':'+(spans[i].ts.getMinutes().toString().length==1 ? '0' : '')+spans[i].ts.getMinutes()+(spans[i].ts.getHours()>11 ? 'pm' : 'am')+' '+(daylightSavings(spans[i].ts) ? 'AEDT' : 'AEST'); } } } relativeTimestampsTimeout = window.setTimeout('relativeTimestamps()', 1000*60); } addLoadEvent(relativeTimestamps); function setActiveNav () { if (document.getElementById('nav_1st') && document.getElementById('nav_2nd')) { if (typeof activenav == 'string') setClassUnsetSiblings(document.getElementById('n-'+activenav), 'active'); else if (getQueryStringVariable('section') != '') { setClassUnsetSiblings(document.getElementById('n-'+getQueryStringVariable('section')), 'active'); } else if (window.location.pathname == '/news/' || window.location.pathname == '/news/default.htm') setClassUnsetSiblings(document.getElementById('n-newshome'), 'active'); else { var sections = new Array('justin','australia','world','business','sport','entertainment','weather','opinion','blogs','video','audio','photos','feeds','alerts'); for (var i=0; i 1) { for (var i=0; i rHighlights.length-1) num = 0; // positive overflow if (typeof now == 'undefined') var now = false; if (now) rHighlightAutomatic = false; rHighlightNewObj = rHighlights[num]; for (var i=0; i