(function($){var template;var counter=0;$.notifications=function(msg,options){counter++;var settings=$.extend({},$.notifications.defaults,options);if(!template){template=$('<div id="jquery-notifications"></div>').appendTo(document.body);}
var n=$('<div class="'+settings.type+'" id="jquery-notifications-'+counter+'">'+msg+'</div>').hide().appendTo("#jquery-notifications");if(settings.effect=="fade"){n.fadeIn(settings.fadeSpeed);}else{n.slideDown(settings.fadeSpeed);}
if(settings.stick){var close=$('<a href="javascript:void(0);">'+settings.close+'</a>').click(function(){if(settings.effect=="fade"){$(this.parentNode).fadeOut(settings.fadeSpeed,function(){$(this).remove();});}
else{$(this.parentNode).slideUp(settings.fadeSpeed,function(){$(this).remove();});}});close.appendTo(n);}
if(!settings.stick){var notificationsDelayer=delayTimer(settings.timeout);notificationsDelayer(update,{counter:counter,effect:settings.effect,fadeSpeed:settings.fadeSpeed});}};$.notifications.success=function(msg,options){return $.notifications(msg,$.extend({},options,{type:"success"}));};$.notifications.error=function(msg,options){return $.notifications(msg,$.extend({stick:true},options,{type:"error"}));};$.notifications.warning=function(msg,options){return $.notifications(msg,$.extend({},options,{type:"warning"}));};function update(params){if(params.effect=="fade"){$("#jquery-notifications-"+params.counter).fadeOut(params.fadeSpeed,function(){$(this).remove();});}else{$("#jquery-notifications-"+params.counter).slideUp(params.fadeSpeed,function(){$(this).remove();});}}
function delayTimer(delay){var timer;return function(fn,params){timer=clearTimeout(timer);if(fn)
timer=setTimeout(function(){fn(params);},delay);return timer;};}
$.notifications.defaults={type:"notice",timeout:10000,stick:false,fadeSpeed:800,close:"x",effect:"fade"};$.n=$.notifications;})(jQuery);

$(document).ready(function(){

    $("#action-button").click(function(){
        $("iframe").hide();
        $("#action-form").dialog({
            modal: true,
            width: 400
        });
        return false;
    });
    $("#action").hover(function(){
        $(this).toggleClass("hover");
    });
    $("#id_departure_date, #id_return_date").datepicker({
        duration: '',
        constrainInput: false
    });
    $("#action-form select, #action-form input, #action-form textarea").hover(
        function(){
            $(this).parent().find("span").toggle();
        }
    );
    $("#phoenix-aviation").hover(function(){
        $("#phoenix-aviation-bg").fadeTo(200, 1);
    }, function(){
        $("#phoenix-aviation-bg").fadeTo(200, 0.6);
    });
    $("#nav > li").mouseenter(function(){
        $ul = $(this).find("ul");
        $("#nav").find("ul").not($ul).stop(true, true).slideUp(200);
        $ul.stop(true, true).slideDown(400);
    });
    $("#nav").mouseleave(function(){
        $(this).find("ul").stop(true, true).slideUp(400);
    });
    var h = 0;
    $(".related").each(function(){
       var rh = $(this).height();
       if(rh > h){
           h = rh;
       }
    });
    $(".related").height(h);
    $(".related").hover(function(){
        $(this).animate({marginTop:-41}, 200);
    }, function(){
        $(this).animate({marginTop:-20}, 200);
    });
    $(".related").click(function(){
        location.href = $(this).find("a")[0].href;
    });
    $("form").submit(function(){
        var f = $(this);
        var fld = f.find("li > input[type=hidden]");
        var s = fld[0].name;
        var r = s.split("").reverse().join("");
        fld[0].value = r;
        f.find("input.button")
            .val('Sending ...')
            .attr('disabled', 'disabled');
        $.post(f.attr("action"),
            f.serialize(),
            function(data) {
                f.find("input.button")
                    .removeAttr('disabled')
                    .val('Sent');
                if(data.type == 'error'){
                    $.n(data.msg);
                    f.find("input.button").val('Send');
                }
                else if(data.type == 'redirect'){
                    window.location.replace(data.msg);
                }
                else
                {
                    f.find("textarea, input[type=text]").each(function(i, el){
                        $(this).val('');
                    });
                    $.n.success(data.msg);
                }
            },
            'json'
        );
        return false;
    });
});






