
var mx,my;			//鼠标x坐标

function gel(a){
	return document.getElementById?document.getElementById(a):null;
}
function openPreviewWin(surl,stitle,skey){
		var wh=jQuery(window).height();  //窗口高度
		var ww=jQuery(window).width();  //窗口宽度
		var sw=screen.width; //显示器宽度
		var leftw;    //屏幕左边宽度

		var ttop=jQuery(window).scrollTop();    //滚动条高度
		if(sw==1024){
			leftw=732;
		}else if(sw==800){
			leftw=510;
		}else{
			leftw=770;
		}

		gel("prv-window").style.width=ww-leftw-10+"px";
		gel("prv-window").style.height=wh-90+"px";  //其中减去的60px为标题栏高度
		gel("prv-window").style.top=ttop+10+"px";
		gel("prv-window").style.left=leftw+"px";
		gel("prv-contentid").style.height=wh-90+"px";
		gel("prv-frame").style.height=wh-90+"px";

		//获取尺寸中的数值
		var mystr=gel("prv-window").style.width;
		var npw=mystr.substring(0,mystr.length-2); //prv-window宽度
		//alert("tpx="+tpx);
		var mystr=gel("prv-window").style.height;
		var nph=mystr.substring(0,mystr.length-2);	//prv-window高度

		gel("prv-contentid").style.width=npw-40+"px";


		//url转向
		gel("prv-frame").src=surl;
		gel("title_text").innerHTML = stitle;
		//jQuery("prv-contentid").css("width",Number(gel("prv-window").style.width)-200+"px");
		//jQuery("").css("","");
		//alert("document.body.clientHeight=" + document.body.clientHeight);
		//alert("MouseX=" + Number(gel("prv-window").style.width)-200+"px");
		jQuery("#prv-window").css("display", "block");

}


	function mouseMove(ev)
	{
	 ev= ev || window.event;
		var mousePos = mouseCoords(ev);

				return mx=mousePos.x;
				return my=mousePos.y;
	}
	function mouseCoords(ev)
	{
	 if(ev.pageX || ev.pageY){
		 return {x:ev.pageX, y:ev.pageY};
	 }
	 return {
			 x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
			 y:ev.clientY + document.body.scrollTop - document.body.clientTop
	 };
	}

document.onmousemove = mouseMove;

function closePreviewWin(){
  jQuery("#prv-window").css("display", "none");
}

function getWinSize() {
  return {
    width: jQuery(window).width(),
    height: jQuery(window).height()
  }
}

function getWinScroll() {
  return {
    top: jQuery(window).scrollTop(),
    left: jQuery(window).scrollLeft()
  }
}

function previewScrollTo($) {
  navigator.userAgent.toLowerCase().indexOf("msie") != -1 ? jQuery("#prv-contentid").attr("scrollTop", $ - 75) : jQuery("#prv-contentid").attr("scrollTop", $ - 100)
}

var termNavPosition = new Array(20);
function gotoNextKey(B) {
  ct(g_title, g_encodedQuery, g_pos, "MAG_HIT", undefined, undefined, "gotonext=1");
  var _ = termNavPosition[B],
  $ = _ + 1,
  A = B + "_" + $;
  A = document.getElementById(A);
  _ = document.getElementById(B + "_" + _);
  if (A) {
    previewScrollTo(A.offsetTop);
    if (_) _.className = "";
    A.className = "hlb";
    termNavPosition[B] = $
  } else if ($ == 1) {
    previewScrollTo(0);
    termNavPosition[B] = +0
  } else {
    A = B + "_1";
    A = document.getElementById(A);
    previewScrollTo(A.offsetTop);
    if (_) _.className = "";
    A.className = "hlb";
    termNavPosition[B] = 1
  }
}
function resetIndex() {
  for (var $ = 0; $ < 20; $++) termNavPosition[$] = 0
}
function onLinkClick() {
  ct(g_title, g_encodedQuery, g_pos, "MAG_HIT", undefined, undefined, "linkclick=1")
}
function onImgLoad(A) {
  A.onload = null;
  var _ = jQuery(A),
  $ = A.width;
  if ($ > g_winWidth - 80) {
    $ = A.height * (g_winWidth - 80) / $;
    _.css("width", g_winWidth - 80);
    _.css("height", $)
  }
  if (A.width < 50 && A.height < 50) A.style.display = "none";
  else if (A.width < 30 || A.height < 30) A.style.display = "none";
  else {
    _.before("<br>");
    _.after("<br>")
  }
}
function resizeVideo() {
  jQuery(".ydPrvVideo").each(function(A, _) {
    A = jQuery(_);
    _ = A.width();
    var $ = A.height();
    if (_ > g_winWidth - 80) {
      _ = $ * (g_winWidth - 80) / _;
      A.width(g_winWidth - 80);
      A.height(_)
    }
  })
}

