/************************************************************************************************************
Ajax dynamic list
Copyright (C) September 2005  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com

************************************************************************************************************/	
var xPos, yPos;
var ARROW_HEAD_LPOS = 65;

//addEvent(window, 'load', loadMousMoveEvent);

function loadMousMoveEvent(){
    if(!isPortal){
        addEvent(window, 'mousemove', setXYpos);
    }
}

function setXYpos(event){
    //alert('');
    if(!event)event = window.event;
    //alert(e);
    xPos = event.clientX;
    yPos = event.clientY;
    $("debug").innerHTML="XPos = "+xPos+" YPos = "+yPos
    //return window.event;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function showBubbleTipCommon(e, text, divId, spanId, halfWidth, height){
    hideBubbleTip();
    if(document.all)e = event;
    var obj = $(divId);
    var obj2 = $(spanId);
    obj2.parentNode.style.height= height + "px";
    obj2.innerHTML = text;
    obj.style.display = 'block';
    //alert(tt_GetClientW());
    //alert(obj.offsetWidth);
    var scrollXY = getScrollXY();
    var st = scrollXY[1];//Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
    var leftPos = e.clientX - halfWidth;
    if(leftPos<0)leftPos = 0;
    // Check if tip exceed page edge ...
    var RightPos = e.clientX + obj.offsetWidth - halfWidth;
    if(divId.indexOf('tag_tooltip',0)>-1 && RightPos>tt_GetClientW()){ // Flip tip to inside: Fixed for tag tip only...
        leftPos = e.clientX - obj.offsetWidth + halfWidth;
        var BottomDivObj = $('Tag_Arrow');
        BottomDivObj.style.backgroundImage = "url('/images/tip/Col_Tag_Bottom_Inv.gif')";
    }
    //alert(RightPos + "--" + (RightPos>tt_GetClientW()));
    //..................................
    obj.style.left = leftPos + scrollXY[0] + 'px';
    obj.style.top = e.clientY - obj.offsetHeight -3 + st + 'px';
    
}

function hideBubbleTip()
{
    try{
        if($('bigbubble_tag_tooltip')!=null)
            $('bigbubble_tag_tooltip').style.display = 'none';
        if($('bubble_tooltip')!=null)
            $('bubble_tooltip').style.display = 'none';
        if($('tag_tooltip')!=null)
            $('tag_tooltip').style.display = 'none';
        else
            this.parent.document.getElementById('bubble_tooltip').style.display = 'none';
    }catch(e){}
}

function showBubbleTip(e,text,height){
    if(typeof height == undefined || height==null || !height){
        height=80;
    }
    showBubbleTipCommon (e, text, 'bubble_tooltip', 'bubble_tooltip_content', ARROW_HEAD_LPOS, height);
    /*
    if(document.all)e = event;
    var documentObj = document;
    var obj = $('bubble_tooltip');
    var obj2 = $('bubble_tooltip_content');
    //var xPos = e.clientX;
    //var yPos = e.clientY;
    var st = Math.max(documentObj.body.scrollTop,documentObj.documentElement.scrollTop);
    if(obj==null){ // Portals handlers: check for dashboard object ...
    //this.parent.showBubbleTip(this.parent.getEventObj(),text);
    //this.parent.getEventObj(event);
    //return;
    documentObj = this.parent.document;
    //e = this.parent.event;
    //alert(documentObj.documentElement.scrollTop);
    //st = documentObj.documentElement.scrollTop;
    //st = documentObj.documentElement.scrollTop;//documentObj.documentElement.scrollTop;
    //xPos = e.screenX;
    //yPos = e.screenY;
    //alert(e.layerY + " ---- " + e.pageY);
    //getMouseXY(e.parent);
    
    
    obj = documentObj.getElementById('bubble_tooltip');
    obj2 = documentObj.getElementById('bubble_tooltip_content');
    
    }
    obj2.parentNode.style.height="80px";
    obj2.innerHTML = text;
    obj.style.display = 'block';
    
    if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
    var leftPos = e.clientX - 65;
    if(leftPos<0)leftPos = 0;
    obj.style.left = leftPos + 'px';
    obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
    //alert(obj.style.top);
    */
}	

function showCompanyDescriptionTip(e,text){
    showBubbleTipCommon (e, text, 'bubble_tooltip', 'bubble_tooltip_content', ARROW_HEAD_LPOS, 180);
}

function showCollaborationTagTip(e, collaborationId){
    var tagText = '<div id=\"WAIT\" class=\"TagWait Purple\">Loading... Please Wait</div><iframe width=\"345\" height=\"180\" src=\"/collaborations/collaborationtags.html?collaboration='+collaborationId+'\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" allowtransparency=\"true\" onload=\"hideWait();parent.closeBubble=true;\"  style=\"display:none\"></iframe>';
    showBubbleTipCommon (e, tagText, 'tag_tooltip', 'tag_tooltip_content', ARROW_HEAD_LPOS, 180);
}
function showForumTagTip(e, forumId){
    var tagText = '<div id=\"WAIT\" class=\"TagWait Purple\">Loading... Please Wait</div><iframe width=\"345\" height=\"180\" src=\"/forums/threadtags.html?forum='+forumId+'\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" allowtransparency=\"true\" onload=\"hideWait();parent.closeBubble=true;\" style=\"display:none\"></iframe>';
    showBubbleTipCommon (e, tagText, 'tag_tooltip', 'tag_tooltip_content', ARROW_HEAD_LPOS, 160);
}

function showExpertiseTip(e,accountId){
    var tagText = "<div id=\"WAIT\" class=\"TagWait Purple\">Loading... Please Wait</div><iframe width=\"375\" height=\"210\" src=\"/member/accountexpertise.html?account="+accountId+"\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" allowtransparency=\"true\" onload=\"hideWait(event);parent.closeBubble=true;\" style=\"display:none\"></iframe>";
    showBubbleTipCommon(e, tagText, 'bigbubble_tag_tooltip', 'bigbubble_tag_tooltip_content', ARROW_HEAD_LPOS, 210);
}

function hideWait(event){
    $("WAIT").style.display="none";
    $("WAIT").nextSibling.style.display="";
}