window.onload = function(){ AdjustWidth(); }
window.onresize= function(){ AdjustWidth(); }

function AdjustWidth()
{
	var w = document.body.clientWidth;
	var c = document.getElementById("container");
	if(w<=1000)
	{
		c.setAttribute("style","width: 780px" );
		c.style.width = "780px";
	}
	else
	{
		c.setAttribute("style","width: 970px" );
		c.style.width = "970px";
	}
}

function bookmarksite(title,url)
{
    if (window.sidebar)
           window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print)
    {
           var elem = document.createElement('a');
           elem.setAttribute('href',url);
           elem.setAttribute('title',title);
           elem.setAttribute('rel','sidebar');
           elem.click();
    } 
else if(document.all)
           window.external.AddFavorite(url, title);
}

function showPopTip(me, bShow)
{
    //bShow: can be the text, or false to hide
    if(!me)
        return;
    var d=document.getElementById("pop_tip");
    if(!d)
        return;
    if(!bShow)
    {
         d.style.display="none";
         return;
    }

    cc=document.getElementsByTagName('*');
    for(i=0; i<cc.length; i++)
    {
       if(cc[i].className=='lcontent')
           cc=cc[i];
    }
    if(!cc)
        return;

  var x= 0, y=0;
  var dd=me;
  while(dd!=null)
  {
      x+= dd.offsetLeft;
      y+= dd.offsetTop;
      dd=dd.offsetParent;
      if(dd==cc)
         break;
  }
  dd=document.getElementById("pop_tip_c");
  if(dd)
    dd.innerHTML=bShow;
       
  //move it to closed position
  d.style.left=x+me.offsetWidth-10+'px';
  d.style.top=y-120+'px';
  d.style.display="block";
  //correct the y position
  d.style.top=y-d.offsetHeight+"px";
}

function showDiv(divName, showCmd, focusTo)
{
    //showCmd: true, false, 'switch'
    var d=document.getElementById(divName);
    if(!d)
         return;
    var bShow=showCmd;
    if(showCmd=='switch')
    {
        if(d.style.display=='none')
            bShow=true;
        else
            bShow=false;
    }
    if(bShow)
       d.style.display="block";
   else
       d.style.display="none";
   if(bShow&&focusTo)
   {
       d=document.getElementById('theForm');
       if(d)
       {  d=d.elements[focusTo];
          if(d){ d.focus();}
       }
   }
}
