﻿    function fillterStringFin(str)
    {     
        var strReturn = str;    
        //tạm thời chỉ cover trường hợp thẻ form nằm ngay đầu đoạn reponseText
        if (str.toUpperCase().indexOf('<FORM') != -1)
        { 
            strReturn = str.replace(str.substring(str.toUpperCase().indexOf('<FORM'),str.indexOf('>') +1 ),'');
        }
        strReturn = strReturn.replace('</form>','');
        strReturn = strReturn.replace('</Form>','');
        strReturn = strReturn.replace('</FORM>','');                                              
        return strReturn;                                                                                     
              
    }
    function filerStringFPTSFIT(str)
    {
        var strReturn;
        strReturn = str.substring(str.indexOf('<fptsfit>'),str.indexOf('</fptsfit>'));
        return strReturn;
    }
    
    function loadpageFin(page_request, containerid){
        var st;
        if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
        {
            //alert(page_request.responseXML.documentElement.getElementsByTagName('compname').context.childNodes(0).text);
            st=page_request.responseText;
            document.getElementById('LoadingFin').style.display ='none';
            
            //document.getElementById('_ctl0_lblReport').style.visibility ='visible';
            document.getElementById('_ctl0_lblReport').innerHTML= filerStringFPTSFIT(fillterStringFin(st));  
                
        
        }
    }
   	function ajaxpageFin(url, containerid, subID)
	{
        var page_request = false;
        if (window.XMLHttpRequest) // if Mozilla, Safari etc
            page_request = new XMLHttpRequest()
        else if (window.ActiveXObject)
        { // if IE
            try 
            {
                page_request = new ActiveXObject("Msxml2.XMLHTTP")
            } 
            catch (e)
            {
                try
                {
                    page_request = new ActiveXObject("Microsoft.XMLHTTP")
                }
                catch (e)
                {
                }
            }
        }
        else
            return false
        if (subID != '0')
        {
            var strSubstring = url.split("?",2);
            var strSubstring2 = strSubstring[1].split("&",1);
            strSubstring = "s=" + subID;
            url = url.replace(strSubstring2,strSubstring);   
        }
        document.getElementById('LoadingFin').style.height = 15;
        document.getElementById('LoadingFin').style.visibility ='visible';
        document.getElementById('LoadingFin').style.display ='block';
        //document.getElementById('_ctl0_lblReport').style.visibility ='hidden';            
        
        page_request.onreadystatechange=function(){
            loadpageFin(page_request, containerid)
        }
        page_request.open('POST', url, true)
        page_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        page_request.setRequestHeader("Content-Length", "0");
	    page_request.send(url);

    }
    function strcleanup(str)
    {
        var strreturn;
        strreturn = str.replace('amp;','')
        strreturn = strreturn.replace('amp;','')
        strreturn = strreturn.replace('amp;','')
        return strreturn;
    }
    function ShowLiveRatios()
    {
        document.getElementById('TableLiveRatios').style.visibility ='visible';
    }
    function HideLiveRatios()
    {
        document.getElementById('TableLiveRatios').style.display ='none';
    }
/*    	
	var urlD="ProcessLoadRuntime.aspx";

   
    function ajLoadInfFin(sid,querystr)
    {
        //alert(urlD+'?s='+sid+'&'+querystr);
        ajaxpageFin(urlD+'?s='+sid+'&'+querystr,'PanelLoadRuntime');
    }



*/	
