function writeMenu(Page)
{
  with (document)
  {
    write("");
    var j = 0;
    var first;
	var contentvalue;

	for (i in Page)
    {
	   first = i;
	   contentvalue = Page[i];
		if (j>0)
	   {
       write("<font color=\"#ffffff\"> | </font>");
	   }
	   	
	   if (contentvalue.substring(0, 7)=="http://")
	   {
		   write("<a href=\"" + contentvalue + "\">");
		   write(i);
		   write("</a>");

	   }
       else {
		   write("<a href=\"#\" onClick=\"setContent('"+i+"');\">");
		   write(i);
		   write("</a>");
       }
       j++
    }
  }
}
function writeSubList(List)
{
  with (document)
  {
    write("");
    var j = 0;
    var first;
	var contentvalue;

	for (i in List)
    {
	   first = i;
	   contentvalue = List[i];
		if (j>0)
	   {
       write("");
	   }
	   	
	   if (i.substring(0,4)=="Main")
	   {
		   write("<h2 class=\"sidebar-title\">");
		   write(contentvalue);
		   write("</h2>");

	   }	
       else {
			if (contentvalue.substring(0, 7)=="http://")
			{
			  write("<li><a href=\"" + contentvalue + "\">");
			  write(i);
			  write("</a></li>");
			}	
			else {
			  write();
			  write("<li><a href=\"#\" onClick=\"setList('"+i+"'); setNewsPath('"+i+"');\">");
			  write(i);
			  write("</a></li>");
       	}
		}
       j++
    }
  }
}
function writeSubList2(List)
{
  with (document)
  {
	write("");
	var j = 0;
	var first;
	var contentvalue;
	var count = 0;

	for (i in List)
    {
	   first = i;
	   contentvalue = List[i];
	   if (i.substring(0,4)=="Main")
	   {
			if (count>0)
			{
				write("</dl>"); 
			}
			else
			{
				write("<h2>");
			}
			if (count>0)
			{
				write("</div><div id=\"profile-container\"><h2 class=\"sidebar-title\">");
			}
			write(contentvalue);
			write("</h2>");
			write("<dl class=\"profile-datablock\">");
			count++
	   }	
       else {
		if (contentvalue.substring(0, 7)=="http://")
			{
			  write("- <a href=\"" + contentvalue + "\">");
			  write(i);
			  write("</a><br>");
			}	
		else {
			write("- <a href=\"#\" onClick=\"setList2('"+i+"'); setNewsPath('"+i+"');\">");
			write(i);
			write("</a><br>");
       		}
       }
       j++
    }
  }
}
function writeSubList3(List)
{
  with (document)
  {
    write("");
    var j = 0;
    var first;
	var contentvalue;

	for (i in List)
    {
	   first = i;
	   contentvalue = List[i];
		if (j>0)
	   {
       write("");
	   }
	   	
	   if (i.substring(0,4)=="Main")
	   {
		   write("<h2 class=\"sidebar-title\">");
		   write(contentvalue);
		   write("</h2>");

	   }	
       else {
			if (contentvalue.substring(0, 7)=="http://")
			{
			  write("<li><a href=\"" + contentvalue + "\">");
			  write(i);
			  write("</a></li>");
			}	
			else {
			  write();
			  write("<li><a href=\"#\" onClick=\"setList3('"+i+"'); setNewsPath('"+i+"');\">");
			  write(i);
			  write("</a></li>");
       	}
		}
       j++
    }
  }
}
function writeContact(Contact)
{
  with (document)
  {
    write("");
    var j = 0;
    var first;
	var contentvalue;

	for (i in Contact)
    {
	   first = i;
	   contentvalue = Contact[i];
		if (j>0)
	   {
       write(" | "); 
	   }
	   	
	   if (contentvalue.substring(0, 7)=="http://")
	   {
		   write("<a href=\"" + contentvalue + "\">");
		   write(i);
		   write("</a>");

	   }	
       else {
		   write("<a href=\"#\" onClick=\"setContact('"+i+"'); setNewsPath('"+i+"');\">");
		   write(i);
		   write("</a>");
       }
       j++
    }
  }
}
function writeNewsList(News)
{
  with (document)
  {
    write("");
    var j = 0;
    var first;
    for (i in News)
    {
		first = i;
		write("<li><b>"+i+"</b>");
		write("");
		write(News[i].substring(0,140));
       write(" ... [<a href='#' onClick=\"setNews(News); setNewsPath('"+i+"');\">more</a>]</li>");
       j++
	   if (j == 3) break; 
	}
  }
}
function setContent(zz)
{
document.getElementById("myContent").innerHTML = Page[zz];
document.getElementById("myPath").innerHTML = "\\&nbsp;"+document.title;
Content.Callback = r_cb;
Content.Callback = e_cb;
}
function setSubContent(ss)
{
document.getElementById("myContent").innerHTML = Sub[ss];
}
function setNewsPath(zz)
{
document.getElementById("myPath").innerHTML = "\\&nbsp;"+document.title+"&nbsp;>&nbsp;"+zz;
}
function setList(ll)
{
document.getElementById("myContent").innerHTML = BL[ll];
}
function setList2(ll)
{
document.getElementById("myContent").innerHTML = BT[ll];
}
function setList3(ll)
{
document.getElementById("myContent").innerHTML = BS[ll];
}
function setContact(cc)
{
if (cc=="About Me")
	{
	document.getElementById("myContact").innerHTML = Contact[cc];
	a_cb();
	}	
else {
	document.getElementById("myContact").innerHTML = Contact[cc];
	c_cb();
	}
}
function setNews(News)
{
  var ss;

    ss=("");
    var j = 0;
    var first;
    for (i in News)
    {
       first = i;
       ss+=("<h2 class=\"date-header\">");
       ss+=(i.substring(0,12));
       ss+=("</h2><div class=\"post\"><h3 class=\"post-title\">");
       ss+=(i.substring(14,150));
       ss+=("</h3><div class=\"post-body\"><p>");
	   ss+=("");
	   ss+=(News[i]+"</p></div><p class=\"post-footer\"><em>&nbsp;</em><a class=\"comment-link\">&nbsp;</a></p></div>");
       j++
    }
	document.getElementById("myContent").innerHTML = ss;
}

// This script based on Paul Snowden's work described on A List Apart
//  <http://www.alistapart.com/stories/alternate/>
// Certain modifications (setFontSize and related) by Eric Meyer
//  <http://www.meyerweb.com/eric/>

function setActiveStyleSheet(title) {
  var i, a, main;
  if (title) {
    for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
      if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title')) {
        a.disabled = true;
        if(a.getAttribute('title') == title) a.disabled = false;
      }
    }
  }
}

function getActiveStyleSheet() {
    var i, a;
    for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
      if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') && !a.disabled) return a.getAttribute('title');
    }
    return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
    if(a.getAttribute('rel').indexOf('style') != -1
       && a.getAttribute('rel').indexOf('alt') == -1
       && a.getAttribute('title')
       )
       return a.getAttribute('title');
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = '; expires='+date.toGMTString();
  }
  else expires = '';
  document.cookie = name+'='+value+expires+'; path=/';
}

function readCookie(name) {
  var nameEQ = name + '=';
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function eraseCookie(name) {
	createCookie(name,'',-1);
}

function setFontSize(fontVal) {
	var fontSet = document.getElementById('fontSet');
	var docBase = new Array(); docBase = document.getElementsByTagName('body');
	if (!fontVal) {fontVal = document.getElementById('fontSet').value;}
	var docSize = fontVal+'px';
	createCookie('melo-size', fontVal, 365);
	docBase[0].style.fontSize = docSize;
	if (fontSet) {fontSet.value = fontVal;}
}

window.onload = function(e) {
  var cookie = readCookie('melo-style');
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
  var cookie2 = readCookie('melo-size');
  if (cookie2) {setFontSize(cookie2);}
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie('melo-style', title, 365);
}

// HOLIDAYS
function gothere() {

  var dt=new Date();
  var mm,dd,yy,dy;
  var date="  ";

  mm=dt.getMonth()+1;
  dd=dt.getDate();
  yy=dt.getYear();
  dy=dt.getDay();


// if month or day are single digit, make them two digits
  mm = (mm < 10) ? "0"+mm : mm;
  dd = (dd < 10) ? "0"+dd : dd;
  
  // This year tweak will cease to work when Epoch Time ends in 2038...
  yy = yy % 100;
  yy += (yy < 38) ? 2000 : 1900;
 
  datep = "http://www.earthcalendar.net/_php/lookup.php?mode=date&m="+mm+"&d="+dd+"&y="+yy+""; 	
  window.location.href=datep;
}
// end hiding -->

openWin = function(url,name,width,height,xpos,ypos,chrome,scroll){  var x, y, w, h, moveX=0, moveY=0, features="";  chrome = chrome ? "yes" : "no";  scroll = scroll ? "yes" : "no";  features += "toolbar="+chrome+",location="+chrome+",status="+chrome+",menubar="+chrome;  features += ",scrollbars="+scroll+",resizable="+scroll;  if(width) features += ",width="+width;  if(height) features += ",height="+height;  if(xpos && window.screen){    w = window.screen.availWidth;    width = parseInt(width);    switch(xpos){      case "left": x = 0; break;      case "center": x = (w-width)/2; break;      case "right": x = w-width; break;      default: x = xpos;    }    features += ",screenX="+x+",left="+x;    var moveX = x;  }  if(ypos && window.screen){    h = window.screen.availHeight;    height = parseInt(height);    switch(ypos){      case "top": y = 0; break;      case "middle": y = (h-height)/2; break;      case "bottom": y = h-height; break;      default: y = ypos;    }    features += ",screenY="+y+",top="+y;    var moveY = y;  }  openWinReference = window.open(url,name,features);  if(moveX || moveY){    // position the window for browsers that don't recognize screenX, screenY    openWinReference.moveTo(moveX,moveY);  }}openScroll = function(url,name,width,height){  openWin(url,name,width,height,false,false,false,"scroll");}openCenter = function(url,name,width,height){  openWin(url,name,width,height,"center","middle");}openCenterScroll = function(url,name,width,height){  openWin(url,name,width,height,"center","middle",false,"scroll");}openFull = function(url,name){  openWin(url,name,false,false,false,false,"chrome","scroll");}// ||||||||||||||||||||||||||||||||||||||||||||||||||Menu = {timer : null, current : null};Menu.getStyle = function(name){	if(document.getElementById) return document.getElementById(name).style;	else if(document.all) return document.all[name].style;	else if(document.layers) return document.layers[name];}Menu.show = function(name){	if(this.timer) clearTimeout(this.timer);	this.getStyle(name).visibility = "visible";	this.current = name;}Menu.hide = function(){	this.timer = setTimeout("Menu.doHide()",300);}Menu.doHide = function(){	if(this.current){		this.getStyle(this.current).visibility = "hidden";		this.current = null;	}}// ||||||||||||||||||||||||||||||||||||||||||||||||||

function adjust(f) {
	var h = "auto";
	var w = "auto";
//alert(f);
		if (f.contentDocument) {
			h = f.contentDocument.documentElement.offsetHeight + 20 + "px";
			// the following line doesn't work as desired
			w = f.style.width = f.contentDocument.documentElement.offsetWidth + 20 + "px";
		} else if (f.contentWindow) {
			h = f.contentWindow.document.body.scrollHeight + 5 + "px";
			w = f.contentWindow.document.body.scrollWidth + 5 + "px";
		}
//alert(h);
//alert(w);
		f.setAttribute("width",w);
		f.setAttribute("height",h);
}