 // ############################################
// ## 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 = '<div id="divShareLinks">';
// del.icio.us
sharingList += '<a href="javascript:openExternal(\'http://del.icio.us/post?v=4&noui&jump=close&url='+url+'&title='+title+'\',true)"><img src="/images/misc/share_del.gif" align="absmiddle" border="0" />del.icio.us</a><br/>\n';
// Digg
sharingList += '<a href="javascript:openExternal(\'http://digg.com/submit?phase=2&url='+url+'&title='+title+'&bodytext='+abstr+'&topic=Tennis\',true)"><img src="/images/misc/share_digg.gif" align="absmiddle" border="0" />Digg</a><br/>\n';
// facebook
sharingList += '<a href="javascript:openExternal(\'http://www.facebook.com/sharer.php?u='+url+'&t='+title+'&e='+abstr+'&topic=Tennis\',true)"><img src="/images/misc/share_facebook.gif" align="absmiddle" border="0" />Facebook</a><br/>\n';
// Newsvine
sharingList += '<a href="javascript:openExternal(\'http://www.newsvine.com/_wine/save?popoff=1&u='+url+'&e='+abstr+'&h='+title+'\',true)"><img src="/images/misc/share_newsvine.gif" align="absmiddle" border="0" />Newsvine</a><br/>\n';
// permalink
sharingList += '<a href="javascript:void(0);" onClick="permaLink(\''+url+'\',\''+title+'\',\''+abstr+'\')"><img src="/images/misc/share_permalink.gif" align="absmiddle" border="0" />Permalink</a><br/>\n';
sharingList += '</div>'; 
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="/usg/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();
// 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','/includes/js/popup.js');
h[0].appendChild(s);
}
// call a function to record a page view
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="/includes/css/popup.css" type="text/css"/>');
//printWindow.document.write('<scr' + 'ipt src="/includes/js/popup.js" type="text/javascript">');
//printWindow.document.write('<\/scr' + 'ipt>');
printWindow.document.write('</head><body>');
printWindow.document.write('		<div id="popupcontainer">');
printWindow.document.write('			<div id="header"><img src="/images/misc/ma_he_emailfriend.gif" width="406" height="26" border="0" alt="Email this link to a friend"/></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)" onclick="sendemail(\'emailform\');"><img class="popupbtn" src="/images/misc/ma_ms_send.gif" width="85" height="15" border="0" alt="Send email"/></a>');
printWindow.document.write('				<a href="javascript:void(0)" onclick="window.close();"><img class="popupbtn" src="/images/misc/ma_ms_close.gif" width="110" height="15" border="0" alt="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','/includes/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,"\\'")));
