
	jQuery(document).ready(function(){
		calendar_today = new Date;
		jQuery('#pick_a_date').datepicker(
			{
				dateFormat : 'yy-mm-dd',
			onSelect: function(date) {
				jQuery('#traveling_date').val(date);
			},
			beforeShowDay: function(date) {
				if (date < calendar_today) {
					return false;					
				} else {
					return[disabled_days[date.getDay()]];	
				}
			} 	
			}				
		);
        jQuery('.gallery_thumbnail a').lightBox();
		
		jQuery('#ticket_prices').hide();
		//Create the Superfish Menus!
		jQuery("ul.slidingmenu").superfish({
			hoverClass	: "sfHover",
			delay		: 500,
			animation	: {opacity:"show"},
			speed		: "slow"
		});

		  jQuery("select#origin_town").change(function(){
            jQuery('#ticket_prices').slideUp('slow');
		  	jQuery("select#destination_town").html('<option value="-1">Please Wait...</option>');
		    jQuery.getJSON("/includes/getDestinations.php",{id: jQuery(this).val(), ajax: 'true'}, function(j){
		      var options = '';
			  
		      for (var i = 0; i < j.length; i++) {
		        options += '<option value="' + j[i].value + '">' + j[i].name + '</option>';
		      }
		      jQuery("select#destination_town").html(options);
		    })
		  });

          jQuery("select#destination_town").change(function(){
            if (jQuery(this).val() != -1) {
            jQuery('#ticket_prices').slideUp('slow');
		    jQuery.getJSON("/includes/getPrices.php",{
                origin: jQuery("select#origin_town").val(),
                destination: jQuery("select#destination_town").val(),
                ajax: 'true'
                }, function(j){

		      if (j.length == 1) {

                jQuery("#ticket_origin_town").val(jQuery("select#origin_town").val());
                jQuery("#ticket_destination_town").val(jQuery("select#destination_town").val());
jQuery("select#origin_town").val().substr(0, 1).toUpperCase() + jQuery("select#origin_town").val().substr(1)
                jQuery("span.price_healthcare").html(j[0].healthcare);
                jQuery("span.price_school").html(j[0].school);
                jQuery("span.price_standard").html(j[0].standard);
                jQuery("span.origin_town").html(jQuery("select#origin_town").val().substr(0, 1).toUpperCase() + jQuery("select#origin_town").val().substr(1));
                jQuery("span.destination_town").html(jQuery("select#destination_town").val().substr(0, 1).toUpperCase() + jQuery("select#destination_town").val().substr(1));
                jQuery('#ticket_prices').slideDown('slow');

                price_standard = parseFloat(j[0].standard);
                price_healthcare = parseFloat(j[0].healthcare);
                price_school = parseFloat(j[0].school);
                price_child = parseFloat(0.00);
                jQuery("#ticket_prices select").change();
              }


            });

           }

          });

          jQuery("#ticket_prices select").change(function(){



            var tickets_standard = parseFloat(jQuery("select[name='standard_tickets'] option:selected").val());
            var tickets_healthcare = parseFloat(jQuery("select[name='healthcare_tickets'] option:selected").val());
            var tickets_school = parseFloat(jQuery("select[name='school_tickets'] option:selected").val());
            var tickets_child = parseFloat(jQuery("select[name='child_tickets'] option:selected").val());

            var all_tickets_cost =
            (price_standard * tickets_standard) +
            (price_healthcare * tickets_healthcare) +
            (price_school * tickets_school) +
            (price_child * tickets_child);
            //alert(price_standard + ' '+ tickets_standard + ' '+ price_healthcare + ' '+ tickets_healthcare + ' '+ price_school + ' '+ tickets_school + ' '+ price_child + ' '+ tickets_child);
            jQuery("#total_ticket_cost").val('$'+all_tickets_cost.toFixed(2));


          });
		
		
	});