function writeNoFrameLinks ()
{

    if (window.top == window.self)
    {

       window.document.write ('<td valign="bottom" class="manualMenuItem" nowrap="nowrap"><a href="index.html" title="click to go to the framed version of the manual"><img alt="*" src="/imgs/view-manual.png" border="0" /></a>&#160;<img style="background-color: #999999;" alt="*" height="24" src="/imgs/spacer1x1.gif" width=1" />&#160;<a href="../index.html" title="click to return to the JoSQL home page"><img alt="*" src="/imgs/home.png" border="0" /></a></td>');

    }

}

function getSidebar ()
{

    if (window.location.href.indexOf ('manual') != -1)
    {

	var t = getFile ('../sidebar.html');

    } else {

	var t= getFile ('sidebar.html');

    }

  if (!t)
  {

    return '<td width="250" valign="top"><table border="0" cellspacing="0" cellpadding="0"><tr><td class="header"><table border="0" cellpadding="0" cellspacing="0"><tr><td class="sideBarImg"><img alt="Why are you seeing this?" src="/imgs/download.png" /></td><td nowrap="nowrap" width="100%" class="sideBarHeader">Wheres the Menu?&#160;</td></tr></table></td></tr><tr><td class="i5LR"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="content2"><tr><td class="i3" colspan="2"><span class="sideBarText2">You are seeing this instead of the menu because your browser is <b>OUT OF DATE</b>!  It\'s time you upgraded to a better one (if you want to see the menu...).</span></td></tr><tr><td colspan="2" bgcolor="#dddddd"><img alt="*" height="1" width="100%" src="/imgs/spacer1x1.gif" /></td></tr><tr><td style="padding: 3px;" align="center" colspan="2"><a href="http://www.mozilla.com" target="_blank"><img border="0" alt="Get Firefox" src="/imgs/getfirefox.gif" /></a></td></tr></table></td></tr></table></td>';

  }  

  return t;

}

function getManualMenubar ()
{

  var t = getFile ('../manual-menubar.html');

  if (!t)
  {

    return '<td width="250" valign="top"><table border="0" cellspacing="0" cellpadding="0"><tr><td class="header"><table border="0" cellpadding="0" cellspacing="0"><tr><td class="sideBarImg"><img alt="Why are you seeing this?" src="/imgs/download.png" /></td><td nowrap="nowrap" width="100%" class="sideBarHeader">Wheres the Menu?&#160;</td></tr></table></td></tr><tr><td class="i5LR"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="content2"><tr><td class="i3" colspan="2"><span class="sideBarText2">You are seeing this instead of the menu because your browser is <b>OUT OF DATE</b>!  It\'s time you upgraded to a better one (if you want to see the menu...).</span></td></tr><tr><td colspan="2" bgcolor="#dddddd"><img alt="*" height="1" width="100%" src="/imgs/spacer1x1.gif" /></td></tr><tr><td style="padding: 3px;" align="center" colspan="2"><a href="http://www.mozilla.com" target="_blank"><img border="0" alt="Get Firefox" src="/imgs/getfirefox.gif" /></a></td></tr></table></td></tr></table></td>';

  }  

  return t;

}

function getFile (path)
{

  var request = false;
 
  try 
  {

     request = new XMLHttpRequest();
 
  } catch (trymicrosoft) {

     try 
     {
    
        request = new ActiveXObject("Msxml2.XMLHTTP");

     } catch (othermicrosoft) {

        try 
        {

           request = new ActiveXObject("Microsoft.XMLHTTP");

        } catch (failed) {

           request = false;

        }
  
     }

   }

  if (!request)
  {

    return false;

  }

  request.open ("GET",
                path,
                false);

  request.send (null);

  return request.responseText;

}

function setVisible (elId,
		     imgId)
{
    
    var e = window.document.getElementById (elId); 

    if (e == undefined)
    {

	return;

    }
	
    e.style.visibility = 'visible';
    e.style.display = '';
	
    var imge = window.document.getElementById (imgId);

    if (imge != undefined)
    {

	imge.src = '/imgs/up.gif';
	   
    }

    var c = readCookie ('josql-manual');

    if (c)
    {

	if (c.indexOf (elId) == -1)
	{

	    c = c + '$' + elId;

	}

    } else {

	c = elId;

    }

    // Set the cookie value.
    createCookie ('josql-manual', c, 0.04);    

}

function setHidden (elId,
		    imgId)
{
    
    var e = window.document.getElementById (elId); 

    if (e == undefined)
    {

	return;

    }
	
    e.style.visibility = 'hidden';
    e.style.display = 'none';
	
    var imge = window.document.getElementById (imgId);

    if (imge != undefined)
    {

	imge.src = '/imgs/down.gif';
	   
    }

    var c = readCookie ('josql-manual');

    if (c)
    {

	// Split on $
	var parts = c.split ('$');

	c = "";

	for (var i = 0; i < parts.length; i++)
	{

	    if (parts[i] != elId)
	    {

		if (c.length > 0)
		{

		    c = c + '$';

		}

		c = c + parts[i];

	    }

	}

	// Set the cookie value.
	createCookie ('josql-manual', c, 0.04);    

    }

}

function initMenuBar ()
{

    var c = readCookie ('josql-manual');

    if (c)
    {

	// Split on $
	var parts = c.split ('$');

	for (var i = 0; i < parts.length; i++)
	{

	    setVisible (parts[i],
			parts[i] + '_img');

	}

    }

}

function toggleView (elId,
		     imgId)
{
  
    var e = window.document.getElementById (elId); 
    
    if (e == undefined)
    {

	return;
	
    }

    if (isVisible (elId))
    {

	// Set it hidden.
	setHidden (elId,
		   imgId);

      } else {

	// Set it visible.
	setVisible (elId,
		    imgId);

    }

}

function isVisible (id)
{

    var e = window.document.getElementById (id); 

    return ((e.style.visibility == 'visible')
	    ||
	    (e.style.visibility == '')
	   );

}

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 var 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);
}
