﻿// JScript File

//        function ChangeHeight(h, id)
//        {
//            var iframe = document.getElementById(id);
//            
//            //iframe.height = h;            
//            //iframe.onload=new function(){};
//            iframe.document.onreadystatechange=fnStartInit;
//            
//            
//        }
        
        
        function fnStartInit()
        {
           //alert(document.readyState);                
           
           if (document.readyState=="complete")
           {                
              // Finish initialization.
              if(ifrOptions!=null){
                PrivateChangeHeight(getInnerHeight(ifrOptions), "ifrOptions");               
              }
           }
        }
        
        function PrivateChangeHeight(h, id)
        {           
            
            var iframe = document.getElementById(id);
            
            iframe.height = h;            
        }
        
        function ChangeHeight(h, id)
        {        
            
            var iframe = document.getElementById(id);
            //PrivateChangeHeight(getInnerHeight(iframe), id);
            iframe.onload=new function(){PrivateChangeHeight(getInnerHeight(this), "ifrOptions");};
            
            //iframe.document.onreadystatechange=fnStartInit;
            //var d = iframe.contentWindow ? iframe.contentWindow.document : iframe.contentDocument;
            //d.onreadystatechange=fnStartInit;
            
            //iframe.height = h;            
            
        }
        
        function AddHeight(h, id)
        {
            var iframe = document.getElementById(id);
            
            iframe.height += h;
        }
        function AppendQueryString(id)
        {
            var iframe = document.getElementById(id);            
            var address = window.location.href;
            var query = window.location.search;
            
            iframe.src += query;
        }
        
        function getInnerHeight(iframe){
            
            var d=iframe.contentWindow ? iframe.contentWindow.document : iframe.contentDocument;
            var h=0;
            if(!d)
                var d=iframe.document;
               
            if(d){
                if(d.documentElement && d.compatMode && d.compatMode=="CSS1Compat"){
                    if(d.documentElement){
                        h=d.documentElement.scrollHeight;                        
                    }else{ 
                        if(d.body){
                            h=d.body.scrollHeight;                        
                        }
                    } 
                }                
            }
            //debugger;
            if(h){ 
                h+=getInsets(d);
                h += 30;
            }
            
            //alert(h);
            
            
            return h ? "" +h+"px" : "1800px"; //1100 is a default value
        }
        
        function getInsets(d){
            if(d.body){
                if(d.body.currentStyle)
                    with (d.body.currentStyle)
                    return (parseInt(marginTop)||0) +
                        (parseInt(marginBottom)||0) +
                        (parseInt(paddingTop)||0) +
                        (parseInt(paddingBottom)||0);
            }
            if(d.defaultView && d.defaultView.getComputedStyle)
                with (d.defaultView)
                return parseInt(getComputedStyle(d.body,"").
                        getPropertyValue("margin-top"))+
                        parseInt(getComputedStyle(d.body,"").
                        getPropertyValue("margin-bottom"))+
                        parseInt(getComputedStyle(d.body,"").
                        getPropertyValue("padding-top"))+
                        parseInt(getComputedStyle(d.body,"").
                        getPropertyValue("padding-bottom"));
            return 0;
        }
        
        function resizeIframe(){
            //debugger;
            if(window['already']==null || window['already']==false)
                //ifrOptions.frameElement.style.height=getInnerHeight(ifrOptions);
                ChangeHeight(getInnerHeight(ifrOptions), "ifrOptions");
            else
                window['already']=false;
        }
        
        //window.parent.ChangeHeight(getInnerHeight(ifrOptions), "ifrOptions"); 
        
        