var timeoutLength = 500;
var commercialTimer;
var residentialTimer;
var rollUpTimer;

var commercialSectionalTimer;
var residentialSectionalTimer;
var rollUpSeriesTimer;

//ROLL UP SUBMENUS
function expandRollUp() {
    closeResidential();
    closeCommercial();
    var theDiv = document.getElementById("rollup");
    theDiv.style.display = 'block';
    keepRollUp();
    var item = document.getElementById("rollupitem");
    item.className = "gbtnactive";
}

function timeRollUp() {
    rollUpTimer = setTimeout("closeRollUp();", timeoutLength);
}

function keepRollUp() {
    clearTimeout(rollUpTimer);
}

function closeRollUp() {
    var theDiv = document.getElementById("rollup");
    theDiv.style.display = 'none';
    var item = document.getElementById("rollupitem");
    item.className = "gbtn";
}

//COMMERCIAL SUBMENUS
function expandCommercial() {
    closeResidential();
    closeRollUp();
    var theDiv = document.getElementById("commercial");
    theDiv.style.display = 'block';
    keepCommercial();
    var item = document.getElementById("commercialitem");
    item.className = "gbtnactive";
}

function timeCommercial() {
    commercialTimer = setTimeout("closeCommercial();", timeoutLength);
}

function keepCommercial() {
    clearTimeout(commercialTimer);
}

function closeCommercial() {
    var theDiv = document.getElementById("commercial");
    theDiv.style.display = 'none';
    var item = document.getElementById("commercialitem");
    item.className = "gbtn";
}

// RESIDENTIAL SUBMENUS
function expandResidential() {
    closeCommercial();
    closeRollUp();
    var theDiv = document.getElementById("residential");
    theDiv.style.display = 'block';
    keepResidential();
    var item = document.getElementById("residentialitem");
    item.className = "gbtnactive";
}

function timeResidential() {
    residentialTimer = setTimeout("closeResidential();", timeoutLength);
}

function keepResidential() {
    clearTimeout(residentialTimer);
}

function closeResidential() {
    var theDiv = document.getElementById("residential");
    theDiv.style.display = 'none';
    var item = document.getElementById("residentialitem");
    item.className = "gbtn";
}

// COMMERCIAL SECTIONAL DOOR TYPE SERIES
function expandCommercialSectional() {
    closeAll();
    var theDiv = document.getElementById("commercialSectional");
    theDiv.style.display = 'block';
    keepCommercialSectional();
}

function timeCommercialSectional() {
    commercialSectionalTimer = setTimeout("closeCommercialSectional();", timeoutLength);
}

function keepCommercialSectional() {
    clearTimeout(commercialSectionalTimer);
}

function closeCommercialSectional() {
    var theDiv = document.getElementById("commercialSectional");
    theDiv.style.display = 'none';
}


// RESIDENTIAL SECTIONAL DOOR TYPE SERIES
function expandResidentialSectional() {
    closeAll();
    var theDiv = document.getElementById("residentialSectional");
    theDiv.style.display = 'block';
    keepResidentialSectional();
}

function timeResidentialSectional() {
    residentialSectionalTimer = setTimeout("closeResidentialSectional();", timeoutLength);
}

function keepResidentialSectional() {
    clearTimeout(residentialSectionalTimer);
}

function closeResidentialSectional() {
    var theDiv = document.getElementById("residentialSectional");
    theDiv.style.display = 'none';
}


// ROLL UP DOOR TYPE SERIES
function expandRollUpSeries() {
    closeAll();
    var theDiv = document.getElementById("rollupSeries");
    theDiv.style.display = 'block';
    keepRollUpSeries();
}

function timeRollUpSeries() {
    rollUpSeriesTimer = setTimeout("closeRollUpSeries();", timeoutLength);
}

function keepRollUpSeries() {
    clearTimeout(rollUpSeriesTimer);
}

function closeRollUpSeries() {
    var theDiv = document.getElementById("rollupSeries");
    theDiv.style.display = 'none';
}

function closeAll(){
    closeCommercialSectional();
    closeResidentialSectional();
    closeRollUpSeries();
}
