
 function gettime(date){
    var nowtime=new Date();
    var timespan = parseInt((nowtime.getTime()-date.getTime())/1000);//秒差
    if(timespan<60) return timespan+'秒前';
    if(timespan<(60*60)) return parseInt(timespan/60)+'分前';
    if(timespan<(60*60*24)) return parseInt(timespan/(60*60))+'小时前';
    if(timespan<(60*60*24*30)) return parseInt(timespan/(60*60*24))+'天前';
    if(timespan<(60*60*24*365)) return parseInt(timespan/(60*60*24*30))+'个月前';
    return parseInt(timespan/(60*60*24*365))+'年前';
 }
    isSafari = (document.childNodes && !document.all && !navigator.taintEnabled);   
var getXY = function(el) {   
    if (document.documentElement.getBoundingClientRect) { // IE  
        var box = el.getBoundingClientRect();   

        var rootNode = el.ownerDocument;   
        return [box.left + getDocumentScrollLeft(rootNode), box.top +   
                getDocumentScrollTop(rootNode)];   
    } else {   
        var pos = [el.offsetLeft, el.offsetTop];   
        var parentNode = el.offsetParent;   

        // safari: subtract body offsets if el is abs (or any offsetParent), unless body is offsetParent   
        var accountForBody = (isSafari &&   
                el.style['position'] == 'absolute' &&   
                el.offsetParent == el.ownerDocument.body);   

        if (parentNode != el) {   
            while (parentNode) {   
                pos[0] += parentNode.offsetLeft;   
                pos[1] += parentNode.offsetTop;   
                if (!accountForBody && isSafari &&    
                        parentNode.style['position'] == 'absolute' ) {    
                    accountForBody = true;   
                }   
                parentNode = parentNode.offsetParent;   
            }   
        }   

        if (accountForBody) { //safari doubles in this case   
            pos[0] -= el.ownerDocument.body.offsetLeft;   
            pos[1] -= el.ownerDocument.body.offsetTop;   
        }    
        parentNode = el.parentNode;   

        // account for any scrolled ancestors   
        while ( parentNode.tagName && !/^body|html$/i.test(parentNode.tagName) )    
        {   
           // work around opera inline/table scrollLeft/Top bug   
           if (parentNode.style['display'].search(/^inline|table-row.*$/i)) {    
                pos[0] -= parentNode.scrollLeft;   
                pos[1] -= parentNode.scrollTop;   
            }   
               
            parentNode = parentNode.parentNode;    
        }   

        return pos;   
    }   
}   

/**  
 * Returns the left scroll value of the document   
 * @method getDocumentScrollLeft  
 * @param {HTMLDocument} document (optional) The document to get the scroll value of  
 * @return {Int}  The amount that the document is scrolled to the left  
 */  
getDocumentScrollLeft = function(doc) {   
    doc = doc || document;   
    return Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);   
},    

/**  
 * Returns the top scroll value of the document   
 * @method getDocumentScrollTop  
 * @param {HTMLDocument} document (optional) The document to get the scroll value of  
 * @return {Int}  The amount that the document is scrolled to the top  
 */  
getDocumentScrollTop = function(doc) {   
    doc = doc || document;   
    return Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);   
}  

 function showlawyermsg(obj,n){
    
    if(n==1){
        var o=$(obj).parent().next().next().next().next().children('a').get(0);
        obj=o;
    }
   
    if(obj.name=='')return;        
    var s=obj.name.split('|');
    if(s.length==6){
        var pos=getXY(obj);
        var id=s[0];
        var url='http://lawyer.148365.com/user/'+id+'.html';
        var name=s[1];
        var face=s[2];
        var src=face;
        if(src=='')src='/images/NoFacePic1.gif';
        var tel=s[3];
        if(tel=='')tel='暂无';
        var sheng=s[4];
        var shi=s[5];
        document.getElementById('toolimglink').href=url;
        document.getElementById('toolimg').src=src;
        document.getElementById('toolname').href=url;
        document.getElementById('toolname').innerHTML=name+'律师';
        document.getElementById('toolarea').innerHTML=sheng+shi;
        document.getElementById('tooltel').innerHTML='电话:'+tel;
        
        document.getElementById('tooltip').style.left=(pos[0]+45)+'px';
        document.getElementById('tooltip').style.top=(parseInt(pos[1])-45)+'px';
        document.getElementById('tooltip').style.visibility='visible';
    }
 }
