/* Steeline scripts */

/* dropdown navigation */
states = new Array()
states['ACT'] = 'ACT';
states['NSW'] = 'New South Wales';
states['NT'] = 	'Northern Territory';
states['QLD'] = 'Queensland';
states['SA'] = 	'South Australia';
states['TAS'] = 'Tasmania';
states['VIC'] = 'Victoria';
states['WA'] = 	'Western Australia';

locations = new Array();

locations['ACT'] = new Array();
locations['ACT'].push('Canberra');

locations['NSW'] = new Array();
locations['NSW'].push('Albury');
locations['NSW'].push('Batemans Bay');
locations['NSW'].push('Bathurst');
locations['NSW'].push('Broken Hill');
locations['NSW'].push('Coffs Harbour');
locations['NSW'].push('Corowa');
// locations['NSW'].push('Hunter region');
locations['NSW'].push('Lismore');
locations['NSW'].push('Newcastle');
locations['NSW'].push('Pambula');
locations['NSW'].push('Port Macquarie');
locations['NSW'].push('Sydney');
locations['NSW'].push('Wagga Wagga');

locations['NT'] = new Array();
locations['NT'].push('Darwin');


locations['QLD'] = new Array();
// locations['QLD'].push('Agnes Water');
locations['QLD'].push('Atherton');
locations['QLD'].push('Brisbane');
locations['QLD'].push('Brisbane - Supply & Fit Service');
locations['QLD'].push('Bundaberg');
locations['QLD'].push('Cairns');
locations['QLD'].push('Gladstone');
locations['QLD'].push('Gold Coast');
locations['QLD'].push('Gympie');
locations['QLD'].push('Hervey Bay');
locations['QLD'].push('Innisfail');
locations['QLD'].push('Mackay');


locations['SA'] = new Array();
locations['SA'].push('Berri');
locations['SA'].push('Golden Grove');
locations['SA'].push('Mt Gambier');


locations['TAS'] = new Array();
locations['TAS'].push('Hobart');


locations['VIC'] = new Array();
locations['VIC'].push('Bendigo');
locations['VIC'].push('Bendigo - Steel Framing only');
locations['VIC'].push('Corio');
locations['VIC'].push('Dandenong');
locations['VIC'].push('Geelong');
locations['VIC'].push('Gippsland');
locations['VIC'].push('Laverton');
locations['VIC'].push('Mildura');
locations['VIC'].push('Shepparton');

locations['WA'] = new Array();
locations['WA'].push('Perth');


// for primary
function popLocation(inp) {
	inp.location.options.length = 0;
	if(locations[inp.state.value]) {
		inp.location.options[0] = new Option("Please select your Location",'',true, false);
		for(var i = 0; i <locations[ inp.state.value].length;i++) {
			inp.location.options[i+1] = new Option(locations[inp.state.value][i],locations[inp.state.value][i],false, false);
		}
	}
	else
		inp.location.options[0] = new Option("Please select your Location",'',true, false);

}

// for secondary function
function popLocation2(inp) {
	inp.location.options.length = 0;
	if(locations[inp.state.value]) {
		inp.location.options[0] = new Option("Location",'',true, false);
		for(var i = 0; i <locations[inp.state.value].length;i++) {
			inp.location.options[i+1] = new Option(locations[inp.state.value][i],locations[inp.state.value][i],false, false);
		}
	}
	else
		inp.location.options[0] = new Option("Location",'',true, false);

}

function getLocation(inp) {
	var location = inp.location.value.toLowerCase();
	location = location.replace(/ /g,'_');
	// alert(location);
	switch(location)
	{
		case "corio":
			window.location.href = 'geelong/';
			break;
		case "newcastle":
			window.location.href= 'hunter/';
			break;
		case "shepparton":
			window.location.href = 'roofing_centre/';
			break;
		case "albury":
			window.location.href = 'roofing_centre/';
			break;
		case "bathurst":
			window.location.href = 'roofing_centre/';
			break;
		case "corowa":
			window.location.href = 'roofing_centre/';
			break;
		case "coffs_harbour":
			window.location.href = 'mid_north_coast/';
			break;
		case "port_macquarie":
			window.location.href = 'mid_north_coast/';
			break;
		case "sydney":
			window.location.href= 'riverstone/';
			break;
		case "brisbane":
			window.location.href = 'brisbane_-_supply_only_materials/';
			break;
		case "darwin":
			window.location.href = 'berrimah/';
			break;
		default:
			window.location.href= location+'/';
			break;
	}
}

function getLocation2(inp) {
	var location = inp.location.value.toLowerCase();
	location = location.replace(/ /g,'_');
	//alert('Location'+location);
	// window.location.href= '../'+location+'/';
	
	switch(location)
	{
		case "corio":
			window.location.href = '../geelong/';
			break;
		case "newcastle":
			window.location.href= '../hunter/';
			break;
		case "shepparton":
			window.location.href = '../roofing_centre/';
			break;
		case "albury":
			window.location.href = '../roofing_centre/';
			break;
		case "bathurst":
			window.location.href = '../roofing_centre/';
			break;
		case "corowa":
			window.location.href = '../roofing_centre/';
			break;
		case "coffs_harbour":
			window.location.href = '../mid_north_coast/';
			break;
		case "port_macquarie":
			window.location.href = '../mid_north_coast/';
			break;
		case "sydney":
			window.location.href= '../riverstone/';
			break;
		case "brisbane":
			window.location.href = '../brisbane_-_supply_only_materials/';
			break;
		case "darwin":
			window.location.href = '../berrimah/';
			break;
		default:
			window.location.href= '../'+location+'/';
			break;
	}
}


function init() {

	if(document.quickfindform)
	{
		document.quickfindform.state.options[0] = new Option("Please select your State",'',true, false);
		var j = 0;
		for(i in states) {
			document.quickfindform.state.options[j+1] = new Option(states[i],i,false, false);
			j++;
		}
		popLocation(document.quickfindform);
	}

	if(document.changelocationform)
	{
		document.changelocationform.state.options[0] = new Option("State",'',true, false);
		var j = 0;
		for(i in states) {
			document.changelocationform.state.options[j+1] = new Option(i,i,false, false);
			j++;
		}
		popLocation2(document.changelocationform);
	}

}

window.onload = init;