/*
 * Commented out code sets the options back to their defaults.  This
 * ensures that the options are correctly retained when the page is
 * entered via the back button.  Unfortunately, this has the undesirable 
 * effect of allowing a user to select an invalid country.  Since the latter
 * is more undesirable than the former the code has been commented out.
 */

/*
var COUNTRIES;
var COUNTRIES_INDEX;
*/

var CITIES= new Array();

CITIES["Austria"]= new Array("Innsbruck","Salzburg","Vienna");

CITIES["Belgium"]= new Array("Brussels");

CITIES["Bulgaria"]=  new Array();

CITIES["Croatia"]=  new Array();

CITIES["Czech Republic"]= new Array("Prague");

CITIES["Denmark"]= new Array("Copenhagen");

CITIES["England"]= new Array("Bath","Brighton","Cambridge","Cotswolds","Oxford","London","Liverpool", "Stratford upon Avon", "York");

CITIES["France"]= new Array("Avignon","Disneyland Paris","Lyon","Marseille","Nice","Paris","Tours","Versailles");

CITIES["Finland"]= new Array("Helsinki");

CITIES["Germany"]= new Array("Bavaria","Berlin","Dresden","Frankfurt","Munich", "Nuremburg", "Potsdam", "Stuttgart", "Trier");

CITIES["Britain"]= new Array("Bath","Brighton","Cambridge","Cotswolds","Edinburgh","Glasgow","Oxford","London","Liverpool","Stratford upon Avon","York");

CITIES["Greece"]= new Array();

CITIES["Hungary"]= new Array("Budapest");

CITIES["Ireland"]= new Array("Dublin");

CITIES["Italy"]= new Array("Florence","Milan","Naples","Pompeii","Rome","Sorrento","Tuscany","Venice");

CITIES["Luxembourg"]= new Array("Luxembourg City");

CITIES["Macedonia"]= new Array();

CITIES["Netherlands"]= new Array("Amsterdam","Haarlem","Rotterdam","The Hague");

CITIES["Northern Ireland"]= new Array();

CITIES["Norway"]= new Array("Bergen","Oslo");

CITIES["Poland"]= new Array("Warsaw");

CITIES["Portugal"]= new Array("Lisbon");

CITIES["Romania"]= new Array();

CITIES["Scotland"]= new Array("Edinburgh","Glasgow");

CITIES["Serbia & Montenegro"]= new Array();

CITIES["Slovak Republic"]= new Array();

CITIES["Slovenia"]= new Array();

CITIES["Spain"]= new Array("Barcelona","Cataluna","Cordova","Granada","Madrid","Malaga","Seville","Salamanca","Toledo","Valencia","Zaragoza");

CITIES["Sweden"]= new Array("Stockholm");

CITIES["Switzerland"]= new Array("Basel","Bern","Geneva","Interlaken","Lausanne","Lucerne","Montreux","St Moritz","Zermatt","Zurich");

CITIES["Turkey"]= new Array();

CITIES["Wales"]= new Array();


$(document).ready(function(){    
    $("#countrylist").change(drop_down_list);   
});
  
  
function drop_down_list()
{  
   
   var state = $('#countrylist').val();
   
   if( state !=""){  

   var jList= $( "#citylist" );
   jList.empty();
   jList.append(
     $( "<option value='none'>Select city</option>" )
      );
   
   
   // Loop over each value in the array.
 
   $.each(
    CITIES[state],
    function( intIndex, objValue ){  
 
     jList.append(
     $( "<option value='"+objValue+"'>" + objValue + "</option>" )
      );
    }
   );
   
   $('#city_drop_down').show(); // Show the drop down
  }
   
}

function checkform(fname,lang){

  if (fname.countrylist.options[0].selected){
     alert('Pick a Country');
     return false;
  } else{
     countryValue= fname.countrylist.value.toLowerCase();
     
     if(countryValue.indexOf(" ")>0){
       countryValue = countryValue.replace(/ /g,"+");        
     }    
     
     cityValue= fname.citylist.value.toLowerCase();

     if(cityValue.indexOf(" ")>0){
       cityValue= cityValue.replace(/ /g,"+");        
     }
    
     window.location.href = '/'+lang+'/activities/'+countryValue+'/'+cityValue+'/';
     return true;
  }
}



$(window).load(drop_down_list);

