function bookmarksite(title,url){
if (window.sidebar) // Firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // Opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all) // IE
window.external.AddFavorite(url, title);
}

function populate_counties(current_county, current_town, btype){
    
    //current_county = typeof(current_county) != 'undefined' ? current_county : '';
    //current_town = typeof(current_town) != 'undefined' ? current_town : '';
    
    // set the default option for the county select box
    var hotel_counties = document.hotel.counties;
    var hotel_towns = document.hotel.towns;
    var restaurant_counties = document.restaurant.counties;
    var restaurant_towns = document.restaurant.towns;
    var hotel_current_town = '';
    var restaurant_current_town = '';

    var opt_selected = false;
    
    // set the default option for the county select box
    for (var county_name in hotel_menu){
        if (current_county == county_name) opt_selected = true; else opt_selected = false;
        hotel_counties.options[hotel_counties.options.length] = new Option(county_name,county_name,opt_selected,opt_selected);
    }
    for (var county_name in restaurant_menu){
        if (current_county == county_name) opt_selected = true; else opt_selected = false;
        restaurant_counties.options[restaurant_counties.options.length] = new Option(county_name,county_name,opt_selected,opt_selected);
    }
    // set the current location
    if (current_county != ''){
        if (btype == 'hotel') hotel_current_town = current_town;
        else restaurant_current_town = current_town;
            
        populate_hotel_towns(current_county, hotel_current_town);
        populate_restaurant_towns(current_county, restaurant_current_town);

    }
    if (document.signup)populate_signup();
}

function populate_hotel_towns (selected_county,current_town){
    //current_town = typeof(current_town) != 'undefined' ? current_town : '';
    var hotel_towns = document.hotel.towns;
    hotel_towns.options.length = 0;
    if (typeof(selected_county) != 'undefined') hotel_towns.options[hotel_towns.options.length] = new Option('Please Select Town', '');
    for (var town_num in hotel_menu[selected_county]){
        if (current_town == hotel_menu[selected_county][town_num][0]) opt_selected = true; else opt_selected = false;
        hotel_towns.options[hotel_towns.options.length] = new Option(hotel_menu[selected_county][town_num][0],hotel_menu[selected_county][town_num][1],opt_selected,opt_selected);
    }
}

function populate_restaurant_towns (selected_county,current_town){
    //current_town = typeof(current_town) != 'undefined' ? current_town : '';
    var restaurant_towns = document.restaurant.towns;
    restaurant_towns.options.length = 0;
    if (typeof(selected_county) != 'undefined') restaurant_towns.options[restaurant_towns.options.length] = new Option('Please Select Town', '');
    for (var town_num in restaurant_menu[selected_county]){
        if (current_town == restaurant_menu[selected_county][town_num][0]) opt_selected = true; else opt_selected = false;
        restaurant_towns.options[restaurant_towns.options.length] = new Option(restaurant_menu[selected_county][town_num][0],restaurant_menu[selected_county][town_num][1],opt_selected,opt_selected);
    }
}

function url_jump(url) {
    if (url != '') document.location='http://www.'+url;
}

function display_towninfo(state){
  if (state == 'show'){
    document.getElementById('towninfo').style.display = 'block';
    document.getElementById('towninfolink').style.display = 'none';
  }else{
    document.getElementById('towninfo').style.display = 'none';
    document.getElementById('towninfolink').style.display = 'block';
  }
}


// new sign up functions



function populate_signup(){
    var hotel_counties_signup = document.signup.restaurant_counties;
    var restaurant_counties_signup = document.signup.hotel_counties;

        
    for (var county_name in hotel_menu){
        hotel_counties_signup.options[hotel_counties_signup.options.length] = new Option(county_name,county_name,false,false);
    }
    for (var county_name in restaurant_menu){
        restaurant_counties_signup.options[restaurant_counties_signup.options.length] = new Option(county_name,county_name,false,false);
    }
    
}


function display_signup_location(type){
  if (type == 'restaurant'){
    document.getElementById('restaurant_signup').style.display = 'block';
    document.getElementById('hotel_signup').style.display = 'none';
  }else{
    document.getElementById('restaurant_signup').style.display = 'none';
    document.getElementById('hotel_signup').style.display = 'block';
  }
}


function signup_hotel_towns(selected_county){
    var hotel_towns = document.signup.hotel_towns;
    hotel_towns.options.length = 0;
    hotel_towns.options[hotel_towns.options.length] = new Option('Please Select Town', '');
    for (var town_num in hotel_menu[selected_county]){
        hotel_towns.options[hotel_towns.options.length] = new Option(hotel_menu[selected_county][town_num][0],hotel_menu[selected_county][town_num][1],false,false);
    }
}

function signup_restaurant_towns(selected_county){
    var restaurant_towns = document.signup.restaurant_towns;
    restaurant_towns.options.length = 0;
    restaurant_towns.options[restaurant_towns.options.length] = new Option('Please Select Town', '');
    for (var town_num in restaurant_menu[selected_county]){
        restaurant_towns.options[restaurant_towns.options.length] = new Option(restaurant_menu[selected_county][town_num][0],restaurant_menu[selected_county][town_num][1],false,false);
    }
}

function signup_jump(url) {
    if (url != '') document.location='signup_two.php?site='+url;
}

function pleasewait(){
    document.getElementById('pleasewait').style.display = 'block';
    document.getElementById('previewbutton').style.display = 'none';
}




function show_reservation(){
    document.getElementById('reservation_field').style.display = 'block';
    document.getElementById('reservation_button').style.display = 'none';
}


