﻿function loadDefaultFeatures(EnabledListingTypeIDs) { 
    if(EnabledListingTypeIDs.indexOf('8') != -1) {  //Try loading House search features, if available
         loadCommonFeaturesHouse();
         return;
    }
    if(EnabledListingTypeIDs.indexOf('4') != -1) {  //If House not avail, try loading Condo search features
         loadCommonFeaturesCondo();
         return;
    }
    if(EnabledListingTypeIDs.indexOf('2') != -1) {  //If Condo not avail, try loading Multi search features
         loadCommonFeaturesMulti();
         return;
    }
    if(EnabledListingTypeIDs.indexOf('1') != -1) {  //If Multi not avail, try loading Land search features
         loadCommonFeaturesLand();
         return;
    }
}
function initCommonFeatures() {
    $('divBeds').style.display='none';
    $('divBaths').style.display='none';
    $('divSqFt').style.display='none';
    $('divYearBuilt').style.display='none';
    $('divAcres').style.display='none';
    $('divUnits').style.display='none';
}
function loadCommonFeaturesHouse() {
    initCommonFeatures();
    if(FeatureIsEnabled(EnabledCommonFeatureIDsHouse, 1)) {
        $('divBeds').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsHouse, 2)) {
        $('divBaths').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsHouse, 3)) {
        $('divSqFt').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsHouse, 4)) {
        $('divAcres').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsHouse, 5)) {
        $('divUnits').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsHouse, 6)) {
        $('divYearBuilt').style.display='block';
    }
}
function loadCommonFeaturesCondo() {
    initCommonFeatures();
    if(FeatureIsEnabled(EnabledCommonFeatureIDsCondo, 1)) {
        $('divBeds').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsCondo, 2)) {
        $('divBaths').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsCondo, 3)) {
        $('divSqFt').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsCondo, 4)) {
        $('divAcres').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsCondo, 5)) {
        $('divUnits').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsCondo, 6)) {
        $('divYearBuilt').style.display='block';
    }
}
function loadCommonFeatureIDsMulti() {
    initCommonFeatures();
    if(FeatureIsEnabled(EnabledCommonFeatureIDsMulti, 1)) {
        $('divBeds').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsMulti, 2)) {
        $('divBaths').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsMulti, 3)) {
        $('divSqFt').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsMulti, 4)) {
        $('divAcres').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsMulti, 5)) {
        $('divUnits').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsMulti, 6)) {
        $('divYearBuilt').style.display='block';
    }
}
function loadCommonFeatureIDsLand() {
    initCommonFeatures();
    if(FeatureIsEnabled(EnabledCommonFeatureIDsLand, 1)) {
        $('divBeds').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsLand, 2)) {
        $('divBaths').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsLand, 3)) {
        $('divSqFt').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsLand, 4)) {
        $('divAcres').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsLand, 5)) {
        $('divUnits').style.display='block';
    }
    if(FeatureIsEnabled(EnabledCommonFeatureIDsLand, 6)) {
        $('divYearBuilt').style.display='block';
    }    
}
function FeatureIsEnabled(enabledCommonFeatureIDs, featureID) {
    var enabledCommonFeatureIDsAsArray = enabledCommonFeatureIDs.split(",");
    for(var featureCounter = 0 ; featureCounter < enabledCommonFeatureIDsAsArray.length; featureCounter++) {
        if (enabledCommonFeatureIDsAsArray[featureCounter] == featureID) return true;
    }
    return false;
}

