$('button').load(function(){
                li.sort(function(a, b){
                    return $(a).text() > $(b).text() ? 1 : -1;
                });
            });	
$(document).ready(function() {



//$("#clipu").fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200);
		//--Slide menu
		$('#list-menu, #list-info, #list-info-hotel').accordion({
			header: 'a.title',
			//animated: false,
			autoheight: false
		});
		$('#wrapp-list').accordion({
			header: 'a.show',
			active: false,
			//animated: false,
			alwaysOpen: false
		});
		//--End Slide menu
	

   $('#masini').hide();
	$('#hoteluri').hide();
	$('#asigurarile').hide();	

 $('.bilete').click(function() {
$('#bilete').show();
    $('#masini').hide();
	$('#hoteluri').hide();
	$('#asigurarile').hide();
    return false;
  });

  $('.masina').click(function() {
$('#masini').show();
    $('#bilete').hide();
	$('#hoteluri').hide();
	$('#asigurarile').hide();
    return false;
  });

  $('.hotel').click(function() {
$('#hoteluri').show();
    $('#bilete').hide();
	$('#masini').hide();
	$('#asigurarile').hide();
    return false;
  });

  $('.orar').click(function() {
$('#asigurarile').show();
    $('#bilete').hide();
	$('#hoteluri').hide();
	$('#masini').hide();
    return false;
  });

		});
 




$(function(){
	$('.date-pick').datePicker()
	$('#start-date').bind(
		'dpClosed',
		function(e, selectedDates){
			var d = selectedDates[0];
			if (d) {
				d = new Date(d);
				$('#end-date').dpSetStartDate(d.addDays(1).asString());
			}
		}
	);
	$('#end-date').bind(
		'dpClosed',
		function(e, selectedDates){
			var d = selectedDates[0];
			if (d) {
				d = new Date(d);
				$('#start-date').dpSetEndDate(d.addDays(-1).asString());
			}
		}
	);

	$('.date-pick1').datePicker()
	$('#start-date1').bind(
		'dpClosed',
		function(e, selectedDates){
			var d = selectedDates[0];
			if (d) {
				d = new Date(d);
				$('#end-date1').dpSetStartDate(d.addDays(1).asString());
			}
		}
	);
	$('#end-date1').bind(
		'dpClosed',
		function(e, selectedDates){
			var d = selectedDates[0];
			if (d) {
				d = new Date(d);
				$('#start-date1').dpSetEndDate(d.addDays(-1).asString());
			}
		}
	);


  $("#plecare").autocomplete("u/orase.php", {
        width: 260,
        matchContains: true,
        selectFirst: false,
		//formatItem: formatItem,
		formatResult: formatResult
    });

  $("#orasul").autocomplete("u/orase.php", {
        width: 260,
        matchContains: true,
        selectFirst: false,
		//formatItem: formatItem,
		formatResult: formatResult
    });

        $("#sosire").autocomplete("u/orase.php", {
        width: 260,
        matchContains: true,
        selectFirst: false,
		formatResult: formatResult
    });

        $("#avion").autocomplete("u/avion.php", {
        width: 260,
        matchContains: true,
        selectFirst: false,
		multiple: true,
		formatResult: formatResult
    });

  $("#preluare").autocomplete("u/masini.php", {
        width: 260,
        matchContains: true,
        selectFirst: false,
		//formatItem: formatItem,
		formatResult: formatResult
    });

  $("#predare").autocomplete("u/masini.php", {
        width: 260,
        matchContains: true,
        selectFirst: false,
		//formatItem: formatItem,
		formatResult: formatResult
    });


function formatResult(row) {
	//return row[0] + " - <i>" + row[1] + "</i>";
	return row[1];
}

  $('#f_more').hide();
$('#f_more1').hide();
$('#f_more2').hide();
$('#f_more3').hide();

  $('a#more').click(function() {
    $('#f_more').toggle(400);
    return false;
  });
  $('a#more1').click(function() {
    $('#f_more1').toggle(400);
    return false;
  });
  $('a#more2').click(function() {
    $('#f_more2').toggle(400);
    return false;
  });
  $('a#more3').click(function() {
    $('#f_more3').toggle(400);
    return false;
  });

	$('input#dus').click(function() {
			$("#end-date, #end-time, #elb, #elbt").hide("fast");
			$("#end-date").removeClass();
	});
	$('input#dus-int').click(function() {
			$("#end-date, #end-time, #elb, #elbt").show();
});
	//$("input#dus").click(function() {
		//	$("#end-date, #end-time").hide("fast");
			//$("#end-time").hide("fast");
		//	$("input#end-date").removeClass();	

$("#form").validationEngine({scroll:false})

 function validate2fields(){
   if($("#plecare").val() =="" || $("#sosire").val() == ""){
    return true;
   }else{
    return false;
   }
  }



});


		//--Slide menu
		$('#list-menu, #list-info, #list-info-hotel').accordion({
			header: 'a.title',
			//animated: false,
			autoheight: false
		});
		$('#wrapp-list').accordion({
			header: 'a.show',
			active: false,
			//animated: false,
			alwaysOpen: false
		});
		//--End Slide menu

