﻿function changeNav(page) {
    $('ul.navigation a').removeClass('tab');
    $('ul.navigation a.' + page).addClass('tab');
}

$(document).ready(function () {
    //remove target attribute if webkit browser - webkit (chrome, safari) forms will not submit with target attribute.
    if (is_webkit) {
        $('#travel-form').removeAttr('target');
    };
    // validate the form when it is submitted
    $("#travel-form").validate({
        submitHandler: function (form) {
            var cityVal = $('#city1').val(),
                newCityVal = cityVal.substring(0, 3);
                $('#city1').val(newCityVal);

            cityVal2 = $('#city2').val();
            if (cityVal2) {
                newCityVal2 = cityVal2.substring(0, 3);
                $('#city2').val(newCityVal2);
            }
            form.submit();
        }

    });
    $("#dialog").dialog({
        autoOpen: false,
        modal: true
    });
    $("#dialog-2").dialog({
        autoOpen: false,
        modal: true
    });
    var myErrorcode = gup('errorcode');
    if (myErrorcode == '0') {
        $("#dialog").dialog('open');
    };
    if (myErrorcode == '2') {
        $("#dialog-2").dialog('open');
    };
});
