$(function(){
					var url = '/phones/ajax/getModelsByManufacturer';
					var fx = function(j){
						var options = '<option value="">Select Model...</option>';
						if(j == null) {
						  $('select#ctlModel').html(options);
						  return;
						}
						for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
						}
						$('select#ctlModel').html(options);
					}
					// populate models on manufacturer change
					$('select#ctlManufacturer').change(function(){
						$.ajax({url: url, dataType: 'json', data: {manufacturer: $(this).val()}, async: false, success: fx});
					})
					// back-button support (manuf and carrier should be selected, need to handle model)
					// get cookie, set model + manuf & carrier to be safe
					if($.cookie('gus_phone_picker') != null) {
						var theCookie, params, param, manuf, phoneId, carrierId;
						theCookie = $.cookie('gus_phone_picker');
						params = theCookie.split(';');
						param = params[0].split('=');
						manuf = param[1];
						param = params[1].split('=');
						phoneId = param[1];
						param = params[2].split('=');;
						carrierId = param[1];
						$('select#ctlManufacturer').val(manuf);
						$('select#ctlCarrier').val(carrierId);
						// must repopulate model selection for most browsers first
						var manuf = $('select#ctlManufacturer').val();
						if(manuf != null && manuf != '') {
							$.ajax({url: url, dataType: 'json', data: {manufacturer: manuf}, async: false, success: fx});
						}
						$('select#ctlModel').val(phoneId);
					}
					// on form submit, set cookie
					$('input#ctlSubmit').click(function() {		
						var ma = $('select#ctlManufacturer').val();
						var mo = $('select#ctlModel').val();
						if(ma == null || ma == '') {
							alert('Please choose a manufacturer');
							return false;
						}
						if(mo == null || mo == '') {
							alert('Please choose a model');
							return false;
						}
						$.cookie('gus_phone_picker', 'manufacturer='+$('select#ctlManufacturer').val()+';phoneId='+$('select#ctlModel').val()+';carrierId='+$('select#ctlCarrier').val()+';', { path: '/', expires: 10 });
						return true;
					});
				})
