﻿
var dcwith=200;
var showTime = 500;
var timeDO = null;
var prevFrom = null;
var mFrom = null;
var pBox = null;
var pFrom = null;
var frm="<iframe id='prfr' frameborder='0' tabindex='-1' style='z-index:-1;position: absolute;left:0px;top:0px;width:expression(this.parentNode.offsetWidth+\"px\");height:expression(this.parentNode.offsetHeight+\"px\");' scrolling='no' src=''></iframe>";
document.write("<div id='previewBox'  style=\"display: none;width:"+dcwith+"px;\" onMouseOut=\"tips_hid(event);\"></div>");

var posLib_tips = 
{
    getClientLeft:function (el) {
     var r = el.getBoundingClientRect();
     return r.left- this.getBorderLeftWidth(this.getCanvasElement(el));
    },

    getClientTop:    function (el) {
     var r = el.getBoundingClientRect();
      return r.top - this.getBorderTopWidth(this.getCanvasElement(el));
    },

    getLeft:    function (el) {
      return this.getClientLeft(el) + this.getCanvasElement(el).scrollLeft;
    },

    getTop:    function (el) {
      return this.getClientTop(el) + this.getCanvasElement(el).scrollTop;
    },

    getInnerLeft:    function (el) {
      return this.getLeft(el) + this.getBorderLeftWidth(el);
    },

    getInnerTop:    function (el) {
      return this.getTop(el) + this.getBorderTopWidth(el);
    },

    getWidth:    function (el) {
      return el.offsetWidth;
    },

    getHeight:    function (el) {
      return el.offsetHeight;
    },

    getCanvasElement:    function (el) {
      var doc = el.ownerDocument || el.document;    // IE55 bug
      if (doc.compatMode == "CSS1Compat")
        return doc.documentElement;
      else
        return doc.body;
    },

    getBorderLeftWidth:    function (el) {
      return el.clientLeft;
    },

    getBorderTopWidth:    function (el) {
      return el.clientTop;
    },

    getScreenLeft:    function (el) {
      var doc = el.ownerDocument || el.document;    // IE55 bug
      var w = doc.parentWindow;
      return w.screenLeft + this.getBorderLeftWidth(this.getCanvasElement(el)) + this.getClientLeft(el);
    },

    getScreenTop:    function (el) {
      var doc = el.ownerDocument || el.document;    // IE55 bug
      var w = doc.parentWindow;
      return w.screenTop  + this.getClientTop(el);//+ this.getBorderTopWidth(this.getCanvasElement(el))
    }
}
//2
function getobj(o){
	return document.getElementById(o);
}
function showTips(o, c){
	if(!getobj(o + '_temp')){
		var a = document.createElement("div");

		var newY =posLib_tips.getTop(o)+13;	
		var RightEdge = document.body.clientWidth-posLib_tips.getLeft(o);  
		var newX =posLib_tips.getLeft(o)-(dcwith/2)+30;
        if(RightEdge<dcwith)//右边
		{
           newX =posLib_tips.getLeft(o)-150;
        }
       
        if(RightEdge>posLib_tips.getLeft(o))//左边
        {
           newX =posLib_tips.getLeft(o)+150;
        }
        
        var BottomEdge = document.body.clientHeight-posLib_tips.getTop(o);//高
//        if(BottomEdge<10)//上边
//		{
//           newY =posLib_tips.getTop(o)+500;
//        }
       

		with(a.style){
			background = '#fff';
			border = '1px solid #ccc';
			fontSize = '12px';
			position = 'absolute';
			top = newY +'px';
			left = newX +'px';
			right = o.style.right;
			padding = '10px';
			width =dcwith+'px';
			
			overflow = 'hidden';
		}
		a.id = o + '_temp';
		document.body.appendChild(a);
		function Show(){
			if(parseInt(a.style.width) < 200){
				a.style.width = parseInt(a.style.width) + 20 + 'px';
				a.style.height = parseInt(a.style.height) + 10 + 'px';
				setTimeout(Show, 1);
			}
			else{
				a.innerHTML =frm+ c;
			}
		}
		Show();
	}
	o.onmouseout = getobj(o + '_temp').onmouseout = function(e){
		var e = window.event || e;
		var s = e.toElement || e.relatedTarget;
		if(getobj(o + '_temp') && s != getobj(o + '_temp') && s != o && s.parentNode != getobj(o + '_temp')){
			function Hide(){
				if(!getobj(o + '_temp')){
					return false;
				}
				getobj(o + '_temp').innerHTML = '';
				if(parseInt(getobj(o + '_temp').style.width) > 0){
					getobj(o + '_temp').style.width = parseInt(getobj(o + '_temp').style.width) - 20 + 'px';
					//getobj(o + '_temp').style.height = parseInt(getobj(o + '_temp').style.height)  + 'px';
					setTimeout(Hide, 1);
				}
				else{
					document.body.removeChild(getobj(o + '_temp'));
				}
			}
			Hide();
		}
	}
}

