$(document).ready(function(){
				$('#model').bind('change',function(){
					var selectedURL = $('#model>option:selected').val();
					if(selectedURL != ''){
						window.open(selectedURL);
					}
				});
				
				$('#make').bind('change',function(){
					$('#model').empty();
					
					$.ajax({
						url: '/autoquake/available-make-model.xml',
						cache: false,
						dataType: 'xml',
						success: function(responseXML){
							createElement({type:'option',id:'',className:'',appendTo:$('#model'),innerHTML:'Please select',other:{value:''}});
							
							$(responseXML).find('make').each(function(){
								var makeObj = $(this);							
								
								if(makeObj.attr('id') == $('#make>option:selected').val()){
									$(this).find('model').each(function(){
										createElement({type:'option',id:'',className:'',appendTo:$('#model'),innerHTML:$(this).find('name').text(),other:{value:$(this).find('searchUrl').text()}});
									});
									
								}
							});
						}
					});
				});
			});		
			
			//dynamic DOM element creation
			createElement = function(obj){				
				$newDOMElement = $('<' + obj.type + '>'); 
				if(obj.id != ''){$newDOMElement.attr('id',obj.id);}
				if(obj.className != ''){$newDOMElement.attr('class',obj.className);}
				if(obj.innerHTML != ''){$newDOMElement.html(obj.innerHTML);}

				//loop through additional properties of object for dynamically adding via dot notation
				if(typeof(obj.other) == "object"){
					for(property in obj.other){
						$newDOMElement.attr(property,obj.other[property]);
					}
				}

				$(obj.appendTo).append($newDOMElement);				
}