//Entire script below is home page specific
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]); ;
    }
}
if(gi('cboState'))gi('cboState').onchange=statechange;
if(gi('cboState1'))gi('cboState1').onchange=statechange;
function submitHome(){
  if(!gi('chkHomeQuote').checked)
  {
    gi('msgHome').innerHTML='Please click the checkbox above and agree to the terms';
    return;
  }
  gi('msgHome').innerHTML='Submitting your quote request. Please wait...';
  $.post("submitquoterequest.php", {
          txtName:gi('txtName').value,
          txtEmail:gi('txtEmail').value,
          txtTel:gi('txtMobile').value,
          cboState:gi('cboState').options[gi('cboState').selectedIndex].value,
          cboState1:gi('cboState1').options[gi('cboState1').selectedIndex].value,
          cboRegion:gi('cboRegion').options[gi('cboRegion').selectedIndex].value,
          cboRegion1:gi('cboRegion1').options[gi('cboRegion1').selectedIndex].value,
          cboTimeFrame:'',
          txtTimeFrame:'',
          txtMobile:'',
          cboContactMethod:gi('cboContactMethod').options[gi('cboContactMethod').selectedIndex].value,
          cboMoveArea:gi('cboMoveArea').options[gi('cboMoveArea').selectedIndex].value,
          cboMoveSize:gi('cboMoveSize').options[gi('cboMoveSize').selectedIndex].value,
          cboServiceType:gi('cboServiceType').options[gi('cboServiceType').selectedIndex].value,
          cboGarage:'',
          cboPacking:'',
          cboStorage:'',
          txtStreetAddress:gi('txtStreetAddress').value,
          txtSuburb:gi('txtSuburb').value,
          cboHouseType:gi('cboHouseType').options[gi('cboHouseType').selectedIndex].value,
          txtParkingDistance:'',
          cboLocation:'',
          cboDriveway:'',
          txtAccessHeight:'',
          cboRemovalAccess:'',
          txtStreetAddress1:gi('txtStreetAddress1').value,
          txtSuburb1:gi('txtSuburb1').value,
          cboHouseType1:gi('cboHouseType1').options[gi('cboHouseType1').selectedIndex].value,
          txtParkingDistance1:'',
          cboLocation1:'',
          cboDriveway1:'',
          txtAccessHeight1:'',
          cboRemovalAccess1:'',
          txtSpecial:gi('txtSpecial').value
    },
   function(data){
       gi('msgHome').innerHTML='Quote request submitted successfully. Thank you.';
   });
}
function prevHome()
{
  gi('pnlQuote1').style.display='';gi('pnlQuote2').style.display='none'
  gi('msgHome').innerHTML='';
}
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='',msg2='';
var txttext = ['-State\n', '-Region\n', '-Street Address\n', '-Suburb and Postcode\n'];
if (combos[0].selectedIndex == 0) msg += txttext[0];if (combos[2].selectedIndex <= 0) msg += txttext[1];
if (textboxes[0].value == '') msg += txttext[2]; if (textboxes[2].value == '') msg += txttext[3];

if (combos[1].selectedIndex == 0) msg1 += txttext[0]; if (combos[3].selectedIndex <= 0) msg1 += txttext[1];
if (textboxes[1].value == '') msg1 += txttext[2]; if (textboxes[3].value == '') msg1 += txttext[3];

if (combos[6].selectedIndex == 0) msg2 = '\nMove Details\n-Move Area';

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

gi('pnlQuote2').style.display='';gi('pnlQuote1').style.display='none'
for(i=0;i<combos.length;i++)
if(combos[i].selectedIndex>0 && gi('span'+combos[i].id))gi('span'+combos[i].id).innerHTML=combos[i].options[combos[i].selectedIndex].text;
for(i=0;i<textboxes.length;i++)
if(gi('span'+textboxes[i].id)) gi('span'+textboxes[i].id).innerHTML=textboxes[i].value;
gi('spantxtSpecial').innerHTML=gi('txtSpecial').value
}

