//Show the summary and hide the detail
function ShowSummary()
{
	// Start Suckerfish for IE
	if (document.all&&document.getElementById) 
		sfHover();

	BoldSelected();
	externalLinks();
	if (document.getElementById('bdyGuestBook'))
	{	    
        if (document.getElementById('Posted').value == '1')
        {
            scrollTo(0, document.body.offsetHeight);
            document.getElementById('Posted').value = '0';
            document.getElementById('txtComment').value = "";
            document.getElementById('txtEmail').value = "";
            document.getElementById('txtFirstName').value = "";
            document.getElementById('txtLastName').value = "";
        }
	}
	else
	    GetSetVerticalScrollPos(0);
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

/* Opens and closes the items in the list, but only if something inside wasn't clicked */
function OpenClose(el, hdn)
{
    if (document.getElementById(hdn).value == '0') // Nothing has been clicked!
    {
        if (el.className == 'open')
            el.className = 'closed';
        else
            el.className = 'open';
    }
    else
        document.getElementById(hdn).value = '0'; // Reset the click indicator
}

/* Keeps the list open when we click on items within it */
function KeepOpen(hdn)
{
    document.getElementById(hdn).value = '1';
}

function SetTimeVal()
{
    //var d = new Date();
    //document.getElementById('CheckPosting').value = d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
    //var iHours = d.getHours() + 1;
    //var iMonth = d.getMonth() + 1;
    
    //document.getElementById('CheckPosting').value = iMonth + '/' + d.getDate() + '/' + d.getFullYear() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();;
}

/* function: ShowDetail()
 * Show the detail and hide the summary.
 */
function ShowDetail()
{
	el = document.getElementById("detail");
	el.className = 'show';	
	el = document.getElementById("summary");		
	el.className = 'hide';	
}

function BoldSelected()
{
	if (document.getElementsByTagName) 
	{
		var anchors = document.getElementsByTagName('a');
		for (var i=0; i < anchors.length; i++) 
		{
			var anchor = anchors[i];
			if ((anchor == location.href) || (anchor + 'index.aspx' == location.href))
			{	
				anchor.setAttribute('className', 'selected');
				anchor.setAttribute('class', 'selected');
			}
		}
	}	
}

/* Function: GetSetVerticalScrollPos
 * Purpose: Save the scroll position of the current form
 * Parameter: mode: 0 = restore, 1 = save
 * Note: Requires a hidden input field on the form...
 *       <input id="VerticalScrollPos" type="hidden" name="VerticalScrollPos" runat="server">
 */
function GetSetVerticalScrollPos(mode)
{
	f = document.getElementById('VerticalScrollPos');
	pos = 0;
		
	if (window.pageYOffset)
	{
		pos = window.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		pos = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		pos = document.body.scrollTop;
	}
	
	if (mode == 0 && f.value != "")
		scrollTo(0, f.value)
	else if (mode == 1)
		f.value = pos;
		
	setTimeout("GetSetVerticalScrollPos(1)", 500)
}