
/* Copyright © Website Engineers Engineers Limited */

/* XML */
var objXMLHttpRequest;
function loadXMLDoc(strURL, 
                    strReadyStateChange) {
    if (window.XMLHttpRequest) {
        objXMLHttpRequest = new XMLHttpRequest();
        objXMLHttpRequest.onreadystatechange = eval(strReadyStateChange);
        objXMLHttpRequest.open("GET", strURL, true);
        objXMLHttpRequest.send(null)
    } 
    else if (window.ActiveXObject) {
        objXMLHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        if (objXMLHttpRequest) {
            objXMLHttpRequest.onreadystatechange = eval(strReadyStateChange);
            objXMLHttpRequestopen("GET", strURL, true);
            objXMLHttpRequest.send()
        }
    }
}

/* Model List */
function ModelListUpdate() { 
    var objModels = document.getElementById(ModelList.Id);
    if (objXMLHttpRequest.readyState == 4) { 
        if (objXMLHttpRequest.status == 200) { 
            objXML = objXMLHttpRequest.responseXML;
            objModels.length   = 0;
            objModels[0]       = new Option(ModelList.SelectText);
            objModels[0].value = ModelList.SelectText;
            for (var intModel=0; intModel<(objXML.getElementsByTagName(ModelList.ModelTag).length); intModel++) {
                objModels[intModel+1]       = new Option(objXML.getElementsByTagName(ModelList.ModelTag)[intModel].firstChild.data);
                objModels[intModel+1].value = objXML.getElementsByTagName(ModelList.ModelTag)[intModel].firstChild.data
            }
        }
    }
}

function ModelListSendXML() { 
    var objMake = document.getElementById(ModelList.MakeId);
    var strMake = objMake[objMake.selectedIndex].value;
    loadXMLDoc(ModelList.XmlURL+strMake,
               'ModelListUpdate')
}

function ModelListMenu() { 
    this.Id         = 'ctl00_Model';
    this.MakeId     = 'ctl00_Make';
    this.ModelTag   = 'model';
    this.XmlURL     = 'xml-models.aspx?Make=';
    this.XmlNode    = '//model';
    this.SelectText = 'Any Model';
    this.Update     = ModelListSendXML
}
var ModelList = new ModelListMenu;

/* Top Search */
function TopSearchReset() { 
    var objTopSearchBox=document.getElementById(TopSearchBox.Id);
    function SetText(strText) { 
        objTopSearchBox.value=strText
    }
    if (objTopSearchBox.value.length==0) { 
        SetText(TopSearchBox.RestoreText)
    }
    else if (objTopSearchBox.value==TopSearchBox.RestoreText) { 
        SetText(TopSearchBox.ClearText)
    }
}
function SearchBox(strId) {
    this.Id=strId;
    this.Clear=TopSearchReset;
    this.ClearText='';
    this.Restore=TopSearchReset;
    this.RestoreText='Search...'
}
var TopSearchBox = new SearchBox('SearchPhrase');

/* Left Search */
function LeftTabDisplay(strLeftTabId) {
    var strLinksBtn='url(/images/left_navi_search.gif)';
    var strSearchBtn='url(/images/left_navi_search_advanced.gif)';
    var strLinksTabDisplay='none';
    var strSearchTabDisplay='none';
    var objLinksBtn=document.getElementById(LeftSearch.LinksBtnId);
    var objSearchBtn=document.getElementById(LeftSearch.SearchBtnId);
    var objLinksTab=document.getElementById(LeftSearch.LinksTabId);
    var objSearchTab=document.getElementById(LeftSearch.SearchTabId);
    if (strLeftTabId==LeftSearch.LinksTabId) { 
        strLinksBtn='url(/images/left_navi_search_active.gif)';
        strLinksTabDisplay='block' 
    } 
    else {
        strSearchBtn='url(/images/left_navi_search_advanced_active.gif)';
        strSearchTabDisplay='block' 
    }
    objLinksBtn.style.backgroundImage=strLinksBtn;
    objSearchBtn.style.backgroundImage=strSearchBtn;
    objLinksTab.style.display=strLinksTabDisplay;
    objSearchTab.style.display=strSearchTabDisplay 
}
function LeftTabLinks() {
    LeftTabDisplay(LeftSearch.LinksTabId)
}
function LeftTabSearch() {
    LeftTabDisplay(LeftSearch.SearchTabId)
}
function SearchTab() {
    this.LinksBtnId='LeftNaviSearch';
    this.LinksTabId='LeftNaviTabLinks';
    this.SearchBtnId='LeftNaviSearchAdvanced';
    this.SearchTabId='LeftNaviTabSearch';
    this.DisplayLinks=LeftTabLinks;
    this.DisplaySearch=LeftTabSearch;
}
var LeftSearch = new SearchTab();

/* Data Tabs */
function ShowTab(intTabShow) {
    var objTabLeft;
    var objTabRight;
    var objTabData;
    for (intTab=0;intTab<DataTab.TabLeftIds.length;intTab++) {
        objTabLeft  = document.getElementById(DataTab.TabLeftIds[intTab]);
        objTabRight = document.getElementById(DataTab.TabRightIds[intTab]);
        objTabData  = document.getElementById(DataTab.TabDataIds[intTab]);
        objTabLeft.style.backgroundImage  = DataTab.TabLeftBG;
        objTabRight.style.backgroundImage = DataTab.TabRightBG;
        objTabData.style.display='none'
    }
    objTabLeft  = document.getElementById(DataTab.TabLeftIds[intTabShow]);
    objTabRight = document.getElementById(DataTab.TabRightIds[intTabShow]);
    objTabData  = document.getElementById(DataTab.TabDataIds[intTabShow]);
    objTabLeft.style.backgroundImage  = DataTab.ActiveTabLeftBG;
    objTabRight.style.backgroundImage = DataTab.ActiveTabRightBG;
    objTabData.style.display='block'
}

function Tab() {
    this.TabLeftBG        = 'url(/images/data_tab_left.gif)';
    this.TabRightBG       = 'url(/images/data_tab_right.gif)';
    this.ActiveTabLeftBG  = 'url(/images/data_tab_left_active.gif)';
    this.ActiveTabRightBG = 'url(/images/data_tab_right_active.gif)';
    this.TabLeftIds       = ['TabOverview',
                             'TabTechnical',
                             'TabEquipment',
                             'TabSavings',
                             'TabVRT',
                             'TabVRO',
                             'TabHowToPay',
                             'TabWhatToBring',
                             'ctl00_Content_TabStatus'];
    this.TabRightIds      = ['TabOverviewR',
                             'TabTechnicalR',
                             'TabEquipmentR',
                             'TabSavingsR',
                             'TabVRTR',
                             'TabVROR',
                             'TabHowToPayR',
                             'TabWhatToBringR',
                             'TabStatusR'];
    this.TabDataIds       = ['DataOverview',
                             'DataTechnical',
                             'DataEquipment',
                             'DataSavings',
                             'DataVRT',
                             'DataVRO',
                             'DataHowToPay',
                             'DataWhatToBring',
                             'DataStatus'];
    this.ShowOverview    = function ShowOverview()    { ShowTab(0) };
    this.ShowTechnical   = function ShowTechnical()   { ShowTab(1) };
    this.ShowEquipment   = function ShowEquipment()   { ShowTab(2) };
    this.ShowSavings     = function ShowSavings()     { ShowTab(3) };
    this.ShowVRT         = function ShowVRT()         { ShowTab(4) };
    this.ShowVRO         = function ShowVRO()         { ShowTab(5) };
    this.ShowHowToPay    = function ShowHowToPay()    { ShowTab(6) };
    this.ShowWhatToBring = function ShowWhatToBring() { ShowTab(7) };
    this.ShowStatus      = function ShowStatus()      { ShowTab(8) }
}
var DataTab = new Tab();

function ShowJourneyTab(intTabShow) {
    var objTabLeft;
    var objTabRight;
    var objTabData;
    for (intTab=0;intTab<JourneyDataTab.TabLeftIds.length;intTab++) {
        objTabLeft  = document.getElementById(JourneyDataTab.TabLeftIds[intTab]);
        objTabRight = document.getElementById(JourneyDataTab.TabRightIds[intTab]);
        objTabData  = document.getElementById(JourneyDataTab.TabDataIds[intTab]);
        objTabLeft.style.backgroundImage  = JourneyDataTab.TabLeftBG;
        objTabRight.style.backgroundImage = JourneyDataTab.TabRightBG;
        objTabData.style.display='none'
    }
    objTabLeft  = document.getElementById(JourneyDataTab.TabLeftIds[intTabShow]);
    objTabRight = document.getElementById(JourneyDataTab.TabRightIds[intTabShow]);
    objTabData  = document.getElementById(JourneyDataTab.TabDataIds[intTabShow]);
    objTabLeft.style.backgroundImage  = JourneyDataTab.ActiveTabLeftBG;
    objTabRight.style.backgroundImage = JourneyDataTab.ActiveTabRightBG;
    objTabData.style.display='block'
}

function JourneyTab() {
    this.TabLeftBG        = 'url(/images/data_tab_left.gif)';
    this.TabRightBG       = 'url(/images/data_tab_right.gif)';
    this.ActiveTabLeftBG  = 'url(/images/data_tab_left_active.gif)';
    this.ActiveTabRightBG = 'url(/images/data_tab_right_active.gif)';
    this.TabLeftIds       = ['TabTravellingOptions',
                             'TabLocationMap'];
    this.TabRightIds      = ['TabTravellingOptionsR',
                             'TabLocationMapR'];
    this.TabDataIds       = ['DataTravellingOptions',
                             'DataLocationMap'];
    this.ShowTravellingOptions = function ShowTravellingOptions() { ShowJourneyTab(0) };
    this.ShowLocationMap       = function ShowLocationMap()       { ShowJourneyTab(1) }
}
var JourneyDataTab = new JourneyTab();

/* End */
