﻿/* Amended: Matt Brunsdon - 16/12/09 */

//Contents for menu 1: POST OFFICE BOXES
var menu1 = new Array();
var selId = 'ContainerPOB';
menu1[0] = '<a href="javascript:alert2(\'-- Available \', selId, 1);">Available</a>';
menu1[1] = '<a href="javascript:alert2(\'-- Installed \', selId, 2);">Installed</a>';

//Contents for menu 2: MONEY TRANSFER
var menu2 = new Array();
var selid2 = 'ContainerIMT';
menu2[1] = '<a href="javascript:alert2(\'-- Money Order \', selid2, 22);">Money Order</a>';
menu2[2] = '<a href="javascript:alert2(\'-- Western Union Money Transfer \', selid2, 3);">Western Union Money Transfer</a>';

//Contents for menu 3: KEYPOST AUTHERISED OUTLET
var menu3 = new Array();
var selid3 = 'ContainerKAO';
menu3[0] = '<a href="javascript:alert2(\'-- All \', selid3, 15);">All</a>';

//Contents for menu 4: INSTANT PASSPORT PHOTO
var menu4 = new Array();
var selid4 = 'ContainerIPP';
menu4[0] = '<a href="javascript:alert2(\'-- All \', selid4, 16);">All</a>';

//Contents for menu 5:PERSONAL BANKING
var menu5 = new Array();
var selid5 = 'ContainerPB';
menu5[0] = '<a href="javascript:alert2(\'-- All \', selid5, 3);">All</a>';
menu5[1] = '<a href="javascript:alert2(\'-- ING DIRECT Term Deposit Application \', selid5, 30);">ING DIRECT Term Deposit Application</a>';
menu5[2] = '<a href="javascript:alert2(\'-- Load&Go Reloadable Visa Prepaid Cards \', selid5, 34);">Load&Go Reloadable Visa Prepaid Cards</a>';
//menu5[3] = '<a href="javascript:alert2(\'-- Rural Bank Everyday Account \', selid5, 37);">Rural Bank Everyday Account</a>';
//menu5[3] = '<a href="javascript:alert2(\'-- Rural Bank Gold Cash Management Account \', selid5, 38);">Rural Bank Gold Cash Management Account</a>';
menu5[3] = '<a href="javascript:alert2(\'-- Rural Bank Personal Account Application \', selid5, 35);">Rural Bank Personal Account Application</a>';
//menu5[4] = '<a href="javascript:alert2(\'-- Rural Bank Term Deposit \', selid5, 39);">Rural Bank Term Deposit</a>';


//Contents for menu 6: TRAVEL MONEY SERVICE
var menu6 = new Array();
var selid6 = 'ContainerTMS';
menu6[0] = '<a href="javascript:alert2(\'-- All \', selid6, 3);">All</a>';
menu6[1] = '<a href="javascript:alert2(\'-- American Express GlobalTravel card \', selid6, 27);">American Express GlobalTravel card</a>';
menu6[2] = '<a href="javascript:alert2(\'-- American Express Travellers Cheques \', selid6, 3);">American Express Travellers Cheques</a>';
menu6[3] = '<a href="javascript:alert2(\'-- Foreign Currency \', selid6, 3);">Foreign Currency</a>';
menu6[4] = '<a href="javascript:alert2(\'-- Cash Passport \', selid6, 3);">Cash Passport</a>';


//Contents for menu 7:Application & Form Lodgement
var menu7 = new Array();
var selid7 = 'ContainerAFL';

menu7[0] = '<a href="javascript:alert2(\'-- 100 Point Check/Verification \', selid7, 3);">100 Point Check/Verification </a>';
menu7[1] = '<a href="javascript:alert2(\'-- AQN oneCard Application \', selid7, 31);">AQN oneCard Application </a>';

menu7[2] = '<a href="javascript:alert2(\'-- ATO - TFN application for individuals \', selid7, 26);"> ATO - TFN application for individuals  </a>';

menu7[3] = '<a href="javascript:alert2(\'-- Australian Passport New \', selid7, 4);">Australian Passport New </a>';
menu7[4] = '<a href="javascript:alert2(\'-- Australian Passport Renewal \', selid7, 4);">Australian Passport Renewal </a>';

menu7[5] = '<a href="javascript:alert2(\'-- Births, deaths & marriages certificates NSW  \', selid7, 20);">Births, deaths & marriages certificates NSW </a>';


menu7[6] = '<a href="javascript:alert2(\'-- British Passport Application \', selid7, 19);">British Passport Application </a>';

menu7[7] = '<a href="javascript:alert2(\'-- Country Age Pension Fuel Card - WA \', selid7, 25);">Country Age Pension Fuel Card - WA</a>';

menu7[8] = '<a href="javascript:alert2(\'-- Dangerous Goods Security Card - WA \', selid7, 5);">Dangerous Goods Security Card - WA</a>';
menu7[9] = '<a href="javascript:alert2(\'-- Department of Racing, Gaming And Liquor - WA \', selid7, 28);">Department of Racing, Gaming and Liquor - WA</a>';
menu7[10] = '<a href="javascript:alert2(\'-- Firearms Licence Application - WA \', selid7, 21);">Firearms Licence Application - WA</a>';
menu7[11] = '<a href="javascript:alert2(\'-- Identity Verification Form/Request \', selid7, 3);">Identity Verification Form/Request </a>';

menu7[12] = '<a href="javascript:alert2(\'-- ING DIRECT Term Deposit Application \', selid7, 30);">ING DIRECT Term Deposit Application</a>';

menu7[13] = '<a href="javascript:alert2(\'-- Licence to perform high risk work - QLD &#40F1&#41 \', selid7, 6);">Licence to perform high risk work - QLD (F1)</a>';
menu7[14] = '<a href="javascript:alert2(\'-- Licence to perform high risk work - QLD &#40F2&#41 \', selid7, 23);">Licence to perform high risk work - QLD (F2)</a>';

menu7[15] = '<a href="javascript:alert2(\'-- Licence to perform high risk work - VIC &#40L2 & L4&#41 \', selid7, 18);">Licence to perform high risk work - VIC (L2 & L4)</a>';
menu7[16] = '<a href="javascript:alert2(\'-- Maritime Security Identity Card \', selid7, 8);">Maritime Security Identity Card </a>';
menu7[17] = '<a href="javascript:alert2(\'-- National Certificate of Competency - New & Renewal - NSW &#40N3 & R3&#41 \', selid7, 9);">National Certificate of Competency - New & Renewal - NSW (N3 & R3)</a>';
menu7[18] = '<a href="javascript:alert2(\'-- National Police Certificate Application Form - WA \', selid7, 10);">National Police Certificate Application Form - WA</a>';

menu7[19] = '<a href="javascript:alert2(\'-- NSW RSA/ RCG Competency Card Application \', selid7, 29);">NSW RSA/ RCG Competency Card Application</a>';
menu7[20] = '<a href="javascript:alert2(\'-- Onsite Track Easy Rail Safety Worker Card \', selid7, 32);">Onsite Track Easy Rail Safety Worker Card</a>';

menu7[21] = '<a href="javascript:alert2(\'-- Real Estate & Business Supervisory Board \', selid7, 11);">Real Estate & Business Supervisory Board</a>';

menu7[22] = '<a href="javascript:alert2(\'-- Rural Bank Personal Account Application \', selid7, 35);">Rural Bank Personal Account Application</a>';

menu7[23] = '<a href="javascript:alert2(\'-- Settlement Agent Supervisory Board \', selid7, 12);">Settlement Agent Supervisory Board</a>';

menu7[24] = '<a href="javascript:alert2(\'-- Working with Children Check - VIC \', selid7, 14);">Working with Children Check - VIC </a>';
menu7[25] = '<a href="javascript:alert2(\'-- Working with Children Check - WA \', selid7, 13);">Working with Children Check - WA </a>';
menu7[26] = '<a href="javascript:alert2(\'-- WorkSafe VIC - Dangerous Goods and Explosives Licence \', selid7, 24);">WorkSafe VIC - Dangerous Goods and Explosives Licence </a>';


//Contents for menu 8: Passport Interview
//var menu8=new Array()
//var selid8 = 'selPI';
//menu8[0]='<a href="javascript:alert2(\'-- All \', selid8, 4);">All</a>';

//Contents for menu 9: Photopoint
var menu9 = new Array();
var selid9 = 'ContainerPH';
menu9[0] = '<a href="javascript:alert2(\'-- All \', selid9, 17);">All</a>';

//Contents for menu 10: Business Banking
var menu10 = new Array();
var selid10 = 'ContainerBB';
menu10[0] = '<a href="javascript:alert2(\'-- All \', selid10, \'All\');">All</a>';
menu10[1] = '<a href="javascript:alert2(\'-- Adelaide Bank \', selid10, 9);">Adelaide Bank</a>';
menu10[2] = '<a href="javascript:alert2(\'-- Bank of Queensland \', selid10, 33);">Bank of Queensland</a>';
menu10[3] = '<a href="javascript:alert2(\'-- BankWest \', selid10, 1);">BankWest</a>';

//menu10[4] = '<a href="javascript:alert2(\'-- Business Account Referral \', selid10, 36);">Business Account Referral</a>';

menu10[4] = '<a href="javascript:alert2(\'-- CBA \', selid10, 2);">CBA</a>';
menu10[5] = '<a href="javascript:alert2(\'-- Holiday Coast Credit Union \', selid10, 30);">Holiday Coast Credit Union</a>';
menu10[6] = '<a href="javascript:alert2(\'-- NAB  \', selid10, 5);">NAB </a>';
menu10[7] = '<a href="javascript:alert2(\'-- Powerstate Credit Union \', selid10, 22);">Powerstate Credit Union</a>';
menu10[8] = '<a href="javascript:alert2(\'-- Rabobank \', selid10, 27);">Rabobank</a>';

//menu10[9] = '<a href="javascript:alert2(\'-- Rural Bank Business Account Application \', selid10, 40);">Rural Bank Business Account Application</a>';

menu10[9] = '<a href="javascript:alert2(\'-- Rural Bank Agribusiness Lending Referral \', selid10, 36);">Rural Bank Agribusiness Lending Referral</a>';
menu10[10] = '<a href="javascript:alert2(\'-- St.George \', selid10, 13);">St.George</a>';
menu10[11] = '<a href="javascript:alert2(\'-- Suncorp Bank \', selid10, 1);">Suncorp Bank</a>';

//*************************************

var menuwidth = '300px'; //default menu width
var menubgcolor = '#d5d5d5';  //menu bgcolor
var disappeardelay = 600; //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick = "yes";  //hide menu when user clicks within menu?

/////No further editting needed;

var ie4 = document.all;
var ns6 = document.getElementById && !document.all;

if (ie4 || ns6) {
    document.write('<div id="dropmenudiv" style="visibility:hidden;width:' + menuwidth + ';background-color:' + menubgcolor + '" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>');
}

function getposOffset(what, offsettype) {
    var totaloffset = (offsettype == "left") ? what.offsetLeft : what.offsetTop;
    var parentEl = what.offsetParent;
    while (parentEl != null) {
        totaloffset = (offsettype == "left") ? totaloffset + parentEl.offsetLeft : totaloffset + parentEl.offsetTop;
        parentEl = parentEl.offsetParent;
    }
    return totaloffset;
}



function showhide(obj, e, visible, hidden, menuwidth) {
    if (ie4 || ns6) {
        dropmenuobj.style.left = dropmenuobj.style.top = "-500px";
    }

    if (menuwidth != "") {
        dropmenuobj.widthobj = dropmenuobj.style;
        dropmenuobj.widthobj.width = menuwidth;
    }

    if (e.type == "click" && obj.visibility == hidden || e.type == "mouseover") {
        obj.visibility = visible;
    } else if (e.type == "click") {
        obj.visibility = hidden;
    }
}

function iecompattest() {
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
}

function clearbrowseredge(obj, whichedge) {
    var edgeoffset = 0;
    if (whichedge == "rightedge") {
        var windowedge = ie4 && !window.opera ? iecompattest().scrollLeft + iecompattest().clientWidth - 15 : window.pageXOffset + window.innerWidth - 15;
        dropmenuobj.contentmeasure = dropmenuobj.offsetWidth;
        if (windowedge - dropmenuobj.x < dropmenuobj.contentmeasure) {
            edgeoffset = dropmenuobj.contentmeasure - obj.offsetWidth;
        }
    } else {
        var topedge = ie4 && !window.opera ? iecompattest().scrollTop : window.pageYOffset;
        var windowedge = ie4 && !window.opera ? iecompattest().scrollTop + iecompattest().clientHeight - 15 : window.pageYOffset + window.innerHeight - 18;
        dropmenuobj.contentmeasure = dropmenuobj.offsetHeight;
        if (windowedge - dropmenuobj.y < dropmenuobj.contentmeasure) { //move up?
            edgeoffset = dropmenuobj.contentmeasure + obj.offsetHeight;
            if ((dropmenuobj.y - topedge) < dropmenuobj.contentmeasure) { //up no good either?
                edgeoffset = dropmenuobj.y + obj.offsetHeight - topedge;
            }
        }
    }
    return edgeoffset;
}

function populatemenu(what) {
    if (ie4 || ns6) {
        dropmenuobj.innerHTML = what.join("");
    }
}


function dropdownmenu(obj, e, menucontents, menuwidth) {
    if (window.event) {
        event.cancelBubble = true;
    } else if (e.stopPropagation) {
        e.stopPropagation();
    }

    clearhidemenu();
    dropmenuobj = document.getElementById ? document.getElementById("dropmenudiv") : dropmenudiv;
    populatemenu(menucontents);

    if (ie4 || ns6) {
        showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth);
        dropmenuobj.x = getposOffset(obj, "left");
        dropmenuobj.y = getposOffset(obj, "top");
        dropmenuobj.style.left = dropmenuobj.x - clearbrowseredge(obj, "rightedge") + "px";
        dropmenuobj.style.top = dropmenuobj.y - clearbrowseredge(obj, "bottomedge") + obj.offsetHeight + "px";
    }

    return clickreturnvalue();
}

function clickreturnvalue() {
    if (ie4 || ns6) { return false; }
    else return true;
}

function contains_ns6(a, b) {
    while (b.parentNode) {
        if ((b = b.parentNode) == a) {
            return true;
        }
    }
    return false;
}

function dynamichide(e) {
    if (ie4 && !dropmenuobj.contains(e.toElement)) {
        delayhidemenu();
    } else if (ns6 && e.currentTarget != e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget)) {
        delayhidemenu();
    }
}

function hidemenu(e) {
    if (typeof dropmenuobj != "undefined") {
        if (ie4 || ns6) {
            dropmenuobj.style.visibility = "hidden";
        }
    }
}

function delayhidemenu() {
    if (ie4 || ns6) {
        delayhide = setTimeout("hidemenu()", disappeardelay);
    }
}

function clearhidemenu() {
    if (typeof delayhide != "undefined") {
        clearTimeout(delayhide);
    }
}

function setFilter(n) {
    switch (n) {
        case 1: //
            $get('hPostOfficeBoxesAvailable').value = 1;
            $get('hPostOfficeBoxesInstalled').value = "";
            break;
        case 2:
            $get('hPostOfficeBoxesInstalled').value = 1;
            $get('hPostOfficeBoxesAvailable').value = "";
            break;
        case 3:
            $get('hGiroPost').value = 1;
            $get('hMoneyOrder').value = "";
            break;
        case 4:
            $get('hPassportInterviews').value = 1;
            break;
        case 5:
            $get('hDangerousGoodsSecurityCardWA').value = 1;
            break;
        case 6:
            $get('hHighRiskWorkLicenceQLDF1').value = 1;
            break;
        case 7:
            $get('WC_VIC').value = 1;
            break;
        case 8:
            $get('hMaritimeSecurityIdentityCard').value = 1;
            break;
        case 9:
            $get('hNationalCertificateOfCompetencyNSW').value = 1;
            break;
        case 10:
            $get('hNationalPoliceCertificateApplicationFormWA').value = 1;
            break;
        case 11:
            $get('hRealEstateAndBusinessSupervisoryBoardOrSettlementAgentsSupervisoryBoardWA').value = 1;
            break;
        case 12:
            $get('hRealEstateAndBusinessSupervisoryBoardOrSettlementAgentsSupervisoryBoardWA').value = 1;
            break;
        case 13:
            $get('hWorkingWithChildrenCheckWA').value = 1;
            break;
        case 14:
            $get('hWorkingWithChildrenCheckVic').value = 1;
            break;
        case 15:
            $get('hKeyPost').value = 1;
            break;
        case 16:
            $get('hPassportPhoto').value = 1;
            break;
        case 17:
            $get('hPhotoPoint').value = 1;
            break;
        case 18:
            $get('hHighRiskWorkLicenceVic').value = 1;
            break;
        case 19:
            $get('hBritishPassportApplication').value = 1;
            break;
        case 20:
            $get('hBirthsDeathsAndMarriagesCertificatesNSW').value = 1;
            break;
        case 21:
            $get('hFirearmsLicenceApplicationWA').value = 1;
            break;
        case 22:
            $get('hMoneyOrder').value = 1;
            $get('hGiroPost').value = "";
            break;
        case 23:
            $get('hHighRiskWorkLicenceQLDF2').value = 1;
            break;
        case 24:
            $get('hApplicationForDangerousGoodsLicenceVIC').value = 1;
            break;
        case 25:
            $get('hCountryAgePensionFuelCardWA').value = 1;
            break;
        case 26:
            $get('hTFNApplication').value = 1;
            break;
        case 27:
            $get('hGiroPost').value = 1;
            break;
        case 28:
            $get('hDepartmentOfRacingGamingAndLiquorWA').value = 1;
            break;
        case 29:
            $get('hNSWOLGRCompetencyCardApplication').value = 1;
            break;
        case 30:
            $get('hIngDirectTermDepositApplication').value = 1;
            break;
        case 31:
            $get('hAQNoneCardApplication').value = 1;
            break;
        case 32:
            $get('hPegasusRailSafetyWorkerCard').value = 1;
            break;
        case 34:
            $get('hLoadAndGoVisaCard').value = 1;
            break;
        case 35:
            $get('hRuralBankPersonalAccountApplication').value = 1;
            break;
        case 36:            
            $get('hRuralBankLendingReferral').value = 1;
            break;            
        case 37:
            $get('hRuralBankEverydayAccount').value = 1;
            break;
        case 38:
            $get('hRuralBankGoldCashManagementAccount').value = 1;
            break;
        case 39:
            $get('hRuralBankTermDeposit').value = 1;
            break;
        case 40:
            $get('hRuralBankBusinessAccountApplication').value = 1;
            break;            
        //case 30:
        //    $get('hNSWOLGRCompetencyCardApplication').value = 1;
        //    break;
    }
}

function alert2(text, id, filter) {
    
    document.getElementById("selected" + id).innerHTML = text;
    document.getElementById("txtSelected" + id).value = text;
        
    if (id == 'ContainerAFL') {
        clearApplicationFormLodge();
    }    
    if (id == 'ContainerBB' && filter != 36 && filter != 40) {
        $get('hBusBankChqCash').value = filter;
        //alert($get('hBusBankChqCash').value + ' FILTER');
    } else {
        setFilter(filter);
    }
    getFiltersDescription();
}

function clearApplicationFormLodge() {
    //if travel money services, international money trasnfer, not checked clear giropost
    if (($get('selectedContainerTMS').innerHTML == "") && ($get('selectedContainerIMT').innerHTML == "") && ($get('selectedContainerPB').innerHTML == "")) {
        $get('hGiroPost').value = "";
    }
}

// Filter names were disapearing after browser back, needed a way to load the names of the filters
// created hidden input controls to store the names of the filter, and then pass them back to div elements
function loadFilterNames() {
    ////postofficeBoxes
    var selectedContainerPOB = document.getElementById('selectedContainerPOB');
    var selectedContainerIMT = document.getElementById('selectedContainerIMT');
    var selectedContainerKAO = document.getElementById('selectedContainerKAO');
    var selectedContainerIPP = document.getElementById('selectedContainerIPP');
    var selectedContainerPB = document.getElementById('selectedContainerPB');
    var selectedContainerTMS = document.getElementById('selectedContainerTMS');
    var selectedContainerAFL = document.getElementById('selectedContainerAFL');
    var selectedContainerPH = document.getElementById('selectedContainerPH');
    var selectedContainerBB = document.getElementById('selectedContainerBB');

    var _SelectedPOB = document.getElementById('txtSelectedContainerPOB');
    var _SelectedIMT = document.getElementById('txtSelectedContainerIMT');
    var _SelectedKAO = document.getElementById('txtSelectedContainerKAO');
    var _SelectedIPP = document.getElementById('txtSelectedContainerIPP');    

    var _SelectedPB = document.getElementById('txtSelectedContainerPB');
    var _SelectedTMS = document.getElementById('txtSelectedContainerTMS');
    var _SelectedAFL = document.getElementById('txtSelectedContainerAFL');
    var _SelectedPH = document.getElementById('txtSelectedContainerPH');
    var _SelectedBB = document.getElementById('txtSelectedContainerBB');

    if (_SelectedPOB.value != "") {
        selectedContainerPOB.innerHTML = _SelectedPOB.value;
    }
    if (_SelectedIMT.value != "") {
        selectedContainerIMT.innerHTML = _SelectedIMT.value;
    }
    if (_SelectedKAO.value != "") {
        selectedContainerKAO.innerHTML = _SelectedKAO.value;
    }
    if (_SelectedIPP.value != "") {
        selectedContainerIPP.innerHTML = _SelectedIPP.value;
    }
    if (_SelectedPB.value != "") {
        console.log(_SelectedPB);
        selectedContainerPB.innerHTML = _SelectedPB.value;
    }
    if (_SelectedTMS.value != "") {
        selectedContainerTMS.innerHTML = _SelectedTMS.value;
    }
    if (_SelectedAFL.value != "") {
        selectedContainerAFL.innerHTML = _SelectedAFL.value;
    }
    if (_SelectedPH.value != "") {
        selectedContainerPH.innerHTML = _SelectedPH.value;
    }
    if (_SelectedBB.value != "") {
        selectedContainerBB.innerHTML = _SelectedBB.value;
    }
}

function getFiltersDescription() {
    //$get('Description').value = ""
    //    if ($get('selectionContainerPOB').innerHTML != "" ) { $get('Description').value = $get('selectionContainerPOB').innerHTML.replace("-- ", ", "); }    
    //    if ($get('selectionContainerIMT').innerHTML != "") {    $get('Description').value  += selectionContainerIMT.innerHTML.replace("-- ", ", ");}
    //    if ($get('selectionContainerKAO').innerHTML != "") {    $get('Description').value  += selectionContainerKAO.innerHTML.replace("-- ", ", ");}
    //    if ($get('selectionContainerIPP').innerHTML != "") {    $get('Description').value  += selectionContainerIPP.innerHTML.replace("-- ", ", ");}
    //    if ($get('selectionContainerPB').innerHTML != "") {    $get('Description').value  += selectionContainerPB.innerHTML.replace("-- ", ", ");}
    //    if ($get('selectionContainerTMS').innerHTML != "") {    $get('Description').value  += "Hello";}
    //    if ($get('selectionContainerAFL').innerHTML != "") {    $get('Description').value  += selectionContainerAFL.innerHTML.replace("-- ", ", ");}
    //    if ($get('selectionContainerPH').innerHTML != "") {    $get('Description').value  += selectionContainerPH.innerHTML.replace("-- ", ", ");}
    //    if ($get('selPI').innerHTML != "") {    $get('Description').value  += selPI.innerHTML.replace("-- ", ", ");}
    //    if ($get('selectionContainerBB').innerHTML != "") {    $get('Description').value  += selectionContainerBB.innerHTML.replace("-- ", ", ");}
    //var sDesc = $get('Description').value;
    ////sDesc = sDesc.replace("--", ",");
    ////$get('Description').value = sDesc
    //    alert(sDesc);
}

if (hidemenu_onclick == "yes") {
    document.onclick = hidemenu;
}
