/**
 * Change city observator for DropDown object
 */

function ChangeCity() {
  
  this.execute = execute;
  
  function execute(obj) {
    
    var result = obj.getResult();
    
    window.location = 'http://www.crazystag.com/' + result[0] + '/';
    
  }
  
}

/**
 * quick qoute observator for DropDown object
 */
function QuickQuote(field) {
  
  this.execute = execute;
  
  this.field = field;
  
  function execute(obj) {
    
    var result = obj.getResult();
    
    var field = getNodeById(this.field).getElementsByTagName('input');
    
    field[0].value = result[0];
    
  }
  
}

/**
 * Booking destination observator
 */
function BookingDestination() {
  
  this.execute = execute;
  
  function execute(obj) {
    
    var result = obj.getResult();
    
    var field = getNodeById('destinationBooking');
    
    field.value = result[0];
    
  }
  
}

/**
 * Booking date observator
 */
function BookingQuote(field) {
  
  this.execute = execute;
  
  this.field = field;
  
  function execute(obj) {
    
    var result = obj.getResult();
    
    var field = getNodeById(this.field);
    
    field.value = result[0];
    
  }
  
}


/**
 * change destination
 */
function changeDestination(elemId) {
  
  var dropDown = new DropDown;
  
  dropDown.addObservator(new ChangeCity());
  
  dropDown.initialize(elemId, '#313131', '#3b3b3b');
  
}

/**
 * change destination booking
 */
function changeDestinationBooking(elemId) {
  
  var dropDown = new DropDown;
  
  dropDown.addObservator(new BookingDestination());
  
  dropDown.initialize(elemId, '#ffeaea', '#cf5252');
  
}

/**
 * Set booking form
 */
function setBooking(elemId, field) {
  
  var dropDown = new DropDown;
  
  dropDown.addObservator(new BookingQuote(field));
  
  dropDown.initialize(elemId, '#ffeaea', '#cf5252');
  
}

/**
 * Set quick quote form
 */
function setQuickQuote(elemId, field) {
  
  var dropDown = new DropDown;
  
  dropDown.addObservator(new QuickQuote(field));
  
  dropDown.initialize(elemId, '#ffeaea', '#cf5252');
  
}