function qm_togglePopup(popupId){
	var e = document.getElementById(popupId);
	var bg = e.getElementsByTagName("DIV").item(0);
	bg.style.height = e.getElementsByTagName("DIV").item(1).offsetHeight;

	if(bg.filters){
		if(!bg.filters[0]) window.setTimeout(function(){ bg.style.filter = "alpha(opacity=20)"; }, 1);
	} else {
		bg.style.MozOpacity = "0.20";
		bg.style.opacity = "0.20";
	}

	if(e && e.style.visibility && e.style.visibility == "visible"){

		e.style.visibility="hidden";

	} else if(e && e.style.visibility && e.style.visibility == "hidden"){

		e.style.visibility="visible";

	}
}


function qm_toggleDynamicPopup(popupId, cell, header, con){
	//alert("calling qm_toggleDynamicPopup with  popupId " + popupId + " cell "  + cell  + " header " + header + " con " + con );
	var e = document.getElementById(popupId);
	var bg = e.getElementsByTagName("DIV").item(0);
	bg.style.height = e.getElementsByTagName("DIV").item(1).offsetHeight;

	if(bg.filters){
		if(!bg.filters[0]) window.setTimeout(function(){ bg.style.filter = "alpha(opacity=20)"; }, 1);
	} else {
		bg.style.MozOpacity = "0.20";
		bg.style.opacity = "0.20";
	}

   var headerYPos = getYPos(cell);
   var popup = getYPos(header);

    headerYPos = headerYPos - popup;
    var posY =  headerYPos.toString() + "px";
    var cellX = getXPos(cell);
    var posX = 80;       
           posX = posX.toString() + "px";
     e.style.left = posX;
     e.style.top = posY;

	 if(e && e.style.visibility && e.style.visibility == "hidden"){
			e.style.visibility="visible";
      }
    
}


function qm_togglePopupGone(popupId){
	var e = document.getElementById(popupId);
	var bg = e.getElementsByTagName("DIV").item(0);

	if(e && e.style.visibility && e.style.visibility == "visible"){
		e.style.visibility="hidden";

	}
}

function getYPos(ele){
 //alert("getting element by id " + ele )
    var obj = document.getElementById(ele);
// alert("obj" + obj);
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;

    return curtop;
}

function getXPos(ele){
    var obj = document.getElementById(ele);
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;

}

function setHoverDiv(symbolLink, symboChart){   
	symbolLink.hover( function(){
	                var titleDivString = $(this).attr(symboChart);
	                var dialog = $('#'+titleDivString);
	                var scrollTop = $(window).scrollTop();
	               if($(window).scrollTop() + $(window).height() == $(document).height()
	                       && (symbolLink.position().top  + $(window).scrollTop()) > $(document).height()  ) {
	                    dialog.css("top", symbolLink.position().top - scrollTop - 60);
	               } else {
	                  dialog.css("top", symbolLink.position().top - scrollTop);   
	               }
	                              
	               
	               dialog.css("left", symbolLink.position().left + symbolLink.width() + 25);
	                              
	               var viewportRight  = $(window).width();
	               var absoluteRight  = symbolLink.position().left + symbolLink.width() + 25 + 350;
	               
	               if (absoluteRight > viewportRight) {
	                    var nowleft = dialog.css("left");
	                    dialog.css("left",symbolLink.position().left - 325);
	                    dialog.css("right",symbolLink.position().right + symbolLink.width() + 25);
	                }
	               
	               dialog.css("position", "fixed"); 
	               dialog.show();               
	               },function () {
	               var symbolLink = $(this);
	                var titleDivString = $(this).attr('titlediv');
	                var dialog = $('#'+titleDivString);
	                         dialog.hide();
	  });
	}


function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}

function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 

function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}
                 




