﻿///Common/images/_skysales/
// Balloon_popup


//Creates popup balloons for rollovers. 
//Usage:
//In html file, define a div within a div containing the text/elements to be in the popup
//  <div><div id="popup_contents" style="display:none;"><div id="inner_contents" style="height:50px;width:50px; background-color:White;">
//   popup text
//   </div></div>
//
//
// Also define an element in your page to be an anchor for the div. Then call the popup and depop 
// functions on your mouseover element:
//
// <tr id="popup_anchor" >
//            <td>
//           <img src="sample.bmp" onmouseover="popup('popup_contents','popup_id', 'popup_anchor');" onmouseout="depopup('popup_id')"/>
//            </td>
//        </tr>

var table_outline_start = '<TABLE class="PopupBalloon" style="Z-INDEX: 1" cellSpacing="0" cellPadding="0" border="0"><TR style="HEIGHT: 1px"><TD style="BACKGROUND: url(/Common/images/_skysales/balloon_top_border.gif)" colSpan="3"></TD></TR><TR><TD style="BACKGROUND: url(/Common/images/_skysales/balloon_left_border.gif); WIDTH: 1px"></TD><TD id="content_cell" style="BACKGROUND-COLOR: white">'
var table_outline_end = '</TD><TD style="BACKGROUND: url(/Common/images/_skysales/balloon_right_border.gif); WIDTH: 2px"></TD></TR><TR><TD colSpan="3"><TABLE cellSpacing="0" cellPadding="0" width="100%" border="0" ><TR style="HEIGHT: 6px;"><TD style="BACKGROUND-IMAGE: url(/Common/images/_skysales/balloon_bottom_border.gif); WIDTH: 1px"></TD><TD style="BACKGROUND: url(/Common/images/_skysales/balloon_tab.gif); WIDTH: 20px"></TD><TD style="BACKGROUND: url(/Common/images/_skysales/balloon_bottom_border.gif) repeat-x left top;padding: 0px 0px 0px 3px;"></TD></TR></TABLE></TD></TR></TABLE>'


//popup: shows the popup
//
// contents:   pointer to DIV that defines the text/html elements to place in the popup
// popup_id:   a unique string to use as the id of the newly created popup
// anchor:     the HTML element that defines where to put the popup
// x, y  :     offsets to the anchor to help with placement (generic browser)
// ff_x, ff_y: offsets to use for firefox. 

function popup(contents, popup_id, anchor, x, y, ff_x, ff_y)
{
 
    
    //first see if popup exists yet
      
    var thisPopup = document.getElementById(popup_id);
    if (thisPopup == null)
    {

        //create a new div that includes the table outline 
        var ni = document.getElementById(anchor);
        var newdiv = document.createElement('div');
        var divIdName = popup_id;
        newdiv.setAttribute('id',divIdName);
        newdiv.style.position = "absolute";
        newdiv.style.visibility = "visible";
        
        var contents = document.getElementById(contents);
        var anchor_x = findPosX(anchor);
        var anchor_y = findPosY(anchor);
        var real_left = 0;
        var real_top = 0;
        
        if (isFireFox())
        {
            real_left = anchor_x + ff_x  + "px";
            real_top = anchor_y + ff_y + "px";

        }
        else
        {
            real_left = anchor_x + x + "px";
            real_top = anchor_y + y + "px";
         
        }
        
        newdiv.style.left = real_left;
        newdiv.style.top = real_top;
         
        if (IsIE6())
        {
            var ifr = document.createElement("iframe");
           
            ifr.setAttribute("frameBorder", "0");
            ifr.setAttribute('id', popup_id + "_IFRAME");
            ifr.style.left = real_left;
            ifr.style.top = real_top;
            ifr.style.width = contents.offsetWidth + 3 + "px"; //3 = the width of the img elements in the table
            ifr.style.height = contents.offsetHeight + 7 + "px"; //7 = the height of the img elements in the table
           
            ifr.setAttribute("src", "");
            ifr.style.position="absolute";
             
            document.body.appendChild(ifr);  
           
            newdiv.innerHTML = table_outline_start + contents.innerHTML + table_outline_end;
       
    }
    else
    {
                newdiv.innerHTML = table_outline_start + contents.innerHTML + table_outline_end;

    }
    
        debugwrite(newdiv.innerHTML);
        document.body.appendChild(newdiv);
        
  
}
    else
    {
        thisPopup.style.visibility = 'visible';
    }
  
}

function debugwrite(str)
{
        var mytext = document.getElementById("mytext");
        if (mytext != null)
        {
            mytext.value = str;
        }
}


function depopup(popup_id)
 {
    var d = document.getElementById(popup_id);
  var i = document.getElementById(popup_id + "_IFRAME");
  
  if (d != null)
  {
    d.style.visibility='hidden';
    document.body.removeChild(d);
  }
  if (i != null)
  {
    document.body.removeChild(i);
  }
}


function IsIE6()
{
  
   if(navigator.userAgent.indexOf("MSIE 6.0") > -1)
    {
    var ret = 1;
    }
 else
  {
    var ret = 0;
    }
    return ret;

   

}

function isFireFox()
{
    if(navigator.userAgent.indexOf("Firefox") > -1)
    {
    var ret = 1;
    }
 else
  {
    var ret = 0;
    }
    return ret;
}



function findPosX(parent)
  {
  var obj = document.getElementById(parent);
  
  var curleft = 0;
  if (obj.offsetParent)
  {
  while (obj.offsetParent)
  {
  curleft += obj.offsetLeft
  obj = obj.offsetParent;
  }
  }
  else if (obj.x)
  curleft += obj.x;
  return curleft;
  }

  function findPosY(parent)
  {
  
  var obj = document.getElementById(parent);
  
  var curtop = 0;
  if (obj.offsetParent)
  {
  while (obj.offsetParent)
  {
  curtop += obj.offsetTop
  obj = obj.offsetParent;
  }
  }
  else if (obj.y)
  curtop += obj.y;
  return curtop;
  }

