function ContentLayout(){
    this.listView = true; //false voor kaartweergave
    this.closedHeight = 35;
    this.openedHeight = 0;
    this.defaultOpenedHeight = 460;
    
    /*Als de ClientId van de huidige pagina via C# kan worden doorgegeven is deze array niet nodig*/
    this.allPages = [];
    this.allPages[0]= "contentVeld_ucAanbodlijstMakelaar_updatePanel";
    this.allPages[1] = "contentVeld_ucOverzichtMakelaars_updatePanelMakelaars";
    this.allPages[2]= "contentVeld_ucInformatie_updatePanel";
    this.allPages[3]= "contentVeld_ucHome_upHome";
    this.allPages[4] = "contentVeld_ucInfoQualisConcept_updatePanel";
    this.allPages[5] = "contentVeld_ucInfoBedrijfsinformatie_updatePanel";
    this.allPages[6] = "contentVeld_ucInfoServices_updatePanel";
    this.allPages[7] = "contentVeld_ucInfoShowcases_updatePanel";
    this.allPages[8] = "contentVeld_ucInfoSupport_updatePanel";
    this.allPages[9] = "contentVeld_ucListFaq_updatePanel";
    this.allPages[10] = "contentVeld_ucInfoColofon_updatePanel";
    this.allPages[11] = "contentVeld_ucInfoDisclaimer_updatePanel";
    this.allPages[12]= "contentVeld_ucAanbodTotaal_updatePanel";
    this.allPages[13]= "contentVeld_ucAanbodMeestBekeken_updatePanel";
    this.allPages[14]= "contentVeld_ucAanbodRecent_updatePanel";
    this.allPages[15]= "contentVeld_ucAanbodRecentVerkocht_updatePanel";
    this.allPages[16]= "contentVeld_ucAanbodGeselecteerd_updatePanel";
    this.allPages[17]= "contentVeld_ucInfoContact_updatePanel";
    this.allPages[18]= "contentVeld_ucEmailNotificatieConfirmCancel_updatePanel";
    this.allPages[19]= "contentVeld_ucSitemap_upSitemap";
   
    /*De ID's van de pagina's waar de zoekbalk altijd getoond moet worden */
    this.pagesWithSearch = [];
    this.pagesWithSearch[0]= "contentVeld_ucAanbodTotaal_updatePanel";
    this.pagesWithSearch[1]= "contentVeld_ucAanbodRecent_updatePanel";
    this.pagesWithSearch[2]= "contentVeld_ucAanbodRecentVerkocht_updatePanel";
    this.pagesWithSearch[3]= "contentVeld_ucAanbodMeestBekeken_updatePanel";
    this.pagesWithSearch[4]= "contentVeld_ucAanbodGeselecteerd_updatePanel";
    this.pagesWithSearch[5]= "contentVeld_ucAanbodlijstMakelaar_updatePanel";
}

ContentLayout.prototype.IsOpened = function(){
   if (document.getElementById("content").offsetHeight <= this.closedHeight) return false;
   else return true;
};

ContentLayout.prototype.IsPageWithSearch = function(){
var bool = false;
    for (var x = 0; x<this.pagesWithSearch.length; x++){
        if (document.getElementById(this.pagesWithSearch[x])){
            bool = true;
        }
    }   
return bool;
};

ContentLayout.prototype.GetPageId = function(){
    for (var x = 0; x<this.allPages.length; x++){
        if (document.getElementById(this.allPages[x])){
            return this.allPages[x];
        }
    }
};


ContentLayout.prototype.ShowSearch = function(){

this.IsPageWithSearch(); 

    if (this.IsOpened()){
        if (this.IsPageWithSearch()){
        document.getElementById("thirdheader").style.display = 'block';
        }else{
        document.getElementById("thirdheader").style.display = 'none';
        }
    }
    
    if(!this.IsOpened()){
        document.getElementById("thirdheader").style.display = 'block';
    }

};

ContentLayout.prototype.Opened = function() {

    document.getElementById("content").style.overflow ='auto';
    document.getElementById("content").style.visibility='visible';
    
    document.getElementById("footerarrow").className = 'up';
    document.getElementById("content").style.height = this.openedHeight+'px';
    document.getElementById("container").className = 'contentopened';
    this.ShowSearch();
    QualisSearchMenu.Close(); //Sluit het uitgebreid zoeken
    //alert("opened");

};

ContentLayout.prototype.Closed = function(){
    document.getElementById("content").style.overflow ='hidden';
    document.getElementById("content").style.visibility='hidden';
    document.getElementById("footerarrow").className = 'down';
    document.getElementById("content").style.height =  this.closedHeight+'px';
    document.getElementById("container").className = 'contentclosed';
    this.ShowSearch();
    QualisContentLayout.SetMapView();
};


ContentLayout.prototype.AnimateOpen = function()
{
    thisObj = this; //zorgt ervoor dat methods en properties ook bruikbaar zijn binnen de 
        if(!this.IsOpened())
        {
            stepSize = 100;      
            intervalId = setInterval("steps()", 50);
            steps = function()
            {
                height = document.getElementById("content").offsetHeight + stepSize;
                document.getElementById("content").style.visibility='visible';
                document.getElementById("content").style.height = height+'px';
           
                if (height > thisObj.openedHeight)
                {
                    clearInterval(this.intervalId);
                    thisObj.Opened();
                    QualisContentLayout.SetListView();
                }
            };
    }    
};

ContentLayout.prototype.AnimateClose = function(){
    thisObj = this; //zorgt ervoor dat methods en properties ook bruikbaar zijn binnen de 
        if(this.IsOpened()){
        stepSize = 100;      
        intervalId = setInterval("steps()", 50);
        steps = function(){
        height = document.getElementById("content").offsetHeight;
            if(height > thisObj.closedHeight){
            height = document.getElementById("content").offsetHeight - stepSize;
            document.getElementById("content").style.height = height+'px';           
            }
            if(height < stepSize){
                clearInterval(this.intervalId);
                thisObj.Closed();
                //alert("else");
            }
        };
    }
};

ContentLayout.prototype.Toggle = function()
{
    if(this.IsOpened()) this.AnimateClose();
    else this.AnimateOpen();
};

ContentLayout.prototype.SetView = function(){
    if(this.listView) this.SetListView();
    else this.SetMapView();
};

ContentLayout.prototype.ViewListener = function(){
   
    //wordt aangeroepen in de cs van pagina's die reageren op de lijstweergave/kaarweergave
    if(!this.listView) this.Closed();
    else this.Opened();
};

ContentLayout.prototype.SetHeight = function(){
//Deze switch uitbreiden als je de hoogte van een andere pagina wilt aanpassen.

//alert(this.GetPageId());

switch(this.GetPageId()){
    case "contentVeld_ucHome_upHome":
    this.openedHeight = 380;
    break;
    default:
    this.openedHeight = this.defaultOpenedHeight;
}

if(this.IsOpened()){
        this.Opened();
    }
};

ContentLayout.prototype.SetListView = function(){
    this.listView = true;
    document.getElementById("listviewlink").className = "active";
    document.getElementById("mapviewlink").className = "notactive";
};
ContentLayout.prototype.SetMapView = function(){
    this.listView = false;
    document.getElementById("listviewlink").className = "notactive";
    document.getElementById("mapviewlink").className = "active";
};
QualisContentLayout = new ContentLayout();