 // ############################################
// ## Function: shareOptions - display/hide the
// ## sharing options div
// ## Arguments: none
// ############################################
function shareOptions()
{
var open = false;
if (document.getElementById('sharing'))
{
if(document.getElementById('sharing').style.display != 'block')
{
open = true;
}
if (open)
{
// document.getElementById('sharing').innerHTML = loadShare(pageURL,pageTitle.replace(/'/g,"\\'"),pageAbstr.replace(/'/g,"\\'"));
document.getElementById('sharing').style.display = 'block';
}
else
{
document.getElementById('sharing').style.display = 'none';
}
}
popupMeasure('shared');
}
// ############################################
// ## Function: loadShare - write the contents
// ## of sharing options div
// ## TODO: Allow additional sites via a config or object
// ## Arguments: url
// ## title
// ## abstr
// ############################################
function loadShare(url,title,abstr)
{
var sharingList = '<ul id="shareLinks">';
// del.icio.us
sharingList += '<li id="delicious"><a href="javascript:openExternal(\'http://del.icio.us/post?v=4&noui&jump=close&url='+url+'&title='+title+'\',true)">del.icio.us</a></li>';
// Digg
sharingList += '<li id="digg"><a href="javascript:openExternal(\'http://digg.com/submit?phase=2&url='+url+'&title='+title+'&bodytext='+abstr+'&topic=Tennis\',true)">Digg</a></li>';
// facebook
sharingList += '<li id="facebook"><a href="javascript:openExternal(\'http://www.facebook.com/sharer.php?u='+url+'&t='+title+'&e='+abstr+'&topic=Tennis\',true)">Facebook</a></li>';
// Newsvine
sharingList += '<li id="newsvine"><a href="javascript:openExternal(\'http://www.newsvine.com/_wine/save?popoff=1&u='+url+'&e='+abstr+'&h='+title+'\',true)">Newsvine</a></li>';
// permalink
sharingList += '<li id="permalink"><a href="javascript:void(0);" onClick="permaLink(\''+url+'\',\''+title+'\',\''+abstr+'\')">Permalink</a></li>';
sharingList += '</ul>'; 
return sharingList;
}
// ############################################
// ## Function: permaLink - write a pop-up 
// ## w/ the url, etc as cp-able contents
// ## Arguments: url
// ## title
// ## abstr
// ############################################
function permaLink(url,title,abstr)
{
printWindow = window.open('','perma_window','menubar=no,toolbar=no,scrollbars=no,width=434,height=440');
// Write the header and doc info to the new window
printWindow.document.write('<html><head><title>'+ decodeURIComponent(title) +'</title><link rel="stylesheet" href="/aus/css/popup.css" type="text/css"/>');
printWindow.document.write('</head><body>');
printWindow.document.write('		<div id="popupcontainer">');
printWindow.document.write('			<div id="header"><div>PERMALINK</div></div>');
printWindow.document.write('			<div id="popupform">');
printWindow.document.write('				<div style="padding: 10px 20px 15px 20px;">');
printWindow.document.write('					Select and copy the URL, title or description from the fields below and paste ');
printWindow.document.write('					them into your prefered bookmarking website or application.');
printWindow.document.write('				</div>');
printWindow.document.write('				<form id="emailform" class="cssform">');
printWindow.document.write('					<p>');
printWindow.document.write('						<label for="url">URL:</label>');
printWindow.document.write('						<textarea id="url" name="url" rows="2" cols="30" style="height:40px;" onfocus="this.select;">'+ decodeURIComponent(url) +'</textarea>');
printWindow.document.write('					</p>');
printWindow.document.write('					<p>');
printWindow.document.write('						<label for="title">Title:</label>');
printWindow.document.write('						<textarea id="title" name="title" rows="2" cols="30" style="height:40px;" onfocus="this.select;">'+ decodeURIComponent(title) +'</textarea>');
printWindow.document.write('					</p>');
printWindow.document.write('					<p>');
printWindow.document.write('						<label for="abstract">Description:</label>');
printWindow.document.write('						<textarea id="abstract" name="abstract" rows="4" cols="30" onfocus="this.select;">'+ decodeURIComponent(abstr) +'</textarea>');
printWindow.document.write('					</p>');
printWindow.document.write('					<div style="padding: 1px 20px 1px 20px;"></div>');
printWindow.document.write('				</form>');
printWindow.document.write('			</div>');
printWindow.document.write('			<div id="footer">');
printWindow.document.write('				<a href="javascript:void(0)" class="blackLink" onclick="window.close();">Close window</a>');
printWindow.document.write('			</div>');
printWindow.document.write('		</div>');
printWindow.document.write('</body></html>');
printWindow.document.close();
// call a function to record a page view
var h = printWindow.document.getElementsByTagName('head');
if (h != null)
{
// append the script
var s = printWindow.document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src','/aus/js/popup.js');
h[0].appendChild(s);
}
popupMeasure('permalink');
} 
// ############################################
// ## Function: email a friend - write a pop-up 
// ## w/ the url, etc as cp-able contents
// ## Arguments: url
// ## title
// ## abstr
// ############################################
function emailFriend(url,title,abstr)
{
printWindow = window.open('','email_window','menubar=no,toolbar=no,scrollbars=no,width=434,height=544');
// Write the header and doc info to the new window
printWindow.document.write('<html><head><title>'+ decodeURIComponent(title) +'</title><link rel="stylesheet" href="/aus/css/popup.css" type="text/css"/>');
printWindow.document.write('</head><body>');
printWindow.document.write('		<div id="popupcontainer">');
printWindow.document.write('			<div id="header"><div>Email a Friend</div></div>');
printWindow.document.write('			<div id="popupform">');
printWindow.document.write('				<form id="emailform" class="cssform">');
printWindow.document.write('					<input type="hidden" id="title" name="title" value="'+ decodeURIComponent(title) +'"/>');
printWindow.document.write('					<input type="hidden" id="url" name="url" value="'+ decodeURIComponent(url) +'"/>');
printWindow.document.write('					<p>');
printWindow.document.write('						<label for="email">SEND TO:</label>');
printWindow.document.write('						<input class="popupinput" type="text" id="email" name="email"/>');
printWindow.document.write('					</p>');
printWindow.document.write('					<p>');
printWindow.document.write('						<label for="cc">CC:</label>');
printWindow.document.write('						<input class="popupinput" type="text" id="cc" name="cc"/>');
printWindow.document.write('					</p>');
printWindow.document.write('					<p>');
printWindow.document.write('						<label for="message">ADD A PERSONAL MESSAGE:</label>');
printWindow.document.write('						<textarea id="message" name="message"></textarea>');
printWindow.document.write('					</p>');
printWindow.document.write('					<p>');
printWindow.document.write('						<label for="name">ENTER YOUR NAME:</label>');
printWindow.document.write('						<input class="popupinput" type="text" id="name" name="name"/>');
printWindow.document.write('					</p>');
printWindow.document.write('					<p>');
printWindow.document.write('						<label for="from">ENTER YOUR EMAIL ADDRESS:</label>');
printWindow.document.write('						<input class="popupinput" type="text" id="from" name="from"/>');
printWindow.document.write('					</p>');
printWindow.document.write('					<div style="padding: 5px 20px 25px 20px;">');
printWindow.document.write('						Note: Your name, email address, and that of your recipient, will be used only ');
printWindow.document.write('						in the case of transmission errors and to let the recipient know who sent the ');
printWindow.document.write('						story. The information will not be used for any other purpose.');
printWindow.document.write('					</div>');
printWindow.document.write('				</form>');
printWindow.document.write('			</div>');
printWindow.document.write('			<div id="footer">');
printWindow.document.write('				<a href="javascript:void(0)" class="blackLink" onclick="sendemail(\'emailform\');">Send email</a>');
printWindow.document.write('				<a href="javascript:void(0)" class="blackLink" onclick="window.close();">Close window</a>');
printWindow.document.write('			</div>');
printWindow.document.write('		</div>');
printWindow.document.write('</body></html>');
printWindow.document.close();
// get the header
var h = printWindow.document.getElementsByTagName('head');
if (h != null)
{
// append the script
var s = printWindow.document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src','/aus/js/popup.js');
h[0].appendChild(s);
}
// call a function to record a page view
popupMeasure('emailfriend');
} 
// ############################################
// ## Write the sharing links
// ############################################
document.write(loadShare(pageURL,pageTitle.replace(/'/g,"\\'"),pageAbstr.replace(/'/g,"\\'")));
