
function replaceRemoteContent(divid,uri)
{
	HTML_AJAX.replace(divid,uri);
}

function activateSearchFilter(uri)
{
        document.getElementById('searchFilter').innerHTML = '<p>Please wait while we fetch the results.</p>';
        document.getElementById('searchFilter').style.display = 'block';
        document.getElementById('searchResults').style.display = 'none';
//        document.getElementById('searchForm').style.display = 'none';
	HTML_AJAX.replace('searchFilter',uri);
}

function deactivateSearchFilter()
{
        document.getElementById('searchFilter').style.display = 'none';
        document.getElementById('searchResults').style.display = 'block';
 //       document.getElementById('searchForm').style.display = 'block';
}

function toggleItemInfo(id)
{
        a = document.getElementById('itemO'+id);
        b = document.getElementById('itemI'+id);
	if (a.style.display == 'block')
	{
		b.style.display = 'block';
		a.style.display = 'none';
	}
	else
	{
		a.style.display = 'block';
		b.style.display = 'none';
	}
}

function initStandardPage()
{
	if (document.styleSheets[0].media == 'print')
		return;

	replaceRemoteContent('status','http://www.expressobeans.com/portlets/personal.php');
	initControls();
}

var controlsVisible = true;

function initControls()
{
	c = (readCookie('controls','on') == 'on')
	setControls(c);
}


function setControls(on)
{
	if (controlsVisible == on)
		return;	
	controlsVisible = on;
	if (document.styleSheets[0].media == 'print')
		return;
        if (on)
        {
                document.getElementById("controls").style.display = "";
                document.getElementById("ctrlhndl_up").style.display = "inline";
                document.getElementById("ctrlhndl_down").style.display = "none";
                document.getElementById("content").style.margin = "";
                document.getElementById("controls-panel").style.display = "";
        }
        else
        {
                document.getElementById("controls").style.display = "none";
                document.getElementById("ctrlhndl_up").style.display = "none";
                document.getElementById("ctrlhndl_down").style.display = "inline";
                document.getElementById("content").style.margin = "8px";
                document.getElementById("controls-panel").style.display = "none";
        }
//      document.getElementById("upshrinkRightbar").src = smf_images_url + (controlsVisible ? "/upshrink2.gif" : "/upshrink.gif");
}

function toggleControls()
{
        c = !controlsVisible;
	setControls(c);
	setCookie('controls',c?'on':'off',true);
}

function setCookie(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,def_value) {
  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 def_value;
}

function addEngineErrorMsg()
{
  alert("Netscape 6 or Mozilla is needed to install a sherlock plugin");
}
function addEngine(name,ext,cat)
{
  if ((typeof window.sidebar == "object") && (typeof
  window.sidebar.addSearchEngine == "function"))
  {
    //cat="Web";
    //cat=prompt('In what category should this engine be installed?','Web')
    window.sidebar.addSearchEngine(
      "http://www.expressobeans.com/plugins/"+name+".src",
      "http://www.expressobeans.com/plugins/"+name+"."+ext,
      name,
      cat );
  }
  else
  {
    addEngineErrorMsg();
  }
}

