var lightbox = new Lightbox();
var popupRight = new Lightbox({
    element: $('<div id="popup-left" class="popup"><iframe id="popup-iframe" name="popup-iframe" noresize="noresize" frameborder="0" border="0" cellspacing="0" scrolling="no"></iframe><div class="arrow-left"></div></div>'),
    overlay: false,
    transition: 'linkRight',
    width: 300,
    delay: 200,
    offsetX: 12,
    offsetY: 3
});

var popupTop = new Lightbox({
    element: $('<div id="popup-top" class="popup"><iframe id="popup-iframe" name="popup-iframe" noresize="noresize" frameborder="0" border="0" cellspacing="0" scrolling="no"></iframe><div class="arrow-bottom"></div></div>'),
    overlay: false,
    transition: 'linkTop',
    width: 300,
    delay: 200,
    offsetY: -18
});

var popupBasket = new Lightbox({
    element: $('<div id="popup-basket" class="popup"><iframe id="popup-iframe" name="popup-iframe" noresize="noresize" frameborder="0" border="0" cellspacing="0" scrolling="no"></iframe></div>'),
    width: 400,
    transition: 'linkTop'
});


$(document).ready(function() {
    $('a.lightbox').live('click', function() {
        lightbox.open($(this));
        return false;
    });

    $('a.addtobasket').live('click', function() {
        popupBasket.open($(this));
        return false;
    });

    /* removed by hgh
    $('#cabin-select .suite a, a.cvc').hover(
		function() {
		    popupRight.open($(this));
		},
		function() {
		    popupRight.close();
		}
	);
	*/

    $('#basket tbody:even').addClass('odd');
    $('#basket tbody').find('tr:first').addClass('first');
    $('#basket tbody').find('tr:last').addClass('last');

    $('#booking-filter-content li:even, #basket tr:not(.total):even').addClass('odd');
    $('#booking-filter-content .column.inactive').append('<div class="overlay">');

    $('#mainmenu li:not(.selected) a').hover(
		function() {
		    $(this).animate({
		        color: '#e41819',
		        borderBottomColor: '#e41819'
		    }, 'fast')
		},
		function() {
		    $(this).animate({
		        color: '#545454',
		        borderBottomColor: '#545454'
		    }, 'fast')
		}
	);

	$('#submenu_agent li:not(.selected) a').hover(
		function() {
		    $(this).animate({
		        color: '#e41819',
		        borderBottomColor: '#e41819'
		    }, 'fast')
		},
		function() {
		    $(this).animate({
		        color: '#545454',
		        borderBottomColor: '#545454'
		    }, 'fast')
		}
	);

    $('#booking-filter-navigation li:not(.selected) a').hover(
		function() {
		    $(this).animate({
		        backgroundColor: '#fff',
		        color: '#ccc'
		    }, 'fast')
		},
		function() {
		    $(this).animate({
		        color: '#545454',
		        backgroundColor: '#fbfbfb'
		    }, 'fast')
		}
	);

    $('.date-navigation .previous, .date-navigation .next').hover(
		function() {
		    $(this).animate({
		        backgroundColor: '#f0f0f0'
		    }, 'fast')
		},
		function() {
		    $(this).animate({
		        backgroundColor: '#fbfbfb'
		    }, 'fast')
		}
	);

/* hgh: handled by code-behind
    $('#booking-filter-destination ul.select li').click(function() {
        var item = $(this);
        item.siblings().removeClass('selected');
        item.toggleClass('selected');
        if (item.hasClass('selected')) {
            var overlay = $('#booking-filter-cruisetype .overlay');
            overlay.animate({
                opacity: 0
            }, 'fast', function() {
                overlay.hide();
            });
        } else {
            var overlay = $('#booking-filter-cruisetype .overlay');
            overlay.show();
            overlay.animate({
                opacity: 0.75
            }, 'fast');

            $('#booking-filter-cruisetype li').removeClass('selected');

            overlay = $('#booking-filter-calendar .overlay');
            overlay.show();
            overlay.animate({
                opacity: 0.75
            }, 'fast');
        };
        return false;
    });
*/

/* hgh: handled by code-behind
    $('#booking-filter-cruisetype ul.select li').click(function() {
        var item = $(this);
        item.siblings().removeClass('selected');
        item.toggleClass('selected');
        if (item.hasClass('selected')) {
            var overlay = $('#booking-filter-calendar .overlay');
            overlay.animate({
                opacity: 0
            }, 'fast', function() {
                overlay.hide();
            });
        } else {
            var overlay = $('#booking-filter-calendar .overlay');
            overlay.show();
            overlay.animate({
                opacity: 0.75
            }, 'fast');
        };
        return false;
    });
*/
    var days = $('.calendar table tbody td.day:not(.inactive)');
    days.click(function() {
        var day = $(this);
        day.siblings().removeClass('selected');
        day.parent().siblings().find('td').removeClass('selected');
        day.toggleClass('selected');
    });

    days.hover(
		function() {
		    $(this).addClass('hover');
		}, function() {
		    $(this).removeClass('hover');
		}
	);

    $('.button, .graybutton').hover(
		function() {
		    $(this).animate({
		        opacity: 0.75
		    }, 'fast')
		},
		function() {
		    $(this).animate({
		        opacity: 1
		    }, 'fast')
		}
	);

    
    $('#cabin-select td.price:not(.selected)').hover(
		function() {
		    $(this).addClass('hover');
		}, function() {
		    $(this).removeClass('hover');
		}
	/*).click(function() {
	    $(this).siblings().removeClass('selected');
	    $(this).toggleClass('selected');
	}*/);

	/* removed by hgh
	$('#cabin-select .suite a').hover(
	function() {
	var link = $(this);
	popup.open(link);
	}, function() {
	popup.close();
	}
	).click(function() {
	return false;
	});
	*/

    $('.calendar .current').click(function() {
        monthPicker.open($(this));
    });
});
