var sURLGlobal = "";

function getQuerystring()
{
   parentUrl = location.href;
   if (parentUrl.indexOf("?") > 0)
   {
      i = parentUrl.indexOf("?")      
      return parentUrl.substring(i,parentUrl.length);  
   }
   else
   {
      return "";
   }
} 

// loads new pages into the iframe 
function loadIframe(iframeName, url) {
    if (window.frames[iframeName] ) {         	
        sURLGlobal = url + getQuerystring();
        window.frames[iframeName].location = sURLGlobal;                   
        return false;
    }
    return true;

}

function getDomain (thestring) 
{
   //simple function that matches the beginning of a URL
   //in a string and then returns the domain.
   thestring = thestring + "/&d=1";
   var urlpattern = new RegExp("(http|ftp|https)://(.*?)/.*$");
   var parsedurl = thestring.match(urlpattern);
   if (parsedurl)
   {
       return parsedurl[2];
   }
   else
   {
       return "";
   }
}

function resize_iframe()
{
   var name = "I1";
   var sParent = getDomain(location.href);
   var sChild = getDomain(sURLGlobal);
   var bInternal = true;


   if ((sChild == "")||(sChild == null))
   {
      bInternal = true;
   }
   else
   {
      if (sChild.toLowerCase() != sParent.toLowerCase())
      {
         // External page
         bInternal = false;
      }
      else
      {
         // Internal page
         bInternal = true;
      }
   }

   if (bInternal)
   {
      // Internal page
      document.getElementById(name).height=850;
      document.getElementById(name).height=window.frames[name].document.body.scrollHeight;
   }
   else
   {
      // External page
      try
      {
         document.getElementById("ifrdiv").innerHTML = '<iframe id="I1"  height="850" src="' + sURLGlobal + '" name="I1" class="Myframe" frameborder="0" border="0" width="100%" scrolling="auto" ALLOWTRANSPARENCY="true">Your browser does not support inline frames or is currently configured not to display inline frames.</iframe>';
      }
      catch (e)
      {
      }
   }

}