﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/* ----- Windows ----- */

function PopUp(url)
{
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=800,height=700")
}

function acrobatWin()
{
    var url = "http://www.adobe.com/products/acrobat/readstep2.html";
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=650,height=500")
}

function ageingWin()
{
    var url = "http://www.health.gov.au/internet/wcms/Publishing.nsf/Content/health-privatehealth-consumers-charter-index.htm";
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=650,height=500")
}

function atoWin()
{
    var url = "http://www.ato.gov.au";
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=650,height=500")
}

function fgLhcWin()
{
    var url = "http://www.health.gov.au/internet/wcms/publishing.nsf/Content/private-1";
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=650,height=500")
}

function healthWin()
{
    var url = "http://www.health.gov.au";
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=650,height=500")
}

function nibEmployWin()
{
    var url = "http://nib.nga.net.au/bin/fnt_jobs_list.cfm";
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=650,height=500")
}

function nphEmployWin()
{
    var url = "http://www.newph.com.au/professionals/content.htm";
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=650,height=500")
}

function nphWin()
{
    var url = "http://www.newph.com.au";
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=650,height=500")
}

function phioWin()
{
    var url = "http://www.phio.org.au";
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=650,height=500")
}
function travelWin()
{
    var url = "https://www.qbetravelinsurance.com.au/ins/main.asp?id=55&ins=962BC93BF470254C4BEA7BD9520F5C67"
    MM_openBrWindow(url,"","scrollbars=yes,resizable=yes,width=700,height=750")
}

function promoWin(url)
{
    MM_openBrWindow(url,"","scrollbars=no,resizable=no,width=645,height=435")
}

function promoWinTwo(url)
{
    MM_openBrWindow(url,"","scrollbars=no,resizable=no,width=530,height=630")
}

function promoWinThree(url)
{
    MM_openBrWindow(url,"","scrollbars=no,resizable=no,width=428,height=635")
}

function promoWinFour(url)
{
    MM_openBrWindow(url,"","scrollbars=no,resizable=no,width=853,height=605")
}


/* ----- Toolbox functions ----- */
function clearList(lst, lim)
// Clear the elements of select list, lst, from element number, lim, to the end of the list
{
    for (i = lst.length; i >= lim; i--)
        lst[i] = null;
}

function addToList(lst, val, txt)
{
    lst[lst.length] = new Option(txt, val);
}

function refreshCover(lstCover, scale, cover, notSure)
{
    clearList(lstCover, 3); // Keep the common items: Top Cover & Mid Plus
    if (scale == "S")
    {
        addToList(lstCover, 17, "Basic Plus");
        addToList(lstCover, 13, "Basic Saver");
    }
    else if (scale == "C")
    {          
        addToList(lstCover, 17, "Basic Plus");
        addToList(lstCover, 16, "Family Plus");
        addToList(lstCover, 13, "Basic Saver");
    }
    else
    {
        addToList(lstCover, 16, "Family Plus");
        addToList(lstCover, 14, "Family Basic Saver");
    }

        addToList(lstCover, 11, "Public Hospital Plus Extras");
        addToList(lstCover, 19, "Just Hospital");
        addToList(lstCover, 5, "Public Hospital");
        addToList(lstCover, 6, "Quality Extras");
        addToList(lstCover, 10, "Ambulance Only");

    if (notSure)
        addToList(lstCover, -1, "I'm not sure");

    lstCover.value = cover;
    if (lstCover.selectedIndex == -1)
        lstCover.selectedIndex = 0;
}

function refreshLstCover(lstId, lstCoverId, notSure)
{
    var lst = document.getElementById(lstId);
    var scale = lst.options[lst.selectedIndex].value;
    var lstCover = document.getElementById(lstCoverId);
    var cover = lstCover.options[lstCover.selectedIndex].value;
    refreshCover(lstCover, scale, cover, notSure);
}

function initToolbox(lstId, lstCoverId, scale, cover)
{
    var lst = document.getElementById(lstId);
    lst.value = scale;
    var lstCover = document.getElementById(lstCoverId);
    refreshCover(lstCover, scale, cover, false);
}


/* ----- Other common functions ----- */

function TrimString(str) {
    str = str.replace( /^\s+/g, "" );// strip leading
    return str.replace( /\s+$/g, "" );// strip trailing
}
