/**
 * This file is intended to hold Javascript functions
 * which deal with select events from the state drop down to populate the city drop down.  
 * for now, the values for both are hard coded. 
 * the original text fields are overwritten so that non-javascript browsers can still manually enter their 
 * search criteria, but possibility for no results found exists in that case. 
 * 
 * version $Id: searchFields.js,v 1.1.2.6 2008/04/11 23:32:17 ctandy Exp $
**/

var locations =  {
    CA: [
      new Option("Del Norte", "Crescent City"),     
      new Option("- Crescent City", "Crescent City"),
      new Option("- Gold Beach", "Gold Beach"),
      new Option("- Klamath", "Klamath"),
      new Option("Humboldt County", "Arcata"),
      new Option("- Arcata", "Arcata"),
      new Option("- Eureka", "Eureka"),
      new Option("- McKinleyville", "McKinleyville")
    ],
	ID: [
	  new Option("North Idaho", "Coeur d'Alene"),
	  new Option("- Coeur d'Alene", "Coeur d'Alene"),
	  new Option("- Post Falls", "Post Falls"),
	  new Option("- Sandpoint", "Sandpoint"),
	  new Option("Paradise Valley", "Lewiston"),
	  new Option("- Lewiston", "Lewiston"),
	  new Option("- Moscow", "Moscow"),
	  new Option("- Pullman", "Pullman"),
  	  new Option("- Grangeville", "Grangeville")
	],
	OR: [
	  new Option("Columbia Gorge", "The Dalles"),
	  new Option("- The Dalles", "The Dalles"),
	  new Option("- Hood River", "Hood River"),	  
	  new Option("Del Norte", "Brookings"),
	  new Option("- Brookings", "Brookings"),
      new Option("- Gold Beach", "Gold Beach")
	],
	MT: [
	  new Option("Northwest Montana", "Kalispell"),
	  new Option("- Kalispell", "Kalispell"),
	  new Option("- Columbia Falls", "Columbia Falls"),
	  new Option("- Libby", "Libby")
	],
	WA: [
	  new Option("Columbia Basin", "Moses Lake"),
	  new Option("- Moses Lake", "Moses Lake"),
	  new Option("- Ephrata", "Ephrata"),
	  new Option("- Grand Coulee", "Grand Coulee"),
	  new Option("Columbia Gorge", "Goldendale"),
	  new Option("- Goldendale", "Goldendale"),
  	  new Option("Lower Yakima Vly", "Grandview"),
	  new Option("- Grandview", "Grandview"),
	  new Option("- Prosser", "Prosser"),
	  new Option("- Sunnyside", "Sunnyside"),
  	  new Option("North Central WA", "Wenatchee"),
	  new Option("- Wenatchee", "Wenatchee"),
	  new Option("- Leavenworth", "Leavenworth"),
	  new Option("- Chelan", "Chelan"),
	  new Option("- Okanogan", "Okanogan"),	  
  	  new Option("Paradise Valley", "Pullman"),
	  new Option("- Pullman", "Pullman	"),
  	  new Option("- Grangeville", "Grangeville"),   	  
  	  new Option("Spokane County", "Spokane"),
	  new Option("- Spokane", "Spokane"),
	  new Option("- Cheney", "Cheney"),
	  new Option("- Deer Park", "Deer Park"),
  	  new Option("- Newman Lake", "Newman Lake")  
	] 	
};

var chosenCity = null;
var chosenState = null;


function stateSelected(field) {
	var state = field.options[field.selectedIndex].value;
	$('citySelect').options.length = 0;
	var i = 0;
	locations[state].each(function(o) { $('citySelect').options[i] = o; i++});
}

function searchFormRendered(search, city, state, threshold) {
	chosenCity = city;
	chosenState = state;
}

Event.observe(window, 'load', function() {
	Event.observe('sidebarViewBtn', 'mouseover', function() {
		document.getElementById('sidebarViewBtn').style.backgroundImage = 'url(images/ross/sidebar/viewButtonHover.gif)';
	});
	Event.observe('sidebarViewBtn', 'mouseout', function() {
		document.getElementById('sidebarViewBtn').style.backgroundImage = 'url(images/ross/sidebar/viewButton.gif)';
	});
	Event.observe('searchFormSubmitButton', 'mouseover', function() {
		document.getElementById('searchFormSubmitButton').style.backgroundImage = 'url(images/ross/findHover.gif)';		
	});
	Event.observe('searchFormSubmitButton', 'mouseout', function() {
		document.getElementById('searchFormSubmitButton').style.backgroundImage = 'url(images/ross/findButton.png)';
	});
});

function sidebarSubmit(bookCode) {
	openUrl = 'http://directory.rossyellowpages.com/' + bookCode + '/index.htm';	
	window.open(openUrl);
}

function sidebarDirectory(bookCode) {
        getImage = "url(http://directory.rossyellowpages.com/" + bookCode + "/data/images/cover/" + bookCode + ".jpg)";       
	document.getElementById("sideBar").style.backgroundImage = getImage;  	
}

