jQuery().ready(function() {
	if($("#trainJourneyReturnMode:checked").length > 0) {
		$("#trainContainerReturn").show();
	} else {
		$("#trainContainerReturn").hide();
	}	
});

jQuery(function($) {
  $("#trainJourneyRoundtripMode")
              .click(function(){
                  $("#trainContainerReturn").hide();
              });
  $("#trainJourneyReturnMode")
              .click(function(){
                  $("#trainContainerReturn").show();
              });
});

function abreCriteriosIdade() {
    YAHOO.dialog = new YAHOO.widget.Dialog("dialog", {width:"320px", 
                                                      fixedcenter : true, 
                                                      visible:false, 
                                                      draggable:true,
                                                      zindex:11000,
                                                      constraintoviewport:true});
    
    var header = MENSAGENS["txt.criterioIdadeTicket"];
    var body = "<p>" + MENSAGENS["txt.corpoCriteriosIdadeTickets"] + "</p>";
     
    YAHOO.dialog.setHeader(header);
    YAHOO.dialog.setBody(body);
    YAHOO.dialog.render(containerYAHOO);
    YAHOO.dialog.show();
}

function abreCondicoesRailPass() {
    YAHOO.dialog = new YAHOO.widget.Dialog("dialog", {width:"320px", 
                                                      fixedcenter : true, 
                                                      visible:false, 
                                                      draggable:true,
                                                      zindex:11000,
                                                      constraintoviewport:true});
    
    var header = MENSAGENS["txt.condicoesGerais"];
    var body = "<p>" + MENSAGENS["txt.corpoCondicoesRailPassTickets"] + "</p>";
     
    YAHOO.dialog.setHeader(header);
    YAHOO.dialog.setBody(body);
    YAHOO.dialog.render(containerYAHOO);
    YAHOO.dialog.show();
}

YAHOO.example.ACJson = new function() {
  var mySchema = ["results", "name"];
  this.oACDS = new YAHOO.widget.DS_XHR(TRAIN_CITY_CACHE, mySchema);
  this.oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_JSON;
  
  this.originCityName = new YAHOO.widget.AutoComplete('originCityName', 'div_response_originCityName', this.oACDS);
  this.originCityName.prehighlightClassName = "yui-ac-prehighlight";
  this.originCityName.minQueryLength = 2;
  this.originCityName.useIFrame = true;
  this.originCityName.formatResult = function(oResultItem, sQuery) {
    return oResultItem[0];
  };
  
  this.originCityName.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {
      var pos = YAHOO.util.Dom.getXY(oTextbox);
      pos[1] += YAHOO.util.Dom.get(oTextbox).offsetHeight + 2;
      YAHOO.util.Dom.setXY(oContainer,pos);
      return true;
  };
  
  this.destinationCityName = new YAHOO.widget.AutoComplete('destinationCityName', 'div_response_destinationCityName', this.oACDS);
  this.destinationCityName.prehighlightClassName = "yui-ac-prehighlight";
  this.destinationCityName.minQueryLength = 2;
  this.destinationCityName.useIFrame = true;
  this.destinationCityName.formatResult = function(oResultItem, sQuery) {
    return oResultItem[0];
  };
  
  this.destinationCityName.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {
      var pos = YAHOO.util.Dom.getXY(oTextbox);
      pos[1] += YAHOO.util.Dom.get(oTextbox).offsetHeight + 2;
      YAHOO.util.Dom.setXY(oContainer,pos);
      return true;
  };
};
function pesquisarTrens(){
	doSubmitWithLoading();
	document.getElementById("formBuscaTrens").submit();
}