﻿function ajaxVtt_flash(parkId, parkName, panelType) {
    ajaxVtt(parkId, parkName, panelType);
    window.location.href = '#content';
}

function ajaxVtt(parkId, parkName, panelType) {
    var copyContainer = document.getElementById('pageBodyInteriorRightMainCopy');
    if(copyContainer)
        return ajaxVtt_load(parkId, parkName, panelType, copyContainer);
    else {
        var homeContainer = document.getElementById('pageBodyHome');
        homeContainer.id = 'pageBodyInterior';
        homeContainer.innerHTML = 
            '<div class="Border">' + 
                '<div id="pageBodyInteriorRight"><div id="pageBodyInteriorRightMain">' + 
                    '<a name="content" id="content"></a>' + 
                    '<h1>' + 
                        '<a href="./">Visit the Trail</a>' + 
                        '<img src="../images/buttons/chevron.gif" alt="&gt;" width="4" height="8">' + 
                        '<span id="jsVttBreadcrumb"></span>' + 
                    '</h1>' + 
                    '<div class="CopyContainer PaddedContainer" id="pageBodyInteriorRightMainCopy"></div>' + 
                '</div></div>' + 
                '<div id="pageBodyInteriorNavigation">' + 
                    '<h2>Context Navigation</h2>' + 
                    '<ul>' + 
                        '<li><a id="jsVttGeneral" href="javascript:void(0)">General Info</a></li>' + 
                        '<li><a id="jsVttActivities" href="javascript:void(0)">Activities / Facilities</a></li>' + 
                        '<li><a id="jsVttDirections" href="javascript:void(0)">Directions / Contact Info</a></li>' + 
                        '<li><a id="jsVttEvents" href="javascript:void(0)">Events</a></li>' + 
                    '</ul>' + 
                    '<p>' +
                        '<a id="jsVttAdd" href="javascript:void(0)"><img src="../images/buttons/ap-add.jpg" width="180" height="22" alt="Add to My Adventure Planner" /></a><br />' +
                        '<br />' +
                        '<a href="../things-to-do/adventure-planner/"><img src="../images/buttons/ap-view.jpg" width="180" height="22" alt="View My Adventure Planner" /></a><br />' +
                    '</p>' +
                '</div>' + 
                '<div id="pageBodyInteriorClear"></div>' + 
            '</div>';
        
        copyContainer = document.getElementById('pageBodyInteriorRightMainCopy');
        return ajaxVtt_load(parkId, parkName, panelType, copyContainer);
    }
    
    return true;
}

function ajaxVtt_load(parkId, parkName, panelType, copyContainer) {
    var xmlHttp;
    try { xmlHttp = new XMLHttpRequest(); }
    catch(e) {
        try { xmlHttp = new ActiveXObject('Msxml2.XMLHTTP'); }
        catch(e) {
            try { xmlHttp = new ActiveXObject('Microsoft.XMLHTTP'); }
            catch (e) { return true; }
        }
    }
    
    xmlHttp.onreadystatechange = function() {
        if(xmlHttp.readyState == 4) {
            copyContainer.innerHTML = xmlHttp.responseText;
            document.getElementById('jsVttBreadcrumb').innerHTML = '<span>' + parkName + '</span>';
            document.getElementById('jsVttGeneral').className = (panelType == 'general') ? 'Active' : '';
            document.getElementById('jsVttGeneral').onclick = function() { return ajaxVtt(parkId, parkName, 'general'); };
            document.getElementById('jsVttActivities').className = (panelType == 'activities') ? 'Active' : '';
            document.getElementById('jsVttActivities').onclick = function() { return ajaxVtt(parkId, parkName, 'activities'); };
            document.getElementById('jsVttDirections').className = (panelType == 'directions') ? 'Active' : '';
            document.getElementById('jsVttDirections').onclick = function() { return ajaxVtt(parkId, parkName, 'directions'); };
            document.getElementById('jsVttEvents').className = (panelType == 'events') ? 'Active' : '';
            document.getElementById('jsVttEvents').onclick = function() { return ajaxVtt(parkId, parkName, 'events'); };
            document.getElementById('jsVttAdd').onclick = function() { return ajaxAddAdventure(parkId, 'site'); };   
        }
    }
    xmlHttp.open('GET', '../js/ajax-vtt.aspx?parkId=' + parkId + '&requestType=' + panelType, true);
    xmlHttp.send(null);
    return false;
}
