﻿function gi(i){return document.getElementById(i)}
values=[['cboHouseType','cboHouseType1','Studio','Apartment','House','Office'],
['cboLocation','cboLocation1','Ground level house / apartment','Two story house','Three story house','Apartment with lift','Apartment without lift - 1st floor','Apartment without lift - 2nd floor','Apartment without lift - 3rd floor','Apartment without lift - 4th floor'],
['cboState','cboState1','ACT- All','NSW - Central and North Coasts','NSW - Illawarra & South Coast','NSW - Illawarra & Southern Highlands','NSW - Newcastle & Hunter Valley','NSW - Regional','NSW - Sydney Region','NT - All','QLD - Brisbane Region','QLD - Central & Western','QLD - Central Coastal','QLD - Northern','QLD - South Eastern','SA - Adelaide region','SA - Far North','SA - Mid North','SA - South','SA - Spencer Gulf & West Coast','TAS - All','VIC - Melbourne Region','VIC - Northern Victoria','VIC - South Eastern Victoria','VIC - South Western Victoria','WA - Northern','WA - Perth Region','WA - South East & Central','WA - South Western']
]
regions=[['Please select'],['Canberra'],
['Central Coast and region','Lake Macquarie East','Lake Macquarie West','Mid-North Coast','Northern Rivers','Port Stephens','Tweed Coast'],
['South Coast','Southern Highlands','Wollongong & Illawarra'],
['Newcastle','North Coast','Regional/ Other','South Coast'],
['Hunter Valley - Lower','Hunter Valley - Upper','Newcastle & Region'],
['Central Tablelands','Central West Slopes','Far South West','Far West','Monaro/ Snowy Mountains','North West Slopes','Northern Tablelands','Riverina & Murray','Southern Tablelands'],
['Blue Mountains & Surrounds','Canterbury / Bankstown','Eastern Suburbs','Hawkesbury','Hills','Inner West','Liverpool / Fairfield','Macarthur / Camden','North Shore - Lower','North Shore - Upper','North West','Northern Beaches','Parramatta','Southern Suburbs','St George','Sutherland','Sydney City','Western Sydney'],
['Alice Springs','Darwin Area','Katherine','Top End'],
['Brisbane City','Eastern Suburbs','Ipswich & Region','Northern Suburbs','Outer Northern Suburbs','Outer Southern Suburbs','Southern Suburbs','Western Suburbs'],
['Central Outback','Mt Isa & North Western','South Western'],
['Bundaberg & Wide Bay Region','Mackay & Whitsundays Region','Rockhampton & Region'],
['Cairns & Region','Far North','Townsville & Region'],
['Gold Coast & Hinterland','Sunshine Coast & Region','Toowoomba & South Eastern'],
['Adelaide','Adelaide Hills','Eastern Suburbs','North & North East Suburbs','South & South East Suburbs','Western & Beach Suburbs'],
['Far North'],
['Barossa Valley','Clare Valley','Mid North','Riverland'],
['Fleurieu Peninsula','Kangaroo Island','South East'],
['Eyre Peninsula','West Coast','Yorke Peninsula'],
['Central Tasmania', 'East Coast', 'Launceston & North- East', 'North-West', 'West Coast'],
['Bayside','East','Geelong & District','Inner City','Mornington Peninsula','North','North East','North West','Philip Island & District','South East','West','Yarra-Dandenong Ranges'],
['Greater Bendigo Region','Macedon Ranges','North Eastern','North Western','Shepparton & Central North'],
['Gippsland','Lakes & Wilderness'],
['Ballarat and Western District','Grampians','Great Ocean Rd / Otway Ranges'],
['Gascoyne','Kimberley/ North','Pilbara'],
['Coastal Strip','Eastern Suburbs','Freemantle','Inner Northern Suburbs','Inner Southern Suburbs','Inner Western Suburbs','Northern Suburbs','Outer Western Suburbs','Perth City','South Perth Suburbs','Southern Suburbs'],
['Goldfields','Mid West'],
['Esperance Region','Great Southern','Heartlands','South West']]

for(i=0;i<values.length;i++)
{var k=gi(values[i][0]),j=gi(values[i][1]);
for(m=2;m<values[i].length;m++)
{if(k)k.options[m-1]=new Option(values[i][m],values[i][m]);
if(j)j.options[m-1]=new Option(values[i][m],values[i][m]);
}
}

function statechange()
{
changestate(gi(this.id=='cboState'?'cboRegion':'cboRegion1'),this);
}
function changestate(cboRegion,cboState) {
    cboRegion.innerHTML = '';
    if (cboState.selectedIndex) {
        var arr = regions[cboState.selectedIndex];
        cboRegion.options[0] = new Option(regions[0][0]);
        for (i = 0; i < arr.length; i++)
            cboRegion.options[i + 1] = new Option(arr[i]); ;
    }
}
gi('cboState').onchange=statechange;
gi('cboState1').onchange=statechange;

function validateForm()
{
var combos=document.getElementsByTagName('select'),textboxes=document.getElementsByTagName('input');
var message = "The following fields are mandatory:\n\n", msg = '', iscbo = 0, istxt = 0,msg1='';
//var txttext = ['-State\n', '-Region\n', '-Street Address\n', '-Suburb and Postcode\n', '-House Type\n', '-Parking Distance To Door\n', '-Location Accessability\n', '-Driveway\n', '-Access Height Clearance\n', '-Removal Access via Windows\n'];
var txttext = ['-State\n', '-Region\n', '-Street Address\n', '-Suburb and Postcode\n'];
if (combos[0].selectedIndex == 0) msg += txttext[0];if (combos[1].selectedIndex <= 0) msg += txttext[1];
if (textboxes[0].value == '') msg += txttext[2]; if (textboxes[1].value == '') msg += txttext[3];
//if (combos[2].selectedIndex == 0) msg += txttext[4];if (textboxes[2].value == '') msg += txttext[5];
//if (combos[3].selectedIndex == 0) msg += txttext[6]; if (combos[4].selectedIndex == 0) msg += txttext[7];
//if (textboxes[3].value == '') msg += txttext[8]; if (combos[5].selectedIndex == 0) msg += txttext[9];

if (combos[6].selectedIndex == 0) msg1 += txttext[0]; if (combos[7].selectedIndex <= 0) msg1 += txttext[1];
if (textboxes[4].value == '') msg1 += txttext[2]; if (textboxes[5].value == '') msg1 += txttext[3];
//if (combos[8].selectedIndex == 0) msg1 += txttext[4]; if (textboxes[6].value == '') msg1 += txttext[5];
//if (combos[9].selectedIndex == 0) msg1 += txttext[6]; if (combos[10].selectedIndex == 0) msg1 += txttext[7];
//if (textboxes[7].value == '') msg1 += txttext[8]; if (combos[11].selectedIndex == 0) msg1 += txttext[9];

if (msg != '' || msg1 != '') { alert(message + (msg == '' ? '' : 'Origin:\n' + msg) + (msg1 == '' ? '' : '\nDestination:\n' + msg1)); return }

//if(isNaN(parseInt(gi('txtParkingDistance').value))||isNaN(parseInt(gi('txtParkingDistance1').value)))
//{
//alert('Please enter a valid value for Parking Distance To Door');return;
//}
//if(isNaN(parseInt(gi('txtAccessHeight').value))||isNaN(parseInt(gi('txtAccessHeight').value)))
//{
//alert('Please enter a valid value for Access Height Clearance');return;
//}
document.forms[0].submit();
}