var win = null;
function open_popup_dimensions(width,height,url,name) {
	win = window.open(url, name, 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1, width=' + width + ', height=' + height + ', top=0, left=0');
	win.focus();	
}

function dps_popup(uri) {
    open_popup_dimensions(770,377,uri,'DPS')   
}

/* Close a popup window */
function close_now() {
	this.focus();
	self.opener = this;
	self.close();
	window.close();
}

function tell_friends(element) {
    open_popup_dimensions(610, 377, element.href + "&popup=true", 'popup');
    return false;
}

function checkConflictFrom() {
  if ($("ibis_to").value == $("ibis_from").value) {
    alert('Departure point must be different from the destination');
    if ($("ibis_to").selectedIndex == 0) {
      $("ibis_from").selectedIndex = 1;
    } else {
      $("ibis_from").selectedIndex = $("ibis_to").selectedIndex-1;
    }
  }
}

function checkConflictTo() {
  if ($("ibis_to").value == $("ibis_from").value) {
    alert('Departure point must be different from the destination');
    if ($("ibis_from").selectedIndex == 0) {
      $("ibis_to").selectedIndex = 1;
    } else {
      $("ibis_to").selectedIndex = $("ibis_from").selectedIndex-1;
    }
  }
}

function ibisForm() {
  Element.hide("loading_box");
  new Form.Element.EventObserver($("ibis_from"), checkConflictFrom);
  new Form.Element.EventObserver($("ibis_to"), checkConflictTo);
}

function showLoadingGraphic() {
    Element.show('loading_box');
    Element.hide('submit_box');
}

function showLoadingGraphic2(url) {
    Element.show(url);
    window.location = url;
}