/**
Fonctionne avec :
  IE 6.02             PC
  Netscape 7.02       PC
  Netscape 6.2.2      PC
  Netscape 7.1        MAC
  Safari 1.0 (v85)    MAC
  MSIE 5.2            MAC
*/

var isIEMAC = (navigator.appVersion.indexOf("MSIE")>=0 && navigator.appVersion.indexOf("Mac")>=0)? true : false;

function getObj(name)
{
  if (!isIEMAC && document.getElementById)
  {
  	this.obj = document.getElementById(name);
	  this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
  	this.obj = document.all[name];
  	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}


function getLeft(_object, _withParents)
{
  var a_result = 0;
	while (_object!=null)
	{
	  if (!isIEMAC && _object.style.left) a_result+=_object.style.left;
	  if (!isIEMAC && _object.style.pixelLeft) a_result+=_object.style.pixelLeft;
	  if (_object.offsetLeft) a_result+=_object.offsetLeft;
	  if (!isIEMAC && _withParents) _object = _object.parentElement;
	  else _object = null;
	}
	return a_result;
}

function getTop(_object, _withParents)
{
	var a_result = 0;
	while (_object!=null)
	{
	  if (!isIEMAC && _object.style.top) a_result+=_object.style.top;
	  if (!isIEMAC && _object.style.pixelTop) a_result+=_object.style.pixelTop;
	  if (_object.offsetTop) a_result+=_object.offsetTop;
	  if (!isIEMAC && _withParents) _object = _object.parentElement;
	  else _object = null;
	}
	return a_result;
}

function getWidth(_object)
{
  if (_object.clientWidth) return _object.clientWidth;
  if (_object.width) return _object.width;
  return 0;
}

function getHeight(_object)
{
  if (_object.clientHeight) return _object.clientHeight;
  if (_object.height) return _object.height;
  return 0;
}

function showLayer(name)
{
  var x = new getObj(name);
  x.style.visibility = "visible";
}

function hideLayer(name)
{
  var x = new getObj(name);
  x.style.visibility = "hidden";
}

function showPopup(_img)
{
  var a_img;
  var a_popup;
  if (isIEMAC)
  {
    a_img = document.all(_img);
    a_popup = new getObj("popup"+_img);
  }
  else
  {
    a_img = _img;
    a_popup = new getObj("popup"+_img.id);
  }

  a_img.style.position="relative";

  var a_posX = getLeft(a_img);
  var a_posY = getTop(a_img)+getHeight(a_img)-1;

  a_popup.style.left = a_posX;
  a_popup.style.top = a_posY;
  a_popup.style.visibility = "visible";
}

function hidePopup(_img)
{
  hideLayer("popup"+_img.id);
}

function highlightCell(_cell)
{
  _cell.className='menucellh';
}

function unhighlightCell(_cell)
{
  _cell.className='menucell';
}

function openLink(_url)
{
  document.location=_url;
}

function createPopup(_imgId, _array, _width)
{
  document.write("<DIV ID='popup"+_imgId+"' onMouseOver=\"showLayer('popup"+_imgId+"');\" onMouseOut=\"hideLayer('popup"+_imgId+"');\" class='menu' style='POSITION:absolute; VISIBILITY:hidden; z-index:5'>");
  document.write("<table width="+_width+" cellpadding=0 cellspacing=0>");

  for (a_i=0; a_i<_array.length; a_i++)
  {
    document.write("<tr><td class='menucell' onMouseDown=\"openLink('"+_array[a_i][1]+"')\" onMouseOver='highlightCell(this);' onMouseOut='unhighlightCell(this);'>");
    document.write("&nbsp;&nbsp;"+_array[a_i][0]+"</td></tr>");
  }

  document.write("</table>");
  document.write("</DIV>");
}

function createPopupDebug(_imgId, _array)
{
  document.write("<DIV ID='popup"+_imgId+"' onMouseOver=\"showLayer('popup"+_imgId+"');\" onMouseOut=\"hideLayer('popup"+_imgId+"');\" class='menu' style='POSITION:absolute; VISIBILITY:hidden;'>");
  document.write("<table class='menutable' cellpadding=0 cellspacing=0>");
  for (a_i=0; a_i<_array.length; a_i++)
  {
    document.write("<tr><td class='menucell' onMouseDown=\"javascript:parent.frames['frameURL'].goDebug('"+_array[a_i][1]+"')\" onMouseOver='highlightCell(this);' onMouseOut='unhighlightCell(this);'>");
    document.write(_array[a_i][0]+"</td></tr>");
  }

  document.write("</table>");
  document.write("</DIV>");
}

//LeftPanel 和上面代码无关
function showLeftPanel(type){
	var path;
	if(type=="newsList"){
		path="";
	}else if(type=="newsItem"){
		path="../";
	}
	document.write("<table width=\"100%\"><tr><td align=\"center\"><br>");
	document.write("<form action=\""+path+"search2-2.asp\" method=\"post\" name=\"searchtitle\" target=\"_blank\" id=\"searchtitle\">");
	document.write("<input name=\"ttt2\" type=\"text\" id=\"ttt24\" size=\"15\"><br>");
	document.write("<input name=\"sss2\" type=\"radio\" value=\"按新闻标题搜索\" checked>");
	document.write("标题 <input type=\"radio\" name=\"sss2\" value=\"按新闻内容搜索\">");
	document.write("内容 <br><input name=\"imageField\" type=\"image\" src=\""+path+"../images/icon_search.gif\" border=\"0\">");
	document.write("</form></td></tr></table>");
}
