
//Cufon.replace('#subn a, .navigationsCoufon a, h1, h2', { hover: true })
Cufon.replace('#subn a, .navigationsCoufon a, h1, h2', { fontWeight: 'normal', hover: { fontWeight: 'bold'} })


$(document).ready(function () {
    selectHomeMenu();

    footerVisibility();
    //footerPosition();

    photogallery();
    virtualTours();
    $(".datepicker").datepicker();
    packagesSlideShow();
});



$(window).resize(function () {
    footerVisibility();
    //footerPosition();
    $('#cycle').cycle('destroy');
    photogallery();
});


function virtualTours() {
    $('#lipg').click(function () {
        $('#vt').fadeOut('fast', function () {
            $('#cycle, #thumbs').fadeIn('fast');
            $('#gallery li').removeClass('selected');
            $('#lipg').addClass('selected');
        })
    })
    $('#livt').click(function () {
        $('#cycle').cycle('pause');
        $('#thumbs').fadeOut('fast');
        $('#cycle').fadeOut('fast', function () {
            $('#vt').fadeIn('fast');
            $('#gallery li').removeClass('selected');
            $('#livt').addClass('selected');
        })
    })
}

function selectHomeMenu() {
    if ($('#page_13').length > 0) {$('#subMenuNotSel19_1 a').addClass('selected');}
}

function footerVisibility() {
    var wh = $(window).height();
    var minh = 760;
    if (wh <= minh) {
        $('#footer').hide();
        $('#bottom').hide();
    } else {
        $('#footer').show();
        $('#bottom').show();
    }

    //if ($('#right').height() < wh) {

                   $('#right').addClass('fux')
    //}

}

function footerPosition() {
    var windowHeight = $(window).height();
    var containerHeight = $('#hCanvas').height();
    var footerHeight = $('#bottom').height();
    var totalHeight = windowHeight - (containerHeight + footerHeight) - 100;  //footer padding
    if (totalHeight >= 0) {
        $('#bottom, #footer').css('top', totalHeight);
    }
    else {
        $('#bottom, #footer').css('top', 30);
    }

    if ((containerHeight + footerHeight) > windowHeight) {
        $('#right .spacer').height(totalHeight + 40)
    } else {
        $('#right .spacer').height(windowHeight - 60)
    }
    
}





function photogallery() {

    //resize big img
    var ratio;
    var leftStartPos = 148; //r. 48 CSS
    var wh = $(window).height();
    var ww = $(window).width();
    var rw = $('#right').width();
    var lw = $('#left').width();
    var wtouse;
    wtouse = ww - (lw + rw);
    ratio = 1.3;
    
    var imgw = wh * ratio;
    var fh;
    var fw;
    if (imgw <= wtouse) {
        fh = wtouse / ratio;
        fw = wtouse;
    } else {
        fh = wh;
        fw = imgw;
    }

    //hold imgs in center
    if (fw >= wtouse) { $('#cycle, #vt').css('left', (148 - ((fw - wtouse) / 2))).css('top', -(fh - wh) / 2) }
    $('#cycle img, #vt embed, #vt object').height(fh).width(fw).show();

    //start the cycle
    $('#thumbs li a').click(function () {$('#cycle').cycle('pause')})
    $('#cycle').cycle({
        fx: 'fade',
        speed: 700,
        timeout: 6000,
        pager: '#thumbs',
        sync: true,
        pagerAnchorBuilder: function (idx, slide) {
            return '#thumbs li:eq(' + idx + ') a';
        }
    });

    //set canvas width (width for no image template)
    $('#canvas').width(wtouse).show();

}


function packagesSlideShow() {
    $('#sld').cycle({
        fx: 'fade',
        speed: 700,
        timeout: 6000,
        sync: true
    });
}

