function showHideSources(storyId)
{
	var sourceDiv = document.getElementById(storyId + "Sources");
	var sourceLabel = document.getElementById(storyId + "SourceLabel");
	
	if(sourceDiv.style.display == "none")
	{
		sourceDiv.style.display = "block";
		sourceLabel.innerHTML = "Hide Sources";
	}
	else
	{
		sourceDiv.style.display = "none";
		sourceLabel.innerHTML = "View Sources";
	}
}

function openWindow(URL,name,attributes) 
{	
	popupWin = window.open(URL,name,attributes);
	popupWin.focus();
}

function showEmail(storyId, storyTitle)
{
	document.getElementById('emailStoryId').value = storyId;
	document.getElementById('storyTitle').innerHTML = storyTitle;
	document.getElementById('emailFormDiv').innerHTML = document.getElementById('emailFormContentDiv').innerHTML;
	YAHOO.example.container.panelEmail = new YAHOO.widget.Panel("panelEmail", { width:"330px", height:"450px", visible:false, fixedcenter:true, modal: true, constraintoviewport:true } );
	YAHOO.example.container.panelEmail.render();
	YAHOO.example.container.panelEmail.show();
}

function cancelEmail()
{
	YAHOO.example.container.panelEmail.hide();
}

function sendEmail(formObj)
{	
	var div = document.getElementById('emailFormDiv');		
	
	var callback = 
	{
        success : function(o) 
        {        	
            div.innerHTML = o.responseText;
        },
        failure : function(o) 
        {
            div.innterHTML = "Error processing email request";
        }
    }    
    
    div.innerHTML = '<img src="/tr3/images/loading.gif">';
    
	var postData = "emailStoryId=" + escape(formObj.emailStoryId.value) + "&fromAddress=" + escape(formObj.fromAddress.value) + "&toAddress=" + escape(formObj.toAddress.value) + "&comments=" + escape(formObj.comments.value);	      
	
    var conn = YAHOO.util.Connect.asyncRequest("POST", "/p/tqb/emailStory.jsp", callback, postData); 
}