
//var docWd = 0;

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  var sw, ow;

  if (doc.height){
    docHt = doc.height;
    //docWd = doc.width;
  }
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;


    //if (doc.body.scrollWidth) docWd = sw = doc.body.scrollWidth;
    //if (doc.body.offsetWidth) docWd = ow = doc.body.offsetWidth;

    if((sh*1) > 150){
        if (sh && oh) docHt = Math.max(sh, oh);
        //if (sw && ow) docWd = Math.max(sw, ow);
    }
    
    if ((sh*1) > 0 ){
        docHt = sh;
        //docWd = sw;
    }else{
        docHt = oh; 
        //docWd = ow;

    }
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  
  if ( iframeEl && iframeWin ) {

    iframeEl.style.height   = "auto"; // helps resize (for some) if new doc shorter than previous  
    //iframeEl.style.width    = "auto"; // helps resize (for some) if new doc shorter than previous  

    var docHt = getDocHeight(iframeWin.document);


    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + "px";
    //if (docWd > 0) iframeEl.style.width = docWd + "px";

  }



}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}

function calcHeight()
{
	//find the height of the internal page
	var the_height=	document.getElementById('servicearea').contentWindow.document.body.scrollHeight;

	//change the height of the iframe
	document.getElementById('servicearea').height=the_height;
}

$("#servicearea").css("height", "1px");
var h = $("#servicearea",top.document).contents().height();
$("#servicearea").css("height", h);


