var isShowing=false;

function showMortgageCalculator(){

if(!isShowing) {
                var divE=document.createElement("div");
                    divE.id="MortgageCalcID";
                    divE.style.position="absolute";
                    //divE.style.top="100px";
                    //divE.style.left="300px";
                   divE.style.width="340px";
                    divE.style.height="300px";
                    var cen = getCenter();
                        divE.style.left=cen.ri+"px";
                        divE.style.top=cen.down+"px"; 
                    if(!document.all)divE.style.border="1px solid black"; 
                     divE.style.backgroundColor="#DDDDDD";   
                var tableE=document.createElement("table");
                    tableE.width="100%"; 
                var tbodyE=document.createElement("tbody");
                var trE=document.createElement("tr");
                var tdE=document.createElement("td");
                    tdE.innerHTML="Mortgage loan calculator";
                    trE.appendChild(tdE);
                    tdE = document.createElement("td");
                    tdE.style.width="20px";
                    tdE.innerHTML="X";
                    tdE.style.cursor="pointer";
                    tdE.onclick=closeMortgageCalc;
                    tdE.style.textAlign="right";
                    tdE.style.backgroundColor="red";
                    trE.appendChild(tdE);
                    tbodyE.appendChild(trE);
                    trE=document.createElement("tr");
                    tdE=document.createElement("td");
                    tdE.colSpan="2";
                 var iE =document.createElement("iframe");
                      iE.src="http://www.billcut.com/jsp/util/mortgageCalculator.html";
                      iE.style.width="100%";
                      iE.style.height="250px";
                      iE.style.border="none"; 
                      tdE.appendChild(iE);
                      trE.appendChild(tdE);
                    tbodyE.appendChild(trE); 

                    tableE.appendChild(tbodyE);
                    divE.appendChild(tableE);
                    document.body.appendChild(divE);
                    isShowing=true;
                }  
   
 

}

function getCenter(){
var sX=0,sY=0;
   if(document.body && typeof document.body.scrollTop !="undefined"){
           sX +=document.body.scrollLeft;
           sY +=document.body.scrollTop;
          if(document.body.parentNode && typeof document.body.parentNode.scrollTop !="undefined"){
               sX += document.body.parentNode.scrollLeft;
               sY += document.body.parentNode.scrollTop;
           }
   }
   else if(typeof window.pageXOffset != "undefined"){
      sX += window.pageXOffset;
      sY == window.pageYOffset;
     }

var x = Math.round((getWindowW()-340)/2)+sX;
var y = Math.round((getWindowH()-300)/2)+sY;
    
return {ri:x,down:y};
  

}

function getWindowH(){
var  isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? 
            true : false;

  if (window.innerHeight) {
        return window.innerHeight;
    } else if (isIE6CSS) {
        // measure the html element's clientHeight
        return document.body.parentElement.clientHeight;
    } else if (document.body && document.body.clientHeight) {
        return document.body.clientHeight;
    }
    return 0;

}

function getWindowW(){
var  isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? 
            true : false;
 if (window.innerWidth) {
        return window.innerWidth;
    } else if (isIE6CSS) {
        // measure the html element's clientWidth
        return document.body.parentElement.clientWidth;
    } else if (document.body && document.body.clientWidth) {
        return document.body.clientWidth;
    }
    return 0;

}

function closeMortgageCalc(){
  if(document.getElementById("MortgageCalcID")) document.body.removeChild(document.getElementById("MortgageCalcID"));
  isShowing=false;
}
