//Dynamic Search update
//(c) linkagogo 2004-2005

var m_searchtarget;
var m_slowquery;
var xmlhttp=getHttp();

function doquery()
{
    var searchString = m_searchtarget.value;
    var _obj = document.getElementById('SearchResultArea');
    if (searchString == "")
    {
      _obj.style.display = 'none';
    }
    else
    {
      if (xmlhttp)
      {
        var _loc = "GoGoSearch?search="+searchString;
        xmlhttp.open("GET", _loc, true);
        xmlhttp.onreadystatechange=function()
        {
          if (xmlhttp.readyState==4)
          {
            _obj.innerHTML = xmlhttp.responseText; 
            _obj.style.display = '';
          }
        }
        xmlhttp.send(null);
      }
      else
      {
         _obj.innerHTML = "<h1>GoGoSearch not supported on this browser</h1>"; 
         _obj.style.display = '';
      }

    }
}
function setHTML(_url, _node)
{
      if (xmlhttp)
      {
	_node.innerHTML = "Loading bookmark properties...";
        xmlhttp.open("GET", _url, true);
        xmlhttp.onreadystatechange=function()
        {
          if (xmlhttp.readyState==4)
          {
            _node.innerHTML = xmlhttp.responseText;
            window.status   = _node.document.getElementById('UrlString').innerText;
          }
        }
        xmlhttp.send(null);
      }
      else
      {
         _node.innerHTML = "<h1>Properties lookup not supported on this browser</h1>";
      }
}
function delayquery(target){
    clearslowquery();
    m_searchtarget = target;
    m_slowquery = window.setTimeout('doquery()',800)
}
function clearslowquery(){
if (m_slowquery)
  clearTimeout(m_slowquery);
}

function getHttp()
{
  var xmlhttp
  try
  {
    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
    try
    {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (E)
    {
      xmlhttp=false
    }
  }
  if (!xmlhttp)
  {
    try
    {
      xmlhttp = new XMLHttpRequest();
    }
    catch (e)
    {
      xmlhttp=false
    }
  }
  return xmlhttp;
}


//Pop-it menu- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT

////No need to edit beyond here

//var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ie4=document.all
var ns6=document.getElementById&&!document.all
var ns4=document.layers

var m_current
var m_currenty
var m_currentUrl
var m_target

function delayshowmenu(e, urlId, target){
  clearslowmenu()
  m_currentx=ie4? event.clientX : ns6? e.clientX : e.x
  m_currenty=ie4? event.clientY : ns6? e.clientY : e.y
  m_currentUrl=urlId
  m_target=target
  slowmenu = window.setTimeout('showslowmenu()',1500)
}

function showslowmenu(){
  var spaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
  var menu = '';

  var _target = m_target==0?'':m_target==1?' target=LinkaGoGo':' target=_blank';

  menu +='<div class="menuitems"><a'+_target+' href="To?url='+m_currentUrl+'">Open'+spaces+'</a></div>';
  menu +='<hr border=1>'
  menu +='<div class="menuitems"><a target=linkaEdit href="Modify?url='+m_currentUrl+'&src=hmu&action=del">Delete'+spaces+'</a></div>'
  menu +='<div class="menuitems"><a target=linkaEdit href="Modify?url='+m_currentUrl+'&src=hmu&action=ren">Rename'+spaces+'</a></div>'
  menu +='<hr border=1>'
  menu +='<div class="menuitems"><a target=linkaEdit href="Modify?url='+m_currentUrl+'">Edit'+spaces+'</a></div>'

  showmenu(m_currentx, m_currenty, menu)
}


var v_status;
var v_ad_area;
var v_comment_area;

//function showmenu(e,which){
function showmenu(eventX, eventY, which){

var v_comment = document.getElementById('comment');
if (xmlhttp && v_comment)
{
 v_status = window.status;
 v_ad_area = document.getElementById('ad_area');
 v_comment.removeChild(v_ad_area);
 v_comment_area = document.createElement('span');
 setHTML('Modify?url='+m_currentUrl+'&action=prop', v_comment_area);

 v_comment.appendChild(v_comment_area);
 v_comment.style.visibility = 'visible';
 v_ad_location = document.getElementById('adLocation');
 v_comment.style.left = ''+(document.body.scrollLeft+v_ad_location.offsetLeft)+'px';
 v_comment.style.width = ''+v_ad_location.offsetWidth+'px';
 v_comment.style.top = ''+(document.body.scrollTop+2)+'px';
}

if (!document.all&&!document.getElementById&&!document.layers)
return

clearhidemenu()

menuobj=ie4? document.all.popmenu : ns6? document.getElementById("popmenu") : ns4? document.popmenu : ""
menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj

if (ie4||ns6)
menuobj.innerHTML=which
else{
menuobj.document.write('<layer name=gui bgColor=#E6E6E6 width=165 onmouseover="clearhidemenu()" onmouseout="hidemenu()">'+which+'</layer>')
menuobj.document.close()
}

menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.gui.document.width
menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.gui.document.height
//eventX=ie4? event.clientX : ns6? e.clientX : e.x
//eventY=ie4? event.clientY : ns6? e.clientY : e.y

//Find out how close the mouse is to the corner of the window
var rightedge=ie4? document.body.clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie4? document.body.clientHeight-eventY : window.innerHeight-eventY

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX-menuobj.contentwidth : ns6? window.pageXOffset+eventX-menuobj.contentwidth : eventX-menuobj.contentwidth
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX : ns6? window.pageXOffset+eventX : eventX

//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.thestyle.top=ie4? document.body.scrollTop+eventY-menuobj.contentheight : ns6? window.pageYOffset+eventY-menuobj.contentheight : eventY-menuobj.contentheight
else
//menuobj.thestyle.top=ie4? document.body.scrollTop+event.clientY : ns6? window.pageYOffset+eventY : eventY
menuobj.thestyle.top=ie4? document.body.scrollTop+eventY : ns6? window.pageYOffset+eventY : eventY
menuobj.thestyle.visibility="visible"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"


  var v_comment = document.getElementById('comment');
  if (xmlhttp && v_comment)
  {
    window.status = '';

    if (v_comment_area)
    {
      v_comment.removeChild(v_comment_area);
      v_comment_area = null;
    }

    if (v_ad_area)
    {
      v_comment.appendChild(v_ad_area);
      v_ad_area = null;  
    }
    v_comment.style.visibility = 'hidden';
  }
}

function dynamichide(e){
if (ie4&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
if (ie4||ns6||ns4)
delayhide=setTimeout("hidemenu()",500)
clearslowmenu()
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

function clearslowmenu(){
if (window.slowmenu)
clearTimeout(slowmenu)
}

function highlightmenu(e,state){
if (document.all)
source_el=event.srcElement
else if (document.getElementById)
source_el=e.target
if (source_el.className=="menuitems"){
source_el.id=(state=="on")? "mouseoverstyle" : ""
}
else{
while(source_el.id!="popmenu"){
source_el=document.getElementById? source_el.parentNode : source_el.parentElement
if (source_el.className=="menuitems"){
source_el.id=(state=="on")? "mouseoverstyle" : ""
}	
}
}
}

if (ie4||ns6)
document.onclick=hidemenu
