function headlinesShare()
{
var sp;
var thisURL;
var thisTitle;
if (sp = document.getElementById('headlinesShare'))
{
thisURL = window.location.href;
thisTitle = document.title;
sp.innerHTML = '<p><a href="javascript:window.print()">Print</a> | <a href="http://www.abc.net.au/cgi-bin/common/mailto/mailto-nojs_query.pl?'+ thisURL +'">Email</a>&nbsp;&nbsp; SHARE: <a href="http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url='+thisURL+';title='+thisTitle+'" target="_blank" onclick="window.open(\'http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url='+thisURL+';title='+thisTitle+'\', \'Delicious\',\'toolbar=no,width=700,height=600,resizable=yes\'); return false;">del.icio.us</a> | <a href="http://digg.com/submit?url='+thisURL+'" target="_blank" onclick="window.open(\'http://digg.com/submit?url='+thisURL+'\', \'Digg\',\'toolbar=no,width=800,height=600,resizable=yes,scrollbars=yes\'); return false;">Digg</a> | <a href="http://www.stumbleupon.com/newurl.php?url='+thisURL+'" target="_blank" onclick="window.open(\'http://www.stumbleupon.com/newurl.php?url='+thisURL+'\', \'StumbleUpon\',\'toolbar=no,width=800,height=600,resizable=yes,scrollbars=yes\'); return false;">StumbleUpon</a> | <a href="http://www.facebook.com/sharer.php?u=='+thisURL+'&amp;t='+thisTitle+'" target="_blank" onclick="window.open(\'http://www.facebook.com/sharer.php?u='+thisURL+'&amp;t='+thisTitle+'\', \'Facebook\',\'toolbar=no,width=800,height=600,resizable=yes,scrollbars=yes\'); return false;">Facebook</a> | <a href="http://www.google.com/bookmarks/mark?op=add&amp;hl=en&amp;bkmk='+thisURL+'&amp;annotation=&amp;labels=&amp;title='+thisTitle+'" target="_blank" onclick="window.open(\'http://www.google.com/bookmarks/mark?op=add&amp;hl=en&amp;bkmk='+thisURL+'&amp;annotation=&amp;labels=&amp;title='+thisTitle+'\', \'Google\',\'toolbar=no,width=800,height=600,resizable=yes,scrollbars=yes\'); return false;">Google</a> | <a href="http://www.angkorone.com" target="_blank" onclick="window.open(\'http://www.angkorone.com/share.aspx?u='+thisURL+'&t='+thisTitle+'\', \'Share\',\'toolbar=0,status=0,width=1000,height=540\'); return false;">AngkorOne</a></p>';
}	
}

//---------------------  Media functions required by all pages with media

// parameter "insertafter"- required for inpage players usually the object "this"

function paramcheck (pass_mediaurl, pass_insertafter, pass_mywidth, pass_myheight, pass_autoplay, pass_guid, pass_caption, pass_mediatitle, pass_medialink) {
	if (!pass_mediaurl) {return true} else {mediaurl = pass_mediaurl};
	if (!pass_insertafter) {return true} else {insertafter = pass_insertafter};
	if (!pass_mywidth) {mywidth = '100%'} else {	mywidth = pass_mywidth};
	if (!pass_myheight) {myheight = mywidth} else {myheight = pass_myheight	};
	if (!pass_autoplay) {autoplay = 'true'} else {autoplay = pass_autoplay};
	if (!pass_caption) {caption = ""} else {caption = pass_caption};
	if (!pass_mediatitle) {mediatitle = ""} else {mediatitle = pass_mediatitle};
	if (!pass_medialink) {medialink = ""} else {medialink = pass_medialink};

	playerstyle = 'inpage';
}

function showVideo (mediaurl, insertafter, mywidth, autoplay, guid, caption, mediatitle, medialink) {
	paramcheck(mediaurl, insertafter, mywidth, "", autoplay, guid, caption, mediatitle, medialink);
	media_type = "video";
	play_media();
		return false;
}

function showAudio (mediaurl, insertafter, mywidth, autoplay, guid, caption, mediatitle, medialink) {
	paramcheck(mediaurl, insertafter, mywidth, "", autoplay, guid, caption, mediatitle, medialink);
	media_type = "audio";
	play_media();
		return false;
}

function showPhotos () {
	slideshow = new Array();
	slideshowIndex = 0;
	gallery_items = (gallery_array.length - 1) /3;
	j = 1;
	// Load items into slideshow
	for (var i=0; i<gallery_items; i++) {
		slideshow[i] = new StoryPhoto(gallery_array[j], "285", gallery_array[j+1], gallery_array[j+2]);
		j = j + 3;
	}
	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('sspPhoto')) {
			var div = document.createElement('div');
			div.id = 'sspPhotoNav';
			div.innerHTML = '<a href="javascript:slideshowPrev();"><img style="float:left;" src="/img/common/space.gif" width="20" height="20" /></a><a href="javascript:slideshowNext();"><img style="float:right;" src="/img/common/space.gif" width="20" height="20" /></a>';
			sp.insertBefore(div, 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, navtext;
	if (img = document.getElementById('sspPhotoImg')) {
		if (img.src != slideshow[slideshowIndex].src) {
			img.src = slideshow[slideshowIndex].src;
			img.width = slideshow[slideshowIndex].width;
			img.title = slideshow[slideshowIndex].caption;
			img.alt = img.title;
		}
	}
	if (caption = document.getElementById('sspPhotoCaption')) {
		caption.innerHTML = slideshow[slideshowIndex].caption + " (" + slideshow[slideshowIndex].copyright + ")";
	}
	if (navtext = document.getElementById('sspPhotoNo')) {
		if(gallery_items > 1)
		{navtext.innerHTML = 'PHOTO ' + (slideshowIndex+1) + ' of ' + slideshow.length;}
		else {navtext.innerHTML = 'PHOTO ';}
	}
}

function StoryPhoto (src, width, caption, copyright) {
	this.src = src;
	this.width = width;
	this.caption = caption;
	this.copyright = copyright;
}

function play_media () {
	if (playerstyle == "external" || playerstyle == "") {
		open(mediaurl, "mediaplayer");
	} else {
	player_width = 330; //default size
	player_height = 160; //default size
	media_item = "";
	
		if (mediaurl.indexOf('.flv') != -1) {
			//newsplayer currently forces autoplay
			media_item = '<object class="player_flv" type="application/x-shockwave-flash" data="http://www.abc.net.au/news/swf/flvplayer.swf" width="' + player_width + '" height="' + player_height + '">';
			media_item += '<param name="movie" value="http://www.abc.net.au/news/swf/flvplayer.swf" />';
			media_item += '<param name="allowFullScreen" value="true" />';
			media_item += '<param name="wmode" value="transparent" />';
			media_item += '<param name="flashvars" value="mediaURL=' + mediaurl + '&autoPlay=' + autoplay + '" />';
			media_item += '<\/object>';
		}
		
		if (mediaurl.indexOf('.mp3') != -1) {
			//newsplayer currently forces autoplay
			player_height = Math.round(player_width / 7); 
			media_item = '<object class="player_mp3" type="application/x-shockwave-flash" data="http://www.abc.net.au/australianetwork/flash/player_mp3.swf" width="' + player_width + '" height="' + player_height + '">';
			media_item += '<param name="movie" value="http://www.abc.net.au/australianetwork/flash/player_mp3.swf" />';
			media_item += '<param name="wmode" value="transparent" />';
			media_item += '<param name="flashvars" value="mediaURL=' + mediaurl + '&autoPlay=' + autoplay + '&glassyplayer=false&playershadow=false&playerbgcolor=#2E2E2E&pausecolor=#FFFFFF&scrubcolor=#FFFFFF&scrubbgcolor=#1A1A1A&itemtimecolor=#FFFFFF&volumeiconcolor=#FFFFFF&timetextcolor=#FFFFFF&loadingbarcolor=#777777&loadingbgcolor=#FFFFFF" />';
			media_item += '<\/object>';
		}
		
		if ((mediaurl.indexOf('.jp') != -1) || (mediaurl.indexOf('.gif') != -1)) {
			media_item += '<img src="' + mediaurl + '" alt="" title="" border="0" width="' + player_width + '" />';
		}
		
		if (mediaurl.indexOf('google_map.htm') != -1) {
			media_item += '<iframe src="' + mediaurl + '" width="' + player_width  + '" height="' + player_height + '" frameborder="0" scrolling="no"></iframe>';
		}
		
		startInpage(media_item);
	}
}


function showMap (insertafter, mywidth, latitude, longitude, caption) {
	if (!latitude) return true;
	if (!longitude) return true;
	mediaurl = 'http://www.abc.net.au/local/maps/google_map.htm?latitude=' + encodeURIComponent(latitude) + '&amp;longitude=' + encodeURIComponent(longitude) + '&amp;caption=' + encodeURIComponent(caption);
	paramcheck (mediaurl, insertafter, mywidth, '', '', '', '', caption, '', '');
	media_type = "map";
	play_media();

	return false;
}



function startInpage (media_item) {
	if (temp = document.getElementById("inpageplayer")) {
		if (temp.parentNode == insertafter.parentNode) {  // i have the player
			removeInpage();
			return false;
		} else {   // my brother has the player
			removeInpage();
			var div = document.createElement("DIV");
			div.id = "inpageplayer";
			insertafter.parentNode.insertBefore(div, insertafter.nextSibling);
			div.innerHTML = media_item;
		}
	} else {   // nobody has the player
		var div = document.createElement('DIV');
		div.id = "inpageplayer";
		insertafter.parentNode.insertBefore(div, insertafter.nextSibling);
		div.innerHTML = media_item;
	}
}

function removeInpage() {
	if (temp = document.getElementById("inpageplayer")) {
		temp.innerHTML = "";
		temp.parentNode.removeChild(temp);
		delete temp;
	}
}


function addUnloadEvent(func)
{
	var oldonunload = window.onunload;
	if (typeof window.onunload != 'function'){
    	window.onunload = func;
	} else {
		window.onunload = function(){ oldonunload(); func(); };
	}
}


addUnloadEvent(removeInpage);
