$(document).ready(function() {

	$("#vehicle_make_search").change(function () {
		var index = this.selectedIndex;
				
		if (index > 0)
		{
			var value = this.options[index].value;
				
			//alert('/app/vehicle_search.js.asp?make=' + escape(value));
			$("#vehicle_model_search").load('/app/vehicle_search.js.asp?make=' + escape(value));
			$("#vehicle_model_search_div").css({"display" : "block"});
			$("#vehicle_year_search_div").css({"display" : "none"});
		}
		else
		{
			$("#vehicle_model_search_div").css({"display" : "none"});
			$("#vehicle_year_search_div").css({"display" : "none"});
		}
	});

	$("#vehicle_model_search").change(function () {
		var index = this.selectedIndex;

		var make_i = $("#vehicle_make_search").get(0).selectedIndex;
		var make = $("#vehicle_make_search").get(0).options[make_i].value;

		if (index > 0)
		{
			var value = this.options[index].value;
			//alert('/app/vehicle_search.js.asp?make=' + escape(make) + '&model=' + escape(value));
			$("#vehicle_year_search").load('/app/vehicle_search.js.asp?make=' + escape(make) + '&model=' + escape(value));
			$("#vehicle_year_search_div").css({"display" : "block"});
		}
		else
		{
			$("#vehicle_year_search_div").css({"display" : "none"});
		}
	});

	$("#vehicle_year_search").change(function () {
		$("#vehicle_search").get(0).submit();
	});




	//Main search
	$("#main_vehicle_make_search").change(function () {
		var index = this.selectedIndex;
				
		if (index > 0)
		{
			var value = this.options[index].value;
				
			//alert('/app/vehicle_search.js.asp?make=' + escape(value));
			$("#main_vehicle_model_search").load('/app/vehicle_search.js.asp?make=' + escape(value));
			$("#main_vehicle_model_search_div").css({"display" : "block"});
			$("#main_vehicle_year_search_div").css({"display" : "none"});
		}
		else
		{
			$("#main_vehicle_model_search_div").css({"display" : "none"});
			$("#main_vehicle_year_search_div").css({"display" : "none"});
		}
	});

	$("#main_vehicle_model_search").change(function () {
		var index = this.selectedIndex;

		var make_i = $("#main_vehicle_make_search").get(0).selectedIndex;
		var make = $("#main_vehicle_make_search").get(0).options[make_i].value;

		if (index > 0)
		{
			var value = this.options[index].value;
			//alert('/app/vehicle_search.js.asp?make=' + escape(make) + '&model=' + escape(value));
			$("#main_vehicle_year_search").load('/app/vehicle_search.js.asp?make=' + escape(make) + '&model=' + escape(value));
			$("#main_vehicle_year_search_div").css({"display" : "block"});
		}
		else
		{
			$("#main_vehicle_year_search_div").css({"display" : "none"});
		}
	});

	$("#main_vehicle_year_search").change(function () {
		$("#main_vehicle_search").get(0).submit();
	});
	


});
		

function showHideLayer(objectId){
	var styleObject = getStyleObject(objectId);
	var v = getStyleObject(objectId).visibility;
	
    if(styleObject) {
		
		if(v == 'hidden') {
			styleObject.visibility = "visible";
		}else{
			styleObject.visibility = "hidden";
		}
		return true;
    } else { 
		return false;
	}
}


// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.
//
// ************************
// layer utility routines *
// ************************

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;

    }
} // changeObjectVisibility

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject



