$(document).ready(function(){
	$('#tabs').tabs();
	$('#tabs').bind('tabsselect', function(event, ui) {
		$.post('ajax/dealer_locator_output.php?mode=1&dl_tab=' + ui.index);
	});
	$( '#tabs' ).bind( 'tabsshow', function(event, ui) {
	  $('.toggle').slideToggle('slow');
	  SetFocus(ui.index);
	});
	$('#frmzip').validate();
});

function SetFocus(tabid) {
	switch (tabid) {
		case 0:
			document.frmzip.zip_code.focus();
		break;
		case 1:
			document.frmprovince.province.focus();
		break;
	}
}

function ChangeState(strstate) {
	$('#ajaxcityselect').html('Loading cities...please wait.');
	$.post('ajax/dealer_locator_output.php?mode=2&state=' + strstate, 
		function (output){
			$('#ajaxcityselect').html(output);
	});
}

function ChangeProvince(strProvince) {
	$('#ajaxcacityselect').html('Loading cities...please wait.');
	$.post('ajax/dealer_locator_output.php?mode=6&province=' + strprovince, 
		function (output){
			$('#ajaxcacityselect').html(output);
	});
}

function GetByZip(f) {
	$('#usresults').html('<p align="center">Loading...please wait.</p>');
	$.post('ajax/dealer_locator_output.php?mode=3', $(f).serialize(),
		function(output){
			$('#usresults').html(output);
		});
}

function GetByState(f) {
	$('#usresults').html('<p align="center">Loading...please wait.</p>');
	$.post('ajax/dealer_locator_output.php?mode=4', $(f).serialize(),
		function(output){
			$('#usresults').html(output);
		});
}

function GetByProvince(f) {
	$('#caresults').html('<p align="center">Loading...please wait.</p>');
	$.post('ajax/dealer_locator_output.php?mode=5', $(f).serialize(),
		function(output){
			$('#caresults').html(output);
		});
}
