
function ShowPageHeader()
{
	s = new String(location.href);
	s = FormatURL(s);


	var label1 = "test";
	var label2 = "test";


	if(GetActiveUser()!=null) {	
		document.write("   <td valign='top' width='111'>&nbsp;</td>");
		document.write("   <td valign='top' width='17'>&nbsp;</td>");
		document.write("   <td valign='top'><a href='javascript:logout();'><img border='0' src='http://www.absoluteastronomy.com/images/pageelements/logout.gif'></a></td>");
	}	
	else {
		document.write("   <td valign='top' width='111px'><a href='http://www.absoluteastronomy.com/usersettings.exe?url="+s+"'><img border='0' src='http://www.absoluteastronomy.com/images/pageelements/signup.gif' align='right'></a></td>");
		document.write("   <td valign='top' width='5'><img border='0' src='http://www.absoluteastronomy.com/images/pageelements/divider.gif'></td>");
		document.write("   <td valign='top'><a href='http://www.absoluteastronomy.com/login.exe?url="+s+"'><img border='0' src='http://www.absoluteastronomy.com/images/pageelements/login.gif' align='left'></a></td>");
	}
}

function ShowPageFooter()
{
	document.write("        <table border='0' cellpadding='0' style='border-collapse: collapse' width='100%'>");
	document.write("          <tr>");
	document.write("            <td height='25'>");
	document.write("            <font face='Arial' size='1'>");
	document.write("            <p align='right'><font color='#8a867a'>AbsoluteAstronomy.com © 2009.&nbsp; All Rights Reserved.&nbsp;&nbsp;</font>");
	document.write("            <a href='http://www.absoluteastronomy.com/about.htm'><font color='#316AC5'>About</font></a>&nbsp;");
	document.write("	    <font color='#7A776B'>|&nbsp;</font>");
	document.write("	    <a href='http://www.absoluteastronomy.com/privacy.htm'><font color='#316AC5'>Privacy Policy</font></a>&nbsp;");
	document.write("	    <font color='#7A776B'>|&nbsp;</font>");
	document.write("	    <a href='http://www.absoluteastronomy.com/terms.htm'><font color='#316AC5'>Terms of Use</font></a>&nbsp;");
	document.write("	    <font color='#7A776B'>|&nbsp;</font>");
	document.write("	    <a href='http://www.absoluteastronomy.com/Contact.exe'><font color='#316AC5'>Contact</font></a>&nbsp;&nbsp;</font></td>");
	document.write("          </tr>");
	document.write("        </table>");
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return null;
}

function setCookie(name, value, expires, path, domain, secure ) { 
	var today = new Date(); 
  	today.setTime(today.getTime());  
  	if (expires) {  
		expires = expires * 1000 * 60 * 60 * 24; 
	}

	var expires_date = new Date( today.getTime() + (expires) ); 
	document.cookie = name+'='+escape(value) + 
        ((expires) ? ';expires='+expires_date.toGMTString() : '') +  
        ((path) ? '; path=' + path : '') + 
        ((domain) ? ';domain=' + domain : '') + 
        ((secure) ? ';secure' : '');
} 

function login(username, url) {
	setCookie("username",username,500,"/");
	if(url!="")
	Redirect(url);
}

function logout() {
	setCookie("username","",-1,"/");
	
	alert("You are now logged out");
	window.location.reload();
}

function GetActiveUser() {
	return getCookie("username");
}

function PreCacheImages() {
	Image1= new Image(150,20);
	Image1.src = "http://www.absoluteastronomy.com/images/pageelements/greenback.gif";

	Image2 = new Image(10,30);
	Image2.src = "http://www.absoluteastronomy.com/images/pageelements/greengradienttab.gif";
}


function DisplayLink (url, label)
{
	url = "<a href='"+url+"' class='link1'>"+label+"</a>"
	document.write(url);
}

function GotoIconPage()
{
  document.UserForm.Action.value = "showicons";
  document.UserForm.submit();
}


function Redirect(url)
{

	//this.location.href = url;
	document.location.replace(url);
}

function FormatURL(url)
{
	s = new String((url));
	s = s.replace(/&/g,"*am");
	s = s.replace(/=/g,"*eq");
	s = s.replace(/\+/g,"*pl");
	s = s.replace(/\?/g,"*qu");

	return s;
}

function addbookmark(url,title)
{

        if (window.sidebar) { // firefox
              window.sidebar.addPanel(title, url,"");
        } 
	else if( document.all ) { //MSIE
                window.external.AddFavorite(url, title);
        } 
	else {
               alert("Sorry, your browser doesn't support this");
        }
}

function linkselect(label,linktext)
{
	prompt (label,linktext);
}



function Post(url)
{


	user = getCookie("username");
	
	s = new String(location.href);
	s = FormatURL(s);

	if (user!=null) 
	{
		s = "&url="+s;
			
		newurl = url+"&user="+user;
		newurl = "http://www.absoluteastronomy.com/"+newurl+s;

		window.location.href = newurl;
	}
	else
	{
		s = "?url="+s;
		alert("Sorry, you must be logged in to post a discussion message");
		newurl = "http://www.absoluteastronomy.com/login.exe";
		newurl = newurl+s;
		Redirect(newurl);
	}
}

function timer(sec, hoverpopup) {
	seconds=parseInt(sec)
	if(seconds>0) {
		seconds--
		timerID=setTimeout("timer(seconds)",1000)
	}else{
		HidePopup(hoverpopup)
	}
}


function showByLink2(SpanID,link,TopicID) {
    var OverviewText = document.getElementById(SpanID+"o").innerHTML;
    var test = GetHoverPopup(SpanID+"o",TopicID);    
    if (document.layers && document.layers[SpanID]) {
        document.layers[SpanID].top = link.y + 25
        document.layers[SpanID].display = 'block';
    }
    else if (document.all) {
        document.all[SpanID].style.display = 'block';

        if (document.all[SpanID].myFlag == null) {
            document.all[SpanID].style.posTop = document.all[SpanID].offsetTop + 25;
        }

        document.all[SpanID].myFlag = true;
    }
}

function showByLink(SpanID,link,ImagePath) {
    
    if (document.layers && document.layers[SpanID]) {
        document.layers[SpanID].top = link.y + 25
        document.layers[SpanID].display = 'block';
    }
    else if (document.all) {
        document.all[SpanID].style.display = 'block';

        if (document.all[SpanID].myFlag == null) {
            document.all[SpanID].style.posTop = document.all[SpanID].offsetTop + 25;
        }

        document.all[SpanID].myFlag = true;
    }
    //ImagePath = "<IMG SRC="+ImagePath+">";
    //ImagePath = "http://www.absoluteastronomy.com/images/pixel";
    //ImagePath = "<IMG SRC="+ImagePath+">";
    //OverviewText = document.getElementById(SpanID).innerHTML;	
    //OverviewText = OverviewText.replace("Topic Image", ImagePath);
    //document.getElementById(SpanID).innerHTML = OverviewText;
}

function hide(SpanID) {

    if (document.layers && document.layers[SpanID])
        document.layers[SpanID].display = 'none';
    else if (document.all)
        document.all[SpanID].style.display = 'none';
}

function WikipediaFooter (Page)
{
	document.write("<br><br><table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='100%'>");
	document.write("<tr><td width='100%'><font color='#737373' size='1' face='Arial'>The source of this article is </font>");
	document.write("<font size='1' face='Arial'><a class='link1' href='http://www.wikipedia.org/wiki/"+Page+"'>");
	document.write("Wikipedia</a></font><font color='#737373' size='1' face='Arial'>, the free encyclopedia.&nbsp; The text of this article is licensed under the </font>");
	document.write("<font size='1' face='Arial'><a class='link1' href='http://www.gnu.org/copyleft/fdl.html'>GFDL</a>.")
	document.write("</td></tr></table>");
}


function ShowThumbnail(ImageName) {
	var Folder1 = ImageName.substring(0, 1);
	var Folder2 = ImageName.substring(0, 2);
	var ImagePath = "<div class='thumb tleft'><img border='0' src='http://63.229.12.241/thumbs/"+Folder1+"/"+Folder2+"/"+ImageName+"'></div>";
	document.write(ImagePath);
}

function GetTodayInHistoryLink(type)
{
   var months=new Array(13);
   months[1]="January";
   months[2]="February";
   months[3]="March";
   months[4]="April";
   months[5]="May";
   months[6]="June";
   months[7]="July";
   months[8]="August";
   months[9]="September";
   months[10]="October";
   months[11]="November";
   months[12]="December";
   var time=new Date();
   var lmonth=months[time.getMonth() + 1];
   var date=time.getDate();

   if(type==1)
      document.write("<a class='linkbar1' href='http://www.absoluteastronomy.com/topics/" + lmonth + "_" + date +"'>&nbsp;Today in History</a>");
   else
      document.write("<a class='link6' href='http://www.absoluteastronomy.com/topics/" + lmonth + "_" + date +"'>more...</a>&nbsp;&nbsp;");
}
