var BASE_URL = BASE_DOMAIN + 'climate/cdo/education/';

var educationParamType = EMPTY_STRING;

function xmlHttpStatusProceed() {
    document.getElementById('mainHeading').innerHTML = makeMainHeadingTag();
    document.getElementById('dynamicProductArea').innerHTML
        = cleanNestedDocument(xmlHttp.responseText);
    insertIntroductionMap('flash');

    return;
}

function xmlHttpStatusError() {

    return;
}

function insertIntroductionMap(mapType) {

    if (document.getElementById && document.createElement           &&
        document.getElementById('introductionACIMap')       != null &&
        document.getElementById('introductionACIMapSwitch') != null) {

        var mapID       = document.getElementById('introductionACIMap');
        var switchID    = document.getElementById('introductionACIMapSwitch');
        var mapChunk    = EMPTY_STRING;
        var switchChunk = EMPTY_STRING;

        if (mapType == 'flash') {
            mapChunk    = '<object type="application/x-shockwave-flash" data="australian-climate-influences/ci-introduction-map.swf" width="590" height="480" standby="Loading"><param name="movie" value="australian-climate-influences/ci-introduction-map.swf"><param name="loop" value="false"><img src="australian-climate-influences/ci-introduction-map.jpg" width="590" height="480" alt="Click text labels for details" usemap="#climateInfluencesMap" /></object>';
            switchChunk = '<p style="float: right;"><a href="javascript:insertIntroductionMap(\'noflash\')">No Flash Version</a></p>';
        }
        else {
            mapChunk    = '<img src="australian-climate-influences/ci-introduction-map.jpg" width="590" height="480" alt="Click text labels for details" usemap="#climateInfluencesMap" />';
            switchChunk = '<p style="float: right;"><a href="javascript:insertIntroductionMap(\'flash\')">Flash Version</a></p>';
        }

        mapID.innerHTML    = mapChunk;
        switchID.innerHTML = switchChunk;
    }

    return;
}

function loadProduct(paramType) {
    educationParamType = paramType;
    document.getElementById('areasAffectedImage').src
        = 'australian-climate-influences/place_holder.gif';
    setAddressBar();

    return;
}

function loadBookmarkedProduct(paramType) {
    educationParamType = paramType;
    document.getElementById('areasAffectedImage').src
        = 'australian-climate-influences/place_holder.gif';

    if (educationParamType == EMPTY_STRING ||
        educationParamType == 'introduction') {
    
        document.getElementById('extra-breadcrumbs').innerHTML
            = ' &gt; ' + getEnglishProductName();
    }
    else {
        document.getElementById('extra-breadcrumbs').innerHTML
            = '&gt; <a href="javascript:loadProduct(\'introduction\')">' +
              'Australian Climate Influences</a>'                        +
              ' &gt; ' + getEnglishProductName();
    }

    chooseRequest();

    return;
}

function chooseRequest() {

    if (educationParamType == EMPTY_STRING ||
        educationParamType == 'introduction') {
    
        sendRequest('australian-climate-influences/introduction.html',
                    'text/xml');
    }
    else {
        sendRequest(constructURL(), 'text/xml');
    }

    return;
}

function setAddressBar() {
    var saveHref = document.location.href.split('#')[0];
    saveHref     = saveHref.split('?')[0];
    document.location.href = saveHref + '?bookmark=' + educationParamType;
    document.location.hash = 'page-top';

    return;
}

function updateAffectedAreaImage(paramType) {
    educationParamType = paramType;

    if (educationParamType == EMPTY_STRING) {
        document.getElementById('areasAffectedImage').src
            = 'australian-climate-influences/place_holder.gif';
    }
    else {
        document.getElementById('areasAffectedImage').src = constructImageURL();
    }

    return;
}

function constructURL() {
    var url = BASE_URL + educationParamType + '.html';

    return url;
}

function constructImageURL() {
    var url = BASE_URL + educationParamType + '/' + educationParamType +
              '_info_small.gif';

    return url;
}

function makeMainHeadingTag() {
    var heading = '<h1>' + getEnglishProductName() + '</h1>';

    return heading;
}

function getEnglishProductName() {
    var heading = 'Australian Climate Influences';

    if (educationParamType == 'blockinghigh') {
        heading = 'Blocking Highs';
    }
    else if (educationParamType == 'blockhighex') {
        heading = 'Blocking High Example';
    }
    else if (educationParamType == 'cutofflow') {
        heading = 'Cut-off Lows';
    }
    else if (educationParamType == 'cutofflowex') {
        heading = 'Cut-off Low Example';
    }
    else if (educationParamType == 'eastcoastlow') {
        heading = 'East Coast Lows';
    }
    else if (educationParamType == 'eclexample') {
        heading = 'East Coast Low Example';
    }
    else if (educationParamType == 'easterlytrough') {
        heading = 'Easterly Trough';
    }
    else if (educationParamType == 'easterlytroughex') {
        heading = 'Easterly Trough Example';
    }
    else if (educationParamType == 'enso') {
        heading = 'El Ni&#241;o Southern Oscillation (ENSO)';
    }
    else if (educationParamType == 'walkercirculation') {
        heading = 'The Walker Circulation';
    }
    else if (educationParamType == 'elnino') {
        heading = 'El Ni&#241;o';
    }
    else if (educationParamType == 'elninoexample') {
        heading = 'El Ni&#241;o Example';
    }
    else if (educationParamType == 'elninoexample2') {
        heading = 'Contrasting El Ni&#241;o Example';
    }
    else if (educationParamType == 'lanina') {
        heading = 'La Ni&#241;a';
    }
    else if (educationParamType == 'laninaexample') {
        heading = 'La Ni&#241;a Example';
    }
    else if (educationParamType == 'fronts') {
        heading = 'Frontal Systems';
    }
    else if (educationParamType == 'frontexample') {
        heading = 'Front Example';
    }
    else if (educationParamType == 'iod') {
        heading = 'Indian Ocean';
    }
    else if (educationParamType == 'iodexample') {
        heading = 'Indian Ocean Example';
    }
    else if (educationParamType == 'mjo') {
        heading = 'The Madden-Julian Oscillation';
    }
    else if (educationParamType == 'mjoexample') {
        heading = 'Madden-Julian Oscillation Example';
    }
    else if (educationParamType == 'nwcloudband') {
        heading = 'Northwest Cloudbands';
    }
    else if (educationParamType == 'nwcloudex') {
        heading = 'Northwest Cloudband Example';
    }
    else if (educationParamType == 'sam') {
        heading = 'Southern Annular Mode';
    }
    else if (educationParamType == 'samexample') {
        heading = 'Southern Annular Mode Example';
    }
    else if (educationParamType == 'stridge') {
        heading = 'The Sub-tropical Ridge';
    }
    else if (educationParamType == 'strexample') {
        heading = 'Sub-tropical Ridge Example';
    }
    else if (educationParamType == 'monsoon') {
        heading = 'The Australian Monsoon';
    }
    else if (educationParamType == 'monsoonexample') {
        heading = 'Monsoon Example';
    }
    else if (educationParamType == 'trades') {
        heading = 'Trade Winds';
    }
    else if (educationParamType == 'tradesexample') {
        heading = 'Trade Winds Example';
    }
    else if (educationParamType == 'tc') {
        heading = 'Tropical Cyclones';
    }
    else if (educationParamType == 'tcexample') {
        heading = 'Tropical Cyclone Example';
    }
    else if (educationParamType == 'td') {
        heading = 'Tropical Depressions';
    }
    else if (educationParamType == 'tdexample') {
        heading = 'Tropical Depression Example';
    }
    else if (educationParamType == 'uppertrough') {
        heading = 'Upper Level Trough';
    }
    else if (educationParamType == 'uppertroughex') {
        heading = 'Upper Level Trough Example';
    }
    else if (educationParamType == 'westtrough') {
        heading = 'West Coast Trough';
    }
    else if (educationParamType == 'westtroughex') {
        heading = 'West Coast Trough Example';
    }

    return heading;
}
