﻿//http://dean.edwards.name/packer/
//simple Modal Popup

//NonStandard CSS Styles

	
var heightOfContent;
var heightOfPopUp;

var heightOfContentInEm;
var heightOfPopUpInEm;

var positionOfDetailLink;
var positionOfDetailLinkInEm;

     
//get the height of div all
window.onload = function()
{
    heightOfContent = document.getElementById('all').offsetHeight;
    heightOfContentInEm = heightOfContent / 16;
}

function showModal(obj, path, printPath)
{
    //get the position of the detail link
    //var posX = obj.offsetLeft;
    var posY = obj.offsetTop;
    while(obj.offsetParent)
    {
        //posX=posX+obj.offsetParent.offsetLeft;
        posY=posY+obj.offsetParent.offsetTop;
        if(obj==document.getElementsByTagName('body')[0])
        {
            break;
        }
        else
        {
            obj=obj.offsetParent;
        }
    }

    document.getElementById("modalOverlay").style.display ="block";
    document.getElementById("productPopUp").style.display ="block";
    document.getElementById("FillTheFrame").innerHTML = "<iframe marginheight=0 marginwidth=0 frameborder=0 src=\"" + path + "\"  scrolling=no width=660px height=500px id=DetailFrame></iframe>";
    document.getElementById("printPopUp").innerHTML = "<a target=\"_blank\" href=\"" + printPath + "\">Print</a>";

    //heightOfPopUp = document.getElementById('productPopUp').offsetHeight;
    //heightOfPopUpInEm = heightOfPopUp / 16;

    //positionOfDetailLinkInEm = posY /16;

    document.getElementById("modalOverlay").style.height = heightOfContentInEm +"em";

    var newYPos = positionOfDetailLinkInEm - heightOfPopUpInEm;
    //document.getElementById("productPopUp").style.top = newYPos +"em";
}






//hides the Overlay and PopUp
function hideModal()
   {
   document.getElementById("modalOverlay").style.display ="none";
   document.getElementById("productPopUp").style.display ="none";
   }