﻿
function ajaxPageHeaderFooterProvider(aspx){
    if(typeof(aspx)=="undefined"){
        try{ 
            var tpx=escape(wwwSiteDefaultUrl.replace(".aspx","__$$ASPX"))
            this.aspx=tpx;
        } catch(e){
            this.aspx="/default__$$ASPX";
        }
    } else {
        this.aspx=aspx;
    }
    this.headerText="";
    this.footerText="";
    this.preStr="<a class=\"hidden\">&nbsp;</a>";
 
    this.headerLoad=false;
    this.headerCtrl=false;
    this.footerLoad=false;
    this.footerCtrl=false;
    
    var cTh=this;

     
    this.createXmlHttp=function(){
         var http;
         if(window.XMLHttpRequest){
               try
               {
                    http = new XMLHttpRequest();
               }
               catch(e)
               {
               }
          }else if(window.ActiveXObject){
                 var arrXmlHttpTypes = ['MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.3.0','Microsoft.XMLHTTP'];
                 for(var i=0;i<arrXmlHttpTypes.length;i++){
                    try
                    {
                        http = new ActiveXObject(arrXmlHttpTypes[i]);
                    }
                    catch(ex)
                    {
                    }//不支持MSXML.XMLHttp对象的IE
                }
        }
        return http;
      }
     this.showHeader=function(){
       if(cTh.headerLoad && cTh.headerCtrl){
            var div=document.getElementById("ctrlAjaxPageHeaderctl10000");
            div.innerHTML=cTh.preStr +cTh.headerText;

           var fDiv=document.getElementById("htmlProxyPagerHeaderDiv4Seo");
           if(fDiv){
              fDiv.style.display="none";
           }
       }
      
     }
     this.showFooter=function(){
       if(cTh.footerLoad && cTh.footerCtrl){
            var div=document.getElementById("ctlAjaxPageFooterCtrl20000");
            div.innerHTML=cTh.preStr+ cTh.footerText;
       }
     }
     this.getPageInfo=function(){
          var http1=cTh.createXmlHttp();
          if(!http1)
             return ;
          http1.open("GET","/GetPageHeader.aspx?ASPX="+cTh.aspx,true);
          http1.onreadystatechange=function(){
               if(http1.readyState==4){
                   if(http1.status==200){
                           cTh.headerText=http1.responseText;
                           cTh.headerLoad=true;
                           cTh.showHeader();
                         
                          
                   } else {
                          cTh.headerText="";
                   }
               } else {
                  cTh.onGetting();
               }
          }
          http1.send(null);
          
          //////////////////
          var http2=cTh.createXmlHttp();
          http2.open("GET","/GetPageFooter.aspx?ASPX="+cTh.aspx,true);
          http2.onreadystatechange=function(){
               if(http2.readyState==4){
                   if(http2.status==200){
                            cTh.footerText=http2.responseText;
                            cTh.footerLoad=true;
                            cTh.showFooter();
                            
                    
                           
                   } else {
                            cTh.headerText="";
                   }
               } else {
                  cTh.onGetting();
               }
          }
          http2.send(null);
     }
   
    this.onGetting=function(){
    }
    
    this.onError=function(){
    }
    this.setPageHeaderInfo=function(){
        //if(parent.location.hostname.split('.').length>=4)
        //{
        //    document.write("<script language=\"javascript\" type=\"text/javascript\" src=\"http://js.studyez.com/WebSitesJs/websiteHeader.js\" ></script>");
        //}
        //else
        //{
           //var div=document.getElementById("ctrlAjaxPageHeaderctl10000");
           cTh.headerCtrl=true;
           cTh.showHeader();
	//}
    }
    this.setPageFooterInfo=function(){
        //if(parent.location.hostname.split('.').length>=4)
        //{
        //    document.write("<script language=\"javascript\" type=\"text/javascript\" src=\"/script/FooterFilter.aspx\" ></script>");
        //}
        //else
        //{
          // var div=document.getElementById("ctlAjaxPageFooterCtrl20000");
           cTh.footerCtrl=true;
           cTh.showFooter();
	//}
    }
     
}
   
   
