function setupFavouriteLinks() {
  $$('a.favouritesList').each(function(link) {
    link.observe('click', function(event) {
      event.stop();
      $('remoteWindow').hide();
      new Ajax.Updater(
        $('remoteWindow'),
        link.href, {
          parameters: { link_id: link.id },
          method: 'get',
          evalScripts: true,
          onComplete: function() {
            showRemoteWindow(link);
          }
        }
      );
    });
  });
}

function setupFeedbackLinks() {
  $$('a.feedbackLink').each(function(link) {
    link.observe('click', function(event) {
      event.stop();
      $('remoteWindow').hide();
      new Ajax.Updater(
        $('remoteWindow'),
        link.href, {
          method: 'get',
          evalScripts: true,
          onComplete: function() {
            showRemoteWindow(link);
          }
        }
      );
    });
  });
}

function showRemoteWindow(origin) {
  var queue = Effect.Queues.get('remoteWindow');
  queue.each(function(effect) { effect.cancel(); });
  var remoteWindow = $('remoteWindow');
  remoteWindow.show();
  new Effect.Opacity('remoteWindow', { to: 1, duration: 0.00000001 });
  remoteWindow.setStyle({
    top:  (((document.viewport.getHeight() - remoteWindow.getHeight()) / 2) + document.viewport.getScrollOffsets().top) + 'px',
    left: ((document.viewport.getWidth() - remoteWindow.getWidth()) / 2) + 'px'
  });
}

document.observe('dom:loaded', function() {

  if ($('searchQuery')) $('searchQuery').defaultValueActsAsHint();

  if ($('contentBoxes')) Sortable.create('contentBoxes', { elements: $$('.contentBox'), handles: $$('.contentBox li.move a'), constraint: 'vertical', onChange: updateDisplaySettings });
  if ($('map')) Map.Instance = new Map('map', { lat: 37.4419, lng: -122.1419 });
  if ($('watchlist')) Watchlist.Instance = new Watchlist('watchlist', { onUpdate: adjustContainerSize });
  if ($('favouritesList')) FavouritesList.Instance = new FavouritesList('favouritesList', { onUpdate: function() { adjustContainerSize(); } });
  if ($('searchList')) SearchList.Instance = new SearchList('searchList');
  if ($('destinationList')) DestinationList.Instance = new DestinationList('destinationList', 'destinationMarker', { onClick: showRemoteWindow });

  setupFavouriteLinks();
  setupFeedbackLinks();

  $$('.contentBox').each(function(box) {
    options = {
      onClose: function(box) {
        $$('a.contentBoxTrigger[href="#' + box.box.id + '"]').each(function(trigger) {
          trigger.removeClassName('active');
        });
        adjustContainerSize();
        updateDisplaySettings();
      },
      onOpen: function(box) {
        $$('a.contentBoxTrigger[href="#' + box.box.id + '"]').each(function(trigger) {
          trigger.addClassName('active');
        });
        adjustContainerSize();
        updateDisplaySettings();
      },
      onResize: function(box) {
        adjustContainerSize();
        updateDisplaySettings();
      }
    }
    if (box.hasClassName('clustered')) {
      box = new ClusteredContentBox(box, 'contentBoxes', options);
    } else {
      box = new ContentBox(box, 'contentBoxes', options);
    }
    ContentBox.AllBoxes.push(box);
    if ((box_item = document.location.href.split('#')).length >= 2) {
      box_id  = box_item.last().split(';')[0];
      item_id = box_item.last().split(';')[1];
      if (box.box.id == box_id) {
        box.open();
        box.scrollTo(item_id);
        if (box.hasDetailView) {
          box.displayDetails(null, item_id);
        } else {
          box.activate(item_id);
        }
      }
    }
  });

  $$('a.contentBoxTrigger').each(function(trigger) {
    trigger.observe('click', function(event) {
      event.stop();
      trigger = Event.element(event);
      box = ContentBox.AllBoxes.find(function(b) {
        return b.box.id == trigger.href.split('#').last();
      });
      if (trigger.hasClassName('active')) {
        box.close(event);
      } else {
        box.open(event);
      }
    });
  });

  if ($('ticker')) {
    initScroll();
  }

  function adjustContainerSize() {
    var leftHeight = 0;
    if ($('contentBoxes')) {
      leftHeight = $('contentBoxes').select('div.contentBox').inject(0, function(acc, box) {
        return acc + box.getHeight();
      })
      leftHeight += (Prototype.Browser.IE ? 100 : 0);
    } else if ($('favouritesList')) {
      leftHeight = $('favouritesList').getHeight();
    } else if ($('searchList')) {
      leftHeight = $('searchList').getHeight();
    } else {
      return;
    }
    rightHeight = $('mapBar') ? $('mapBar').getHeight() : 0;
    height = (leftHeight < rightHeight) ? rightHeight : leftHeight;
    $('main').setStyle({ height: height + 'px' });
  }

  function updateDisplaySettings(box) {
    box_ids = $$('#contentBoxes div.contentBox').select(function(box) { return box.readAttribute('active') == 'true' }).map(function(box) {
      return [box.id, box.down('.content-holder').visible() ? 'full' : 'collapsed'];
    }).toQueryString('boxes');
    new Ajax.Request(
      '/users/update_display_settings',
      {
        method: 'put',
        parameters: 'content_area=' + $('contentArea').className + '&authenticity_token=' + AuthenticityToken + '&' + box_ids
      }
    );
  }

  adjustContainerSize();

});

var SearchList = Class.create({

  initialize: function(container) {
    this.container = $(container);
    this.list = this.container.down('ul.gallery');
    this.list.items = this.list.items = this.list.select('li.searchItem');
    this.setup();
  },

  setup: function() {
    this.list.items.each(function(item) {
      item.down('.teaserContent').observe('click', function(event) {
        this.linkToDetail(event);
      }.bind(this));
    }, this);
  },

  linkToDetail: function(event) {
    element = Event.element(event);
    if (element.nodeName.toLowerCase() == 'a' || (element.nodeName.toLowerCase() == 'img' && (element.hasClassName('locationLink') || element.hasClassName('favouritesListLink') || element.hasClassName('feedbackLink')))) {
      return;
    }
    event.stop();
    var item = Event.findElement(event, 'li.searchItem');
    document.location.href = item.down('a.originUrl').getAttribute('href');
  }

});

var DestinationList = Class.create({

  initialize: function(container, destinationMarker, options) {
    this.container = $(container);
    this.destinationMarker = $(destinationMarker);
    this.continents = $$('#continentList li.continent');
    this.items = this.container.select('li.destination');
    this.onClickCallback = options.onClick;
    this.hover = true;
    this.setup();
  },

  setup: function() {
    this.items.each(function(item) {
      item.iconPosition = {
        x: item.readAttribute('iconPosition').split(';').first(),
        y: item.readAttribute('iconPosition').split(';').last()
      }
      item.continent = item.readAttribute('iconContinent');
      if (!item.down('a').hasClassName('directLink')) {
        item.down('a').observe('click', function(event) {
          event.stop();
          this.selectDestination(item.id, item.down('span.destinationUrl').innerHTML);
        }.bind(this));
      }
      item.observe('mouseover', function(event) {
        this.destinationMarker.show();
        this.destinationMarker.setStyle({
          left: item.iconPosition.x + 'px',
          top: item.iconPosition.y + 'px'
        });
        if (!this.hover) return;
        this.activateContinent(item.continent);
        this.items.each(function(item) { item.removeClassName('active'); })
        item.addClassName('active');
      }.bind(this));
      item.observe('mouseout', function(event) {
        this.destinationMarker.hide();
        if (!this.hover) return;
        this.activateContinent(null);
        this.items.each(function(item) { item.removeClassName('active'); })
      }.bind(this));
    }, this);
    this.continents.each(function(continent) {
      continent.active = false;
      continent.observe('click', function(event) {
        event.stop();
        $('remoteWindow').hide();
        new Ajax.Updater(
          'remoteWindow',
          continent.down('a').href, {
            method: 'get',
            evalScripts: true,
            onComplete: function() {
              $('remoteWindow').setStyle({ width: '230px' });
              this.onClickCallback();
            }.bind(this)
          }
        );
      }.bind(this))
    }, this);
  },

  selectDestination: function(id, url) {
    $('remoteWindow').hide();
    new Ajax.Updater(
      'remoteWindow',
        url, {
        parameters: { item_id: id },
        method: 'get',
        evalScripts: true,
        onComplete: function() {
          $('remoteWindow').setStyle({ width: '230px' });
          this.onClickCallback();
        }.bind(this)
      }
    );
  },

  activateDestinations: function(continent) {
    this.items.each(function(item) {
      if (item.hasClassName('filterable')) {
        if (item.readAttribute('iconContinent') == continent || continent == 'all') {
          item.show();
        } else {
          item.hide();
        }
      }
    });
  },

  activateContinent: function(continentId) {
    this.continents.each(function(continent) {
      if (continent.id == continentId) {
        continent.down('a').addClassName('active');
      } else {
        continent.down('a').removeClassName('active');
      }
    });
  }

});

var FavouritesList = Class.create({

  initialize: function(container, options) {
    this.container = $(container);
    this.list = this.container.down('ul.gallery');
    this.onUpdateCallBack = options.onUpdate;
    this.setup();
  },

  setup: function() {
    this.list.items = this.list.items = this.list.select('li.favouredItem');
    this.list.items.each(function(item) {
      new Ajax.InPlaceEditor(item.down('.notes .text'), item.down('a.updateNotesUrl').getAttribute('href'), {
        cancelControl: false,
        okControl: 'link',
        externalControl: 'editNotes_' + item.id,
        externalControlOnly: true,
        highlightcolor: 'transparent',
        rows: 10,
        cols: 78
      });
      item.down('.teaserContent').observe('click', function(event) {
        this.linkToDetail(event);
      }.bind(this));
      item.down('img.closeButton').observe('click', this.removeItem.bindAsEventListener(this));
    }, this);
  },

  update: function() {
    document.location.reload();
  },

  linkToDetail: function(event) {
    element = Event.element(event);
    if (element.nodeName.toLowerCase() == 'a' || (element.nodeName.toLowerCase() == 'img' && element.hasClassName('locationLink') || element.hasClassName('feedbackLink'))) {
      return;
    }
    event.stop();
    var item = Event.findElement(event, 'li.favouredItem');
    document.location.href = item.down('a.originUrl').getAttribute('href');
  },

  removeItem: function(event) {
    event.stop();
    var item = Event.findElement(event, 'li.favouredItem');
    new Ajax.Request(item.down('a.removeUrl').href, {
      method: 'delete',
      onSuccess: function() {
        item.remove();
        if (this.onUpdateCallBack) this.onUpdateCallBack();
      }.bind(this)
    });
  }

});

var ContentBox = Class.create({

  initialize: function(box, container, options) {
    this.box = $(box);
    this.container = $(container);
    if (!this.box.visible()) this.box.remove();
    this.box.writeAttribute({ active: (this.box.visible() ? 'true' : 'false') })
    this.list = this.box.down('ul.gallery');
    this.list.expanded = false;
    this.list.items = this.list.select('li.item');
    this.hasDetailView = !this.box.hasClassName('noDetailView');
    this.detailPane = this.box.down('div.detail');
    this.list.items.each(function(item, index) {
      if (this.hasDetailView) item.observe('click', this.handleItemClick.bindAsEventListener(this));
      if (index > 4) item.hide();
    }, this);
    this.expandable = !this.box.hasClassName('noExpandCollapseToggling');
    if (this.expandable) {
      this.toggleExpandButton = this.box.down('a.expandButton');
      this.toggleExpandButton.observe('click', function(event) {
        if (this.list.expanded) {
          this.shrinkList(event);
        } else {
          this.expandList(event);
        }
      }.bind(this));
    }
    this.scrollUpButton = this.box.down('a.top-btn');
    this.scrollDownButton = this.box.down('a.bottom-btn');
    if (this.list.items.length > 5) {
      this.scrollUpButton.observe('click', this.scrollUp.bindAsEventListener(this));
      this.scrollDownButton.observe('click', this.scrollDown.bindAsEventListener(this));
    } else {
      stop = function(event) { event.stop(); }
      this.scrollUpButton.observe('click', stop);
      this.scrollDownButton.observe('click', stop);
    }
    this.list.current = 0;
    this.setupScrolling();
    this.toggleCollapseButton = this.box.down('h2');
    this.toggleCollapseButton.observe('click', this.toggleCollapse.bindAsEventListener(this));
    this.closeButton = this.box.down('a.closeButton');
    this.closeButton.observe('click', this.close.bindAsEventListener(this));
    this.setupActions();
    this.onCloseCallBack = options.onClose;
    this.onOpenCallBack = options.onOpen;
    this.onResizeCallBack = options.onResize;
  },

  handleItemClick: function(event) {
    element = Event.element(event);
    if (element.nodeName.toLowerCase() == 'a' || (element.nodeName.toLowerCase() == 'img' && (element.hasClassName('locationLink') || element.hasClassName('favouritesListLink') || element.hasClassName('feedbackLink'))) || (div = Event.findElement(event, 'div') && Event.findElement(event, 'div').hasClassName('contact-details'))) {
      return;
    }
    var item = Event.findElement(event, 'li.item');
    this.displayDetails(event);
  },

  setupActions: function() {
    this.list.items.each(function(item) {
      if (item.down('a.location')) {
        if (Watchlist.Instance.contains(item.id)) {
          item.down('a.location').hide();
        } else {
          item.down('a.location').show();
        }
      }
    }, this);
  },

  setupScrolling: function() {
    if (this.list.items.length <= 5 || this.list.current == (this.list.items.length - 5)) {
      this.scrollDownButton.addClassName('disabled-btn');
    } else {
      this.scrollDownButton.removeClassName('disabled-btn');
    }
    if (this.list.items.length <= 5 || this.list.current == 0) {
      this.scrollUpButton.addClassName('disabled-btn');
    } else {
      this.scrollUpButton.removeClassName('disabled-btn');
    }
  },

  scrollUp: function(event) {
    if (event) event.stop();
    if (this.list.current == 0) return;
    this.list.items[this.list.current - 1].show();
    this.list.items[this.list.current + 4].hide();
    this.list.current -= 1;
    this.setupScrolling();
  },

  scrollDown: function(event) {
    if (event) event.stop();
    if (this.list.current == (this.list.items.length - 5)) return;
    this.list.items[this.list.current].hide();
    this.list.items[this.list.current + 5].show();
    this.list.current += 1;
    this.setupScrolling();
  },

  scrollTo: function(item_id) {
    index = this.list.items.indexOf(this.list.items.find(function(item) { return item.id == item_id; }));
    if (index < this.list.current) {
      (this.list.current - index).times(function() {
        this.scrollUp();
      }.bind(this));
    } else if (index > (this.list.current + 4)) {
      (index - (this.list.current + 4)).times(function() {
        this.scrollDown();
      }.bind(this));
    }
  },

  expandList: function(event) {
    if (event) event.stop();
    this.detailPane.hide();
    this.list.expanded = true;
    this.box.down('div.content-block').setStyle({
      width: '640px'
    });
    this.box.down('div.content-block').select('.contact-details').each(function(contactDetail) {
      contactDetail.show();
    });
    this.toggleExpandButton.update('less');
    this.toggleExpandButton.up('span').removeClassName('more');
    this.toggleExpandButton.up('span').addClassName('less');
  },

  shrinkList: function(event) {
    if (event) event.stop();
    this.detailPane.show();
    this.list.expanded = false;
    this.box.down('div.content-block').setStyle({
      width: '320px'
    });
    this.box.down('div.content-block').select('.contact-details').each(function(contactDetail) {
      contactDetail.hide();
    });
    if (this.expandable) {
      this.toggleExpandButton.update('more');
      try {
        this.toggleExpandButton.up('span').addClassName('more');
        this.toggleExpandButton.up('span').removeClassName('less');
      } catch(e) {}
    }
  },

  displayDetails: function(event, item_id) {
    var item = null
    if (event) {
      event.stop();
      item = Event.findElement(event, 'li.item');
    } else {
      item = this.list.items.find(function(item) { return item.id == item_id; });
    }
    this.shrinkList(event);
    if (item) {
      this.activate(item.id);
      new Ajax.Updater(
        this.detailPane,
        item.down('a.detailsUrl').getAttribute('href'),
        { method: 'get' }
      );
    }
  },

  activate: function(item_id) {
    this.list.items.each(function(item) {
      if (item.id == item_id) {
        item.addClassName('active');
      } else {
        item.removeClassName('active');
      }
    });
  },

  toggleCollapse: function(event) {
    if (Event.element(event).nodeName.toLowerCase() == 'a') return;
    this.box.down('.content-holder').toggle();
    if (this.onResizeCallBack) this.onResizeCallBack(this);
  },

  open: function(event) {
    if (event) event.stop();
    this.container.insert({ top: this.box });
    this.box.show();
    this.box.down('.content-holder').show();
    this.box.writeAttribute({ active: 'true' })
    this.setupActions();
    if (this.onOpenCallBack) this.onOpenCallBack(this);
  },

  close: function(event) {
    event.stop();
    this.box.writeAttribute({ active: 'false' })
    this.box.remove();
    if (this.onCloseCallBack) this.onCloseCallBack(this);
  }

});

var ClusteredContentBox = Class.create(ContentBox, {

  initialize: function($super, box, container, options) {
    $super(box, container, options);
    this.clusterLinks = this.box.select('a.clusterLink');
    this.clusterLinks.each(function(link) {
      link.observe('click', this.toggleCluster.bindAsEventListener(this));
    }, this);
    this.allItems = this.list.items.clone();
    this.displayCluster('all');
    if (this.box.down('a.allClusters')) this.box.down('a.allClusters').addClassName('active');
  },

  toggleCluster: function(event) {
    event.stop();
    link = Event.element(event);
    cluster = link.href.split('#').last();
    this.displayCluster(cluster);
    this.clusterLinks.each(function(link) {
      link.removeClassName('active');
    });
    link.addClassName('active');
  },

  displayCluster: function(cluster) {
    this.list.items.each(function(item) {
      item.hide();
      item.remove();
    });
    this.list.items = this.allItems.select(function(item) {
      return (cluster == 'all' || item.down('div').hasClassName('cluster_' + cluster));
    });
    counter = 0;
    this.list.items.each(function(item) {
      this.list.insert({ bottom: item });
      if (counter++ < 5) item.show();
    }, this);
    this.list.current = 0;
    if (this.list.expanded) {
      this.expandList();
    } else {
      this.shrinkList();
    }
    this.setupScrolling();
    if (this.list.items[0]) this.displayDetails(null, this.list.items[0].id);
    this.box.down('.content-holder').show();
    if (this.onResizeCallBack) this.onResizeCallBack(this);
  }

});

ContentBox.AllBoxes = $A();

var Watchlist = Class.create({

  initialize: function(container, options) {
    this.container = $(container);
    this.onUpdateCallBack = options.onUpdate;
    this.setupList();
    this.setupMarkers();
  },

  setupList: function() {
    this.list = this.container.down('ul');
    this.list.items = this.list.select('li.item');
    this.list.items.each(function(item) {
      item.observe('click', function(event) {
        element = Event.element(event);
        if (element.nodeName.toLowerCase() == 'a' || (element.nodeName.toLowerCase() == 'img' && element.hasClassName('favouritesListLink') || element.hasClassName('feedbackLink'))) return;
        var item = Event.findElement(event, 'li.item');
        this.setActiveItem(item);
        Map.Instance.zoomToMarker(item.id)
      }.bind(this));
      item.down('a.closeButton').observe('click', function(event) {
        event.stop();
        link = Event.element(event);
        item = link.up('li.item');
        new Ajax.Request(
          '/watchlists/remove_from_list',
          {
            method: 'delete',
            parameters: { id: item.readAttribute('associationId'), authenticity_token: AuthenticityToken },
            onSuccess: function(transport) {
              item.remove();
              this.setupList();
              this.setupMarkers();
            }.bind(this)
          }
        );
        if (this.onUpdateCallBack) this.onUpdateCallBack();
      }.bind(this));
    }, this);
  },

  refresh: function() {
    new Ajax.Updater(
      this.container,
      '/watchlists/show',
      {
        method: 'get',
        onComplete: function() {
          this.setupList();
          setupFavouriteLinks();
          setupFeedbackLinks();
          if (this.onUpdateCallBack) this.onUpdateCallBack();
          this.setupMarkers();
        }.bind(this)
      }
    );
  },

  setupMarkers: function() {
    Map.Instance.clearMarkers();
    this.list.items.each(function(item) {
      marker = Map.Instance.addMarker(parseFloat(item.readAttribute('lat')), parseFloat(item.readAttribute('lng')), item.id);
      item.down('img.markerImage').writeAttribute({ src: marker.getIcon().image });
      GEvent.bind(marker, 'click', this, this.handleMarkerClicked.curry(item.id));
    }, this);
  },

  handleMarkerClicked: function(id, marker) {
    var item = this.list.items.find(function(item) {
      return item.id == id;
    });
    this.setActiveItem(item);
    Map.Instance.zoomToMarker(id)
  },

  setActiveItem: function(item) {
    this.list.items.each(function(item) {
      item.removeClassName('active');
    });
    item.addClassName('active');
  },

  contains: function(id) {
    return this.list.items.any(function(item) {
      return item.id == ('watchlist_' + id);
    })
  }

});

var Map = Class.create({

  initialize: function(map, defaults) {
    this.container = $(map);
    this.map = new GMap2(document.getElementById(map));
    this.map.setCenter(new GLatLng(parseFloat(this.container.readAttribute('latitude')), parseFloat(this.container.readAttribute('longitude'))), 12);
    this.map.addControl(new GSmallMapControl());
    this.map.addControl(new GMapTypeControl());
    this.clearMarkers();
    this.baseIcon = new GIcon(G_DEFAULT_ICON);
    this.baseIcon.iconSize = new GSize(20, 34);
    this.baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    this.baseIcon.iconSize = new GSize(20, 34);
    this.baseIcon.shadowSize = new GSize(37, 34);
    this.baseIcon.iconAnchor = new GPoint(9, 34);
    this.baseIcon.infoWindowAnchor = new GPoint(9, 2);
  },

  clearMarkers: function() {
    this.nextLetter = 'A';
    this.markers = $H();
    this.map.clearOverlays();
  },

  addMarker: function(lat, lng, id) {
    var point = new GLatLng(lat, lng);
    var marker = this.buildMarker(point, id);
    this.markers.set(id, marker);
    this.map.addOverlay(marker);
    this.setBounds();
    marker.show();
    return marker;
  },

  buildMarker: function(point, id) {
    var letteredIcon = new GIcon(this.baseIcon);
    letteredIcon.image = "http://www.google.com/mapfiles/marker" + this.nextLetter + ".png";
    letteredIcon.transparent = "http://www.google.com/mapfiles/marker" + this.nextLetter + ".png";
    var marker = new GMarker(point, { icon: letteredIcon });
    this.nextLetter = this.nextLetter.succ();
    return marker;
  },

  zoomToMarker: function(id) {
    marker = this.markers.get(id)
    if (marker) this.map.panTo(marker.getPoint());
  },

  setBounds: function() {
    var bounds = new GLatLngBounds();
    this.markers.values().each(function(marker) {
      bounds.extend(marker.getPoint());
    })
    this.map.setZoom(this.map.getBoundsZoomLevel(bounds));
    this.map.setCenter(bounds.getCenter());
  }

});

Array.prototype.toQueryString = function(name) {
  var parts = new Array;
  for (var i = 0; i < this.length; i++) {
    parts.push(encodeURIComponent(name) + '[]=' + encodeURIComponent(this[i]));
  }
  return parts.join('&');
}

/*
 * External ticker code (PSD2HTML)
 */

var ul = false;
var _scroller = false;
var ul_offsetWidth = 0;
var _speed = 2;
var _is_paused = false;
var _is_right2left = false;
var _timeout = 30;

function initScroll() {
	ul = document.getElementById('step-scroll');
	if(ul) {
		ul_offsetWidth = ul.offsetWidth;
		var _content = ul.innerHTML;		
		ul.innerHTML = _content + _content + _content;		
		_scroller = ul.parentNode.parentNode;
		_scroller.scrollLeft = ul_offsetWidth;
		_scroller._start = ul_offsetWidth - _scroller.offsetWidth;
		_scroller._end = 2*ul_offsetWidth;
		_go();
		_scroller.onmouseover = function() {
			_is_paused = true;
		}
		_scroller.onmouseout = function() {
			_is_paused = false;
		}
	}
}

function _go() {
  if(!_is_paused) _scroller.scrollLeft += _speed * (_is_right2left ? -1 : 1);
  if(_is_right2left && _scroller.scrollLeft <= _scroller._start) _scroller.scrollLeft += ul_offsetWidth;
  if(!_is_right2left && _scroller.scrollLeft >= _scroller._end) _scroller.scrollLeft -= ul_offsetWidth;
	window.setTimeout("_go()", _timeout);
}
