

function $(objID) { 
  return document.getElementById(objID); 
}
function addEvent(w, e, f) {
  if (document.all) {
    w.attachEvent(('on'+e), f);
  } else {
    w.addEventListener(e, f, false);
  }
}
function Offset(e)
{
  var t = e.offsetTop;
  var l = e.offsetLeft;
  var w = e.offsetWidth;
  var h = e.offsetHeight-1;

  while(e=e.offsetParent)
  {
    t+=e.offsetTop;
    l+=e.offsetLeft;
  }
  return {
    top : t,
    left : l,
    width : w,
    height : h
  }
}
var browser = {};

browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
browser.isIE = window.ActiveXObject ? true : false;
browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);

function neverCombox() { with(this)
{
  // Custom Variables.
  this.debug = false;
  this.height = 18;
  this.width = null;
  this.number = null;
  this.edit = false;
  this.onchange = null;


  // System Variables.
  this._ctlIDs = [];
  this._offsets = {};
  this._this = this;
  this._value = null;
  this._onchangeArgs = [];
  this._ctlStyle = "ctlSelect";
  this._selStyle = "selected";
  this._unselStyle = "unselected";
  this._arowStyle = "arow";
  this._eltprefix = "e__";
  this._iptprefix = "i__";
  this._wprprefix = "w__";
  this._arwprefix = "a__";

  this.chkWrapper = function(ctlSelID) { with(this)
  {
    if (!$(_wprprefix+ctlSelID))
    {
      var mWrapper = _this.buildWrapper(ctlSelID, _offsets.ctlSelID);
      this.addOptions(ctlSelID);
    } else {
      var mWrapper = $(_wprprefix+ctlSelID);
    }
    return mWrapper;
  }};

  this.buildWrapper = function(ctlSelID, ctlOffset) { with(this)
  {
    var mWrapper, mWOffsets;
    mWOffsets = Offset($(_iptprefix+ctlSelID)); // real offset
    mWrapper = document.createElement("DIV");
    document.body.appendChild(mWrapper);
    mWrapper.style.position = "absolute";
    mWrapper.style.display = "none";
    mWrapper.setAttribute("id", _wprprefix+ctlSelID);
    //mWrapper.className = _ctlStyle;
    mWrapper.style.left = mWOffsets.left +'px';
    mWrapper.style.top = (parseInt(mWOffsets.top) + parseInt(mWOffsets.height)) +'px';
    if (number)
    {
      mWrapper.style.height = (height * number) +'px';
      mWrapper.style.overflow = "";//设置auto出现滚动条
    }
    function checkMouseDown(evt) {
      var el = window.event?event.srcElement:evt.target;
      if( el.id.indexOf(_eltprefix+ctlSelID)>-1 || 
      el.id.indexOf(_iptprefix+ctlSelID)>-1 || 
      el.id.indexOf(_wprprefix+ctlSelID)>-1 || 
      el.id.indexOf(_arwprefix+ctlSelID)>-1 )
      {
        return;
      }
      $(_wprprefix+ctlSelID).style.display="none";
      $(_iptprefix+ctlSelID).className = _ctlStyle
    }
      // register event, need event manager
    addEvent(document,'mousedown',checkMouseDown);
    return mWrapper;
  }};

  this.addOption = function(ctlSelID, text, value, idx) { with(this)
  {
    var nWrapper;
    var ctlObj = $(ctlSelID);
    var iptObj = $(_iptprefix+ctlSelID);
    var mWrapper = $(_wprprefix+ctlSelID);

    nWrapper = document.createElement("DIV");
    mWrapper.appendChild(nWrapper);
    nWrapper.setAttribute("id", nWrapper.id = _eltprefix+ctlSelID+idx);
    nWrapper.style.cursor = "default";
    nWrapper.innerHTML = nWrapper.title = text;
    nWrapper.style.height = height+'px';
    nWrapper.setAttribute("ctlValue", value);

    nWrapper.onmouseover = function()
    {
      for (var j=0; j<mWrapper.childNodes.length; j++) 
      {
        if (mWrapper.childNodes[j]==this) mWrapper.childNodes[j].className = _selStyle; 
        else mWrapper.childNodes[j].className = _unselStyle; 
      }
    };
    nWrapper.onselectstart = nWrapper.onclick = function()
    {
      iptObj.value = this.innerHTML;
      iptObj.setAttribute("ctlValue", this.getAttribute("ctlValue"));
      mWrapper.style.display = "none";
      //iptObj.className = _selStyle;
      if (onchange && _value != iptObj.value)
      {
        onchange.apply(this,_onchangeArgs);
        _value = iptObj.value;
      }
      event.returnValue = false;
    };

    return nWrapper;
  }};

  this.addOptions = function(ctlSelID) { with(this)
  {
    var ctlObj = $(ctlSelID);
    var mWrapper = $(_wprprefix+ctlSelID);
    for (var i=0; i<ctlObj.length; i++)
    {
      nWrapper = _this.addOption(ctlSelID, ctlObj[i].text, ctlObj[i].value, i)
      if (ctlObj[i].value==_this.getValue(ctlSelID)) 
      { 
        nWrapper.className = _selStyle; 
      } else { 
        nWrapper.className = _unselStyle; 
      }
    }
  }};

  this.simulates = function() { with(this)
  {
    var ret=false;
    for (var i=0; i<_ctlIDs.length; i++)
    ret=_this.simulate(_ctlIDs[i]);
    return ret;
  }};
  this.simulate = function(ctlSelID) { with (this)
  {
    var ctlOffset;
    var iptObj, arwObj, ctlObj; 
    
    ctlObj = $(ctlSelID);
    ctlOffset = Offset(ctlObj);

    iptObj = document.createElement("INPUT");
    arwObj = document.createElement("INPUT");
    arwObj.type = "button";
    arwObj.setAttribute("id", _arwprefix+ctlSelID);
    //Mozilla and Opera browser do not support "Webdings" fontfamily
    if (browser.isIE) {//arwObj.value = "▼";
      arwObj.value = "6";
      arwObj.style.fontFamily = "Webdings";
    } else {
      arwObj.value = "⊿";
    }
    arwObj.style.width = height +'px';
    arwObj.onclick = function()
    {
      this.blur();
      _this.expand(ctlSelID);
    };
    if (!edit)
    {
      iptObj.onclick = iptObj.onselectstart = function()
      {
        _this.expand(ctlSelID);
        event.returnValue = false; 
      }
    }
    iptObj.setAttribute("id", _iptprefix+ctlSelID);
    iptObj.title = arwObj.title = "click expand options";
    iptObj.style.cursor = arwObj.style.cursor = "default";
    iptObj.className = _ctlStyle;
    arwObj.className = _arowStyle;
    iptObj.style.width = (parseInt(width) || ctlObj.offsetWidth) +'px';
    if (height) iptObj.style.height = arwObj.style.height = height+'px';
    
    for (var i=0; i<ctlObj.length; i++)
    {
      if (ctlObj[i].defaultSelected)
      {
        iptObj.value = _value = ctlObj[i].text;
        iptObj.setAttribute("ctlValue", ctlObj[i].value);
        break;
      }
    }

    if (!_value)
    {
      iptObj.value = _value = ctlObj[0].text;
      iptObj.setAttribute("ctlValue", ctlObj[0].value);
    }

    if (!edit) iptObj.readOnly=true;

    if (!$(_arwprefix+ctlSelID)) ctlObj.parentNode.insertBefore(arwObj, ctlObj.nextSibling||null);
    if (!$(_iptprefix+ctlSelID)) ctlObj.parentNode.insertBefore(iptObj, ctlObj.nextSibling||null);
    if (!debug) ctlObj.style.display = 'none';
    _offsets.ctlSelID = ctlOffset;
    iptObj.style.height = height +'px';
    if (parseInt(iptObj.offsetHeight)>height) {
      arwObj.style.height = iptObj.offsetHeight;
    }

    return true;
  }};
  //return this;
}};

// public api
neverCombox.prototype.init = function(ctlSelIDs) { with(this)
{
  _this.addCombox(ctlSelIDs);
  this.simulates();
}};

neverCombox.prototype.setStyles = function(ctlStyle, selStyle, unselStyle) { with(this)
{
  _ctlStyle = arguments[0], _selStyle = arguments[1], 
  _unselStyle = arguments[2]; _arowStyle = arguments[3];

}};

neverCombox.prototype.getValue = function(ctlSelID) { with(this)
{
  if ($(_iptprefix+ctlSelID)) return $(_iptprefix+ctlSelID).getAttribute("ctlValue");
  else return null;
}};

neverCombox.prototype.getText = function(ctlSelID) { with(this)
{
  if ($(_iptprefix+ctlSelID)) return $(_iptprefix+ctlSelID).value;
  else return null;
}};

neverCombox.prototype.setOnchangeHandler = function(func) { with(this)
{
  if (typeof(func)!="function")
  return window.alert('never combox setOnchangeHandler handler Error\n\n"' + f.toString() + '" not a function or not initialize before setOnchangeHandler handler method.');
  onchange = f;
  if (arguments.length > 0)
  for (var i=0; i<arguments.length; i++)
  _onchangeArgs[i-1] = arguments[i];
}};

neverCombox.prototype.addItem = function(ctlSelID, text, value) { with(this)
{
  if (!edit) return -1; this.chkWrapper(ctlSelID);
  var ctlObj = $(ctlSelID); if (!ctlObj) return "argument must be has ctlSelID";
  for (var i=0; i<$(ctlSelID).length; i++)
  if ($(ctlSelID)[i].value==value) return window.alert('never combox:\nthis value "' + value + '" has been exists!');
  $(ctlSelID).options.add(new Option(text||value, value, false, false)); this.simulate(ctlSelID);
  if ($(_wprprefix+ctlSelID)) _this.addOption(ctlSelID, text||value, value, $(ctlSelID).length-1);
  return true;
}};

neverCombox.prototype.removeItem = function(ctlSelID, idx) { with(this)
{
  if (!edit) return -1;
  var isremoved = false;
  var ctlObj = $(ctlSelID); if (!ctlObj) return "argument must be has ctlSelID";
  var mWrapper = this.chkWrapper(ctlSelID);
  var iptObj = $(_iptprefix+ctlSelID);
  idx = parseInt(idx); idx<-1?idx=0:(idx>ctlObj.length?idx=ctlObj.length:"");
  for (var j=0; j<mWrapper.childNodes.length; j++) 
  {
    if (idx==j)
    {
      mWrapper.childNodes[j].parentNode.removeChild(mWrapper.childNodes[j]);
      ctlObj.remove(j);
      iptObj.value=(mWrapper.childNodes[j+1])?mWrapper.childNodes[j+1].innerHTML:"";
      var value = (mWrapper.childNodes[j+1])?mWrapper.childNodes[j+1].getAttribute("ctlValue"):"";
      iptObj.setAttribute("ctlValue", value);
      isremoved = true;
    }
  }
  return isremoved;
}};

neverCombox.prototype.writeItem = function(ctlSelID, idx, text, value) { with(this)
{
  if (!edit) return -1;
  var iswrited = false;
  var ctlObj = $(ctlSelID); if (!ctlObj) return "argument must be has ctlSelID";
  var mWrapper = this.chkWrapper(ctlSelID);
  var iptObj = $(_iptprefix+ctlSelID);
  idx = parseInt(idx); idx<-1?idx=0:(idx>ctlObj.length?idx=ctlObj.length:"");
  for (var j=0; j<mWrapper.childNodes.length; j++) 
  {
    if (idx==j)
    {
      mWrapper.childNodes[j].innerHTML=text;
      mWrapper.childNodes[j].setAttribute("ctlValue", text||value);
      ctlObj.options[j].text=text, ctlObj.options[j].value=text||value;
      iptObj.value=text;
      iptObj.setAttribute("ctlValue", text||value);
      iswrited = true;
    }
  }
  return iswrited;
}};

neverCombox.prototype.getSelectedIndex = function(ctlSelID) { with(this)
{
  var ctlObj = $(ctlSelID); if (!ctlObj) { window.alert("arguments Object must be has ctlSelID"); return -1; }
  var mWrapper = this.chkWrapper(ctlSelID);
  for (var j=0; j<mWrapper.childNodes.length; j++) 
  {
    if (mWrapper.childNodes[j].getAttribute("ctlValue")==_this.getValue(ctlSelID)) 
    return j;
  }
  return -1;
}};

neverCombox.prototype.addCombox = function(ctlSelIDs) { with(this)
{
  if (ctlSelIDs.indexOf(",")>0)
  {
    var aCtlSel = ctlSelIDs.split(",");
    for(var i=0; i<aCtlSel.length; i++)
    _ctlIDs.push(aCtlSel[i]);
  } else { _ctlIDs.push(ctlSelIDs) };
  return 1;
}};


neverCombox.prototype.expand = function(ctlSelID) { with(this)
{
  var mWrapper = this.chkWrapper(ctlSelID);
  var iOffsets = Offset($(_iptprefix+ctlSelID));
	var arwObj = $(_arwprefix+ctlSelID)
  var iptObj = $(_iptprefix+ctlSelID);
  var ctlObj = $(ctlSelID);
  var element;

  iptObj.className = _ctlStyle;
  mWrapper.className = _ctlStyle;
  mWrapper.style.left = iOffsets.left+'px';
  mWrapper.style.top = (iOffsets.top+iOffsets.height)+'px';
	mWrapper.style.width = iptObj.offsetWidth+arwObj.offsetWidth+'px';

  if (mWrapper.style.display=="none")
  {
    for (var i=0; i<ctlObj.length; i++)
    {
      element = $(_eltprefix+ctlSelID+i);
      if (ctlObj[i].value==_this.getValue(ctlSelID) && element) {
        element.className = _selStyle;
      } else if (element) {
        element.className = _unselStyle;
      }
    }
    mWrapper.style.display = "block";
    return true;
  }

  if (mWrapper.style.display=="block")
  {
    mWrapper.style.display = "none";
    //iptObj.className = _selStyle;
    return true;
  }

  return false;
}};

neverCombox.prototype.restore = function(ctlSelID) { with(this)
{
  if ($(ctlSelID).style.display=="none") {
    $(ctlSelID).style.display = "";
    $(_eltprefix+ctlSelID).style.display =
    $(_iptprefix+ctlSelID).style.display =
    $(_wprprefix+ctlSelID).style.display =
    $(_arwprefix+ctlSelID).style.display = "none";
  } else {
    $(ctlSelID).style.display=="none";
    if ($(_eltprefix+ctlSelID)) {
      $(_eltprefix+ctlSelID).style.display =
      $(_iptprefix+ctlSelID).style.display =
      $(_wprprefix+ctlSelID).style.display =
      $(_arwprefix+ctlSelID).style.display = "none";
    }
  }
}};



<!--video搜索JS-->			

function head_search()
{
	var obj = document.getElementById("selectType");
	var context = document.getElementById("context").value;
	var lk = document.getElementById("link");
	var dest;
	if(obj.selectedIndex == 0)
	{
		dest = "/searchre.htm?q=";
	}
	else if(obj.selectedIndex == 2)
	{
		dest = "/groupsch.htm?s=";
	}
	else if(obj.selectedIndex == 1)
	{
	dest = "/userinfo.htm?u=";
	}
	lk.href = "http://video.qq.com" +dest+ encodeURIComponent(context);
	return true;
}

<!--TV搜索JS-->	
var key = [];

key[0] = "十兄弟";

key[1] = "我的师傅系黄飞鸿";

key[2] = "杨家将";

key[3] = "勇探实录";

function initHeight()
{
	window.parent.document.getElementById("search_frm").height = document.body.scrollHeight;
}
function WriteHotKey()
{
	var html="";
	for (var i=0; i<key.length && i<8; ++i)
	{
		html += "<a href=\"javascript:doSearch('"+key[i]+"')\" class=\"padlr5\">"+key[i]+"</a>";
	}
	document.write(html);
}
function SearchInputLook(param)
{
	if(event.keyCode==13 || param==1)
	{
		if(document.getElementById("word").value == "") 
		{
			alert("请输入您要搜索的关键字!");
			return false;
		}
		var url="http://tv.qq.com/search.htm?word="+escape(document.getElementById("word").value);
		//window.parent.location.href=url;//当前窗口打开
		window.open(url,'','');//另一窗口打开
		return true;
	} 
}
function doSearch(key)
{
	var url="http://tv.qq.com/search.htm?word="+escape(key);
	//window.parent.location.href=url;//当前窗口打开
	window.open(url,'','');//另一窗口打开
}
