﻿window.onload = function qsOnLoad() {
    var qs = 's_' + window.location.search.substring(1);
    if (null != qs) {
        switch (qs) {
            case 's_academicSchedulingSoftware':
                solutionShow(qs, document.getElementById('as'), 'p_campus');
                break;
            case 's_cateringSoftware':
                solutionShow(qs, document.getElementById('cs'), 'p_pro;p_ent;p_work;p_campus');
                break;
            case 's_eventCalendarSoftware':
                solutionShow(qs, document.getElementById('ecs'), 'p_mc');
                break;
            case 's_eventManagementSoftware':
                solutionShow(qs, document.getElementById('ems'), 'p_pro;p_ent;p_campus');
                break;
            case 's_eventSchedulingSoftware':
                solutionShow(qs, document.getElementById('ess'), 'p_lite;p_pro;p_ent;p_work;p_campus;p_legal');
                break;
            case 's_facilitySchedulingSoftware':
                solutionShow(qs, document.getElementById('fss'), 'p_lite;p_pro;p_ent;p_work;p_campus;p_legal');
                break;
            case 's_lawFirmScheduling':
                solutionShow(qs, document.getElementById('lfs'), 'p_legal');
                break;
            case 's_masterCalendarSoftware':
                solutionShow(qs, document.getElementById('mcs'), 'p_mc');
                break;
            case 's_officeHotelingSoftware':
                solutionShow(qs, document.getElementById('ohs'), 'p_work');
                break;
            case 's_resourceSchedulingSoftware':
                solutionShow(qs, document.getElementById('ress'), 'p_lite;p_pro;p_ent;p_work;p_campus;p_legal');
                break;
            case 's_roomDiagrammingSoftware':
                solutionShow(qs, document.getElementById('rds'), 'p_mm;p_rv');
                break;
            case 's_roomSchedulingSoftware':
                solutionShow(qs, document.getElementById('rss'), 'p_lite;p_pro;p_ent;p_work;p_campus;p_legal');
                break;
            case 's_remoteInterfaceSoftware':
                solutionShow(qs, document.getElementById('ris'), 'p_kiosk');
                break;
            case 's_webInterfaceSoftware':
                solutionShow(qs, document.getElementById('wis'), 'p_virtual');
                break;
            default:
                break;
        }
    }
}

function resetListcolors() {
    var tocs = document.getElementById('tocID');
    var tocLength = tocs.childNodes.length;
    if (null != tocs) {
        for (var i = 0; i < tocLength; i++) {
            if (undefined != tocs.childNodes.item(i).style) {
                tocs.childNodes.item(i).style.color = '#006699';
            }
        }
    }
}

function HideProductDivs() {
    document.getElementById('productResults').style.display = 'none';
    var divs = document.getElementsByTagName('div');
    var divLength = divs.length;
    for (var i = 0; i < divLength; i++) {
        var sPos = divs.item(i).id.indexOf('p_');
        if (sPos >= 0) {
            divs.item(i).style.display = 'none';
        }
    }
}

function solutionShow(solutionType, clickedElement, solutionList) {
    resetListcolors();
    HideProductDivs();
    document.getElementById('productResults').style.display = 'inline';
    var divs = document.getElementsByTagName('div');
    var divLength = divs.length;

    clickedElement.style.color = '#ff6600';
    for (var i = 0; i < divLength; i++) {
        var item = divs.item(i);
        var pos = item.id.indexOf('s_');
        if (pos >= 0) {
            if (item.id === solutionType) {
                item.style.display = 'inline';  
            }
            else {
                item.style.display = 'none';
            }
        }
        else {
            var sPos = item.id.indexOf('p_');
            var solutionArray = solutionList.split(';');
            if (sPos >= 0) {
                for (var t = 0; t < solutionArray.length; t++) {
                    if (item.id === solutionArray[t]) {
                        item.style.display = 'inline';
                    }
                }
            }
        }
    }
}

function expandDesc(prod) {
    var prodId = prod.substring(3);
    var divs = document.getElementsByTagName('div');
    var divLength = divs.length;
    for (var i = 0; i < divLength; i++) {
        var item = divs.item(i);
        var pos = item.id.indexOf('pid');
        var anchorPos = item.id.indexOf('sid');
        if (pos >= 0) {
            if (item.id === prod) {
                item.style.display = 'inline';
            }
            else {
                item.style.display = 'none';
            }
        }
        if (anchorPos >= 0) {
            if (item.id === 'sid' + prodId) {
                item.style.display = 'none';
            }
            else {
                item.style.display = 'inline';
            }
        }
    }
}

